Hello,
I would like to know what code was executing when an nRESET occurred. Is there a shadow register of the Program Counter that survives a warm start?
Thank you,
Charlie Johnston
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
I would like to know what code was executing when an nRESET occurred. Is there a shadow register of the Program Counter that survives a warm start?
Thank you,
Charlie Johnston
Hi Charlie,
I've found the Link Register (Register 14) useful in this sort of situation. This persists over nRESET and should give you an idea of where the program failed. The Link Register contains the return address when a Branch with Link (BL or BLX) instruction is executed.
Regards, Tony.
Hi Tony,
I was considering the LR, but several ARM references say it can also be used as a general purpose register. Using the LR may be useful during debug when you can evaluate the address, but I'm looking for a value to store in an error message when an external watchdog triggers nRESET. So far, LR is the closest to what I'm looking for.
Thanks, Charlie Johnston
Hi Charlie,
Would the last function entry address be sufficient? If so, we could investigate the use of entry and exit hooks inserted as a compiler option. These are essentially functions invoked on function entry/exit in which you could, for example, store the function address in uninitialised RAM so that it would be available following warm reset,
Let me know, if this sounds like it might be an idea and you've not used these things before, then I can dig out my notes! I'm using TMS570, CCS 5.3 and CGT 5.0.1 but I had this working on CCS 4 and CGT 4.7.
Regards, Tony.
Hi Charlie,
Just in case I go home before you've had time to consider.
An example entry hook function would be something like:
void Rm_EntryHook(void (*addr)())
{
*noInitRamFuncAddr = addr;
}
This is notified to compiler under Project Properties>CCS Build>ARM Compiler>Advanced Options>Entry/Exit Hook Options then define --entry_hook function name (Rm_EntryHook in my example) and choose --entry_parm as 'address'. You will need to define the function prototype.
You might also need the PRAGMAs to stop entry hook insertion into the entry hook itself (although that does sound a bit weird!), so:
#pragma NO_HOOKS (Rm_EntryHook)
#pragma NO_HOOKS (Rm_ExitHook)
Regards, Tony
Hi Tony,
Thanks for pointing out this CCS option and how to use it. This could be very helpful, more precise than using the LR. We'll now have to see if we can afford the overhead.
I'll assume there is no PC shadow register from the absence of a TI reply.
Charlie Johnston
Hi Charlie,
You are correct in that there is no shadow register for storing off this type of information in the case of an external register. There is; however, information retained within the ESM regarding any relevant error conditions within the microcontroller that were not cleared or caused a reset. Also, if the error was due to an uncorrectable error, this information is retained through a nRST. Perhaps these combined with the methods outlined by Tony would be useful to you.
Tony and Chuck,
Thanks for your time. This should be enough info to see if I can capture what I need.
Charlie Johnston