SSZT621 september   2018 MSP430FR2355

 

  1.   1
  2.   2
    1.     3
    2.     Additional Resources

Winter Yu

GUID-BEDBA29E-CAB9-4001-8032-704BF41E76B1-low.jpg

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.

GUID-41FEEDE8-EA79-4E5B-8992-9CE4264696F4-low.png Figure 1 DAC Output Waveform

The 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.

GUID-559025F1-B822-4653-922D-65161BC70E31-low.png Figure 2 PWM DAC Implementation

The 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 :

Equation 1. f c l o c k = f p w m × 2 N

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:

  • PWM audio playback is easy to implement using an MCU without an on-chip DAC.
  • The waveform generated by the DAC is smoother than PWM, which has intrinsic ripple.
  • For the PWM method, higher resolution needs a higher timer clock frequency, which increases power consumption.
  • The PWM method needs an extra low-pass filter.

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.

GUID-8D50A950-5EF3-4F12-A9CB-E2ECD46F5BBD-low.png Figure 3 Audio Application Using the MSP430 Smart Analog Combo

The 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.

GUID-2FA43C57-743D-4D4F-B271-A59DA3CD1CA7-low.jpg Figure 4 Wav File Format Structure

Figure 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.

GUID-A66660D8-5338-4C62-8B87-D0FD36BC0805-low.png Figure 5 Smart Analog Combo DAC Mode

For 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.”

Additional Resources