Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
8XC196Kx,8XC196Jx,87C196CA microcontroller family user's manual.1995.pdf
Скачиваний:
57
Добавлен:
23.08.2013
Размер:
3.97 Mб
Скачать

CHAPTER 11

ANALOG-TO-DIGITAL 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.

11.1 A/D CONVERTER FUNCTIONAL OVERVIEW

The A/D converter (Figure 11-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. It can also monitor an input and set the A/D interrupt pending bit when the input voltage crosses over or under the programmed threshold voltage.

Analog Inputs *

 

 

 

 

 

 

 

 

 

EPA or PTS

 

 

 

 

 

Command

 

 

VREF

ANGND

 

 

 

Analog Mux

 

 

 

 

 

 

 

 

 

Control

 

Sample

Succession

 

Logic

 

Approximation

 

 

 

and Hold

 

A/D

 

 

 

 

Converter

Status

 

 

 

 

 

 

 

 

AD_RESULT

AD_COMMAND

AD_TIME

AD_TEST

* Multiplexed with port inputs

 

 

 

 

 

 

 

 

 

A2652-01

Figure 11-1. A/D Converter Block Diagram

11-1

8XC196Kx, Jx, CA USER’S MANUAL

11.2 A/D CONVERTER SIGNALS AND REGISTERS

Table 11-1 lists the A/D signals and Table 11-2 describes the control and status registers. Although the analog inputs are multiplexed with I/O port pins, no configuration is necessary.

Table 11-1. A/D Converter Pins

Port Pin

A/D Signal

A/D Signal

Description

Type

 

 

 

 

 

 

 

P0.7:0

ACH7:0 (Kx)

I

Analog Inputs

P0.7:2

ACH7:2 (CA, Jx)

 

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.

 

 

 

 

V REF

PWR

Reference Voltage

 

 

 

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

 

 

 

 

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

Mnemonic

Address

Description

 

 

 

AD_COMMAND

1FACH

A/D Command

 

 

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

 

 

conversion starts immediately or is triggered by the EPA, and

 

 

selects the operating mode.

 

 

 

AD_RESULT

1FAAH, 1FABH

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 channel 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_TEST

1FAEH

A/D Conversion Test

 

 

This register enables conversions on ANGND and VREF and

 

 

specifies adjustments for zero-offset errors.

 

 

 

AD_TIME

1FAFH

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.

 

 

 

11-2

 

 

ANALOG-TO-DIGITAL CONVERTER

 

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

 

 

 

Mnemonic

Address

Description

 

 

 

P0_PIN

1FDAH

Port 0 Pin State

 

 

Read P0_PIN to determine the current values of the port 0 pins.

 

 

Reading the port induces noise into the A/D converter, decreasing

 

 

the accuracy of any conversion in progress. We strongly

 

 

recommend that you not read the port while an A/D conversion is in

 

 

progress. To reduce noise, the P0_PIN register is clocked only

 

 

when the port is read.

 

 

 

11.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 register, 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 the 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“Programming the EPA and Timer/Counters” on page 10-17.) The A/D scan mode of the peripheral transaction server (PTS) allows you to perform multiple conversions and store their results. (See “A/D Scan Mode” on page 5-26.)

Once the A/D converter receives the command to start a conversion, a delay time elapses before sampling begins. (EPA-initiated conversions begin after the capture/compare event. Immediate conversions, those initiated directly by a write to AD_COMMAND, begin within three state times after the instruction is completed.) During this sample delay, the hardware clears the successive approximation register and selects the designated multiplexer channel. After the sample delay, the device connects the multiplexer output to the sample capacitor for the specified sample time. After this sample window closes, it disconnects the multiplexer output from the sample capacitor so that changes on the input pin will not alter the stored charge while the conversion is in progress. The device then zeros the comparator and begins the conversion.

11-3

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