> = > In the main code the interrupt enable bits are significant in that = > they will prevent a peripheral from generating an interrupt. So the = > interrupt flag bits can safely be ignored. > = > Once an interrupt (any interrupt) forces execution of the interrupt = > service routine the interrupt enable bits become useful flags to tell = > which peripheral's service request should be honoured. But now the = > interrupt flag bits (all that are set) become significant and cannot = > be ignored. Whether the peripheral's interrupt enable bit is set or = > not it's interrupt flag bit must be cleared or the processor will be = > hung repeatedly reentering the interrupt service routine. > = Since a new interrupt won't be generated if its IE bit is clear there will = be = no new interrupt generated so the interrupt will not be reentered if only t= he = IF bit without its IE bit is set. Figure 9-10 in the datasheet explains thi= s = (and the wake up from sleep) better than with 1000 words. The IF bit should= not = be cleared in the ISR if the IE bit is not set since the non ISR code could = look for this bit. I have actually done this where timer0 caused interrupts= to = generate notes of a certain frequency in a buzzer while the main program = checked for other conditions, including timer1 with its IF bit, to tell whe= n to = stop playing one note and go on to the next. Here is one way to efficiently check both IE and IF bits for timer0: isr_tmr0_start btfsc INTCON,TIOE btfss INTCON,TOIF goto isr_tmr0_end isr_tmr0_on bcf INTCON,TOIF ;rest of tmr0 isr here isr_tmr0_end ;check other interrupt sources here ... Note also that you have three conditions to check for with the periferal = interrupts: In addition to the IE and IF bits there is also the PEIE bit. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D Ruben J=F6nsson AB Liros Electronic Box 9124, 200 39 Malm=F6, Sweden TEL INT +46 40142078 FAX INT +46 40947388 ruben@pp.sbbs.se =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist