cancel
Showing results for 
Search instead for 
Did you mean: 

How to read SPI correctly?

LChan.5
Associate II

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.

4 REPLIES 4
TDK
Guru

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
Associate II

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.

Post minimal but complete compilable program exhibiting the problem.

JW

LChan.5
Associate II

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