Part Number: MSP432P401R
Hi all,
Is there any way to read the Core LR register in C?
(If yes, don't bother reading on! If no, further details follow to give a background of why I need to read the LR register. Perhaps if a direct read is not possible, then maybe I can restructure my approach so that I don't need to read the LR register)
I'm working with the TIRTOS/SYSBIOS exception handlers.
I've decided to use the standard exception handlersbecause they provide some useful preprocessing of the exception status and provide output to the console that helps me determine that my custom exception handling is working properly.
My configuration is as follows
- m3Hwi.excHandlerFunc is undefined, so one of the default handlers will be used,
- m3Hwi.enableException = true while developing to get full exception decoding while developing, will switch to false once things settle
- m3Hwi.excHookFunc = "&myExceptionHook" gives me a function that can perform some custom exception handling.
My custom execption handler (myExceptionHook) dumps the exception context (plus some extra system state) to external flash (bitbashed) so that it can be read out later to try and diagnose the exception.
The problem here is the myExceptionHook gets passed an exception context that contains the state of the LR register prior to the exception, but not the state of the LR register after the exception. The value after the exception provides some information about the context in which the exception occurred, and it is decoded by the standard exception handler. I'd like to be able to do the same thing when I read the exception context from flash.
One potential alternative is to stop using the in built exception handlers and have a full custom handler (i.e. define m3Hwi.excHandlerFunc = "&myExceptionHandler"). myExceptionHandler is passed two parameters - an exception stack (which can be processed into an ExceptionContext structure) and what I assume is the current state of the LR. I've tried this but I run into problems trying to replicate the Hwi_excFillContext() function. The HWI module has access to data structures etc that I don't.
Cheers
Julian