Or if you are using the 18F series use the LAT registers which keep an image of what you latched out to the parallel port. John Dammeyer Automation Artisans Inc. http://www.autoartisans.com Ph. 1 250 544 4950 > -----Original Message----- > From: piclist-bounces@mit.edu > [mailto:piclist-bounces@mit.edu] On Behalf Of Jinx > Sent: Thursday, March 15, 2007 3:30 PM > To: Microcontroller discussion list - Public. > Subject: Re: [PIC] First shot errors > > > > rlf PORTB ; move to RB1 > > Rikard, it's not recommended to use content-modifying instructions > (incf, decf, rlf, rrf etc) directly on a port. In your case > it will probably > work because you're just "moving" an LED. The issue is read-modify- > write. The contents of the port are read, modifed, and then written > back to the port. The problem is that hardware, commonly if any > capacitance is present, may not react as fast as the s/w > > http://www.piclist.com/techref/readmodwrite.htm > > What would be better for you to do is use a shadow register. This > will be internal RAM and therefore can be modified correctly as fast > as the s/w. When the change has been made, it's written to the port > > Like this - > > movf portb,w ; read the port > movwf b_shadow ; copy into shadow reister > rlf b_shadow,w ; modify, result in W > movwf portb ; write modified value back to port > > As for the delays, I use these routines when all that's needed are > approximate delays. They're easily modified for exact delays, but > with IntRC these are usually good enough > > ;================================================ > ; Delays @ 4MHz Fosc > ;================================================ > > s2 movlw .20 ;2 second delay > movwf del4 > dec2 call ms100 ;call 100ms 20 times > decfsz del4 > goto dec2 > return > > ms100 movlw .156 ;100ms delay > movwf del3 > movlw .5 > movwf del1 > nop > nop > nop > nop > nop > next1ms call ms1 > nop > incfsz del3 > goto next1ms > return > > ms1 movlw .10 ;1ms delay > movwf del1 > lp1 nop > incfsz del1 > goto lp1 > nop > nop > return > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist