Hi, I'm trying to get spi communication to work on my due, but I am getting some unexpected results. I know how to use SPI on the Uno, Nano and Mega board but somethings happening to the Due. I connected a logic analyzer to the spi header (except for the 5v pin) and told the due to send 0xAA. I tried using the old API (https://www.arduino.cc/en/Reference/DueExtendedSPI) and the new API (https://www.arduino.cc/en/Tutorial/SPITransaction), but both yield different and wrong results. When I use the new API the due lowers the CS for one clock cycle. When I use the old API the due sends for bits then raises the CS. What am I doing wrong?
this is basically the code I am using
#include <SPI.h>
// The setup() function runs once each time the micro-controller starts
void setup()
{
//Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB
}
/*
test area
*//*
SPI.begin(52); // SPI Module 'wake up'
SPI.setClockDivider(52, SPI_CLOCK_DIV128 );
SPI.setDataMode(52, SPI_MODE0);
SPI.setBitOrder(52, MSBFIRST);
delay(200); // SPI delay for initialization
*/
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0)); // SPI setup SPI communication
SPI.begin(52);
while (true)
{
SPI.transfer(52, 0xAA, SPI_LAST);
delay(20);
}
}
void loop()
{
}