271 / 342 page

LM3S310 Data Sheet
October 6, 2006
271
Preliminary
13.3
Initialization and Configuration
The following example shows how to configure analog comparator to read back its output value
from an internal register.
1.
Enable the analog comparator 0 clock by writing a value of 0x00100000 to the RCGC1 register
in the System Control module.
2.
In the GPIO module, enable the GPIO port/pin associated with C0- as a GPIO input.
3.
Configure the internal voltage reference to 1.65 V by writing the ACREFCTL register with the
value 0x0000030C.
4.
Configure comparator 0 to use the internal voltage reference and to not output a value on the
C0O
pin by writing the ACCTL0 register with the value of 0x0000040C.
5.
Delay for some time.
6.
Read the comparator output value by reading the ACSTAT0 register’s OVAL value.
Change the level of the signal input on C0- to see the OVAL value change.
EN=1
RNG=0
Total resistance in ladder is 32 R.
The range of internal reference in this mode is 0.825–2.37 V.
RNG=1
Total resistance in ladder is 24 R.
The range of internal reference for this mode is 0.0–2.0625 V.
Table 13-4.
Internal Reference Voltage and ACREFCTL Field Values (Continued)
ACREFCTL Register
Output Reference Voltage Based on VREF Field Value
EN Bit Value
RNG Bit Value
V
RE F
AV
DD
R
VRE F
R
T
----------------
×
=
V
REF
AV
DD
VREF
8
+
()
32
-----------------------------
×
=
V
REF
0.825
0.103 VREF
⋅
+
=
V
RE F
AV
DD
R
VRE F
R
T
----------------
×
=
V
REF
AV
DD
VREF
()
24
--------------------
×
=
V
REF
0.1375 VREF
⋅
=