SPI - SPDR

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

Do not see changes to SPDR in AVRStudio, ICE200, in I/O Memory window at $0f.

Device is 4433, a slave. Talking with MPC823. The received byte is what is seen. Perhaps the debugger is showing the input buffer, and not the transmit buffer?

After I do this:
out SPDR, r17

when I look at $0f in the I/O Memory Window, I do not see the value that is in r17 there in $0f, SPDR.

Is this normal? Oh, I should admit that the master receives the correct byte! So perhaps is not a big problem!

With all congeniality,
Joe

admin's test signature
 

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

Joe,
SPDR is used for both transmit and receive. After you write to it with (out SPDR,r17), it is shifted to the output shift register on the next clock cycle. Then it acts as the input register and will show what the incoming datum is. I would hope to see the contents of r17 in SPDR but for only one clock cycle.

I hope this helps,

Scott Pierskalla

admin's test signature
 

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

>> I would hope to see the contents of r17 in SPDR but for only one clock cycle. <<

I don't think so, but I'm not an expert.

It's a double set of registers

- the write goes straight into the shift registers
- the read register is loaded at the end of the shifting cycle

John P.

admin's test signature
 

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

SPDR is really two registers, one for input and one for output.

When you write, the data goes to the output register to be shipped to the other device. When you read, you see the input from the other device.

If you read, then write, then read again, before any data is shifted via the master clock, you will read the same data both times.

admin's test signature
 

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

OK, thanks Scott, John, Laurence!

I now see that the SDPR is "write only" for out/transmit direction.

Reads will bring in what the block diagram (for SPI) shows as "READ DATA REGISTER", and as you guys said, the OUT SPDR, goes to the shift register, hence is not readable to me.

Sound correct?

admin's test signature