GMS81C5108
58
JUNE 2001 Ver 1.0
14. ANALOG TO DIGITAL CONVERTER
The analog-to-digital converter (A/D) allows conversion
of an analog input signal to a corresponding 8-bit digital
value. The A/D module has four analog inputs, which are
multiplexed into one sample and hold. The output of the
sample and hold is the input into the converter, which gen-
erates the result via successive approximation. The analog
supply voltage is connected to AV
DD
of ladder resistance
of A/D module.
The A/D module has two registers which are the A/D mode
register (ADMR) and A/D data register (ADDR). The
ADMR register, shown in Figure 14-1, controls the opera-
tion of the A/D converter module. The port pins can be
configured as analog inputs or digital I/O. To use analog
inputs, each port should be assigned analog input port by
setting input mode by R2DR direction register. And select
the corresponding channel to be converted by setting
ADAN[1:0].
The processing of conversion is start when the start bit
ADST is set to “1”. After one cycle, it is cleared by hard-
ware. The register ADDR contains the result of the A/D
conversion. When the conversion is completed, the result
is loaded into the ADDR, the A/D conversion status bit
ADF is set to “1”, and the A/D interrupt flag ADIF is set.
The block diagram of the A/D module is shown in Figure
14-1. The A/D status bit ADF is automatically set when A/
D conversion is completed, cleared when A/D conversion
is in process. The conversion time takes maximum 30 uS
(at f
MAIN
= 4MHz).
Figure 14-1 A/D Converter Block Diagram & Registers
AV
DD
R20/AN0
R21/AN1
R22/AN2
R23/AN3
ANEN
00
01
10
11
S/H
Successive
Approximation
Circuit
A D IF
Resistor
Ladder
Circuit
ADAN[1:0]
ADDR (8-bit)
Sample & Hold
A/D Interrupt
ADDRESS : 0ED
H
RESET VALUE : Undefined
A/D Converter
Data Register
ANEN
ANEN
ANEN
ANEN
ADMR (A/D Mode Register)
ADDRESS : 0EC
H
RESET VALUE : -0--0001
B
-
ADEN
-
-
ADAN1
ADAN0
ADST
ADF
ADF (A/D Status bit)
0 : A/D Conversion is in process
1 : A/D Conversion is completed
ADST (A/D Start bit)
1 : A/D Conversion is started
After 1 cycle, cleared to “0”
0 : Bit force to zero
00 : Channel 0 (R20/AN0)
01 : Channel 1 (R21/AN1)
10 : Channel 2 (R22/AN2)
11 : Channel 3 (R23/AN3)
ADEN (A/D Converter Enable bit)
1 : Enable
0 : Disable
ADDR (A/D Data Register)
ADDRESS : 0ED
H
RESET VALUE : Undefined
ADD7
ADD6
ADD5
ADD4
ADD3
ADD2
ADD1
ADD0
ADAN[1:0] (A/D Converter Input Selection)
Bit : 7 6 5 4 3 2 1 0
R/W
R/W
R/W
R
R/W
Bit : 7 6 5 4 3 2 1 0
R
R
R
R
R
R
R
R
Comparator
Downloaded from
Elcodis.com
electronic components distributor