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

CHAPTER 12 ANALOG-TO-DIGITAL (A/D) CONVERTER

The analog-to-digital (A/D) converter can convert an analog input voltage to a digital value and set the A/D interrupt pending bit when it stores the result. It can also monitor a pin and set the A/D interrupt pending bit when the input voltage crosses over or under a programmed threshold voltage. This chapter describes the A/D converter and explains how to program it.

12.1 A/D CONVERTER FUNCTIONAL OVERVIEW

The A/D converter (Figure 12-1) can convert an analog input voltage to an 8- or 10-bit digital result and set the A/D interrupt pending bit when it stores the result. In addition, the 8XC196EA A/D features separate conversion result registers for each channel and a 16-channel auto-scan- ning mode that reduces the need for external multiplexing.

Analog Inputs

 

 

 

 

 

 

 

 

 

EPA

 

 

 

 

 

Command

 

 

VREF

ANGND

 

 

 

Analog Mux

 

 

 

 

 

 

 

 

Status

Control

 

Sample

Successive

 

Logic

 

Approximation

 

 

 

and Hold

 

A/D

 

 

 

 

Converter

 

 

 

 

AD_SCAN

AD_COMMAND

AD_TIME

AD_TEST

AD_RESULTx

AD_RESULT

 

 

 

 

 

 

 

 

A3379-01

Figure 12-1. A/D Converter Block Diagram

12-1

8XC196EA USER’S MANUAL

12.2 A/D CONVERTER SIGNALS AND REGISTERS

Table 12-1 lists the A/D signals and Table 12-2 describes the control and status registers.

 

 

Table 12-1. A/D Converter Signals

Signal Name

Type

 

Description

 

 

 

 

ACH15:0

I

 

Analog Inputs

 

 

 

Input channels to the A/D converter. See the “Voltage on Analog Input

 

 

 

Pin” specification in the datasheet for acceptable voltage ranges.

 

 

 

 

ANGND

GND

 

Reference Ground

 

 

 

Must be connected for A/D converter and port operation.

 

 

 

 

VREF

PWR

 

Reference Voltage

 

 

 

Must be connected for A/D converter and port operation.

 

 

 

 

Table 12-2. A/D Control and Status Registers

Mnemonic

Address

Description

 

 

 

AD_COMMAND

1E74H

A/D Command

 

 

This register selects the A/D channel, controls whether the A/D

 

 

conversion starts immediately or is triggered by the EPA, initiates

 

 

automatic scan on selected channel inputs, and selects the

 

 

operating mode.

 

 

 

AD_RESULT

1E72H

A/D Result

 

 

For an A/D conversion, the high byte contains the eight MSBs from

 

 

the conversion, while the low byte contains the two LSBs from a 10-

 

 

bit conversion (undefined for an 8-bit conversion), indicates which

 

 

A/D channel was used, and indicates whether the A/D is idle.

 

 

For a threshold-detection, calculate the value for the successive

 

 

approximation register and write that value to the high byte of

 

 

AD_RESULT. Clear the low byte or leave it in its default state.

 

 

 

AD_RESULT0

1E50H, 1E51H

A/D Result on Channel x

AD_RESULT1

1E52H, 1E53H

These registers contain the data result from an autoscan sequence.

AD_RESULT2

1E54H, 1E55H

The low byte of each register contains the eight LSBs from the

AD_RESULT3

1E56H, 1E57H

conversion, while the high byte contains the two MSBs from a 10-bit

AD_RESULT4

1E58H, 1E59H

conversion (undefined for an 8-bit conversion).

AD_RESULT5

1E5AH, 1E5BH

 

AD_RESULT6

1E5CH, 1E5DH

 

AD_RESULT7

1E5EH, 1E5FH

 

AD_RESULT8

1E60H, 1E61H

 

AD_RESULT9

1E62H, 1E63H

 

AD_RESULT10

1E64H, 1E65H

 

AD_RESULT11

1E66H, 1E67H

 

AD_RESULT12

1E68H, 1E69H

 

AD_RESULT13

1E6AH, 1E6BH

 

AD_RESULT14

1E6CH, 1E6DH

 

AD_RESULT15

1E6EH, 1E6FH

 

 

 

 

12-2

 

 

ANALOG-TO-DIGITAL (A/D) CONVERTER

 

Table 12-2. A/D Control and Status Registers (Continued)

 

 

 

Mnemonic

Address

Description

 

 

 

AD_SCAN

1E70H

A/D Scan

 

 

This register selects A/D channels to be included in an autoscan

 

 

sequence.

 

 

 

AD_TEST

1E76H

A/D Conversion Test

 

 

This register enables conversions on ANGND and VREF and

 

 

specifies adjustments for zero-offset errors.

 

 

 

AD_TIME

1E77H

A/D Conversion Time

 

 

This register defines the sample window time and the conversion

 

 

time for each bit.

 

 

 

INT_MASK

0008H

Interrupt Mask

 

 

The AD bit in this register enables or disables the A/D interrupt. Set

 

 

the AD bit to enable the interrupt request.

 

 

 

INT_PEND

0009H

Interrupt Pending

 

 

The AD bit in this register, when set, indicates that an A/D interrupt

 

 

request is pending.

 

 

 

12.3 A/D CONVERTER OPERATION

An A/D conversion converts an analog input voltage to a digital value, stores the result in the AD_RESULT and AD_RESULTx registers, and sets the A/D interrupt pending bit. An 8-bit conversion provides 20 mV resolution, while a 10-bit conversion provides 5 mV resolution. An 8-bit conversion takes less time than a 10-bit conversion because it has two fewer bits to resolve and the comparator requires less settling time for 20 mV resolution than for 5 mV resolution.

You can convert either the voltage on an analog input channel or a test voltage. Converting the test inputs allows you to calculate the zero-offset error, and the zero-offset adjustment allows you to compensate for it. This feature can reduce or eliminate off-chip compensation hardware. Typically, you would convert the test voltages and adjust for the zero-offset error before performing conversions on an input channel. The AD_TEST register allows you to select a test voltage and program a zero-offset adjustment.

A threshold-detection compares an input voltage to a programmed reference voltage and sets the A/D interrupt pending bit when the input voltage crosses over or under the reference voltage.

A conversion can be started by a write to the AD_COMMAND register or it can be initiated by the EPA, which can provide equally spaced samples or synchronization with external events. (See “Configuring the EPA and Timer/Counter Signals” on page 11-15) The A/D scan mode allows you to perform multiple conversions and store their results in the corresponding AD_RESULTx registers.

12-3

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