AnsweredAssumed Answered

RTC Autowake Up & Hard Faults

Question asked by kikugawa.sho on Apr 30, 2012
Latest reply on Apr 30, 2012 by kikugawa.sho
I'm running into a strange issue where if I have the RTC auto-wakeup enabled, I intermittently get hard faults when I run the software through the debugger, break, then step through the code. Seems to happen more frequently if I break after sleep. The hard fault reason is either INVPC or INVSTATE, and some preliminary digging through I find that the LR register has some bogus value (last time this happened, value is at 0xFFFFFFF1). I don't see anything unusual in my stack either. If I take off the RTC auto-wakeup, the processor doesn't hard fault.

I'll implement the Joseph Yui hard fault handler if the above isn't enough to go by.

EDIT: the CPU state at the hard fault is as follows
r0 = 0x00000000
r1 = 0x0000000b
r2 = 0x00000007
r3 = 0x00000000
r4 = 0x080085a8 <- Am looking at what this is
r5, r6 = 0x00000000
r7 = 0x42470000
r8-r11 = 0x00000000
r12 = 0x20001608
sp = 0x20001588
lr = 0xFFFFFFF1
pc = 0x08000350
xPSR = 0x81000003
SP_main = 0x20001588
SP_process, CFBP = 0x00000000

Also the code is compiled with the -fpic flag on (this is a requirement so I can't change it

I went ahead and implemented the hard fault handler and got this:
[Hard fault handler - all numbers in hex]
R0 = 0
R1 = b
R2 = 7
R3 = 0
R12 = 20001608
LR [R14] = 8000319  subroutine call return address
PC [R15] = 8008800  program counter
PSR = 80000013
BFAR = e000ed38
CFSR = 20000
HFSR = 40000000
DFSR = 8
AFSR = 0