#include <ADUC816.H>
#include <stdio.h>

void main (void)
{
/*-----------------------------------------------
Configure the serial port
-----------------------------------------------*/
SCON  = 0x50;
TMOD |= 0x20;
TH1   = 0xFA;
TR1   = 1;
TI    = 1;
PCON |= 0x80;

/*-----------------------------------------------
Configure the A/D to sequentially convert each
input channel.
-----------------------------------------------*/
  ADC0CON = 0x17;
  SF = 0x0D;


while (1)
  {
  unsigned int conv_val;

/*-----------------------------------------------
Start a conversion and wait for it to complete.
-----------------------------------------------*/
  ADCMODE |= 0x12;
  while (RDY1 != 1);
  RDY0 = 0;										/*Ready bit for PRIMARY ADC

/*-----------------------------------------------
Read A/D data and print it out.
-----------------------------------------------*/
  conv_val = ADC0M | ((ADC0H) << 8);

  printf ("Aux ADC Channel 3 = 0x%4.4Xrn", conv_val);
  }

}