cancel
Showing results for 
Search instead for 
Did you mean: 

Flash Erase Error

shijinjose
Associate

I am working on STM32WLE5CCU6 mcu and try to erase the flash. But always giving me the error status as 0xFFFFFFFF.

 

whatever address we provide , the errorStatus is always 0xFFFFFFFF

memAddress = FLASH_BASE + (110*FLASH_PAGE_SIZE); //0x08037000

uint32_t eraseFlash(uint32_t memAddress)

{

uint32_t errorStatus = 0;

FLASH_EraseInitTypeDef flashEraseStruct = {0};

flashEraseStruct.TypeErase = FLASH_TYPEERASE_PAGES;

flashEraseStruct.Page = (MemAddress - FLASH_BASE) / FLASH_PAGE_SIZE;

flashEraseStruct.NbPages = 1;

 

HAL_FLASH_Unlock();

HAL_FLASHEx_Erase(&flashEraseStruct, &errorStatus);

HAL_FLASH_Lock();

if(errorStatus == 0xFFFFFFFF)rtn = 0;

printf("errorStatus : %.X\r\n",errorStatus);

return rtn;

}

 

can anyone help me with this ?

1 REPLY 1
TDK
Guru

Check the return value of HAL_FLASHEx_Erase to assess whether or not it succeeded. It will return HAL_OK on success. The error status variable is always initialized to 0xFFFFFFFF for page erases and does not indicate an error.

stm32wlxx-hal-driver/Src/stm32wlxx_hal_flash_ex.c at a496d1eebd7394fb880ebfdd56fdcb5f2cce687b · STMicroelectronics/stm32wlxx-hal-driver

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