2023-05-03 10:15 PM - edited 2023-11-20 06:30 AM
Hi everyone,
i am using the stm32g0b1cet6 controller. in which I am working with flash memory. I am using the FLASH_WaitForLastOperation function. In that function, one flash SR register's CFGBSY bit is not reset, and due to that all other flash write and erase processes it not working.
this issue is coming randomly.
before calling FLASH_WaitForLastOperation function I am clearing error flags as shown below
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPTVERR);
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPERR);
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PROGERR);
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_WRPERR);
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGAERR);
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_SIZERR);
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGSERR);
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_MISERR);
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_FASTERR);
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_RDERR);
can someone please provide some input ASAP.
Solved! Go to Solution.
2023-12-09 07:34 AM
The "SystemClock_Config ()" is generated by CubeMX, I haven't enabled any interrupts in the testcode. After the code is generated by CubeMX I have added the code related to reading of the CFGBZY flag after SystemClock_Config function call, and the issue is even observed before doing any operation related to Flash except reading the state of CFGBZY flag. The issue is very random, sometimes the issue is observed continuously on every power cycle for more than 5 times and sometimes it is not observed. It's been a few months since I worked on it, don't have enough time to go back to it. My suspection is also on HAL, need to check whether the issue occurs without using HAL.
2023-12-09 07:43 AM - edited 2023-12-09 11:24 AM
I haven't found any root cause for the issue, I don't have enough time to spend on it, as soon as the issue is resolved, I moved to some other tasks.
2023-12-09 09:34 AM
When FLASH_SR error flags are set, the erase/programming doesn't work. It is quite logical, but it is not clearly documented in the reference manuals. But, of course, ST has no time for fixing such "unimportant" issues... That said, these flags do not appear without reason.
Last year I also reported this to SEGGER, because the J-Link was also failing to erase/program the flash, if the error flags were set.
https://www.segger.com/downloads/jlink/ReleaseNotes_JLink.html
Version V7.68b (2022-07-22)
DLL
ST STM32F7, STM32G0, STM32G4, STM32H7, STM32L0, STM32L1, STM32L4, STM32L5: Flash programming failed if any flash error bits were set before flash operation. Fixed.
2024-03-03 12:44 PM
I had the same problem with STM32G0B1CC and your solution helped!
Thank you very much!