This application note demonstrates how to add audio playback to any application using a
general-purpose ST7 microcontroller. To demonstrate this feature, an evaluation board,
source code in C, schematics, and layout are available.
The Audio player evaluation board reconstructs audio signals through the PWM of a
ST7FLITES2 microcontroller. Serial Flash is used to store the audio data in a binary file
format. To store this audio data in the Flash, the sound files need to be in .wav format so that
can be converted into .bin file format with the help of the PC GUI available with this package.
Once the data is stored, the microcontroller reads it through an SPI interface and generates
the sound using the PWM feature. A sixth order low pass filter removes any unwanted high
frequency components from the signal before passing it through a speaker.
The key features of the Audio player evaluation board are as follows:
■ 1% calibrated on-chip RC oscillator. The used microcontroller, ST7FLITES2, contains an
internal RC oscillator with an accuracy of 1% for a given device. It can be calibrated to
obtain a frequency required for the application. There is therefore no need for any external
oscillator.
■ LVD (brown-out) on chip. The purpose of the Low Voltage Detector (LVD) is to ensure that
the ST7 always functions in its safe area. No external reset circuit is required.
This evaluation board includes the following main components:
●8-bit microcontroller: ST7FLITES2. However, the ST7Flite02 can also be used.
●An external 8 MBit Serial Flash, M25P80 family
●External components to build a low cost passive filter.
●An audio amplifier (TDA7233)
●3.3V low-cost voltage regulator
Figure 1.Audio player evaluation board block diagram
ST7Lite02
DIP16
File Index
6th order
RC filter
Vol ume
Control
Powe r
Amplifier
TDA
7233
Play
Reset
Microcontroller
SPI
Serial
Flash
Volt age
External
Input
Regulator
Powe r
Supply Circuit
ZIF
Socket
Binary LED display
The main features of the evaluation board are as follows:
●Plays pre-recorded audio clips stored on an ST 8-Mbit serial Flash
●Can play up to 15 different audio files
●Easy to use Index and Play push-buttons
●Power input 6V DC
●Phone-quality sound: 8 kHz/8 bit
External
Speaker
Connection
1.1 Instructions for use
Assuming the external Flash is already programmed with sounds, you need to:
1.Power-on the board
2. Connect the board to the speaker
3. Select the desired sound by pressing the Index button. The File Index indicates the
sound to be played with the help of 4 LEDs.
4. Push the Play Sound button.
5. Adjust the volume potentiometer to your convenience.
3/23
Audio player evaluation board overviewAN2400
Figure 2.Labeled diagram of Audio player evaluation board
ICC Connector
External
Speaker Jack
ZIF Socket
for Flash
Power LED
File Index
Power Jack
LEDs
File Index
Switch
Volume Control
Play Switch
4/23
AN2400Audio player evaluation board concept
2 Audio player evaluation board concept
2.1 Audio recording
A PC is used to prepare audio to be programmed onto the external serial Flash. The file
must contain audio data as well as some basic file management structure to allow the ST7
to pick the correct audio during playback.
The serial Flash is used to store the audio files in binary format. For this purpose, it is
necessary to have the audio files in .wav format which allows them to be converted to a .bin
file to be programmed into the serial Flash.
For conversion to binary, the .wav files should have an 8 kHz sampling frequency and 8-bit
quantization format. These files are input into the provided WAV Converter utility to generate
a single .bin file.
Figure 3.Sound recording flow
Original SoundSamplingQuantifying
Recording process: Can be done on a standard PC, in a recording studio, or just some existing audio samples
Standard
8kHz/8-bit
WAV
.WAV files
WAV
WAV
WAV File StorageConversion to Binary FileBurn binary file to M25P
PC Processing: Convert the .WAV files into a propriety binary file used to reprogram the onboard serial Flash
011011011
001010101
BIN
Serial Flash Memory
Once this process is completed, the board is ready to play customized sounds provided by
the user.
A sound is selected using the Index push-button, and then heard by pressing the Play
button.
5/23
Audio reproduction flowAN2400
3 Audio reproduction flow
Figure 4.Audio reproduction flow
MCU reads data from
Serial Flash through SPI
Micro Data Processing: Complete source code free available from ST
Train of Pulses PWM
timer featureFilter
6th Order RC
Analog Filtering
Low-Pass
Filter quality/cost tradeoff can be achieved by
populating or not the filter capacitors
Reconstructed signal
to Speaker
Reproduction of “phone
quality” audio
Data, which is stored in the serial Flash, is read by the microcontroller through the SPI
interface. This data is then fed through the timer registers to generate a PWM output whose
duty cycle varies according to the data value.
The sequential path of the data flow from the serial Flash to the speaker is shown in
Figure 5.
Figure 5.Flow of data from external serial flash to external speaker
Internal
SPI
CLOCK
PWM Timer Feature
LITE TIMER
w/ WATCHDOG
PORT A
12-BIT AUTO-
RELOAD TIMER
PA7:0
(8 bits)
External
Filter/Speaker
FLASH
MEMORY
ADDRESS AND DATA BUS
(1 or 1.5K Bytes)
RAM
(128 Bytes)
DATA EEPROM
(128 Bytes)
External
Serial Flash
SPI Data
Tr an s fe r
V
V
RESET
PB4:0
(5 bits)
1 MHz. RC OSC
+
PLL x 4 or x 8
LVD/AVD
DD
SS
POWER
SUPPLY
CONTROL
8-BIT CORE
ALU
PORT B
8-BIT ADC
6/23
AN2400Audio reproduction flow
The microcontroller initiates the communication when it selects the Flash and starts reading
the data on a full duplex, synchronous basis. Once the microcontroller reads the data, it
generates a train of pulses using the PWM feature of the 12-bit auto reload timer. This is
explained with the help of an example:
Audio samples of 8 kHz, 8-bit format are to be reproduced. This data is coded in an 8bit format (with values from 0 to 255).
To reproduce the audio with sampling rate of 8 kHz, the microcontroller outputs each
value in every 1/8000 sec (every 125 µs). This means that the period of the PWM is set
at 125µs.
If the coded value of the audio signal is “1”, the microcontroller needs to generate the
PWM signal with a HIGH output for 1 count and LOW for the rest of the 255 counts.
This is shown in the figure below:
Figure 6.Waveform depicting the microcontroller output
1
x
BIN
Flash
1
256256256256
x
255
(256 - x)
Data value of 1 is read from Flash and ART generates
a PWM pulse with a duty cycle high of length 1
with 255 low.
Data value of x is read from Flash and ART generates
a PWM pulse with a duty cycle high of length x
and (256-x) low.
Varying duty cycles
Figure 7 below shows how the duty cycle register generates this output.
This process uses a duty cycle register, a 12-bit auto reload register and an up-counter.
When an up-counter overflow occurs (OVF event), the ATR value is loaded into the upcounter, the preloaded duty cycle is transferred to the duty cycle register. The PWM0 signal
is then set to a high level. Finally, when the upcounter matches the DCRx value, the PWM0
signal is set to a low level.
To use this sequence for audio generation, the following steps are taken:
1.When the up-counter reaches 0xFFF, an overflow event occurs. At this point, the PWM
output becomes high.
2. The ATR register value is loaded into the up-counter which in this example is 0xF00.
0xF00 is selected to maintain a range of 0-FF i.e. 0xF00-0xFFF for an 8-bit resolution
.wav file.
3. The DCR lower 8-bit register (DCR0L) is loaded with a value that the microcontroller
has read from the serial Flash. The DCR0H register value remains 0x0F. In this
7/23
Loading...
+ 16 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.