Configure analog pins, voltage reference and digital I/O (ADCON1)
Select A/D input channel (ADCON0)
Select A/D acquisition time (ADCON2)
Select A/D conversion clock (ADCON2)
Turn on A/D module (ADCON0)
Configure A/D interrupt (if desired):
Clear ADIF bit
Set ADIE bit
Set GIE bit
Wait the required acquisition time (if required).
Start conversion, set GO/DONE bit (ADCON0 register)
如果使用 CCP2 的 special event trigger 則不用手動設置 GO/DONE bit
Wait for A/D conversion to complete (Wait for the A/D interrupt)
Read A/D Result registers (ADRESH:ADRESL); clear bit, ADIF, if required.
For next conversion, go to step 1 or step 2, as required. The A/D conversion time per bit is defined as TAD. A minimum wait of 2 TAD is required before the next acquisition starts.