Skip to main content
LChan.5
Associate II
June 15, 2020
Question

How to read SPI correctly?

  • June 15, 2020
  • 4 replies
  • 1307 views

I use Nucleo board (STM32L053R8) to connect SPI slave. The SPI command had been sent to slave correctly, and slave also return the expected value (0x2C). But Nucleo SPI master cannot get the return data correctly. The RXNE is raised without problem, but the content of DR is wrong. it was 0xff. attachment is the trace diagram from logic analyzer. is there any other thing need to be configured? thank you.

This topic has been closed for replies.

4 replies

TDK
Super User
June 15, 2020

MISO is 0xFF for 3 bytes before it's 0x2C. Sure you're just not reading it enough? SPI returns a byte for every byte sent.

"If you feel a post has answered your question, please click ""Accept as Solution""."
LChan.5
LChan.5Author
Associate II
June 16, 2020

Thanks for the reply.

I only get one interrupt. I also try to read content for 2 times (16-bit data format) in ISR. it's still 0xffff.

waclawek.jan
Super User
June 16, 2020

Post minimal but complete compilable program exhibiting the problem.

JW

LChan.5
LChan.5Author
Associate II
June 16, 2020

I change to polling and read after every write. I can get the correct response from device now. thank you.