You are certainly welcome to it but I don't think it will help you much more than I have said already. It is the technique not the actual code that is relevant - this was written in Oberon-07 for the LPC2xxx series:
PROCEDURE TimerHandler[4]; (* 4 for IRQ or FIQ *)
VAR
lnk: INTEGER;
BEGIN
INC(timeVal);
(* Retrieve the saved value of the link register *)
SYSTEM.GET(SYSTEM.FP + (13 * 4), lnk);
Out.Char('t'); Out.Int(timeVal, 6); Out.Hex(lnk, 12); Out.Ln;
(* Clear the MR0 interrupt *)
SYSTEM.PUT(LPC.T1IR, {0});
(* Update the VIC priority hardware *)
SYSTEM.PUT(LPC.VICVectAddr, 0)
END TimerHandler;
The value (13 * 4) is explained by the fact that the following instructions are excuted on entry to the interrupt handler:
stmdb sp!, { r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 fp lr }
mov fp,sp
So all we are doing is accessing the value of the link register (lr = R13) using the value of the stack pointer (sp = R14) that was saved in the frame pointer (fp = R12)
It might be even easier on the LPC17xx. I can't find my mbed (being miniature is not always a good thing!) but I've just had a look at the code generated for the LPCXpresso. It looks as though lr is untouched in the IRQ handler. I just don't know the best way of accessing the value of lr using C.
Regards,
Chris.
I have a program that occasionally hangs in some function (loop) and I was hoping someone has a way of telling me where the program is hung. I could ground the NMI or some other pin to tell the program to printf its pc address but that is a little much for me to do. Any suggestions would be welcome.
regards