pic microcontroller discussion list <> wrote on Thursday, March 13, 2003 10:22 AM: > I'm wondering if a single pin of portD can be > toggle input or output by using BCF, > e.g > BCF TRISD,7 ; to set bit 7 of portD as output > > The above don't seem to work. > > However, if i use: > MOVLW 7FH > MOVWF TRISD > > I measure and confirmed that pin 7 of portD goes low. > Check your bank bits, if necessary for your processor. If it's not an 18F, you will need something like > Initialization: MOVLW 00H > MOVWF PORTD bsf STATUS,RP0 ; bank 1 for TRISx registers > MOVLW FFH > MOVWF 80H^TRISD ;set all input bcf STATUS,RP0 ; bank 0 for normal operation However, the real problem is probably that when you change the port to an output, it's initial value will be what it's just read on its input. Try adding clrf PORTD after you have change the tristate, to clear any output pins. Apart from that, I can't think why there might be a difference between your bcf and movlw approaches, if those are the only changes to the code. Nigel -- Nigel Orr, Design Engineer nigel@axoninstruments.co.uk Axon Instruments Ltd., Wardes Road,Inverurie,Aberdeenshire,UK,AB51 3TT Tel:+44 1467 622332 Fax:+44 1467 625235 http://www.axoninstruments.co.uk -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads