I've been working with PIC16F877. Can someone please explain how to configure its pins to be analog or digital?
I saw somewhere that we need to configure
ADCON1, but don't really understand how that works.
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It only takes a minute to sign up.Sign up to join this community
See datasheet, Section 11.0 (Register 11-2), page 112.
You select the operation of the pins by setting the four bits
PCFG3:PCFG0 in the
according to the table in the datasheet.
The power-on default of these bits is
0000, which means that all the pins AN0...AN7 are configured as analog inputs.
To configure all the AN-pins as digital, you set the
PCFG bits to
011x (x means don't care). The rest of the combinations are in the datasheet.