cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 SPI peripheral driver

KGupt.1
Associate III

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

3 REPLIES 3
Chris1
Senior III

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

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
Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal

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.