Skip to main content
SWenn.1
Senior III
Apr 30, 2023 1:01 AM UTC
Question

HardFault Interrupt when trying to erase flash?

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 5:30 PM UTC

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
Jun 1, 2023 7:27 PM UTC

This has been resolved...