Hello everyone, I have encountered the problem of using dual/multiple ADC inputs into PIC. I am using 2 ADC channels and outputting the result onto a LCD. The output that I receive is always that for the PORT with the higher pin (eg. If I am using pin RA1 & RA0, only the conversion of RA1 is received in my LCD display) There seems to be an overwrite of the RA1 over RA0. This problem persist when I am using different input pins.
The below mentioned is the code for ADC reading and initialisation. :
Thank you for your help.
void ADC_init() // for init of ADC
{
ADCON1=0x82;
TRISA=0xff;
}
int read_ADC_channel(unsigned int channel_number) // for reading
{
int value;
switch(channel_number)
{
case 0:
ADCON0 = 0b01000011;
case 1:
ADCON0 = 0b01001011;
default:;
}
DelayMs(1);
ADGO=1; //start AD conversion
while(ADGO) //wait for conversion to finish
{};
value=(ADRESH<<8)+ADRESL; //read the values in the registers
return(value);
}
The below mentioned is the code for ADC reading and initialisation. :
Thank you for your help.
void ADC_init() // for init of ADC
{
ADCON1=0x82;
TRISA=0xff;
}
int read_ADC_channel(unsigned int channel_number) // for reading
{
int value;
switch(channel_number)
{
case 0:
ADCON0 = 0b01000011;
case 1:
ADCON0 = 0b01001011;
default:;
}
DelayMs(1);
ADGO=1; //start AD conversion
while(ADGO) //wait for conversion to finish
{};
value=(ADRESH<<8)+ADRESL; //read the values in the registers
return(value);
}