Skip to main content
KGupt.1
Associate III
Jul 28, 2022 7:42 PM UTC
Question

STM32F103 SPI peripheral driver

Hey guys I am having one issue, with the stm32f103 SPI peripheral. I have developed my SPI bare metal mode(spi_mast_tran_byte(), spi_mast_recv_byte() : see pitchers below) and w25q128 flash memory in which I am reading its JDEC ID which is at address 9F and JDEC ID is 0xEF4018( which can be seen on logic analyzer output). But when I read the JDEC ID with my code of W25q128 API ( W25_Read_ID()). what I am observing is that my first byte read from SPI is always 0xff, which should be instead 0x9f.

I am not able to get why on reading the spi slave every time the first byte read is 0xff, even though in logic analyzer it is showing something else.

I am guessing there is something with my SPI peripheral driver but not able to make out what exactly is the issue.0693W00000QMPM5QAP.jpg0693W00000QMPM0QAP.jpg0693W00000QMPMAQA5.jpg

This topic has been closed for replies.

3 replies

Chris1
Associate II
Jul 28, 2022 7:58 PM UTC

Your 2nd while loop in the receive function appears to be missing ;.

Tesla DeLorean
Guru
Jul 28, 2022 10:05 PM UTC

You have STM32 MCU not an MPU, will fix the tagging so this is in the right subforum.

Post code in an editable form, not screenshots/bitmaps, they are unworkable

Use the code posting tool, see </> icon below edit/post window.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal
Jul 29, 2022 3:23 AM UTC

As master, focus on rxne and not txe. They don't pop at the same time. Txe before transfer, rxne after transfer is completed. Use 4 wire bidir mode, don't try monodir at first.