Skip to main content
LChan.5
Associate II
Jun 15, 2020 8:59 AM UTC
Question

How to read SPI correctly?

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
Jun 15, 2020 11:09 AM UTC

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
Jun 16, 2020 1:03 AM UTC

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
Jun 16, 2020 2:09 AM UTC

Post minimal but complete compilable program exhibiting the problem.

JW

LChan.5
LChan.5Author
Associate II
Jun 16, 2020 5:04 AM UTC

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