|
|
View previous topic :: View next topic |
Author |
Message |
zilog Guest
|
PIC18F87J10 internal ADC trouble |
Posted: Thu Jul 19, 2007 1:06 pm |
|
|
I am trying to read an external potentiometer attached to AN0 as a kind of hello world for the AD, using Vdd/Vss as reference. The problem is that I have only constructed an elaborate random generator it seems. I want to use the internal acquisition timer to time the sampling.
Please have a look and tell me what I am doing wrong.
Code: |
#byte ADRESH = 0xFC4
#byte ADRESL = 0xFC3
#byte ADCON0 = 0xFC2
#byte ADCON1 = 0xFC1
#byte ADCON2 = 0xFC0
#bit ADCAL = ADCON0.7
#bit ADGODONE = ADCON0.1
#bit ADON = ADCON0.0
{
input(PIN_A0); //make inputs
input(PIN_A1);
input(PIN_A2);
input(PIN_A3);
input(PIN_A4);
ADCON0 = 0b10000000; //cal, AN0
ADCON1 = 0b00001010; //Vdd-Vss, AN4-AN0
ADCON2 = 0b00111010; //20TAD, left justified, Tclk/32
ADON = 1;
ADGODONE = 1; //start calibration
while (ADGODONE);
ADCAL = 0; //normal mode
ADGODONE = 1; //start first conversion
while (ADGODONE);
while (1) {
while (ADGODONE);
printf(Maxputc, "%x\n\r", ADRESH);
delay_ms(100);
MaxKeepMAX3110Alive();
ADGODONE = 1;
}
}
|
|
|
|
zilog Guest
|
|
Posted: Thu Jul 19, 2007 2:06 pm |
|
|
I found it in the errata, now it works. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|