Pages: [1]   Go Down
Author Topic: SPI protocol  (Read 257 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

...
« Last Edit: August 27, 2014, 11:48:14 am by thom_7 » Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 152
Posts: 6192
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
digitalWrite(slaveSelect, LOW);
byte sendHighData = 0xff;
byte sendLowData = 0;
byte highData = SPI.transfer(sendHighData);
byte lowData = SPI.transfer(sendLowData);
digitalWrite(slaveSelect, HIGH);
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 152
Posts: 6192
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 152
Posts: 6192
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Pages: [1]   Go Up
Jump to: