Analog Digital Converter for DAQ-2543


This examples demonstrates reading the Analog to Digital Converter of TLC2543 on the DAQ-2543 board. The example relies on Get_TLC2543() function from BiPOM Library. All 11 channels are supported in this example.

Toolkit:ARM Development System

Location:/bipom/devtools/GCC/LPC2000/examples/adc/TLC2543

Code Example


int main (void)
{
	UBYTE channel;
	UINT value;

	/* Initialize the system */
	Initialize();

	/* Send messages */
	uart0Puts("\n\rBIPOM MINI-MAX/ARM");
	uart0Puts("\n\rTLC2543  EXAMPLE");

startTests:

	uart0Puts( "\n\rPlease press a key to start" );

    /* Loop forever until user presses a key */
    uart0GetchW();

    /*************** ANALOG-DIGITAL-CONVERTER TEST ********************/

    /* Read ADC internal diags */

    /* Channel 12 is internal and it is Zero Point test of ADC */
    value = Get_TLC2543(12);

    if( value > 0 )
    {
    	uart0Puts( "\n\rError ADC zero point, press a key" );
    	tiprintf( "\n\rZero=%d", value);
	   	uart0GetchW();
    }

    /* Channel 11 is internal and it is Middle Point test of ADC */
    value = Get_TLC2543(11);
    
    if( value > 2048 || value < 2047 )
    {
	    uart0Puts( "\n\rError ADC middle point, press a key" );
	    tiprintf( "\n\rMiddle=%d", value);
	    uart0GetchW();
    }
    
    /* Channel 13 is internal and it is Full Scale Point test of ADC */
    value = Get_TLC2543(13);
    
    if( value < 4095 )
    {
	    uart0Puts( "\n\rError ADC full scale, press a key" );
	    tiprintf( "\n\rFull=%d", value);
		uart0GetchW();
    }
    
    /* Read all ADC channels */
    uart0Puts( "\n\rReading ADC channels, press a key to stop..." );
    
    for( ;; )
    {
	    tiprintf( "\n\r" );
	    tiprintf( " Ch0=04%d", 	Get_TLC2543( 0 ) );
	    tiprintf( " Ch1=%04d",	Get_TLC2543( 1 ) );
	    tiprintf( " Ch2=%04d",	Get_TLC2543( 2 ) );
	    tiprintf( " Ch3=%04d",	Get_TLC2543( 3 ) );
	    tiprintf( " Ch4=%04d",	Get_TLC2543( 4 ) );
	    tiprintf( " Ch5=%04d",	Get_TLC2543( 5 ) );
	    tiprintf( " Ch6=%04d",	Get_TLC2543( 6 ) );
	    tiprintf( " Ch7=%04d",	Get_TLC2543( 7 ) );
	    tiprintf( " Ch8=%04d", 	Get_TLC2543( 8 ) );
	    tiprintf( " Ch9=%04d", 	Get_TLC2543( 9 ) );
	    tiprintf( " Ch10=%04d", Get_TLC2543( 10 ) );

	    /* User pressed a key to exit */
	    if( uart0Getch() != -1 )   
	    	break;
    }
	
	uart0GetchW();
    
    goto startTests;    
}