2021-07-06 04:40 AM
typedef struct
{
UINT32 R0;
UINT32 R1;
UINT32 R2;
UINT32 R3;
UINT32 R12;
UINT32 LR;
UINT32 PC;
UINT32 IPSR;
}STACK_DATA_TYPE;
2021-07-06 04:53 AM
The PSP address indicates the stack top of the pre-exception thread task. When hard fault exception handler excute, it would push R0/1/2/3/12/LR/PC/IPSR into the task stack, so through the PSP value, also get the LR/PC value. But why the LR/PC value are equal 0xFFFFFFFF, now how can find the bug?
typedef struct
{
UINT32 R0;
UINT32 R1;
UINT32 R2;
UINT32 R3;
UINT32 R12;
UINT32 LR;
UINT32 PC;
UINT32 IPSR;
}STACK_DATA_TYPE;
void HardFaultISP(void)
{
unsigned int u32LR_Bak, u32PC_Bak;
STACK_DATA_TYPE *pSP;
pSP = (STACK_DATA_TYPE *)__get_PSP();
u32LR_Bak = pSP->LR;
u32PC_Bak = pSP->PC;
}
2021-07-06 09:23 AM
Are you looking at the right stack?
LR as passed (not stacked) should be a magic value imparting the stack to use.
Probably want the entry code in assembler, be easier that way.
https://github.com/cturvey/RandomNinjaChef/blob/main/KeilHardFault.c
2021-07-07 09:26 PM
Thank your answer�?
2021-07-07 09:29 PM
You meaning through the function "__get_PSP()" running in the hardFaultIsp() , we can't get the correct process stack address ?