This application note describes how to use PWM hardware to generate a .WAV audio file. It is targeted for STR7/STR9 microcontroller users.
This document describes a method for audio playback on STR7 and STR9 microcontrollers using Pulse Width Modulation (PWM) to simulate a Digital-to-Analog Converter (DAC). It details the requirements for .WAV file formats, specifically supporting PCM, 8-bit mono audio at sample rates of 8000, 11025, 22050, or 44100 Hz. The solution utilizes a system timer to manage data reading and a PWM timer to generate the analog signal, which is then filtered and amplified.
| Supported Sample Rates | 8000/11025/22050/44100 Hz |
|---|---|
| PWM Output Duty Cycle Range | 0% to 100% |
| Recommended Low-Pass Filter Cutoff Frequency | 4 kHz |
| Example Flash Memory | M25P64 (64-Mbit) |
| Example Audio Amplifier | TS4871 |
The built-in Pulse Width Modulation (PWM) module is used to generate a signal whose pulse width is proportional to the amplitude of the sample data.
The filter cut-off frequency is set to 4 kHz to ensure the PWM carrier is removed while passing the audio spectrum.