cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4: ST Example SPI Not Functioning - Sector Erase

Rogers.Gary
Senior II
Posted on October 13, 2015 at 03:03

Hi,

The example provided by ST for SPI flash programming has a function called sFLASH_EraseSector

However, it does not seem to work....it appears to hang without ever coming back. I'm using the exact files as provided in spi_flash.c, and spi_flash.h

I can write and read, but that's not consistent. For example, if I write some bytes at address 0x70000 once, it reads ok.

When I run it a second time, it returns junk.

Then, I run the call to sFLASH_EraseSector, and although it doesn't return, I terminate the debugger. Then, I comment out the call to sFLASH_EraseSector, run it again, and it reads and writes OK, returning the right string.

Can anyone who's used this device (M25P), on an STM32F405, provide any suggestions as to why this is happening? What would cause this? Why the call to sFLASH_EraseSector doesn't return, but seems to work when run and force terminated?

Please...anyone????

2 REPLIES 2
Posted on October 13, 2015 at 03:31

The audience is fairly limited here. Not sure I have an M25P family device on an STM32 based board, but I have used other SPI Flash devices on STM32 and other platforms.

The devices have little internal state machines, so you'll want to carefully observe the transition from one command to another, and then waiting for status. Compare logic analyzer plots against documented wave forms. The fact the second use works, does suggest there's an issue demarcating one interaction from another, don't glitch the CS, there's probably some minimum high time requirement. You'd also want to make sure that the device has been correctly identified, the erase block size understood, and the correct command is used, seemed to recall some 3 or 4 byte commands depending on the size of the array.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Rogers.Gary
Senior II
Posted on October 13, 2015 at 05:47

thanks clive1.

I have found a weird ambiguity on the M25P128 datasheet, Figure 4.

In note 2 just below figure 4, it says this:

''these pull up resistors...''.

Y

et, the diagram shows the CS resistors pulled down to Vss, while the CLK line is pulled high.

That makes no sense at all. I thought CS and CLK are typically pulled high, whether it's internal or external.

What's with that?