| |
Example to read two A/D Channels of LTC1298
/////////////////////////////////////////////////////////////////////////
//// EX_AD12.C ////
//// ////
//// This program will read both A/D channels and display the ////
//// results as both a voltage and raw hex number over the RS-232. ////
//// A reading is taken every second. ////
//// ////
//// (C) Copyright 1996,1997 Custom Computer Services ////
//// ////
/////////////////////////////////////////////////////////////////////////
#include <16F84.H>
#fuses HS,NOPROTECT,NOWDT
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_A3, rcv=PIN_A2)
#include
void display_data( long int data ) {
char volt_string[6];
convert_to_volts( data, volt_string );
printf(volt_string);
printf(" (%4lX)",data);
}
main() {
long int value;
adc_init();
printf("Sampling:\r\n");
do {
delay_ms(1000);
value = read_analog(0);
printf("\n\rCh0: ");
display_data( value );
value = read_analog(1);
printf(" Ch1: ");
display_data( value );
} while (TRUE);
}
|