When an interrupt like TMR0 is turned off and on again using some C code to do it I would expect that on turning it on the interrupt would count to 255 and fire the macro after that. But I find that it fires the macro immediately it is turned on. Is there a way around that?
If I used the Flowcode command to turn it off and on again would it be different? I forget now but think I was using C to be faster.
//Turn on interrupts
//C Code:
intcon.T0IE = 1; // Turn timer on
intcon.PEIE = 1; // Enable peripheral interrupts
intcon.GIE = 1; // Enable global interrupts
Interrupt
Moderator: Benj
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
Re: Interrupt
The timer interrupt flag will still be set every timeout period, even though no interrupt occurs due to it being disabled.
Hence an interrupt occurs immediately that the interrupt is re-enabled.
So before you re-enable the timer interrupt you will need to clear the timer overflow interrupt flag T0IF
Hence an interrupt occurs immediately that the interrupt is re-enabled.
So before you re-enable the timer interrupt you will need to clear the timer overflow interrupt flag T0IF