Go Down

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


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


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);


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.


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

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131