Skip to main content
arnold_w
Senior II
March 11, 2019
Question

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

  • March 11, 2019
  • 4 replies
  • 845 views

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?

This topic has been closed for replies.

4 replies

Tesla DeLorean
Guru
March 11, 2019

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 VenmoUp vote any posts that you find helpful, it shows what's working..
Pavel A.
Super User
March 11, 2019

What voltage parameter do you specify for the erase?

Is this voltage indeed supplied to the MCU?

-- pa

arnold_w
arnold_wAuthor
Senior II
March 12, 2019

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?

AvaTar
Senior III
March 12, 2019

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

arnold_w
arnold_wAuthor
Senior II
March 12, 2019

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?