> >> MOVF PORTB,W > >> MOVWF SHADOWB > >> MOVLW B'100' > >> IORWF SHADOWB,W > >> MOVWF PORTB > >> > > = > > One thing to watch out for here is interrupts. If you write to another = pin in > > port B in the interrupt routine, a bit banged serial output for example= , you > > have to make sure that the interrupt routine isn't executed between whe= n you > > read the content of the port to the shadow register until you write it = back. > > Otherwise the change made by the interrupt routine will be undone when = you > > write back the shadow register. > = > Good programming practice would dictate that the interrupt routine also = > uses the shadow, so there would be no problem. > = 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 when t= he = non interrupt code does MOVWF PORTB. The key is, appart from using a shadow = register, is to never read back from the port to the shadow register. /Ruben =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