ANALOG-TO-DIGITAL (A/D) CONVERTER

12.5 DETERMINING A/D STATUS AND CONVERSION RESULTS

You can read the AD_RESULT register (Figure 12-6) to determine the status of the A/D convert- er. The AD_RESULT register is cleared when a new conversion is started; therefore, to prevent losing data, you must read both bytes before a new conversion starts. If you read AD_RESULT before the conversion is complete, the result is not guaranteed to be accurate.

The conversion result is the ratio of the input voltage to the reference voltage:

VIN ANGND

VIN ANGND

RESULT (8-bit)= 255 × ------------------------------------------

RESULT (10-bit)= 1023 × ------------------------------------------

VREF ANGND

VREF ANGND

You can also read the interrupt pending register (see Table 12-2 on page 12-2) to determine the status of the A/D interrupt.

AD_RESULT (Read)

Address:

1FAAH

 

Reset State (MC, MD):

FFC0H

 

Reset State (MH):

7FC0H

The A/D result (AD_RESULT) register consists of two bytes. The high byte contains the eight most- significant bits from the A/D converter. The low byte contains the two least-significant bits from a ten- bit A/D conversion, indicates the A/D channel number that was used for the conversion, and indicates whether a conversion is currently in progress.

15

ADRLT9 ADRLT8 ADRLT7 ADRLT6

7

ADRLT1

ADRLT0

STATUS

 

 

 

 

8

ADRLT5 ADRLT4 ADRLT3 ADRLT2

0

ACH3

ACH2

ACH1

ACH0

 

 

 

 

 

 

Bit

Bit

Function

 

 

 

Number

Mnemonic

 

 

 

 

 

 

 

 

 

 

 

 

 

15:6

ADRLT9:0

A/D Result

 

 

 

 

 

These bits contain the A/D conversion result.

 

 

 

 

 

 

 

 

 

5

Reserved. This bit is undefined.

 

 

 

 

 

 

 

 

 

4

STATUS

A/D Status

 

 

 

 

 

Indicates the status of the A/D converter. Up to 8 state times are required

 

 

 

 

 

to set this bit following a start command. When testing this bit, wait at

 

 

 

 

 

least the 8 state times.

 

 

 

 

 

0 = A/D is idle

 

 

 

 

 

1 = A/D conversion is in progress

 

 

 

 

 

 

 

 

 

3:0

ACH3:0

A/D Channel Number

 

 

 

 

 

These bits indicate the A/D channel number that was used for the

 

 

 

 

 

conversion.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 12-6. A/D Result (AD_RESULT) Register — Read Format

 

 

 

 

12-9

 

 

 

 

 

 

 

 

 

 

Page 274
Image 274
Intel 8XC196MH, 8XC196MD, 8XC196MC manual Determining A/D Status and Conversion Results, Adresult Read, ADRLT90