This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to Generate Exceptions on Cortex M3?

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?

Parents Reply Children
No data