Hello,
I'm running into an issue where, after about an hour of running my program on my TM4C123GH6PZ, the microcontroller goes into the Fault ISR. I want to walk through the steps I've taken so far and look for some advice or tips moving forward.
I attempted to use this document here to debug the fault. I've determined from the NVIC_FAULT_STAT register that I'm running into an invalid state usage fault. The NVIC_FAULT_ADDR is reading address 0xE000EDF8. From the TM4C123GH6PZ datasheet, this appears to be within the memory reserved for the Cortex-M4F peripherals (sys stick, NVIC, MPU, FPU, and SCB). Looking at the Cortex-M4F data sheet, 0xE000EDF8 appears to be the "debug core register data register." I've come to a dead end here, as I'm not entirely sure if this is a correct fault address.
It sounds like the most common cause of the invalid state usage fault is stack overflow or stack corruption. I read this document and added a hardware watchpoint to monitor __stack. So far, I haven't hit this watchpoint yet but I still hit the FaultISR. I had previously read that sometimes debugging a stackoverflow can be done by setting the entire stack to a specific known value and seeing if/when all the values get modified in memory. I read that this can be done in the linker file but I'm not sure how.
I also noticed that inside my linker file (.cmd), there is the statement
__STACK_TOP = __stack + 1900;
This is carry-over from an old project. My stack size is actually set to 2600. What is the effect of the above statement? From a previous thread on the forums, __STACK_TOP and __STACK_END start as the lowest value of the stack. As the stack is filled, __STACK_TOP decreases towards the value __stack. By setting __STACK_TOP = __stack + 1900, am I incidentally setting my stack to only 1900? My map file shows a stack size of 0xA28 (2600), but it seems like I'm offsetting the stack top at the beginning of the program.
Any help, tips, or thoughts would be widely appreciated! This is my first time really digging into stack usage, so please be light if I'm missing something obvious!
Regards,
CamK