Wouter van Ooijen escreveu: > Ruben J=F6nsson wrote: > = >>>>> MOVF PORTB,W >>>>> MOVWF SHADOWB >>>>> MOVLW B'100' >>>>> IORWF SHADOWB,W >>>>> MOVWF PORTB >>>>> = > > = >> Yes, there still could be problems if the interrupt is just after IORWF = >> SHADOWB,W. Then changes done in the interrupt routine will be undone whe= n the = >> non interrupt code does MOVWF PORTB. The key is, appart from using a sha= dow = >> register, is to never read back from the port to the shadow register. >> = > > Hmmm you are right. But I don't understand your solution? > > BSF shadow, 0 > MOVFW shadow > =3D=3D=3D> interrupt here > MOWF port > > This sequence does not read the port, but changes made by the interrupt = > would still be lost. > = All you need is to disable the interrupts before and re-enable after the sequence. Sometimes you don't have a choice. For absolutely most uses, this very short period (4 TCy including disabling and re-enabling time) with interrupts off will not degrade the performance: bsf shadow,0 bcf INTCON,GIE movfw shadow movwf PORTx bsf INTCON,GIE The interrupt latency will increase at most by 3 TCy. __________________________________________________ Fa=E7a liga=E7=F5es para outros computadores com o novo Yahoo! Messenger = http://br.beta.messenger.yahoo.com/ = -- = http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist