/*

This program demonstrates how to read an analog input (ADC) channel.

*/

#use eziopk25.lib		//	use PK25xx I/O library

#define INPUTCHAN 0	//	assign INPUTCHAN to AIN0

main() {
	float raw, analog;

	eioBrdInit(0);							//	initialize the board
	eioErrorCode = 0;						//	clear error flag
	raw = eioBrdAI(INPUTCHAN+16);		//	read the raw value

	analog = eioBrdAI(INPUTCHAN);		//	read the calibrated value

	if (eioErrorCode & EIO_NODEV) {
		//	the channel doesn't exist
		printf("analog input channel %d doesn't exist!\n",INPUTCHAN);
	} else {
		//	no error reported, print out the values
		printf("analog input channel %d reads 0x%04x, interpreted to %f\n",INPUTCHAN,(int)raw,analog);
	}
}