B) A/D Converter - Motorola 68HC12 User Manual

Table of Contents

Advertisement

A to D Converter:
This section covers the basic function of the A/D converter.
uses a dedicated port, port AD, for its inputs.
on the HC12 and, unlike the 6811, there are also 8 A/D registers allowing 8
simultaneous readings. The implementation of the A/D converter allows for two
different methods of operating the A/D converter.
method.
The interrupt based operation is explained in the section on interrupts.
The A/D converter conversion sequence consists of either 4 or 8 conversions and can
convert either one channel or multiple channels. In scan mode operation, polling
based operation, the flag is set after the conversions have been completed,
signaling the completion of the A/D cycle.
Before running the A/D converter, the system must be initialized by the user.
There are 4 registers that are used to control the A/D Converter.
_H12ADTCTL2, _H12ADTCTL3, _H12ADTCTL4, and _H12ADTCTL5.
_H12ADTCTL2 contains several of the A/D Converter enable bits.
power up (ADPU).
zero then the A/D converter is disabled.
enable (ASCIE).
the bit is set to zero.
Bit 0 is the interrupt flag (ASCIF) which is not used in the polling version of the
A/D converter.
_H12ADTCTL2:
bit 7
bit 6
ADPU
AFFC
_H12ADTCTL3 should always be set to 0x00.
that are related to how the A/D converter operates in background debug mode.
the D-Bug12 monitor is being used, the background debug mode is not being used and
these features should be disabled.
_H12ADTCTL4 is used to select the sample time of the A/D converter and to set the
prescalar for the clock.
_H12ADTCTL4:
bit 7
bit 6
unused
SMP1
There are four different sample times available for the A/D converter. The sample
time is selected by setting the value of SMP1 and SMP0.
that can be used are listed in table 1.
Table 1: Sample Times
SMP1
SMP0
0
0
0
1
1
0
1
1
The prescalar that is used by the A/D converter is determined by the value of PRS0-
PRS4.
The clock input to the prescalar is an 8 MHz clock.
conversion frequency of 500 kHz to 2 MHz.
listed in Table 2.
When this is set to one the A/D converter is enabled, when it is
The interrupt is enabled when the bit equals one and disabled when
In scan mode this bit is set to 0, to disable interrupts.
bit 5
bit 4
AWAI
unused
bit 5
bit 4
SMP0
PRS4
Sample Time________
2 A/D clock periods
4 A/D clock periods
8 A/D clock periods
16 A/D clock periods
There are 8 A/D converter channels
This section covers the polling
Bit 1 is the A/D converter interrupt
bit 3
bit 2
unused
unused
This is used to control several actions
bit 3
bit 2
PRS3
PRS2
The different prescalar values are
8
The A/D converter
These are
Bit 7 is the A/D
bit 1
bit 0
ASCIE
ASCIF
bit 1
bit 0
PRS1
PRS0
The different sample times
This allows for an A/D
As

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents