cancel
Showing results for 
Search instead for 
Did you mean: 

Hard Fault exception is occurring while programming in FAST mode for saving data in stm32G0 Memory

Nchun.1
Senior

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

@TDK 

1 ACCEPTED SOLUTION

Accepted Solutions

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.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

4 REPLIES 4
TDK
Guru

> 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.

If you feel a post has answered your question, please click "Accept as Solution".

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 

 

Nchun1_1-1707195623454.pngNchun1_2-1707195666832.png

 

Thanks & Regards

Narendra C

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.

If you feel a post has answered your question, please click "Accept as Solution".

Thank you @TDK . I will check the example code for fast programming . i just wanted to understand about it