Question
error HardFault_Handler in HAL_FLASH_Program STM32F303K8
I m a beginner with the FLash and I struggle to find a solution to write and read in FLASH.
I wrote the following program but at the function HAL_FLASH_Program the program goes in HardFault_Handler . Looking inside the HAL_FLASH_Program it is possible to see that
FLASH_Program_HalfWord((Address + (2U*index)), (uint16_t)(Data >> (16U*index))); create the error.
thanks for any help.
#define FLASH_STORAGE 0x08005000
#define page_size 0x800
-----main----
HAL_StatusTypeDef HAL_FLASH_Unlock(void);
//Instantiate the FLASH_EraseInitTypeDef struct needed for the HAL_FLASHEx_Erase() function
FLASH_EraseInitTypeDef FLASH_EraseInitStruct = {0};
FLASH_EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES; //Erase type set to erase pages( Available other type is mass erase)
FLASH_EraseInitStruct.PageAddress = 0x08005000; //Starting address of flash page (0x0800 0000 - 0x0801 FC00)
FLASH_EraseInitStruct.NbPages = 1; //The number of pages to be erased
uint32_t errorStatus = 0;
HAL_FLASHEx_Erase(&FLASH_EraseInitStruct,&errorStatus);
uint16_t FData = 1023;
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,0x0801FC00, (uint16_t)FData);
HAL_StatusTypeDef HAL_FLASH_Lock(void);
uint64_t * RDAddr = (uint64_t *) 0x08005000;
uint64_t RData = *RDAddr;