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.

C28X full context save

hi all,

i read SPRU530 Page 95 that C28 can have full context save that:

PUSH   AR1H:AR0H

PUSH  XAR2

PUSH  XAR3....

POP XAR2

POP XAR3...

i have a question that: when should we need take full context save? interrupt nested? And if we don't take full context save, is there any risk(XARx's data will be changed)?

thanks for your support!

  • Martin,

    I think you meant SPRU430E, not SPRU530.

    Context save/restore applies to any interrupt, whether nested or not.  You must save/restore any CPU register MODIFIED BY THE ISR that is not automatically saved by the hardware.  The automatically saved registers are:

    T, ST0,  AH, AL, PH, PL, AR1, AR0, DP, ST1, DBSTAT, IER

    Note that T, AR1, and AR0 are not the extended registers.  So, the user still needs to save XT, XAR1, and XAR0 if the ISR modifies them.  That's why you see these being saved on the p.95 you cite.

    If the register is NOT modified by the ISR, you don't need to save it.

    Note that if you write the ISR in C (which users do for most ISRs), the C-compiler takes care of the context save/restore.

    Regards,

    David 

  • Hi David,

    thanks for your reply!

    Besides, you said that "if you write the ISR in C (which users do for most ISRs), the C-compiler takes care of the context save/restore."   Does it measns that if we write  the ISR in C, the compiler will take full context save automaticl?  Thanks!

  • Martin,

    Yes, the compiler will automatically context save/restore.  But, you must tell the compiler that the function is an ISR.  To do this, you use the interrupt keyword when you declare the function:

    interrupt void MyIsr(void) {
    }

    The interrupt keyword causes the compiler to do the context save/restore, and also to use a IRET instruction for the return.

    If you are using the TI BIOS operating system however, things are a bit different and you don't use the interrupt keyword.  I won't get into that as I suspect you are not using BIOS.

    Regards,

    David