/***************************************************************************
	ad1.c
	
   Z-World, 2001
	This sample program is used with the BL2100 series controllers.

	This program demonstrates how to access the A/D internal test voltages
	in the TLC2543 A/D chips. The program reads the A/D internal voltages
	and then displays the RAW data in the STDIO window. 

	Instructions:
	-------------

	1. Compile and run this program.
	2. The program will display the raw data for a given internal test
	   channel.
	   
	   A/D Channel 								 TLC2543	  	
      ---------------------------------    -------		
	   channel 11  =  (Vref+  - Vref-)/2     0x800      
	   channel 12  =  Vref-						  0x000      
	   channel 13  =  Vref+						  0xFFF		 
	
***************************************************************************/
#class auto

#ifndef _FLASH_
#error "This program must be compiled to Flash."
#endif


///////////////////////////////////////////////////////////////////////////

void main ()
{
	auto int rawdata11, rawdata12, rawdata13;
	auto int numbits;

	brdInit();		// Required for BL2100 series boards
		
	printf("\n\n\r");
	printf("Displaying RAW data for the 12 bit A/D internal test voltages\n\r");
	printf("--------------------------------------------------------------\n\r");

	rawdata11 = anaIn(11);	//read A/D internal test voltage (Vref+ - Vref-)/2
	rawdata12 = anaIn(12);	//read A/D internal test voltage  Vref-
	rawdata13 = anaIn(13);  //read A/D internal test voltage  Vref+

	printf("Rawdata count for ch11 is 0x%03x (Vref+ - Vref-)/2 \r\n", rawdata11);
	printf("Rawdata count for ch12 is 0x%03x  Vref-\r\n", rawdata12);
	printf("Rawdata count for ch13 is 0x%03x  Vref+\r\n", rawdata13);
	
}	
///////////////////////////////////////////////////////////////////////////

