Tool/software: Code Composer Studio
I created a division by 0 error intentionally to invoke Usage FAULT handler but when I print the result it prints ERROR. Instead of executing my Fault handler. I changed the usage fault handler in startup_ccs.c file from default to my custom. How should I handle fault so that they go to my handler?
int
main(void)
{
volatile uint32_t ui32Loop;
main(void)
{
volatile uint32_t ui32Loop;
SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN| SYSCTL_XTAL_16MHZ);
ConfigureUART();
uint32_t a, b ,c, d ,val;
uint32_t status, e, f, g, h , k, faultstatus;
float num;
a = 5;
b = 8;
c = 10;
d = 12;
FlashAllUserRegisterSet(a,b,c,d);
SysCtlDelay(1000);
FlashUserSave();
SysCtlDelay(1000);
UARTprintf("Set\n");
SysCtlDelay(1000);
status = FlashAllUserRegisterGet(&e, &f, &g, &h);
UARTprintf("%d\n",status);
if(status == 0){
UARTprintf("print\n");
UARTprintf("%d\n",f);
UARTprintf("%d\n",e);
UARTprintf("%d\n",g);
UARTprintf("%d\n",h);
}
faultstatus = HWREG(NVIC_FAULT_STAT);
UARTprintf("NVIC_FAULT_STAT => %d \n",faultstatus);
k = UARTCharGet(UART0_BASE);
num = (float)k;
val = ((float)5)/num;
faultstatus = HWREG(NVIC_FAULT_STAT);
UARTprintf("NVIC_FAULT_STAT => %d \n",faultstatus);
UARTprintf("%f\n",val);
}
ConfigureUART();
uint32_t a, b ,c, d ,val;
uint32_t status, e, f, g, h , k, faultstatus;
float num;
a = 5;
b = 8;
c = 10;
d = 12;
FlashAllUserRegisterSet(a,b,c,d);
SysCtlDelay(1000);
FlashUserSave();
SysCtlDelay(1000);
UARTprintf("Set\n");
SysCtlDelay(1000);
status = FlashAllUserRegisterGet(&e, &f, &g, &h);
UARTprintf("%d\n",status);
if(status == 0){
UARTprintf("print\n");
UARTprintf("%d\n",f);
UARTprintf("%d\n",e);
UARTprintf("%d\n",g);
UARTprintf("%d\n",h);
}
faultstatus = HWREG(NVIC_FAULT_STAT);
UARTprintf("NVIC_FAULT_STAT => %d \n",faultstatus);
k = UARTCharGet(UART0_BASE);
num = (float)k;
val = ((float)5)/num;
faultstatus = HWREG(NVIC_FAULT_STAT);
UARTprintf("NVIC_FAULT_STAT => %d \n",faultstatus);
UARTprintf("%f\n",val);
}