Hi all,
I am trying to generate exceptions like Bus Fault, Usage Fault on ARM Cortex-M3. My code for enable exceptions:
void EnableExceptions(void) { UINT32 uReg = SCB->SHCSR; uReg |= 0x00070000; SCB->SHCSR = uReg; //Set Configurable Fault Status Register SCB->CFSR = 0x0367E7C3; //Set to 1 DIV_0_TRP register SCB->CCR |= 0x00000010; //Set priorities of fault handlers NVIC_SetPriority(MemoryManagement_IRQn, 0x01); NVIC_SetPriority(BusFault_IRQn, 0x01); NVIC_SetPriority(UsageFault_IRQn, 0x01); } void UsageFault_Handler(void){ //handle //I've set a breakpoint but system does not hit } void BusFault_Handler(void){ //handle //I've set a breakpoint but system does not hit }
I tried to generate division by zero exception and saw the variables value as "Infinity". However system does not generate any exception on keeps running. Also tried to generate Bus Fault exception and same thing happend.
Also when I comment out to EnableExceptions function system works correctly. What is wrong with my code? Does ARM handle these kind of errors inside of the microprocessor?
DIvision by zero is simply a legal operation in IEEE float. Try integers. Maybe put infinite loops into your interrupt handlers, or a jump to a generic hard fault handler. The value of 0x00070000 doesn't seem to be the one allowing the interrupts you want: http://www.keil.com/appnotes/files/apnt209.pdf