2022-05-15 07:24 AM
Hi!
I'm trying to save values in the FLASH memory, but the values don't are saved. I've implemented erase command in order to preform flash_program command. I'm using a NUCLEO64 - STM32F303RE...
if(HAL_FLASH_Unlock() != HAL_OK)
{
debugPrintln(&huart2, "HAL UNLOCK ERROR");
}
FLASH_PageErase(0);
if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, (uint32_t) 0x08000000, (uint32_t) 0x01) != HAL_OK)
{
debugPrintln(&huart2, "HAL WRITE ERROR 1");
}
if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, 0x08000004, (uint32_t) 0x00000000) != HAL_OK)
{
debugPrintln(&huart2, "HAL WRITE ERROR 2");
}
if(HAL_FLASH_Lock() != HAL_OK)
{
debugPrintln(&huart2, "HAL lOCK ERROR");
}
After the execution, the maps is next:
2022-05-18 02:11 AM
Hello ACast.5,
welcome ST community. I have two questions regarding your code. First is where is your program code stored in the memory that you are writing to the first page of FLASH. And second could you tell me if you get any errors? Regarding erasing and programming flash there is prepared example that is directly prepared for STM32F303RE nucleo board. Please check the STM32F3Cube FW package. The example project could be found under the folder : \STM32Cube_FW_F3_V1.11.3\Projects\STM32F303RE-Nucleo\Examples\FLASH\FLASH_EraseProgram.
With the best regards,
Petr David