Catching and clearing BusFaults in STM32 H743
We are having issues with corrupted flash on the STM32 H7 series. The problem manifests where a read to the offending address in flash will cause a bus fault. We think it is down to bad CRC and the way to resolve is usually to wipe the flash and reprogram. What I would like to do is do this on the fly, so detect the offending address and erase the page. I was hoping to do this roughly though the following:
// enable the busfault handler
SCB->SHCSR|= SCB_SHCSR_BUSFAULTENA_Msk;
// disable all faults
__disable_fault_irq();
__DSB();
// read the offending data here
read()
// check the outcome
if (SCB->SHCSR & SCB_SHCSR_BUSFAULTPENDED_Msk) {
// erase the sector here
}
// reset
__enable_fault_irq();
__DSB();
SCB->SHCSR &= ~SCB_SHCSR_BUSFAULTENA_Msk;However this does not work - the fault is prevented correctly but the pending bit is never set and I don't seem to have anyway to detect that a bus fault would have occurred
What am I missing? Or am I totally barking up the wrong tree?
