xpress_embedo
Advanced Member level 4
I have to sense two analogue voltages with the help of PIC16F877A
But the problem is that my Second Channel of ADC is not working....
Its value is not changing and remains same as that for the first conversion..
Here is my code
Can any one help me regarding this...
But the problem is that my Second Channel of ADC is not working....
Its value is not changing and remains same as that for the first conversion..
Here is my code
Code:
ADCON0 = 0x81;
ADCON1 = 0xC4;
while(1)
{
__delay_us(100);
ADCON0bits.GO = 1; //Start Conversion
while(ADCON0bits.GO == 1); //Wait Here for End of COnversion
adc_data = ADRESH & 0x00FF;
adc_data = adc_data<<8;
adc_data = adc_data | ADRESL;
ADCON0 = 0x80; //A/D Feature is Powered-OFF
/************************************************
Time to Start Second Timer located at AN1
**************************************************/
__delay_ms(20);
ADCON0 = 0x89;
ADCON0bits.GO = 1; //Start Conversion
while(ADCON0bits.GO == 1); //Wait Here for the End of Conversion
adc_phase_data = ADRESH & 0x00FF;
adc_phase_data = adc_phase_data<<8;
adc_phase_data = adc_phase_data | ADRESL;
ADCON0 = 0x80; //A/D Feature is Powered-OFF
/*****************************************
SWITCH BACK to First Analog Channel
******************************************/
ADCON0 = 0x81;
__delay_ms(20);
}
Can any one help me regarding this...