// ATD block set up.
ATD0CTL2 = 0x80; // Enable power up mode for ADC Block
ATD0CTL3 = 0x40; // Set 8 bit conversions.
//===============================================================================
// Trigger, wait, then read a channel and return 8-bit value..
//===============================================================================
byte ReadADC(byte channel)
{
byte status;
// This resets the conversion done flag and starts a new conversion.
ATD0CTL5 = SINGLE_MODE+NO_SCAN_MODE+channel;
for ( ; ; )
{
status = ATD0STAT0;
if( status & SCF )
break;
}
status = ATD0DR7H; // Just the hi byte. Ignore LSB's
ADTValue = status;
return status;
}
Message Edited by JimDon on 2007-02-0206:03 PM
Message Edited by JimDon on 2007-02-0206:04 PM