Skip to main content
SWenn.1
Senior III
April 30, 2023
Question

HardFault Interrupt when trying to erase flash?

  • April 30, 2023
  • 2 replies
  • 1134 views

Hello...

I am using a Nucleo WB55 board. I can run the FLASH_EraseProgram that comes with the WB55 example code successfully. I have pre-existing code and am trying to pull this into my code. I have checked the PWR and the Flash SFR in the debugger between the two codes (the example and mine) and they look the same. When running my code I get a HardFault Interrupt and when running the example I do not.....

Can anyone give me a reason why the following line of code is causing me to get a HardFault Interrupt?

This line of code is in function FLASH_PageErase (stm32wbxx_hal_flash_ex.c). It is being called from HAL_FLASHEx_Erase function within the same file.

 MODIFY_REG(FLASH->CR, FLASH_CR_PNB, ((Page << FLASH_CR_PNB_Pos) | FLASH_CR_PER | FLASH_CR_STRT));

This topic has been closed for replies.

2 replies

ALABR.1
ST Employee
May 30, 2023

Hello SWenn,

Could you provide more information ? What is the address you trying to erase ? Is it page aligned ? Have you check the Flash read/write protection?

It's may be an unauthorized erase (erase at address of the BLE stack for example)

Best Regards,

Axel L.

SWenn.1
SWenn.1Author
Senior III
June 1, 2023

This has been resolved...