Go Down

Topic: SPI protocol (Read 274 times) previous topic - next topic

thom_7

Jul 08, 2014, 07:27 pm Last Edit: Aug 27, 2014, 06:48 pm by thom_7 Reason: 1
...

SurferTim

SPI.transfer() reads and writes at the same time. Your device receives and transmits 16 bits. See page 30 of your manual.

Here is an example of sending and receiving 16 bits (2 bytes). The bytes you are sending are sendHighData (0xff) and sendLowData (0x00), and the bytes you receive from the device will end up in highData and lowData.
Code: [Select]
digitalWrite(slaveSelect, LOW);
byte sendHighData = 0xff;
byte sendLowData = 0;
byte highData = SPI.transfer(sendHighData);
byte lowData = SPI.transfer(sendLowData);
digitalWrite(slaveSelect, HIGH);


SurferTim

You must post your code and explain how the IC is connected to the Arduino. I am not familiar with that IC, but I may be able to help with the SPI part.

SurferTim

That code sets register 0 only. You probably need to set more than that one register. The register data starts on page 23 of your manual.


Go Up