did you check out the spi-slave sample from the SPI folder?
it is very simple.
if you want to return the slave some data, you must fill the SPDR (or spi data register).
And this data can only be returned to the master if the master sends some data.
So this is what happens :
- master send a byte with some value, say 123
- slave clocks out the old value of spdr, so if slave want to return value 234, it must make sure that SPDR is loaded with this value before the master sends data.
- master receives the value from the slave SPDR register.
in the help and datasheet you can see that SPI is just a 16 bit shift register. I hope this explains it.
↧