cancel
Showing results for 
Search instead for 
Did you mean: 

HardFault Interrupt when trying to erase flash?

SWenn.1
Senior III

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));

2 REPLIES 2
ALABR.1
ST Employee

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
Senior III

This has been resolved...