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

Hi all,

I started playing around with a SPI real time clock board a (DS3234 from Sparkfun) and downloaded some libraries.

I am trying to figure out how the functions implemented actually works so I can customize/tweak them for my own need.

Can somebody explain to me what the instrution SPI.transfer(-1) is doing? Is it some kind of shift in the byte to read/write.

Thanks
« Last Edit: August 06, 2012, 04:06:18 am by nemalk » Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1729
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It sends the value 255 over the SPI, and returns a byte from the selected slave.

When you want to read something from a slave device, the master has to put 8 clock cycles onto the SCLK line to time the date coming from the device. To do this you send a dummy byte and read in the response. Usually the dummy byte is either 255 (-1) or 0.

Some devices use full duplex, so every byte you send, you recieve a valid byte at the same time, but in this case, I think it is half duplex (master sends dummy bytes to read in from the slave).
Logged

~Tom~

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Tom.

The code makes more sense for me now  smiley
Logged

Pages: [1]   Go Up
Jump to: