Dear,
I am using nested interrupts in my project with timer 0 (INT1.7) and timer 1 (INT13).
Timer 0 is a 1ms timer to handle my main state machine. In this interrupt I enable the interrupts to make it possible to handle other communication interrupts.
interrupt void CPU_INT_TIMER_T0(void)
{
// Re-enable this interrupt to receive more timer interrupts
IER|=PIE_INT1;
// Acknowledge interrupt group to receive more interrupts for this group
PieCtrlRegs.PIEACK.all=PIE_INT1;
asm(" nop");
// Allow re-entry
EINT;
// Framework general timer interrupt
State_Machine();
DINT;
}
Timer 1 is used to add delay before changing a GPIO pin in a RS485 driver. (set hardware direction pin)
interrupt void CPU_INT_INT13(void)
{
// Call application timer service routine if required
RS485_InterruptRoutine();
// Clear any pending interrupt
IFR&=~PIE_INT13;
}
Problem I am facing is in some cases (not always) when in interrupt of timer 1 is executed while in interrupt of timer 0 the GPIO is set correctly but when exiting timer 0 interrupt the GPIO is set back to previous state.
1) Entering Timer 0 interrupt
2) Start executing State_Machine() code
3) Entering Timer 1 interrupt
4) Execute RS485_InterruptRoutine()
5) Exiting Timer 1 interrupt with GPIO changed
6) Finishing State_Machine() code
7) Exiting Timer 0 interrupt
8 ) Here the GPIO changes back to previous state
Anyone an idea what can cause this? I guess it depends on when interrupt timer 1 is executing the exiting of interrupt 0 is go wrong?
Thanks on advance.