cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H573 Flash Memory did not retain the data after reset and power cycle

Mathan Raja
Associate II

Hi,

I am using the STM32H573I-DK eval board.

I can able to write and read the data in flash memory (sector 127). But after resetting or power cycle it does not retain the data. that sector fills with 0xFFFFFFFF only. 

how do fix this issue?

Here is my code,

 

 

MathanRaja_0-1714994451040.png
#define FLASH_STORAGE_1      0x081FE000

 

bool answer = true;

uint32_t PageError;

FLASH_EraseInitTypeDef flashErase;

HAL_FLASH_Unlock();

flashErase.TypeErase = FLASH_TYPEERASE_SECTORS;

flashErase.Sector = FLASH_SECTOR_127;

flashErase.NbSectors = 1;

flashErase.Banks = FLASH_BANK_2;

volatile HAL_StatusTypeDef status;

status = HAL_FLASHEx_Erase(&flashErase, &PageError);

if(status == HAL_OK){

for (uint32_t i = 0; i < size; i += 16)

{

if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_QUADWOD, FLASH_STORAGE_1 + i, (uint32_t)data) != HAL_OK)

{

answer = false;

break;

}

data += 16;

}}

HAL_FLASH_Lock();

Thanks

Mathan

0 REPLIES 0