ong_yc79
Newbie level 1
Hi All,
I am trying to measure the analog voltage in PIC16F877A. 10 bit data was used for ADC conversion. However, after transmission via serial port, it only shows 8bit data in hyperterminal. Please help
volatile unsigned int ADC_VALUE;
/* Selecting ADC channel */
ADCON0 = (ADC_Channel << 3) + 1;
ADIE = 0;
ADIF = 0;
ADRESL = 0;
ADRESH = 0;
ADGO = 1; /* Staring the ADC process */
while(!ADIF) continue; /* Wait for conversion complete */
ADC_VALUE = ADRESL; /* Getting HSB of CCP1 */
ADC_VALUE += (ADRESH << 8);
return (ADC_VALUE); /* Return the value of the ADC process */
}
void main(void)
{
OPTION=0xFF;
CLRWDT();
serial_setup();
InitialiseADC(0);
putst("\n\n\nInfra Red Distance Mesurement V0.1\n");
putst("Command List:\n");
putst("m - Measure Distance\n");
putst("Start... \n");
char getch_timeout_temp;
for(;
{
getch_timeout_temp=getch_timeout();
if (getch_timeout_temp=='m')
{
int Voltage = ReadADC(0);
putst("RESULT=");
putchdec(Voltage);
putst("\n\r");
}
}
}
I am trying to measure the analog voltage in PIC16F877A. 10 bit data was used for ADC conversion. However, after transmission via serial port, it only shows 8bit data in hyperterminal. Please help
volatile unsigned int ADC_VALUE;
/* Selecting ADC channel */
ADCON0 = (ADC_Channel << 3) + 1;
ADIE = 0;
ADIF = 0;
ADRESL = 0;
ADRESH = 0;
ADGO = 1; /* Staring the ADC process */
while(!ADIF) continue; /* Wait for conversion complete */
ADC_VALUE = ADRESL; /* Getting HSB of CCP1 */
ADC_VALUE += (ADRESH << 8);
return (ADC_VALUE); /* Return the value of the ADC process */
}
void main(void)
{
OPTION=0xFF;
CLRWDT();
serial_setup();
InitialiseADC(0);
putst("\n\n\nInfra Red Distance Mesurement V0.1\n");
putst("Command List:\n");
putst("m - Measure Distance\n");
putst("Start... \n");
char getch_timeout_temp;
for(;
{
getch_timeout_temp=getch_timeout();
if (getch_timeout_temp=='m')
{
int Voltage = ReadADC(0);
putst("RESULT=");
putchdec(Voltage);
putst("\n\r");
}
}
}