EmbDev.net

Forum: µC & Digital Electronics SPI Communication-always returning 0xff in spi_rdr


Author: Aditya K. (stadkama)
Posted on:

Rate this post
0 useful
not useful
I am using atsam4e8c to interact with sensors through SPI. Whenever a 
data is written in spi_tdr, in the spi_rdr in the debug window shows 
0xff and also MISO line is high. Also the SPI_SR, RDRF: Receive Data 
Register Full is 0.

Please let me know is this related to clock or board init or sysclk init 
because the led is always blinking in the interval of 20seconds even 
there is no code to blink the led.
Thank you in advance.

: Edited by User
Author: Jim Meba (turboj)
Posted on:

Rate this post
0 useful
not useful
Reading spi_RDR in debug window is potentially harmful: This is a 
hardware register where reading has side effects!

While you are debugging SPI code, save those registers into a variable 
that you can safely read with the debugger.

Author: Aditya K. (stadkama)
Posted on:

Rate this post
0 useful
not useful
Even if I read in a variable, value still remains in the register. I 
would like to know why is this issue coming. I have configured the 
atsam4e8c in master mode. Even though the address to read the chip id of 
sensor is sent, a value of 0xff is there in the receive register and not 
getting cleared during debug. Once I start a new debug session,proper 
reset value is there.
Thank you in advance.

Author: Jim Meba (turboj)
Posted on:

Rate this post
0 useful
not useful
Aditya K. wrote:
> Even though the address to read the chip id of
> sensor is sent, a value of 0xff is there in the receive register and not
> getting cleared during debug.

Why should RDR get cleared? SPI always sends and receives at the same 
time, so there will be the last transferred value in the RDR.

Do you know that you usually have to transfer a dummy value to be able 
to read from the slave?

Author: Aditya K. (stadkama)
Posted on:

Rate this post
0 useful
not useful
sorry I got confused.When the RDR is read,the RDRF bit should be 
cleared. In my case RDRF bit is not set.
Yes if any data is required from the slave, a dummy value should be 
sent.
In this case,I am trying to read the chip id and also other registers of 
slave by sending its corresponding address, even though the value 
received is 0xff. Please let me know what may be the issue.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.