O'Reilly logo

Microcontroller Programming and Interfacing Texas Instruments MSP430 by Daniel J. Pack, Steven F. Barrett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

250 8. ANALOG PERIPHERALS
Summer
LPF
MSB
LSB
1.25 V
0.625 V
0.3125 V
Digital input value
determines which
switches are closed (1)
and which switches
remain open (0).
Output
0.15625 V
Figure 8.5: A sample 4-bit digital to analog converter. A digital input governs the positions of the
switches, which determine whether or not their corresponding voltage values with respect to the reference
voltage output values should contribute to the converter output value. The output of the converter is
typically connected to a low pass filter before being used to remove any sharp edges resulting from
switching from discrete voltage outputs of the converter.
(Comparator_B) and a successive approximation converter (ADC10 or ADC12). We describe each
in this section.
8.5.1 COMPARATOR
The comparator is the simplest form of the ADC converter in the MSP430 microcontroller. It
compares an input analog value to another analog value. The comparison voltage may be a reference
voltage, or it can be set to another external analog input signal. The comparator outputs either a
logic 1 or 0. Figure 8.6 (a) shows a simplified version of the comparator, called Comparator_B.
It compares two inputs, V
+
and V
, and outputs 1 if V
+
>V
and0ifV
+
<V
. Figure 8.6 (b)
shows the block diagram of the Comparator_B. The inputs V
+
and V
can be either an external
signal or an internal reference voltage. A programmer can choose the input V
+
as a signal connected
to one of pins CB0, CB1,.., and CB15 using the CBIPSEL bits (bits 3-0) in the Comparator_B
Control Register 0 (CBCTL0). Or input V
+
can be mapped to a reference voltage, which can be a
fraction of different levels of voltages including: 1.5V, 2.0V, and 2.5V. The selection of the reference
8.5. MSP430 ANALOG-TO-DIGITAL CONVERTER 251
voltage level is configured by the CBREFL bits (bits 14-13) of the Comparator_B Control Register
2 (CBCTL2).
V+
V-
Comparator
Output
(a) Simplified Comparator
(b) Block diagram of Comparator_B
.
.
.
.
CB0
CB1
CB15
4
CBIPSEL
.
.
.
.
CB0
CB1
CB15
4
CBIMSEL
CBSHORT
Ref
Voltage
CBRSEL
Ref Voltage
Generator
CBREF1
CBREF0
CBRS
2
55
CBEX
V+
V-
CBON
CBF
CBOUT
CBIFG
CBOUTPOL
Figure 8.6: MSP430 Comparator_B: a simple analog-to-digital converter. Frame (a) shows a simplified
input and output relationship of the comparator and frame (b) is the block diagram of the comparator.
The other input of the comparator, V
, can be connected to an external signal using one
of the comparator input pins (CB0, CB1, CB3,..., and CB15), which is selected with CBIMSEL
bits (bits 11-8) of the CBCTL0 register, or to the same reference voltage source used by input V
+
.
The CBRSEL bit in the CBCTL2 register determines which of the two inputs, V
+
(CBRSEL =
0)orV
(CBRSEL = 1) will be connected to the reference voltage.
The CBON bit (bit 10) of the Comparator B Control Register 1 (CBCTL1) turns on (CBON
= 1) and off (CBON = 0) the comparator. The CBF bit of the CBCTL1 register is used to turn

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required