cancel
Showing results for 
Search instead for 
Did you mean: 

how to erase a single page of flash memory

ahmash
Associate II

hello guys i need help with stm32f103 and stmcube ide

i want to erase a pege of flash memory during runtime of programme ,in my case i want to erase page no 63 i have found this following code in hal_flash_ex.c but i dont know how to use it or modify it to get result

HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError)

or may be i am trying a wrong hal function please help me

this function HAL_FLASH_ErasePage() is not available in my hal driver hal_flash.c or hal_flash_ex.c

thanks

1 ACCEPTED SOLUTION

Accepted Solutions
ahmash
Associate II

this is solution and i found it at chatgpt 

HAL_FLASH_Unlock();

// 0x08000000 + (63 * 1024) = 0x0800FC00 //start byte address of page 63

FLASH_PageErase(0x0800FC00);

HAL_FLASH_Lock();

case closed thanks to all

View solution in original post

2 REPLIES 2

 Try some of the examples.   https://github.com/STMicroelectronics/STM32CubeF1/blob/master/Projects/STM32F103RB-Nucleo/Examples/FLASH/FLASH_EraseProgram/Src/main.c#L83

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ahmash
Associate II

this is solution and i found it at chatgpt 

HAL_FLASH_Unlock();

// 0x08000000 + (63 * 1024) = 0x0800FC00 //start byte address of page 63

FLASH_PageErase(0x0800FC00);

HAL_FLASH_Lock();

case closed thanks to all