2014-05-08 02:57 AM
How could I write some code that would access a memory address and wouldn't generate a bus fault if it was incorrect? Or failing that, is there a way to safely check if an address is valid, or maybe even a way to have the BusFault handler return and have normal execution resume?
I'm writing a language interpreter for an STM32F103, and there are some cases when this would be very handy:I've tried quite hard to get something working, but haven't had much luck so far - if I return from the Bus Fault handler (even after clearing the flags) the processor immediately HardFaults.
thanks!2014-05-08 09:13 AM
Just tried this - it was actually SP+24 - I can't count.
My mistake had been trying to clear the busfault active flag with:SCB->SHCSR &= ~SCB_SHCSR_BUSFAULTACT;I had assumed that the repeated BusFault IRQs were because the active flag needed clearing, but in reality the code above caused the HardFault when the function returned (no idea why!). If I remove that, and add code to set the old PC up correctly, it all works! Thanks for your help everyone!