Winter Yu
In this installment of the Smart Analog Combo application series, I would like to discuss the realization of low-cost audio playback using the digital-to-analog converter (DAC) in Smart Analog Combo in MSP430FR2355 microcontroller (MCU).
Some situations may need simple audio playback for sound cues or alarms. In most cases, adding an extra external audio chip for this simple function only adds cost and complexity. It’s much more reasonable to use MCU on-chip peripherals.
Designers generally use one of two approaches to obtain simple audio playback: pulse width modulation (PWM) or a digital-to-analog converter (DAC). Both methods convert a series of digital sound data into an analog electrical signal at a sound sample frequency, which drives a loudspeaker through an audio amplifier to produce sound.
The DAC generates an analog output that is proportional to the digital input it receives. The output voltage of the DAC keeps a constant value at every period, shown in Figure 1. The performance of a DAC is mainly determined by its resolution and settling time.
Figure 1 DAC Output WaveformThe PWM is a popular technique to implement DAC functionality in MCUs that don’t have an integrated DAC module. The PWM DAC approach is not new, but performance limitations have historically confined its use to low-resolution, low-bandwidth applications. PWM commonly generates a series of pulses with a period equal to a signal sample period and a duty cycle equal to a digital signal value using an MCU timer module. After going through a low-pass filter, the output analog voltage is proportional to the pulse duty-cycle shown in Figure 2. Because of the limitation of low-pass filter, the PWM output signal has intrinsic ripple which can’t be eliminated compared to DAC.
Figure 2 PWM DAC ImplementationThe PWM DAC resolution depends on the harmonic ripple generated by the low-pass filter and the duty-cycle resolution. Therefore, PWM duty-cycle resolution directly represents the DAC resolution. Equation 1 expresses the relationship between the frequency of the timer clock source used as a timer tick to increase the timer counter and the PWM signal frequency :
where N is the duty-cycle resolution of the PWM DAC in bits.
Equation 1 shows that higher resolutions need a higher timer clock source frequency, which will reach MCU clock limitations and increase power consumption.
You can now make several conclusions about the advantages and weaknesses of the PWM and DAC methods:
It is possible to configure one of the four Smart Analog Combos in the MSP430FR2355 to DAC buffer mode and implement audio playback functionality.
Figure 3 shows the block diagram of an audio application using a Smart Analog Combo DAC configuration. There are two steps to implementing audio playback: the download stage and the playback stage. In the download stage, you need a computer program to parse audio files and pass the 8-/16-bit data to the MCU through a universal asynchronous receiver transmitter (UART) for storage in external flash memory. In the playback stage, the MCU reads the raw audio data from external flash memory and the DAC converts it to an analog sound wave at an audio sample frequency. Audio files are usually recorded and played at 22.05 kHz or 44.1 kHz.
Figure 3 Audio Application Using the
MSP430 Smart Analog ComboThe main format used on Microsoft Windows systems for raw and typically uncompressed audio bit stream storage is the .wav format. It is an application of the Resource Interchange File Format (RIFF) bit stream format method for storing data in “chunks.” The usual bit stream encoding is in linear pulse-code modulation (LPCM) format.
Figure 4 shows the storage structure of a .wav format file, which includes raw audio data and sample information such as sample rate, number of channels and bits per sample.
Figure 4 Wav File Format
StructureFigure 5 illustrates the configuration of the Smart Analog Combo when implementing an audio application using the MSP430FR2355 MCU. The Smart Analog Combo is configured in DAC buffer mode. An extra timer is necessary in order to trigger the DAC data update at an audio sample rate. After updating the DAC data register, the MCU with ACLK as the timer clock source can enter LPM3 mode to save power consumption. The MCU can only enter LPM0 mode if you’re using the PWM method because the timer module is using SMCLK as a clock source. The power consumption in LPM0 is significantly higher than LPM3.
Figure 5 Smart Analog Combo DAC
ModeFor more details about how to configure Smart Analog Combo in your design, see the application report, “How to Use the Smart Analog Combo in MSP430™ MCUs.”
TI PROVIDES TECHNICAL AND RELIABILITY DATA (INCLUDING DATASHEETS), DESIGN RESOURCES (INCLUDING REFERENCE DESIGNS), APPLICATION OR OTHER DESIGN ADVICE, WEB TOOLS, SAFETY INFORMATION, AND OTHER RESOURCES “AS IS” AND WITH ALL FAULTS, AND DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS.
These resources are intended for skilled developers designing with TI products. You are solely responsible for (1) selecting the appropriate TI products for your application, (2) designing, validating and testing your application, and (3) ensuring your application meets applicable standards, and any other safety, security, or other requirements. These resources are subject to change without notice. TI grants you permission to use these resources only for development of an application that uses the TI products described in the resource. Other reproduction and display of these resources is prohibited. No license is granted to any other TI intellectual property right or to any third party intellectual property right. TI disclaims responsibility for, and you will fully indemnify TI and its representatives against, any claims, damages, costs, losses, and liabilities arising out of your use of these resources.
TI’s products are provided subject to TI’s Terms of Sale (www.ti.com/legal/termsofsale.html) or other applicable terms available either on ti.com or provided in conjunction with such TI products. TI’s provision of these resources does not expand or otherwise alter TI’s applicable warranties or warranty disclaimers for TI products.
Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265
Copyright © 2023, Texas Instruments Incorporated