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.

ISR context save and restore and an NMI error on a C24

Other Parts Discussed in Thread: CCSTUDIO

Im developing a program for the LF2406 using CCSv3.3 . In my build options in linker Ive added the library rts2xx.lib in the Include libraries( -l )  field. But when I look at the generated .asm files, I get a list of undefined references at the end - like this,

"

*****************************************************
* UNDEFINED REFERENCES *
*****************************************************
.global I$$SAVE
.global I$$REST
.end

"

 Im asking because Im trying to Debug an NMI error that happens around every 30-40 minutes, and I was wondering if something was going wrong in the context-save and restore functions used in the ISR. Could this have something to do with it? Any other ideas on how I might Debug it?

  • Harsha,

    I$$SAVE and I$$REST are the ISR context save and restore routines in the rts2xx.lib.  So in your source code .asm files, you're just going to see calls to these external references, but you won't see the source code for the library functions themselves.  All the source for the rts2xx library is provided in the file C:\CCStudio_v3.3\c2400\cgtools\lib\rts.src.  This is a zip file, despite the extension being .src.  Unzip using your zip archiving utility.  The context save/restore routines are in the file saverest.asm.

    I'd say though that the context save/restore routines are not the cause of the problem you are having.  On C24x, the compiler just does a dumb context save/restore where EVERY CPU register is saved and later restored.  Those routines have been around for a very long time (as has the C24x, so I wonder why you are developing on it but that is a different matter).

    Read section 2.5.3 of the LF240x User's Guide SPRU357c (I know, you probably have already read it).  NMI is caused by access to an illegal address.  Change your NMI ISR so that it returns.  Put a breakpoint in the ISR.  When the NMI occurs, you'll hit the breakpoint.  STEP the debugger and see where you return too.  Is it valid memory?  If not, something caused your code to crash and fetch from that address.  Maybe a stack overflow.  If it is valid code, look upstream an instruction or two and see if you're making any data accesses.  The context restore from NMI will also put the CPU registers back together, so you can try to see if a ARx register or DP was 'Bad' when making the data access.  Just some debug thoughts.

    Good Luck,

    David