Hi guys! Can anybody help me with the analog to digital conversion module of PIC16f887
Im trying to input to the vref of the PIC 16f887 and then i wanted to use other adc pins
I declared portD as output with 8 bits of data. I discarded the 2 least significant bits
I input 5 volts at the vref+ pin and then smaller voltages in the other pins to check the
resolution of the conversion
Nothing is happening..is there something wrong with my program?
anyhelp is well appreciated..ThankS!
unsigned int L1,L2,L3,L4,L5,L6,L7,L8;
int i;
void main()
{
ANSEL = 0x00; //Configure AN0 as analog input
ANSEL = 0x08; //Configure AN1 as analog input
ANSEL = 0x04; //Configure AN2 as analog input
ANSEL = 0x0C; //Configure AN3 as analog input
ANSEL = 0x02; //Configure AN4 as analog input
ANSEL = 0x0A; //Configure AN5 as analog input
ANSEL = 0x06; //Configure AN6 as analog input
ANSEL = 0x0E; //Configure AN7 as analog input
ANSEL = 0x01; //Configure AN8 as analog input
ANSEL = 0x09; //Configure AN9 as analog input
ANSELH = 0; //Configure other analog inputs to digital I/O
ADCON0 = 0x90; //Configure Vref+
TRISA = 0xFF; //Configure all PortA input
TRISE = 0x0F; //Configure all PortE input
TRISB = 0x0E; //Configure AN8 and AN9
PORTD = 0; //PortD as output
TRISD = 0; //PortD as output
switch (i)
{
case 0:
{
L1 = ADC_Read (0) >>2; //read from pin AN0
ADCON0 = 0x83; // convert analog to digital
PORTD = L1; // Send output to portD
}break;
case 1:
{
L2 = ADC_Read (1) >>2;
ADCON0 = 0x87;
PORTD = L2;
//Delay_ms (1000)
}break;
case 2:
{
L3 = ADC_Read (4) >>2;
ADCON0 = 0x93;
PORTD = L3;
//Delay_ms (1000)
}break;
case 3:
{
L4 = ADC_Read (5) >>2;
ADCON0 = 0x97;
PORTD = L4;
//Delay_ms (1000)
}break;
case 4:
{
L5 = ADC_Read (6) >>2;
ADCON0 = 0x9B;
PORTD = L5;
//Delay_ms (1000)
}break;
case 5:
{
L6 = ADC_Read (7) >>2;
ADCON0 = 0x9F;
PORTD = L6;
//Delay_ms (1000)
}break;
case 6:
{
L7 = ADC_Read (

>>2;
ADCON0 = 0xA3;
PORTD = L7;
//Delay_ms (1000)
}break;
case 7:
{
L8 = ADC_Read (9) >>2;
ADCON0 = 0xA7;
PORTD = L8;
//Delay_ms (1000)
}break;
}
}