Oh yes, if you want to be thorough: banksel TRISA ; Select proper bank movlw 0xFF ; will set port to all inputs errorlevel -302 ; suppress stupid message movwf TRISA ; set the port errorlevel +302 ; re-enable the message in case we screw up later banksel PORTA ; Select the bank containing PORTA ; NOW we can read the puppy movf PORTA,W 72/73 de WB8RCR http://www.qsl.net/wb8rcr didileydadidah QRP-L #1446 Code Warriors #35 ----- Original Message ----- From: "John J. McDonough" To: Sent: Monday, February 09, 2004 2:25 PM Subject: Re: [PIC:] Reading PortA on 16F877 > Your code will work fine on a 16f84, and will work on an 877 if you are in > bank 0 or 1 (only) - remember the 877 has four banks. You assume RP1 to be > clear. On an 877, RP2 is guaranteed clear and TRISA is in bank 1, but maybe > not in some other part. > > However, > > banksel TRISA > movlw 0xFF > movwf TRISA > banksel PORTA > > will work in any case. > > 72/73 de WB8RCR http://www.qsl.net/wb8rcr > didileydadidah QRP-L #1446 Code Warriors #35 > > ----- Original Message ----- > From: "Paul James E." > To: > Sent: Monday, February 09, 2004 1:59 AM > Subject: Re: [PIC:] Reading PortA on 16F877 > > > > I'm not sure what BANKSEL PORTA is supposed to do. > > Do a > > bsf STATUS, RP0 > > movlw 0xFF > > movwf TRISA > > bcf STATUS, RP0 > > > > This will setup PORTA as all inputs. > > > > Then to read the port, just do a movf 0x05, 0 > > > > This will move the contents of PORTA into the 'w' register. > > > > Then do with 'w' what you need to do. > > > > Regards, > > > > Jim > > > > > > > > > -----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 > > > > -- > > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > > > > -- > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body