Dear C2000 expert,
I used C function as ISR entrance, and would like to call assembly function in C ISR. But I found that if I used ASP instruction at the beginning of assembly function, and NASP at the end of it, then the PC can't be restored to the value that before interrupting. Can you please let me know why? And what is the limitation of using ASP/NASP instruction?
Here is what my code looks like:
1. C function for ISR entrance:
//
// epwm1_timer_isr - Interrupt routines uses in this example
//
__interrupt void
epwm1_timer_isr(void)
{
EPwm1TimerIntCount++;
assembly_func();
//
// Clear INT flag for this timer
//
EPwm1Regs.ETCLR.bit.INT = 1;
//
// Acknowledge this interrupt to receive more interrupts from group 3
//
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}
2. Assembly function code: if the ASP and NASP instructions are in the function, then PC can't be restored into correct value after ISR execute completely.
; label to _assembly_func function
.def _assembly_func
.text
_assembly_func:
;context save
ASP
PUSH AR1H:AR0H
PUSH XAR2
PUSH XAR3
PUSH XAR4
PUSH XAR5
PUSH XAR6
PUSH XAR7
PUSH XT
;-----------------------
; full context restore
POP XT
POP XAR7
POP XAR6
POP XAR5
POP XAR4
POP XAR3
POP XAR2
POP AR1H:AR0H
NASP
LRETR ;Long Return Using RPC
Regards,
Jack