unsigned int temp_res;
unsigned int temp_res1;
char buf2[6];
char buf[6];
int i;
void main() {
UART1_Init(9600);
delay_ms(100);
TRISA = 0xFF;
CMCON = 0x07;
TRISA = 0xFF; // PORTA is input
TRISC = 0; // PORTC is output
TRISB = 0; // PORTB is output
do {
temp_res = ADC_Read(0); // Get 10-bit results of AD conversion
PORTB = temp_res; // Send lower 8 bits to PORTB
PORTC = temp_res >> 8; // Send 2 most significant bits to RC1, RC0
temp_res1=ADC_read(1);
WordToStr(temp_res,buf2 );
for(i = 0; i < 6; i++)
{
UART1_Write(buf2[i]); //Write Channel 0
Delay_us(1);
}
UART1_Write(13); //
WordToStr(temp_res1,buf );
for(i = 0; i < 6; i++)
{
// Write channel 1
UART1_Write(buf[i]);
Delay_us(1);
}
}
while(1);
}