2023-04-11 02:03 AM
Hello Every one I am using NUCLEO-G0B1RE board when trying to store the data in to flash memory address its not updating after erasing but individually if I try only erase or only write data in to flash memory it is working
please suggest me below is my code
at run time i would like to erase and update the data suggest me if went wrong in the code
uint32_t BaseAddr = 0x08041000; //global variable.
uint64_t FlashData = 0xee;////global variable.
inside main function
HAL_FLASH_Unlock();
FLASH_PageErase(2,258);
HAL_FLASH_Lock();
HAL_Delay(100);
HAL_FLASH_Unlock();
HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, BaseAddr, FlashData);
HAL_FLASH_Lock();
2023-04-11 02:44 AM
Hello @Karthik Kumar,
So based on your code, you're trying to erase a page from flash memory and then write data to a specific address in the same page..
you are writing a double word, so your base address (0x08041000) have to be aligned with 8 bytes
The problem is either in the erase or the write operation!
So, verify the erase is successfully done before writing, using HAL_FLASH_GetFlagStatus() function.
for example to wait for the erase operation is complete before HAL_FLASH_Lock();
Verify the write operation by reading back from the address you wrote to, and compare it to the data you wrote.
Hope that helps!
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-04-11 04:05 AM
2024-01-09 02:31 AM
bro i am facing the same issue i am not even getting data if do them induadually also
2024-01-09 02:39 AM