Unable to erase flash memory of STM32G030 using HAL_FLASHEx_Erase
I am working on a project which requires storing values in flash memory so that the values will be retained next time the device is turned on. I tried this on STM32F103C8T6 and it worked without any issues. But on STM32G030C8T6 I'm getting error while trying to erase a page.
The following is the code that I wrote for erasing a flash memory page.
if (HAL_FLASHEx_Erase(&eis, &pageError) != HAL_OK){
HAL_FLASH_Lock();
return HAL_FLASH_GetError();
} else {
HAL_FLASH_Lock();
return 0;
}But it is returning 0x80. I did some debugging and found out that it is "HAL_FLASH_ERROR_PGS". Which by the function's comment, it is a "Programming sequence error". What is this error? how can it be solved? why did it not appear while I was working on F103?
This is the link for the project.
