Interrupt

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Interrupt

Post by echase »

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

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times

Re: Interrupt

Post by LeighM »

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

Post Reply