> > >> 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 anothe= r pin > > > in port B in the interrupt routine, a bit banged serial output for ex= ample, > > > you have to make sure that the interrupt routine isn't executed betwe= en when > > > you read the content of the port to the shadow register until you wri= te it > > > back. Otherwise the change made by the interrupt routine will be undo= ne 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= the > non interrupt code does MOVWF PORTB. The key is, appart from using a shad= ow > register, is to never read back from the port to the shadow register. > = Also remember to not store any intermediate results in another register (ev= en = W) and then write it back to the shadow register. Only use atomic, non = interruptable methods (single instructions or disable interrupts) when = manipulating the bits in the (global) 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