#include <30F6014A.h>
#device ADC=12
#include <float.h>
#include <string.h>
#fuses NOWDT, NOPROTECT, PUT64, BORV27
#use delay (clock=58982400, xtal=7372800)
#use rs232(baud=9600,UART1,ERRORS)
unsigned char adc_value_5[20];
unsigned char adc_value_6[20];
unsigned char ert_adc_value_5;
unsigned char ert_adc_value_6;
unsigned char ert_voltages_5;
unsigned char ert_voltages_6;
void task1()
{
set_adc_channel(5); //read from channel 0
delay_us(10); //delay is required after setting channel and bef.read
//read_adc(ADC_START_ONLY);
ert_adc_value_5=read_adc(); //starts conversion & store it in value
ert_voltages_5=(ert_adc_value_5)*5000/4096;// last result of last conversion
sprintf(adc_value_5,"Ch05=%u",ert_voltages_5);
}
void task2()
{
set_adc_channel(6); //read from channel 0
delay_us(10); //delay is required after setting channel and bef.read
//read_adc(ADC_START_ONLY);
ert_adc_value_6=read_adc(); //starts conversion & store it in value
ert_voltages_6=(ert_adc_value_6)*5000/4096;// last result of last conversion
sprintf(adc_value_6,"Ch06=%u",ert_voltages_6);
}
void main(void) //void=nothing, no return value
{
set_TRIS_D(0x0000);
SETUP_ADC(adc_OFF);
setup_adc_ports(ALL_ANALOG);
setup_adc_ports(sAN0 |sAN1|sAN2|sAN3|sAN4|sAN5|sAN6|sAN7|sAN8|sAN9|sAN10|sAN11|sAN12|sAN13|sAN14|sAN15, VSS_VDD);
setup_adc(ADC_CLOCK_DIV_64 | ADC_TAD_MUL_2);
//setup_adc(ADC_CLOCK_INTERNAL);
while(TRUE)
//if (kbhit()) //check if a character has been received
// c = getc(); //read character from UART
{
task1();
task2();
puts(adc_value_5);
puts(adc_value_6);
puts("Ch99=9999");
}//end while
}//end main