cancel
Showing results for 
Search instead for 
Did you mean: 

Why do I get a programming sequence error during flash erase?

bobdeschambault9
Associate II
Posted on September 09, 2015 at 16:49

Hi,

I am trying to do a sector flash erase of an STM32F429 chip.  When I call HAL_FLASHx_Erase(&FLASH_EraseInitStruct, &sectornb) I get to a call to a function called FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE) and it returns an error: HAL_FLASH_ERROR_PGS or 0x02.  What is a programming sequence error and how might I fix it?

Thanks,

Bob 
2 REPLIES 2
Posted on September 09, 2015 at 16:59

''PGSERR: Programming sequence error

 

Set by hardware when a write access to the Flash memory is performed by the code while

 

the control register has not been correctly configured. Cleared by writing 1.''

My money would be some other bits in the register, like the program bit or the sector number, or you simply haven't cleared the entry/random state for the status/errors. Or an unexpected write has occurred on the array when it's expecting the erase to complete. ie you timed out of the erase and started writing anyway. The JTAG pod can leave the system in a different state than a cold boot. The state of the flash controller should be cleared after you unlock it, before starting a fresh interaction.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
bobdeschambault9
Associate II
Posted on September 09, 2015 at 17:28

Thanks for the advice.  It looks like for some reason the SR register had the PGSERR bit set.  Once I added some code to clear that bit during my flash init code, it started working!