I am new to DUE . I am interfacing a sensor and DUE through SPI. But I get 0 0 0 . . . as response from the sensor. So I just wanted to confirm if my program is proper. My aim is to write a data and read it back from a particular memory . I read through many forums ,but I am still not sure of my problem.
#include <SPI.h>
void setup() {
Serial.begin(9600);
SPI.begin(4);
// opcodes here are samples oly
write_opcode = 0x99;
address= 0x98;
value=0xAA;
read_opcode=0x97;
}
void loop() {
// put your main code here, to run repeatedly:
SPI.beginTransaction(SPISettings(20000000, MSBFIRST, SPI_MODE1));
SPI.transfer(4, write_opcode, SPI_CONTINUE);
SPI.transfer(4, address, SPI_CONTINUE);
SPI.transfer(4, value, SPI_CONTINUE);
SPI.transfer(4, read_opcode, SPI_CONTINUE);
SPI.transfer(4, address, SPI_CONTINUE);
byte rd_value = SPI.transfer(4, 0x00);
Serial.print(rd_value);
SPI.endTransaction();
}
This is written in Arduino DUE. Is my program correct or am I missing something ?
The hardware wiring , I followed from here
http://forum.arduino.cc/index.php?topic=132130.0