>-----Original Message----- >From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] >Sent: 09 August 2006 13:14 >To: piclist@mit.edu >Subject: 16F877A port input / output problem > > > > >I want to have all ports as digital input apart from D which i >wasnt as a digital output. Only problem is i dont really know >what im doing. I have a fairly healthy knowledge of C but a >fairly limited knowledge of PICs > >my code so far is; > > >**** > >// First PIC program > >void main() >{ > PORTA = 0x00; > TRISA = 0x00; > PORTB = 0x00; > TRISB = 0x00; > PORTC = 0x00; > TRISC = 0x00; > PORTD = 0x00; > TRISD = 0x00; > PORTE = 0x00; > TRISE = 0x00; To configure port pins as inputs you have to SET the TRIS bits, e.g. TRISA = 0xFF; /* all inputs */ All analog pins are switched to analog mode by default, so you need to program ADCON1 to make them digital pins: ADCON1 = 0x07; /* configure PORTA for digital operation */ Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist