2024-12-06 11:08 AM - last edited on 2024-12-06 11:20 AM by SofLit
I have a small working touchGFX project with freertos app on a stm32F746-disco.
I want to write a few variables to flash so I am trying to call write/read in StartDefaultTask, but I get a Hard Fault when I go to Lock the Flash. I have tried a few different locations (0x60000000 & 0x70000000) that should not be used.
Why might this not be working?
/* USER CODE BEGIN 0 */
uint32_t Flash_Address = 0x60000000;
/* USER CODE END 0 */
void StartDefaultTask(void *argument)
{
/* USER CODE BEGIN 5 */
// /* Infinite loop */
for(;;)
{
osDelay(100);
HAL_FLASH_Unlock();
HAL_FLASH_Program(FLASH_TYPEPROGRAM_BYTE, Flash_Address, 0x13);
HAL_FLASH_Lock();
}
/* USER CODE END 5 */
}
Solved! Go to Solution.
2024-12-06 11:18 AM - edited 2024-12-06 11:21 AM
Hello,
Flash_Address = 0x60000000 ? How?
The Flash address starts at 0x08000000 and end address at 0x80FFFFF for STM32F746 MCU. 0x60000000 address is not in the range of the internal Flash. Also your procedure to write to the Flash is incorrect. You need to erase the Flash sector before writing to it. Please refer to this example on how to write to the infernal flash memory: https://github.com/STMicroelectronics/STM32CubeF7/tree/master/Projects/STM32756G_EVAL/Examples/FLASH/FLASH_EraseProgram
2024-12-06 11:18 AM - edited 2024-12-06 11:21 AM
Hello,
Flash_Address = 0x60000000 ? How?
The Flash address starts at 0x08000000 and end address at 0x80FFFFF for STM32F746 MCU. 0x60000000 address is not in the range of the internal Flash. Also your procedure to write to the Flash is incorrect. You need to erase the Flash sector before writing to it. Please refer to this example on how to write to the infernal flash memory: https://github.com/STMicroelectronics/STM32CubeF7/tree/master/Projects/STM32756G_EVAL/Examples/FLASH/FLASH_EraseProgram
2024-12-06 12:47 PM
Thanks!