Tamas Rudnai wrote: > On Sat, Jul 11, 2009 at 12:17 PM, Heinz Czychun wrote: > >> Yes, sorry poor wording. Timer 0 is running, but when I >> reprogram the PIC >> with Timer 1 enabled (both running and interrupting), Timer 0 also >> starts interrupting >> even with the INTCON,T0IE bit cleared. >> > > Hi Heinz, > > You do not have the T0IE enabled, but you still check the T0IF in your ISR > routine. T0IF is independent from interrupt, it only tells if the Timer0 was > overflowed or not. What happens is that you get an interrupt from Timer1, > but then the ISR routine realizes that the Timer0 had an overflow as well > therefore you treat the interrupt as it was generated by the Timer0. > > Tamas A classic example where you had *one* interrupt running just OK and then, when adding a second interrupt source, didn't add tests on xxIE-flags to the ISR... :-) So test the xxIE flag *first* then test the xxIF flag. If one xxIE flag is cleared, just jump to the next source. That is : is T0IE set ? (interrupt enabled for TMR0) if no, goto test_tmr1 if yes, check TOIF and run TMR0 ISR if set. test_tmr1: is T1IE set ? (interrupt enabled for TMR1) if no, finish ISR (or goto next source/xxIE flag) if yes, check T1IF and run TMR1 ISR if set. And so on for any number of interrupt sources. Jan-Erik. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist