The classic gotcha...Is PortA configured to work as a digital port? The powerup state of PortA is default analog, and you need to explicitly "fiddle" with the ADCON registers to turn that off and use them as digital inputs. Otherwise, they read as '0' regardless of the actual input state. Mike H. >From: "Aubrey McIntosh, Ph.D." >Reply-To: pic microcontroller discussion list >To: PICLIST@MITVMA.MIT.EDU >Subject: [PIC:] Reading PortA on 16F877 >Date: Mon, 9 Feb 2004 10:32:23 -0600 > >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > > >I want to read either PortA or PortE on a 16F877 chip as digital input. > >I have read the PortA, PortE, and A/D sections of 30292c.pdf >In particular, I have read p113. >On page 218, there is an example to use PortA. I have not done the >CLRF PortA shown in the example, but otherwise comply. I will try this in >the next cycle. > >I have set ADCON1 to 0x06 and verified this with read and display to LEDs. >I have set and verified TRISA to 0x3F > >I do a very simple > banksel PORTA > movf PORTA,w > banksel PORTD ;home of the LEDs. > movwf PORTD > >The LEDs are always dark. I have success with PORTC as an input. > >Thoughts? > > >- -- >Aubrey McIntosh, Ph.D. > > >-----BEGIN PGP SIGNATURE----- >Version: PGPfreeware 7.0.3 for non-commercial use > >iQA/AwUBQCe2FwKlSw8yssF7EQKtwgCeJkH1LfsMeQzKfAIbhTNbV22kqvQAn3bS >eZLvXCkZhjwOSI+CpLj8fz3n >=kizK >-----END PGP SIGNATURE----- > >-- >http://www.piclist.com#nomail Going offline? Don't AutoReply us! >email listserv@mitvma.mit.edu with SET PICList DIGEST in the body _________________________________________________________________ Check out the great features of the new MSN 9 Dial-up, with the MSN Dial-up Accelerator. http://click.atdmt.com/AVE/go/onm00200361ave/direct/01/ -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body