cancel
Showing results for 
Search instead for 
Did you mean: 

Why does my call to FLASH_Erase_Sector fail all of a sudden?

arnold_w
Senior

I am working with the STM32F446 microcontroller and for over a year I've successfully been able to erase sectors from within my code using FLASH_Erase_Sector. Now all of a sudden my code gets stuck whenever I call it! I have looked at the Option Bytes using STM32 ST-LINK Utility and everything looks fine, nothing is write protected. I'm also able to re-program the microcontroller from another microcontroller using the build-it STM bootloader. What on earth has happened to my microcontroller, why does it refuse to erase sectors from within its source code, but not from externally?

5 REPLIES 5

Without specific diagnostics it will be hard to tell.

I'd make sure to clear any pending status from the FLASH unit before starting an erase/programming cycle.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Evangelist III

What voltage parameter do you specify for the erase?

Is this voltage indeed supplied to the MCU?

-- pa

arnold_w
Senior

The specied voltage range and the supplied voltage are both correct.

When I think back, the problem was introduced at about the same time as I introduced a reset pulse that probably was too short (way less than 20 microseconds). So, it is possible that the microcontrollers (there are actually 4 of them and they all have the same problem) were reset with reset pulses that violated the reset hold time while it was either erasing a sector or programming a sector. But can this really create permanent damage? Can I recover them somehow?

This looks like more then just a coincidence. IMHO a question for ST.

arnold_w
Senior

When I read address 0x1FFF C008 (the second option byte) it says 0x30FF, but when upgrading firmware I set it to 0x00FF. Now, bits 14:8 are reserved so maybe it doesn't matter, but maybe it's a clue as what is wrong?