AVR SPI Slave & Shift Register...

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When an AVR is run as an SPI slave and it recieves a data byte, the data byte is...

(I've read each of these)
- copied from the shift register to the data register
- transfered from the shift register to the data register
- moved from the shift register to the data register

My question is, does the shift register retain a copy of the byte recieved or is the shift register cleared by this (copy / transfer / move) to SPDR? I am wanting a data byte sent by the master to be echoed back on the next byte transfer. I don't know if the slave needs to write the byte back to SPDR or if the shift register retains the master's sent data byte.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When you send a byte, a byte is "received" whether or not the remote device actually returns data. Without an input to MISO, that pin will receive what ever happens to be there. Whether or not your byte is "echoed" depends on the remote device.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

> I don't know if the slave needs to write the byte back to SPDR

Yes, it does. Otherwise, it will shift out whatever has been the
last output byte *to* SPDR. The input and output channels are completely
distinct.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.