STM32 F7: lock flash CR and avoid bus fault
Hi,
On a STM32 F7, I would like to lock access to the FLASH_CR by writing a wrong key to the FLASH_KEYR register. Writing a wrong key results in a bus fault (disabling the bus fault raises it to a hard fault).
Could someone help me with a way to write a wrong key to FLASH_KEYR and mask the bus fault? I do not want to mask all bus faults (just this once when writing the wrong key).
__set_FAULTMASK(1);
FLASH->KEYR = 0;
SCB->SHCSR &= ~SCB_SHCSR_BUSFAULTPENDED_Msk;
__set_FAULTMASK(0);
This only works when stepping through a debugger but not in the regular cases.
Any suggestions would be greatly appreciated.
Thank you.
