Hardware manual

Rev. 3.0, 09/98, page 234 of 361
11.3 Operation
The A/D converter performs 8 successive approximations to obtain a result ranging from H'00
(corresponding to AV
SS
) to H'FF (corresponding to AV
CC
).
The A/D converter module can be programmed to operate in single mode or scan mode as
explained below.
11.3.1 Single Mode (SCAN = 0)
The single mode is suitable for obtaining a single data value from a single channel. A/D
conversion starts when the ADST bit is set to “1,” either by software or by a High-to-Low
transition of the ADTRG signal (if enabled). During the conversion process the ADST bit remains
set to “1.” When conversion is completed, the ADST bit is automatically cleared to “0.”
When the conversion is completed, the ADF bit is set to “1.” If the interrupt enable bit (ADIE) is
also set to “1,” an A/D conversion end interrupt (ADI) is requested, so that the converted data can
be processed by an interrupt-handling routine. The ADF bit is cleared when software reads the
A/D control/status register (ADCSR), then writes a “0” in this bit.
Before selecting the single mode, clock, and analog input channel, software should clear the
ADST bit to “0” to make sure the A/D converter is stopped. Changing the mode, clock, or
channel selection while A/D conversion is in progress can lead to conversion errors. A/D
conversion begins when the ADST bit is set to “1” again. The same instruction can be used to
alter the mode and channel selection and set ADST to “1.”
The following example explains the A/D conversion process in single mode when channel 1
(AN1) is selected and the external trigger is disabled. Figure 11.2 shows the corresponding timing
chart.
(1) Software clears the ADST bit to “0,” then selects the single mode (SCAN = “0”) and channel 1
(CH2 to CH0 = “001”), enables the A/D interrupt request (ADIE = “1”), and sets the ADST bit
to “1” to start A/D conversion.
Coding Example: (when using the slow clock, CKS = “0”)
BCLR #5, @H'FFE8 ;Clear ADST
MOV.B #H'7F, ROL
MOV.B ROL, @H'FFEA ;Disable external trigger
MOV.B #H'61, ROL
MOV.B ROL, @H'FFE8 ;Select mode and channel and set ADST to “1”