PDA

View Full Version : Adcon1



Armadus
- 17th June 2010, 17:29
I am using a PIC 18F242 with 20mhz. I want to assign PinA.0 as an ADC input and all other Port A pins as digital inputs. I am currently using TrisaA = %11111111 and ADCON1 = %1001111. The digital input on PortA.2 does not appear to be working, and I assume there is a problem with the way I am reading the ADCON chart. Is ADCON1 = %1001111 correct?

Acetronics2
- 17th June 2010, 17:51
Hi,

Not surprising ...

IF you use external Vref + and Vref - ... :rolleyes: ... A2 and A3 are the Vref+/- inputs ...

IF NOT just try


ADCON1 = %01001110 ; ADCON1 is 8 Bits... not 7 !!!


Alain

Armadus
- 17th June 2010, 19:13
Using ADCON1 = %01001110 corrects my digital input problem, but now PortA.0 does not work as an analog input for ADC. Where can I find some more information on how ADCON1 works?

Acetronics2
- 17th June 2010, 19:29
Using ADCON1 = %01001110 corrects my digital input problem, but now PortA.0 does not work as an analog input for ADC. Where can I find some more information on how ADCON1 works?

Ok, I see ...

You can try to open the 18F242 datasheet, ADC section ( $ 17 , I think )

you also could post the code you've written here, I'm sure it will save lots of time to you ...

Alain

Armadus
- 17th June 2010, 21:28
Thanks for your help. I must have misread the table that I was looking at. The correct setting
is ADCON1 = %10001110.