Page 1 of 1
Interrupt problem?
Posted: Mon Dec 06, 2010 2:56 pm
by wayne millard
Hi team,
Is there a problem with interrupts clashing at the same time.
i have timer0 on a 1ms interrupt to run a clock timer and have RB0 as an event
counter. the problem i have is the event counter miss's counts some times.
Thanks,
Wayne M

Re: Interrupt problem?
Posted: Tue Dec 07, 2010 1:09 pm
by Benj
Hello,
The main problem with interrupts can happen if you have large delays or calls to things like LCDs or other slow reacting devices inside the interrupt service routine. The interrupt macro has to be completed before that perticular interrupt is reactivated.
Take for example this.
interrupt 1 fires and service routine 1 starts.
interrupt 2 then fires and service routine 2 starts
service routine 2 ends
interrupt 2 then fires and service routine 2 starts
service routine 2 ends
service routine 1 ends
Here you can see that service routine 1 is greatly extended in size due to interrupt 2 kicking in.
If you can move any code out of the interrupt routine and instead use a variable to control when the code gets called in the main. The variable is set by the interrupt and then cleared in the main when the code has been executed.