Dear all,
I'm using PowerPac 3.80g / Ewarm 5.40 on STM32F101 Cortex M3 target.
I want to find where the processor enters the hardfault handler. I wrote a small code to display on LCD:
R0 0X12345678 Hard
R1 0X12345678 Fault!
R2 0X12345678
R3 0X12345678
R12 0X12345678
LR 0X12345678
PC 0X12345678
SR 0X12345678
everything is OK, the values are the same as in the debugger window. That's fine, because the problem arises on EMC perturbations on the field and I can't use the debugger.
Question:
When entering in the handler, the displayed values lead to the OS library, where can I find the PC and/or the task running at this time ?
Regards
JLuc
PSP and MSP pointers were swapped in my program. See working code on EWARM 5.40 hereafter (another compiler may push some register before calling save_fault_cpu_state() .
Regards,
Jluc
Display All
I'm using PowerPac 3.80g / Ewarm 5.40 on STM32F101 Cortex M3 target.
I want to find where the processor enters the hardfault handler. I wrote a small code to display on LCD:
R0 0X12345678 Hard
R1 0X12345678 Fault!
R2 0X12345678
R3 0X12345678
R12 0X12345678
LR 0X12345678
PC 0X12345678
SR 0X12345678
everything is OK, the values are the same as in the debugger window. That's fine, because the problem arises on EMC perturbations on the field and I can't use the debugger.
Question:
When entering in the handler, the displayed values lead to the OS library, where can I find the PC and/or the task running at this time ?
Regards
JLuc
PSP and MSP pointers were swapped in my program. See working code on EWARM 5.40 hereafter (another compiler may push some register before calling save_fault_cpu_state() .
Regards,
Jluc
C Source Code
- uint32_t stack[8]; /* uint32_t is unsigned long in S/T libraries */
- void save_fault_cpu_state(uint32_t * stack_ptr){
- OS_TASK* pRunningTask;
- stack[0]= *stack_ptr++; /* R0 */
- stack[1]= *stack_ptr++; /* R1 */
- stack[2]= *stack_ptr++; /* R2 */
- stack[3]= *stack_ptr++; /* R3 */
- stack[4]= *stack_ptr++; /* R12 */
- stack[5]= *stack_ptr++; /* LR */
- stack[6]= *stack_ptr++; /* PC */
- stack[7]= *stack_ptr; /* PSR */
- // Display or printf
- // Get the running task name
- pRunningTask = OS_GetpCurrentTask();/* get ptr */
- printf("%s",pRunningTask->Name);
- }
- void HardFault_Handler(void)
- {
- save_fault_cpu_state((uint32_t *) __get_PSP()); /* It's the IAR's way to get PSP value */
- /* Go to infinite loop when Hard Fault exception occurs */
- while (1)
- {
- }
- }
The post was edited 1 time, last by JLuc ().