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

8.4. DIGITAL TO ANALOG CONVERTER 249
Example: Find the encoded value of the quantization found in the previous example: 738. Recall
we are using 10 bits.
Answer: Since we are using 10 bits to represent this number, the encoded value is
(1 × 2
9
) + (0 × 2
8
) + (1 × 2
7
) + (1 × 2
6
) + (1 × 2
5
) + (0 × 2
4
) + (0 × 2
3
) +
(0 × 2
2
) + (1 × 2
1
) + (0 × 2
0
) = 738.
Thus, the encoded value is 1011100010.
8.4 DIGITAL TO ANALOG CONVERTER
The opposite function of an ADC converter is performed by a Digital-to-Analog (DAC) converter.
The MSP430 microcontroller is one of few microcontrollers with built-in DAC converters. The
input to a DAC converter is an encoded value which specifies the desired output analog value.
Similar to the ADC converter just discussed, a DAC converter must have both minimum and
maximum reference analog voltages. The job of a DAC converter is then to map a minimum digital
representation to its corresponding minimum analog value, a maximum digital representation to the
maximum reference analog value, and representations in between minimum and maximum digital
values to their appropriate analog counter parts. The most common method used to perform a DAC
conversion is to pre-designate the analog weight of each bit in the digital input representation and
then sum up the contributions to form an analog output. For example, suppose the range of output
values for a DAC converter is from 0V to 5V. If we have a four bit DAC converter, from the most to
the least significant bits, each specific bit would be weighted 2.5 V, 1.25 V, 0.625 V, and 0.3125 V.
Thus, a digital input of 1010 to this converter will result in 2.5 + 0.625 = 3.125V , and a digital
input of 1111 to the DAC converter would result in 2.5 + 1.25 + 0.625 + 0.3125 = 4.6875 V .
Given an N-bit converter, it is straightforward to develop the following equation to describe the
relationships among the input, number of bits used, and the output.
Analog output =
digital input
2
N
V
refmax
where N stands for the number of bits used in the converter and V
refmax
represents the
maximum analog reference voltage of the converter.The MSP430 microcontroller uses the summing
technique where each of either 10 or 12 input digital bits to the ATD converter works as a switch
to turn on a weighed voltage. All voltages are added together to generate an output analog voltage.
Figure 8.5 illustrates a four bit DAC converter with the maximum and minimum output values of
2.5V and 0V, respectively.
8.5 MSP430 ANALOG-TO-DIGITAL CONVERTER
Certain MSP430 microcontroller models may have up to two different built-in analog-to-digital
converters to offer flexibility to a user based on applications. These converters are a comparator

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