#include <pic.h>
unsigned int itime;
void delay (unsigned char itime);
void main (void)
{
TRISA=0b10000000; //RA0 input for analog
TRISC=0b11000000; //RC0, RC1 are set as outputs
TRISD=0x11111111; //D is set as output
ADCON1=0b10000000;
//bit7:ADFM:right justified
//bit6-4:unused, read as 0
//bit3-0:all ports configured as analog channels
ADCON0=0b0000001;
//bit7-6:Fosc/2
//bit5-3:using analog channel RA0/AN0
//bit2:ADON not on
//bit1:unimplemented
//bit0: ADON converter module is operating
while(1)
{
delay(100);
//GODONE=1; //start converting ***ADGO=1
//while(GO);
PORTC=ADRESL;
PORTD=ADRESH;
delay(100);
}
}
void delay (unsigned char itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<200;j++);
}