> -----Original Message----- > From: Olin Lathrop [SMTP:olin_piclist@EMBEDINC.COM] > Sent: Wednesday, April 03, 2002 1:56 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [PIC]:16F873 PortC bit 5 revisited > > > > bsf Portc,3 ;port C bit 5 low > > > bcf portc,3 ;so pulse bit 3 four times > > > bsf Portc,3 > > > bcf portc,3 > > > bsf Portc,3 > > > bcf portc,3 > > > bsf Portc,3 > > > bcf portc,3 > > > goto MAIN > > > > This sort of coding is not recommended in PICs. > > > > I think you are better off doing something like this, or keeping a > > shadow register for portc. > > > > ; xxxx = bits that are previously set or cleared. > > > > movlw b'xxxx1xxx' ; PORTC,3 = 1 > > movwf PORTC > > movlw b'xxxx0xxx' ; PORTC,3 = 0 > > movwf PORTC > > > > etc > > There is nothing wrong with successive BCF BSF as long as you understand > the > implications. It is better to learn the issues than to blindly always use > a > shadow register. Many times you won't need that. > This is one of the times it will very likely be needed however. I have had problems with this type of code running at only 4MHz and driving the gate of a MOSFET. Mike -- 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