cancel
Showing results for 
Search instead for 
Did you mean: 

hard fault during flash programing

Mohammadreza-Azizi
Associate

hi. i am trying to save a data into stm32h7b0vbt6 flash memory. so i have used HAL_FLASHEx_Erase to erase one of the sectors and HAL_FLASH_Program to program it. Screenshot 2025-04-27 221957.pngScreenshot 2025-04-27 222042.png

it works and flash will be programed.

Screenshot 2025-04-27 222127.png

but when debuging, code gets stuck to while of the void HardFault_Handler(void) and it doesn't continue. how i fix it?

Screenshot 2025-04-27 222210.png

1 ACCEPTED SOLUTION

Accepted Solutions

At 8K in you're probably erasing the application itself.

Use a sector at the END of memory, not the front.

Look at what is actually reported by the Hard Fault.. the memory address and the processor registers.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

1 REPLY 1

At 8K in you're probably erasing the application itself.

Use a sector at the END of memory, not the front.

Look at what is actually reported by the Hard Fault.. the memory address and the processor registers.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..