mikesmixes777
New Member
I am using a PIC18LF2620. I currently have 3 analog inputs, RA0,RA1 and RA3.
The two values on RA1 and RA3 *edit* are reading correct. THe value I am getting on RA0 is wrong. There is 217mV on the input however my ADC value is 128 which using Vss=3.3V results in 412.3mV.
Is there a specail setting for AN0 which the other analog inputs dont have?
The portion of my code:
Many thanks
Mike
The two values on RA1 and RA3 *edit* are reading correct. THe value I am getting on RA0 is wrong. There is 217mV on the input however my ADC value is 128 which using Vss=3.3V results in 412.3mV.
Is there a specail setting for AN0 which the other analog inputs dont have?
The portion of my code:
Code:
void read_a2d(unsigned int adc_ch) //Read the A2D Inputs
{
unsigned int adcbits;
unsigned int adcbit0, adcbit1, adcbit2, adcbit3;
switch (adc_ch)
{
case 0: // Setup AN0
ADCON1 = 0b00001011; //-Vref=Vdd, +Vref=Vss, AN0:An3 inputs,
ADCON0 = 0b00000000;
ADCON2 = 0b10011010; // (Fosc/32), 6 TAD
ADCON0bits.ADON = 1; //Turn On ADC
break;
case 1: // Setup AN1
ADCON1 = 0b00001011;
ADCON0 = 0b00000100;
ADCON2 = 0b10011010;
ADCON0bits.ADON = 1;
break;
case 3: // Setup AN3
ADCON1 = 0b00001011;
ADCON0 = 0b00001100;
ADCON2 = 0b10011010;
ADCON0bits.ADON = 1;
}
ADCON0bits.GO=1;
while(ADCON0bits.GO)
adctemp = ADRESH;
adctemp = adctemp<<8;
adcbits = adctemp|ADRESL;
adcvalue = adcbits;
adcvalue = ((adcbits*3.3)/(1023));
Many thanks
Mike
Last edited: