Hello! I am currently working on Cortex - M3 using Keil uvision. I have been getting an INVPC hard fault repeatedly. So I increased the stack size from 0x400 to 0x800 and set the stack alignment bit in CCR register at power on.
R0 = 28000134 R1 = 1 R2 = 40000000 R3 = 1 R12 = ae60cd5 LR = 80015b9 PC = 80015be PSR = 2100002c- FSR/FAR: CFSR = 8200 HFSR = 40000000 DFSR = 0 AFSR = 0 BFAR = 28000130
By disassembling the code, I found that the faulty instruction given below which was inside the Timer 2 ISR :
0x080015bc: 4877 wH LDR r0,[pc,#476] ; [0x800179c] = 0x20000130
This is done in attempt to increment a global counter uint16_t uiTimeCounter = 0;
It appears that the memory address got corrupted. Any insights on how should I proceed to solve this would really be helpful. Thank you.
Set a data watchpoint on this address.
If you mean by using debugger then unfortunately I am working without a debugger currently. I have acquired above data through UART. If not, can you please explain exactly how should I do that?
You can use watchpoints in your code w/o debugger. There are some threads inside this forum about this.
Or just connect a debugger and hope the error will also appear when it is attached.