I was actually trying to do this from within an ISR, where it would be blinking slow enough to see, but the read-write info is quite helpful. I was actually o-scoping it to make sure that I understood how TMR0 and prescalers worked. -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Olin Lathrop Sent: Friday, June 22, 2001 4:33 PM To: PICLIST@MITVMA.MIT.EDU Subject: Re: [PIC]: toggle port bit > Will an XORWF properly toggle the bits of an output pin? Such as blinking > an LED with > > > loop > movlw b'0001000' ;pin 3 > xorwf PORTD > goto loop Yes, if the external circuit allows RB3 voltage to get to its new logic level within three instruction times. The XORWF PORTD is a read-modify-write instruction. On the read, it gets the actual pin logical level, not the level it is being driven to. The reason you have three instruction times instead of the four for this loop is that the read occurs at the start of the instruction and the write at the end, so there are three instruction times from the write at the end of the XORWF to the read at the start of the next XORWF. By the way, unless you are running at a rediculously slow clock rate, this will not blink the LED in human terms. It will just appear at a steady 1/2 brightness. Even with a 32KHz oscillator, the LED "blink" rate is 1KHz. Another by the way, the loop doesn't need to include the MOVLW instruction, since W doesn't get changed. ******************************************************************** Olin Lathrop, embedded systems consultant in Littleton Massachusetts (978) 742-9014, olin@embedinc.com, http://www.embedinc.com -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu