2024-02-05 02:47 AM
Hi community,
I am observing Hardfault exception when trying to program internal flash of stm32g030k6t6 MCU in FAST mode . is there anyother FLASH registers i need to enable ?
I have attached the code here
static void write_data_to_application(void)
{
//uint32_t *flash_address = (uint32_t *)FLASH_USER_END_ADDR ;
uint32_t flash_address = 0x08007C00 ;
HAL_StatusTypeDef status = HAL_OK;
HAL_FLASH_Unlock();
status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_FAST, (uint32_t)flash_address, (uint64_t)0xDEAD1731);
HAL_FLASH_Lock();
}
Thanks
Narendra C
Solved! Go to Solution.
2024-02-06 06:29 AM
That's still an invalid argument. Why do you want to use FLASH_TYPEPROGRAM_FAST? Your use case is clearly better suited to FLASH_TYPEPROGRAM_DOUBLEWORD as you aren't programming 256 bytes.
2024-02-05 05:50 AM - edited 2024-02-05 05:50 AM
> status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_FAST, (uint32_t)flash_address, (uint64_t)0xDEAD1731);
This is a bogus call. 0xDEAD1731 is not the location of 256 bytes of data, as required for fast programming.
Probably you want to stick with FLASH_TYPEPROGRAM_DOUBLEWORD and program 64-bits at a time.
2024-02-05 09:06 PM
Hello @TDK ,
I am able to save data in Flash with FLASH_TYPEPROGRAM_DOUBLEWORD . but Hard fault exception is still exists even passing arguments correctly with FLASH_TYPEPROGRAM_FAST
Kindly help
Thanks & Regards
Narendra C
2024-02-06 06:29 AM
That's still an invalid argument. Why do you want to use FLASH_TYPEPROGRAM_FAST? Your use case is clearly better suited to FLASH_TYPEPROGRAM_DOUBLEWORD as you aren't programming 256 bytes.
2024-02-06 09:01 AM
Thank you @TDK . I will check the example code for fast programming . i just wanted to understand about it