The use and explanation of TMS320F28335 interrupt priority and interrupt nesting
[Copy link]
When using interrupts, it is necessary to deal with nested interrupts. Let's take a look at how 28335 implements nested interrupts.
1,28335 interrupts are disabled by default.
After entering the interrupt, the CPU turns off the global interrupt by default, saves the IER, enters the ISR, restores the IER after execution, and then turns on the global interrupt.
However, interrupt nesting can be enabled through software. That is, in the interrupt service function, the software enables the corresponding interrupt IER and executes EINT, that is, opens a global interrupt, so that interrupt nesting can be realized.
The following Timer0 interrupt can be nested by the Timer1 interrupt to achieve the flashing of the LED light.
interrupt void TINT0_ISR(void) // CPU-Timer 0
{
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; //Writing 1 to clear flag,must be needed
CpuTimer0Regs.TCR.bit.TIF=1; //Writing 1 to this bit clears the flag
IER |= M_INT13;//enable timer1 interrupt
EINT;
while(1);
}
interrupt void INT13_ISR(void) // INT13 or CPU-Timer1
{
CpuTimer1Regs.TCR.bit.TIF=1; //Writing 1 to this bit clears the flag
LED1_TOG;
}
Note: Since the IER is saved when entering the interrupt, it does not matter how the IER changes during this process, it will be restored when exiting the interrupt.
2. Interrupt priority
2.1 The PIE interrupt priority we usually talk about is that when several interrupts send requests at the same time, the CPU responds to the high-priority interrupt first, and after processing the interrupt service function, responds to the low-priority interrupt. This is done on the basis of no interrupt nesting. 2.2, when interrupt nesting is turned on, any enabled interrupt can be responded to by the CPU, that is, a low-priority interrupt can also interrupt a high-priority interrupt. This is the biggest difference from other MCUs.
Therefore, when enabling interrupt nesting, you must consider carefully and only enable the interrupts that need to be nested. Control the relationship between interrupt nesting to avoid mutual nesting problems.
|