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

ANALOG-TO-DIGITAL (A/D) CONVERTER

12.4.4 Programming the A/D Command Register

The A/D command register controls the operating mode, the analog input channel, and the conversion trigger.

AD_COMMAND

Address:

1E74H

 

Reset State:

00H

The A/D command (AD_COMMAND) register selects the A/D channel number to be converted, controls whether the A/D converter starts immediately or with an EPA command, initiates automatic scan on selected A/D channel inputs, and selects the conversion mode.

7

 

 

 

 

 

 

 

 

 

 

 

 

 

0

SCAN

M1

 

M0

 

GO

 

 

ACH3

 

ACH2

 

ACH1

ACH0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Bit

Bit

 

 

 

 

 

 

Function

 

 

Number

Mnemonic

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

7

SCAN

A/D Scan

 

 

 

 

 

 

 

 

 

 

 

 

This bit enables and disables automatic scanning.

 

 

 

 

 

0

= disable scan

 

 

 

 

 

 

 

 

 

1

= enable scan

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

6:5

M1:0

A/D Mode

 

 

 

 

 

 

 

 

 

 

 

 

These bits determine the A/D mode.

 

 

 

 

 

 

 

M1 M0

Mode

 

 

 

 

 

 

 

 

 

0

0

 

10-bit conversion

 

 

 

 

 

 

 

0

1

 

8-bit conversion

 

 

 

 

 

 

 

1

0

 

threshold detect low

 

 

 

 

 

 

 

1

1

 

threshold detect high

 

 

 

 

 

 

 

 

 

 

 

 

 

4

GO

A/D Conversion Trigger††

 

 

 

 

 

 

 

 

 

Writing this bit arms the A/D converter. The value that you write to it

 

 

 

determines at what point a conversion is to start.

 

 

 

 

 

0

= EPA initiates conversion

 

 

 

 

 

 

 

1

= start immediately

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

3:0

ACH3:0

A/D Channel Selection

 

 

 

 

 

 

 

 

 

Write the A/D conversion channel number to these bits. The 83C196EA

 

 

 

has 16 A/D channel inputs, numbered 0–15.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

While a threshold-detection mode is selected for an analog input pin, no other conversion can be started. If another value is loaded into AD_COMMAND, the threshold-detection mode is disabled and the new command is executed.

††It is the act of writing to the GO bit, rather than its value, that starts a conversion. Even if the GO bit has the desired value, you must set it again to start a conversion immediately or clear it again to arm it for an EPA-initiated conversion. The GO bit must be set to 0 for A/D SCAN to work.

Figure 12-5. A/D Command (AD_COMMAND) Register

12-9

8XC196EA USER’S MANUAL

12.4.5 Programming the A/D Scan Register

The A/D can operate in a number of conversion modes. On the 8XC196EA, the A/D can operate in an automatic scan mode. In automatic scan mode, each channel is sampled automatically and the conversion result is loaded into the corresponding result register, AD_RESULTx, and AD_RESULT. The AD_SCAN register (Figure 12-6) allows you to include or exclude individual channels from the scan sequence. The scan sequence begins from the least-significant channel number and continues to the most-significant channel number.

AD_SCAN

Address:

1E70H

 

Reset State:

0000H

The A/D scan (AD_SCAN) register allows you to select individual channels to include in the scan sequence and those to exclude. The automatic scan begins with the least-significant channel and ends with the most-significant channel.

15

 

 

 

 

 

 

 

 

 

8

ACH15

ACH14

 

ACH13

ACH12

 

ACH11

ACH10

ACH9

ACH8

7

 

 

 

 

 

 

 

 

 

0

 

 

 

 

 

 

 

 

 

 

 

ACH7

ACH6

 

ACH5

ACH4

 

ACH3

ACH2

ACH1

ACH0

 

 

 

 

 

 

 

 

 

 

 

Bit

Bit

 

 

 

 

Function

 

 

Number

Mnemonic

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

15:0

ACH15:0

 

A/D Channel x

 

 

 

 

 

 

 

 

 

These bits select the channels to be included in the automatic scan.

 

 

 

 

0 = exclude A/D channel x from scan sequence

 

 

 

 

 

 

1 = include A/D channel x in scan sequence

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 12-6. A/D Scan (AD_SCAN) Register

12.4.6 Enabling the A/D Interrupt

The A/D converter can set the A/D interrupt pending bit when it completes a conversion or when the input voltage crosses the threshold value in the selected direction. To enable the interrupt, set the corresponding mask bit in the interrupt mask register (see INT_MASK on page C-33) and execute the EI instruction to globally enable servicing of interrupts. See Chapter 6, “Standard and PTS Interrupts,” for details about interrupts.

12-10

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