Scott Engel

SPI Receive Clocking on E128

Discussion created by Scott Engel on Oct 5, 2006
Latest reply on Oct 7, 2006 by bigmac
From looking at legacy code, it appears that to generate the SPI clock for the master to receive data from the slave, you must place a byte in the data register, which makes sense because the data coming from the slave comes in on a different pin.
 
The SPI guide under CPHA = 0 Transfer Format says:
 
"Data that was previously in the master SPI Data Register should now be in the slave data register and the data that was in the slave data register should be in the master."
 
So for an SPI slave device that takes a two byte command and returns two bytes,  one would:
 
1. Transfer command byte 1
2. Transfer command byte 2
3. Write a dummy value into the data register to clock in the response from the slave
4. Retrieve the value in the data register, which is the byte from the slave.
5. Repeat steps 3. & 4.
 
Is this correct?
 
Thanks,
Eagle Beak

Outcomes