2024-07-25 03:15 AM
HI,
I cannot delete page 15, or other pages, of the STM32C031K6T6 flash chip.
HAL_StatusTypeDef status;
EraseInitStruct.TypeErase=FLASH_TYPEERASE_PAGES;
EraseInitStruct.NbPages=1;
EraseInitStruct.Page=15;
status = HAL_FLASH_Unlock();
status = HAL_FLASHEx_Erase (&EraseInitStruct, &PageError);
status = HAL_FLASH_Lock();
Where am I wrong? Can someone help me?
Thanks everyone in advance.
Solved! Go to Solution.
2024-07-25 05:34 AM
Why can't you erase the page? What happens when you try? What sort of errors or bad behavior do you get vs what do you expect? Be specific, look at the FLASH peripheral registers to determine issues.
Verify write protection settings in option bytes using STM32CubeProgrammer.
Example code is here:
Note that it clears OPTVERR flag. Probably this is an issue of not clearing flags before trying. The debugger is known to set flags that shouldn't be set.
2024-07-25 05:34 AM
Why can't you erase the page? What happens when you try? What sort of errors or bad behavior do you get vs what do you expect? Be specific, look at the FLASH peripheral registers to determine issues.
Verify write protection settings in option bytes using STM32CubeProgrammer.
Example code is here:
Note that it clears OPTVERR flag. Probably this is an issue of not clearing flags before trying. The debugger is known to set flags that shouldn't be set.