How to read SPI correctly?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-15 1:59 AM
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.
- Labels:
-
SPI
-
STM32L0 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-15 4:09 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-15 6:03 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-15 7:09 PM
Post minimal but complete compilable program exhibiting the problem.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-06-15 10:04 PM
I change to polling and read after every write. I can get the correct response from device now. thank you.
