Hi,
I am a little confused about using the A/D converter.
I have a 10MHz resonator with PLL enabled.
This is how I have configured the A/D.
This is how I am taking a reading.Code:TRISA = 255 TRISB = %00000111 ADCON0 = %00000001 'Vref = Vss Vdd, turn on A/D ADCON1 = %11111110 'Only Channel 0 analog ADCON2 = %10110110 'Right justified, 16 TAD, TOSC/64 (for 40MHz)
The results are a little jittery, even though the signal looks stable on the scope.Code:atod: ADCON0.1 = 1 'Start A/D conversion while ADCON0.1 = 1 'Wait for it to finish wend adresult.highbyte = ADRESH adresult.lowbyte = ADRESL angletime = adresult * multiplier temp = (adresult * decimal1) / 10 angletime = angletime + temp temp = (adresult * decimal2) / 100 angletime = angletime + temp ' We now have phase angle delay return
In the data sheet there is talk of taking readings in sleep mode, but I am not sure if this is just for the RC clock source. If I do need to be in sleep mode then the clock will be off, so do I need to set FOSC, and tad differently?
Best regards
Bob.





Bookmarks