Skip to main content
3 of 4
deleted 31 characters in body
newandlost
  • 223
  • 1
  • 4

SPI arduino due conflict with pinMode(), bug?

Consider the following minimal example, where I set pinMode before calling SPI functions:

#include <SPI.h>

void setup()
{  
    pinMode(10, OUTPUT); 
    SPI.begin(10);
    SPI.setDataMode(10,SPI_MODE1);
} 

void loop()
{
    delay(1000);
    SPI.transfer(10,1);
}

Now always when SPI.transfer(10,1) is called in the loop(), I see that the slave selected pin goes down to 1.65V, but not 0 as it shoudl! (see image below)

pin mode set before calling SPI functions

If we don't call pinMode(), like this:

#include <SPI.h>

void setup()
{  
    SPI.begin(10);
    SPI.setDataMode(10,SPI_MODE1);
} 

void loop()
{
    delay(1000);
    SPI.transfer(10,1);
}

we get what we would expect when calling SPI.transfer:

pin Mode not set

Is that a bug or do you have an explanation for that behaviour?

Thank you very much in advance for your time and interest!!!

newandlost
  • 223
  • 1
  • 4