PDA

View Full Version : Pic18f452 adcon



gavo
- 16th April 2011, 17:43
I would like to use the on board A/D on the 18F452 to read a battery voltage through a voltage divider on RA0, RA1, RA2, RA3, and RA5, can anyone please help me set up the ADCON1?

Many Thanks,

Regards,

Gavo

Charles Linquis
- 17th April 2011, 02:15
The datasheet would be a really good place to find out.

But...

ADCON0 = %01000001 ; A/D converter ON, CLK = FOSC/16
ADCON1 = %11001010 ; Right justified, /16, AN0,AN1,AN2,AN4,AN5 as inputs, Vref into AN3

OR

ADCON1 = %11001001 ; Right justified,/16, AN1,AN2,AN3,AN4,AN5 as inputs, Vref = VDD

Will probably work.