118/317
5 - Peripherals
Conversion time: 64 clock cycles of the ADC. The ADC being fed with the core clock
frequency.
These somewhat cryptic features actually mean the following simple facts:
The input voltage must remain positive or null; below zero volt, the conversion yields zero. In
addition, the voltage at any input is limited to –0.3 V. If a signal ranges includes the zero, two
solutions are available as described later in this chapter.
The ADC of the ST7 is a ratiometric converter, that is, it returns a binary number that ex-
presses the ratio between the input voltage and the supply voltage. A input of zero volt (or
lower) provides a binary result of zero; an input of V
DD
(or more) provides a result of 255. The
resolution is eight bits, which means that the converter distinguishes between 2
8
voltage
values, that is 256 values.
Accuracy and linearity are important features since they determine whether a converter is suit-
able or not for a certain job. A discussion of this subject is given below.
The conversion time depends on the core clock frequency. This is a factor that must be taken
into account when selecting the crystal frequency and the division rate, since in slow mode the
clock to the converter is also slowed down.
5.6.2 Using the Analog to Digital Converter
Controlling the ADC is fairly simple, since it is controlled by a single register (ADCCSR).
Bit 5 of the CSR (ADON) is the on/off switch of the ADC. When off, it does not consume power,
reducing the dissipation of the ST7. When switched on again, for the first 30 µsecs, conver-
sions may be inaccurate.
Bits 2 to 0 select the input pin whose value is to be read. The inputs to the ADC are actually
pins taken from a parallel port. So the pins that are to be used as analog inputs must be con-
figured as input, no pull-up, no interrupt (DDR=0, OR=0) to put them in high-impedance and
avoid any disturbance on them.
Six analog inputs are available on the ST72251: PC0 to PC5
Eight analog input are available on the ST72311: PD0 to PD7.
Any write to the ADCCSR register stops the conversion in progress and starts a new one.
When conversion is finished, bit 7 of the ADCCSR (COCO) is set to one meaning that data is
available in the Data Register (ADCDR), and a new conversion starts. The converter thus con-
tinuously converts the input value; any read from the ADCDR will return a value that gives the
voltage of the corresponding input, measured at a time no earlier than the conversion time
specified above (2 speeds). If you do not need a time precision greater than this value, it is
simplest just to leave the converter running continuously and read the value whenever you
need it.
Содержание ST7 Series
Страница 1: ...ST7 8 BIT MCU FAMILY USER GUIDE JANUARY 1999 1 ...
Страница 238: ...238 317 8 C Language and the C Compiler 08 Burn bmp Then use the EPROMer programmer software as described in Chapter 7 ...
Страница 289: ...289 317 10 Second Application a Sailing Computer 10 befor Bs Rw Vw VMG AlphaR AlphaV Before the wind ...