Part Number: TMS320F28384S
Hi champs,
For c28x interrupt nesting, we suggest not to modify PIEIER registers outside of an ISR for that group, otherwise the spurious INTx.1 interrupts can be triggered.
For example, we have INT3.8, INT9.2 and INT9.5 interrupts and want to prioritize INT9.5, if INT9.2 interrupt happens and be latched in IFR.9 before CPU branches to INT3.8 ISR, when we modify PIEIER9 in INT3.8 ISR and then spurious INT9.1 will be triggered, this is the reason we suggest not to modify PIEIER outside of an ISR for that group.
__interrupt void EPWM8_ISR(void) // INT3.8 ISR
{
uint16_t TempPIEIER;
TempPIEIER = PieCtrlRegs.PIEIER9.all; // Save PIEIER register for later
IER |= 0x100; // Set global priority by adjusting IER
IER &= 0x100;
PieCtrlRegs.PIEIER9.all &= 0x0010; // Set group priority by adjusting PIEIER9 to allow
// INT 9.5 to interrupt current ISR
PieCtrlRegs.PIEACK.all |= 0x0100; // Enable PIE interrupts
asm(" NOP"); // Wait one cycle
EINT; // Clear INTM to enable interrupts
// Insert ISR Code here.......
DINT;
PieCtrlRegs.PIEIER9.all = TempPIEIER;
}
If we modify above ISR to below function, modify PIEIER9 for INT9.5 and then clear other bits in IFR register before setting IER register, can we modify PIEIER9 in INT3.8 ISR and avoid the spurious INT9.1 interrupt?
If INT9.2 happens before C28x branches to INT3.8 ISR, since INT9.2 is latched in PIEIFR9.2, the INT9.2 interrupt should can be recover when write back the TempPIEIER to PIEIER9 before returning from INT3.8 ISR.
Is it correct please?
__interrupt void EPWM8_ISR(void) // INT3.8 ISR
{
uint16_t TempPIEIER;
TempPIEIER = PieCtrlRegs.PIEIER9.all; // Save PIEIER register for later
PieCtrlRegs.PIEIER9.all &= 0x0010; // Set group priority by adjusting PIEIER9 to allow
// INT 9.5 to interrupt current ISR
IFR &= 0x100;
IER |= 0x100; // Set global priority by adjusting IER
IER &= 0x100;
PieCtrlRegs.PIEACK.all |= 0x0100; // Enable PIE interrupts
asm(" NOP"); // Wait one cycle
EINT; // Clear INTM to enable interrupts
// Insert ISR Code here.......
DINT;
PieCtrlRegs.PIEIER9.all = TempPIEIER;
}
Regards,
-Luke