cancel
Showing results for 
Search instead for 
Did you mean: 

Flash erase and program

Stefano1
Associate

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.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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:

STM32CubeC0/Projects/NUCLEO-C071RB/Examples/FLASH/FLASH_EraseProgram/Src/main.c at 291f417c07b8e6f997a555b4abafa861551d22e3 · STMicroelectronics/STM32CubeC0 (github.com)

 

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.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

1 REPLY 1
TDK
Guru

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:

STM32CubeC0/Projects/NUCLEO-C071RB/Examples/FLASH/FLASH_EraseProgram/Src/main.c at 291f417c07b8e6f997a555b4abafa861551d22e3 · STMicroelectronics/STM32CubeC0 (github.com)

 

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.

If you feel a post has answered your question, please click "Accept as Solution".