Millions thanks for the prompt reply, Just to digest the information I quickly went through the relevant infos in the manual. All the ports will be outputs with the expiation of B (B1 to B3 = input) following are the comments that I put beside each line Rgds, Aslam dbankif portc ;Couldn t find this in assembly instruction list movf portc, w ;Got you there NO PROBLEM) iorlw b'00011000' ;inclusive OR means 0 has no effect movwf portc ;write modified value back to port (Got it) To clear bits, AND with the appropriate mask: dbankif portc ;Don t get it! movf portc, w ;read the old PORTC value andlw b'11100111' ;got you ANDING with 0 return 0! movwf portc ;write modified value back >> > Hi to every one of you every where > > A Very concrete question: If in the following code I want to clear > > bit 4 and bit 3 and then call the delay and then set both bit 3 and 4 > > Basically, instead of one pin at the time I want to make two pins > > high or low How can I do this? Would simply bcf PORTC, 4,3 work? > >No. BSF and BCF operate on only one bit at a time. To change multiple >bits >simultaneously, you have to write a new value to the whole port. To just >set bits 4 and 3, read the port, OR with the appropriate mask, then write >the result back to the port: > > dbankif portc ;make sure banks are set for access to PORTC > movf portc, w ;read the old PORTC value > iorlw b'00011000' ;make sure bits 4 and 3 are 1 > movwf portc ;write modified value back to port > >To clear bits, AND with the appropriate mask: > > dbankif portc ;make sure banks are set for access to PORTC > movf portc, w ;read the old PORTC value > andlw b'11100111' ;make sure bits 4 and 3 are 0 > movwf portc ;write modified value back to port > >Beware of the read-modify-write behaviour of I/O ports. On a read of the >port register, you get what the pin voltage is, NOT what the output latch >is >set to. These can differ if the pin is an input, or the external circuit >is >forcing the pin level. There is a bit more to this but it's been discussed >many times here before and is also well documented in the manual. Make >sure >you understand the issue. > > >***************************************************************** >Embed Inc, embedded system specialists in Littleton Massachusetts >(978) 742-9014, http://www.embedinc.com > >-- >http://www.piclist.com hint: To leave the PICList >mailto:piclist-unsubscribe-request@mitvma.mit.edu _________________________________________________________________ The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu