Programming a Data in to Flash memory STM32G series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-04-11 2: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();
- Labels:
-
Flash
-
STM32G0 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-04-11 2: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-04-11 4:05 AM
Hello @Sarra.S​ Thank youfor your Response, I got the issue after adding this HAL_FLASH_GetFlagStatus() function.
Please guide me I have shared screen shot below.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-09 2:31 AM
bro i am facing the same issue i am not even getting data if do them induadually also
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-09 2:39 AM
