PDA

View Full Version : What is ADCON?



mbw123
- 5th January 2007, 02:45
Hello everyone,

Can someone tell me how to configure adcon(1)? I need to use all the analog channels on my PIC18F4550 for the adcin command. Can anyone tell me how to read the datasheet?

I have attached a picture of the table from the datasheet for anyone who is interested.

On the table, if I configure adcon1 to the values on the left, does that mean that the corresponding ports will be either analog or digital? And then by default they are analog? And that also means that you cannot make channel 12 analog without making everything else analog? Thanks you for any responses, as this is probably a really stupid question.

-Mike

HenrikOlsson
- 5th January 2007, 07:04
Hi,

ADCON1:
Bit 7 is not used
Bit 6 is not used
Bit 5 sets the negative reference
Bit 4 sets the positive reference
Bit 3-0 sets the pins to Analog or Digital according to the table.

So,
ADCON1 = 0 should do it.
That will assign Vdd and Vss as pos/neg reference for the ADC and set all 13 inputs to analog.

The state at startup depends on the PBADEN configuration bit. (See note 1 just under the table)

As the table shows you can not use AN12 only as analog, if you need one channel only set ADCON1 to 14 and use AN0.

Dont forget to check if there are other functions on any of the pins that need's to be turned off. (Comparators is a classic example)

/Henrik Olsson.

mbw123
- 5th January 2007, 23:55
Thank you very much, Henrik! This problem has been plaguing me forever.

-Mike