Directly driving the ADC is pretty simple. Here is a code snip from a PIC 18LF4620 job. This is for an 8 bit result. Change the ADCON2 definition for 10 bits.
Code:
GetECG: '
trisa.2 = 1
ADCON0 = %00001001 'Ch2 selected, Go/Done = 0, ADC ON
ADCON1 = %00001100 'VRef = Vdd, Vss, <2:0> analog
ADCON2 = %00111111 'Left just (=8 bit), ADacq time = 20 Tad, ADClk = RC
pauseus 50
ADCON0.1 = 1 'start conversion
ADCNotDone:
if adcon0.1 = 1 then adcnotdone
ecgval = adresh
if ecgval > MaxECG then MaxECG = ecgval ' find MAX
if ecgval < MinECG then MinECG = ecgval ' find MIN
'Turn ADC OFF
ADCON0 = %00000000 'AD OFF, Ch0 selected, Go/Done = 0
return
HTH
BrianT
Bookmarks