Here is a short CCS implementation. This program outputs 8 MSB
#include <16f877.h>
#fuses HS,NOWDT,NOPROTECT
#device PIC 16F877 ADC=8
#use delay(clock=20000000)
#use rs232(BAUD=9600,XMIT=PIN_C6,RCV=PIN_C7)
#opt 9
// Reserve top 255 bytes of memory for the bootloader
#ORG 0x1F00,0x1FFFF{}
void reset()
{
setup_port_a(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(1); //Read Pin A1 analog only
delay_us(10);
}
main()
{
int valueADC; //the '#device' directive sets adc to 8 bits
reset();
//printf("Ready");
while(true)
{
valueADC=read_adc();
}
}