Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
8xC196EA microcontroller user's manual.1998.pdf
Скачиваний:
56
Добавлен:
23.08.2013
Размер:
8.29 Mб
Скачать

ANALOG-TO-DIGITAL (A/D) CONVERTER

12.5 DETERMINING A/D STATUS AND CONVERSION RESULTS

You can read the status bit of the AD_RESULT register (Figure 12-7) to determine the status of the A/D converter. 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. However, the AD_RESULTx register retains the individual A/D conversion result until the next sampling of A/D channel x. If you read AD_RESULT register before the conversion is complete, the result is not guaranteed to be accurate. The AD_RESULTx register can be read at any time.

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

RESULT (8-bit) = 255 ×

VIN ANGND

RESULT (10-bit) = 1023 ×

VIN ANGND

V-----RE-------F--------ANGND----------------------

V-----RE-------F--------ANGND----------------------

 

 

You can also read the interrupt pending register (see INT_PEND on page C-35) to determine the status of the A/D interrupt.

12-11

8XC196EA USER’S MANUAL

AD_RESULT (Read)

Address:

1E72H

 

Reset State:

0000H

The A/D result (AD_RESULT) register consists of two bytes. The high byte contains the eight mostsignificant bits from the A/D converter. The low byte contains the two least-significant bits from a 10-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. The 8XC196EA has 16 A/D channel inputs, numbered 0–15.

 

 

 

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

12-12

Соседние файлы в предмете Электротехника