These are the registers used with the A/D converter
PIC 18F2550
Select the A/D inputs with the ADCON1 register. So to select AN0 and AN1 as analogue inputs with voltage references of PIC supply and PIC 0v set ADCON1 = %00001101
AN0 and AN1 must be made inputs with the TRIS register.
Next set the ADCON2 register. For a 10 bit result (0 - 1023) set ADCON2.7 to 1 (right justified). The A/D result will be in registers ADRESH and ADRESL. For an 8 bit result (0 to 255) clear ADCON2.7 to 0 (left justified). The A/D result will be in register ADRESH. The A/D converter needs a fixed time to settle and do the conversion. Set the rest of the bits according to the table in the datasheet for clock speed used.
The pic has only one A/D converter so it must be connected to the relevent A/D pin by the ADCON0 register and the converter turned on. So to select AN0 and turn the converter on, ADCON0 = %00000001. To select AN1, ADCON0 = %00000101. If you make AN3 analogue then AN0, AN1, AN2 will also be analogue input, see the datasheet.
To start the conversion set ADCON0.1 to 1.
Wait for the conversion to finish with for example
WHILE ADCON0.1 = 1 : WEND
The result will be in ADRESH/ADRESL for 16 bit results or ADRESH for 8 bit results depending on the setting of the format in ADCON2.
Hope this will get you started
Phil
Bookmarks