User Manual
83
T89C51AC2
Rev. B – 19-Dec-01
16.6 ADC Standby Mode W hen the ADC is not used, it is possible to set it in standby mode by c learing bit ADEN
in ADCON regi ster. In this m ode its power dissipation is about 1uW.
16.7 IT ADC m anagement An int errupt end-of-conv ersion w il l occu rs when t he bit ADEO C is act ivat ed and the bit
EADC is set. For re-arming the interrupt the bit ADEO C must be cleared by software.
Figure 39. ADC interrupt structure
16.8 Routines examples 1. Configure P 1.2 and P1.3 in ADC channels
// configure channel P1.2 and P1.3 for ADC
ADCF = 0Ch
// Enable the ADC
ADCON = 20h
2. Start a standard conversion
// The variable "channel" contains the channel to convert
// The variable "value_converted" is an unsigned int
// Clear the field SCH[2:0]
ADCON &= F8h
// Select channel
ADCON |= channel
// Start conversion in standard mode
ADCON |= 08h
// Wait flag End of conversion
while((ADCON & 01h)!= 01h)
// Clear the End of conversion flag
ADCON &= EFh
// read the value
value_converted = (ADDH << 2)+(ADDL)
3. Start a precision conversion (need interrupt ADC)
// The variable "channel" contains the channel to convert
// Enable ADC
EADC = 1
// clear the field SCH[2:0]
ADCON &= F8h
// Select the channel
ADCON |= channel
// Start conversion in precision mode
ADCON |= 48h
Note: to enable the ADC interrupt:
EA = 1
ADEOC
ADCON.2
EADC
IEN1.1
ADCI










