I've read this:
and it says:
"Do not modify PIEIER registers outside of an ISR for that group. For example, PIEIER1 should only be modified within an ISR from group 1. Likewise PIEIER2 should only be modified within a group 2 ISR."
Now, I have a TIMER0 task that needs to run periodically at 10msec and which lasts about 3-4 msec. At the same time I need to service an ADC interrupt at 50 kHz and three BLDC motor HALL interrupts at 1000 Hz.
I'm using ADCB1, XINT1,XINT2 and XINT3.
Basically I need my TIMER0 interrupt to be interruptible by everything else.
I create this small test:
__interrupt void timer0_ISR() {
volatile uint32_t d;
uint16_t TempPIEIER;
TempPIEIER = PieCtrlRegs.PIEIER1.all;
IER |= 0x801;
IER &= 0x801;
PieCtrlRegs.PIEIER1.all &= 0x001A;
PieCtrlRegs.PIEIER12.all &= 0x0001;
PieCtrlRegs.PIEACK.all = 0xFFFF;
asm(" NOP");
// Wait one cycle
EINT;
// Clear INTM to enable interrupts
for (d = 0; d < 6666; d++) // waste some time just to prove that interrupts are nested
d = d;
g_timer0_tick++;
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
DINT;
PieCtrlRegs.PIEIER1.all = TempPIEIER;
}
It seems to work, but it is not heeding the warning I quoted above.
I have not observed any adverse signs.
So is this ok, or what is the problem?
If this is not acceptable, then how can I make TIMER0 interrupt so that basically any other interrupt can be serviced while it is running?
In addition to above I will also need to service XINT4 and SPIB_RX interrupts.