I'm trying to debug a randomly occuring Hardfault. In trying to trace down the source I read the CPU registers use the Nordic hardfault_implementation.c which grabs the register values. These values are different then the CPU register values I read at the hardfault via Segger J-Link. Also they different from the follow recommended code from freeRTOS:
__asm volatile
(
" tst lr, #4 \n"
" ite eq \n"
" mrseq r0, msp \n"
" mrsne r0, psp \n"
" ldr r1, [r0, #24] \n"
" ldr r2, handler2_address_const \n"
" bx r2 \n"
" handler2_address_const: .word prvGetRegistersFromStack \n"
);
So I'm at a loss which set of values to go with first of all.
-
Secondly, the PC sometimes halts in RAM i.e. 0x20005828, other times it halts in Flash i.e. 0x23CAC. I believe the memory in the Eclipse Disassembly Window is only RAM memory. How do you go about debugging/finding the source of hardfault bugs? I've tried cross referencing the PC value to the memory locations mapped in the .MAP file as well. I know there are a few other posts on hardfault debugging, but most relate to using Keil not Eclipse for tracing.
-
Randomly the PC value is 0xA5A5A5A5, which i know indicates a Stack Corruption. I am using SAADC and HVX calls on separate threads and very quickly. Could these be grinding down the Stack? I know SAADC blocks during sampling.
I appreciate the help guys.