Design of MP3 player based on Cortex-M3

Publisher:书卷气息Latest update time:2012-09-07 Source: 单片机与嵌入式系统 Keywords:Cortex-M3  STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Introduction
The STM32 series microcontroller uses the latest Cortex-M3 core of ARM. The VSl003 audio decoder chip is the third generation product of the VSlOxx series. It is a single-chip MP3/WMA/MIDI decoder and ADPCM encoder chip produced by VLSI Solution of Finland. This paper uses the STM32 series microcontroller, combined with the decoder chip VSl003, SD card, LCD and other peripherals to design and implement an MP3 player. Its main functions are: play all audio files supported by VSl003, such as MP3, WMA, WAV files, and the sound quality is very good; control the previous/next song, volume increase and decrease, etc. through the joystick; display the song name and playback status through the LCD; this system also implements the card reader function, and the PC can directly read and write the SD card on the development board through the USB interface to facilitate the copying of audio files.

1 STM32 processor
Cortex-M3 is the latest processor core based on ARMv7 architecture launched by ARM. It has the characteristics of high performance, low cost and low power consumption, and is specially designed for embedded applications.
ARMv7 architecture adopts Thumb-2 technology, which is developed on the basis of ARM's Thumb code compression technology and maintains complete code compatibility with existing ARM solutions. Thumb-2 technology uses 31% less memory than pure ARM code, reduces system overhead, and can provide 38% higher performance than Thumb technology.
In terms of interrupt processing, Cortex-M3 integrates Nested Vectored Interrupt Controller NVIC (Nested Vectored Interrupt Controller). NVIC is a tightly coupled part of Cortex-M3 processor, which can configure 1 to 240 physical interrupts with 256 priorities and 8 levels of preemption priority, providing excellent exception handling capabilities for the processor. At the same time, the use of preemption, tail chaining and late arrival technology greatly shortens the response time of abnormal events. During the Cortex-M3 exception handling process, the processor state is automatically saved and restored by hardware, which further shortens the interrupt response time and reduces the complexity of software design.
The Cortex-M3 architecture proposes a new single-line debugging technology. The trace debugging of the Cortex-M3 processor is implemented through the debug access port (Debug Access Port, DAP). The DAP port can be used as a serial wire debug port (SW-DP) or a serial JTAG debug port (SWJ-DP, allowing JTAG or SW protocol). Among them, SW-DP only needs two pins, clock and data, to achieve low-cost trace debugging, avoid using multiple pins for JTAG debugging, and fully support RealView compiler and RealView debugging products. In addition, Cortex-M3 also has the characteristics of high integration, which greatly reduces the chip area. It integrates many tightly coupled system peripherals internally, reasonably utilizes the chip space, and enables the system to meet the control requirements of the next generation of products.
The STM32 series is a microcontroller based on the Cortex-M3 core. It expands high-performance peripherals on the basis of the Cortex-M3 core.

2 VS1003 MP3/WMA audio codec
VS1003 contains a high-performance, low-power DSP processing core (VSDSP), a working memory, a 5.5KB RAM for user programs, a serial SPI bus interface, a high-quality oversampling DAC with adjustable sampling frequency, and a 16-bit sampling ADC. The internal structure of VS1003 is shown in Figure 1.

The MP3 playback process is that STM32 takes data from the SD card through the SPI1 interface, and then sends it to the decoding chip VS1003 for decoding and playback through the SPI2 interface. Here, the decoding module uses a separate SPI interface to reduce interference and noise and improve sound quality.

3 System hardware design
The system is divided into 6 modules in terms of hardware: microcontroller STM32F103, decoding module VSl003, storage module SD card, control joystick, USB interface and display LCD. The system hardware framework is shown in Figure 2.

The following describes the hardware connection between the system's storage module SD card, decoding chip VSl003 and STM32.
3.1 Connection between SD card and STM32
The system uses the STM32 internal interface SPIl to communicate with the SD card. The following describes its pin connection.
PE3: Low level is valid, connected to the chip select pin CD/DAT3 of the SD card. When SPI communicates with the SD card, PE3 needs to be pulled low to operate the SD card.
PA7: Mapped to the master output slave input (MOSI) signal line of the STM32 internal interface SPIl. Here STM32 is the master device and the SD card is the slave device. The data flow is transmitted from STM32 to the SD card. This signal line is used to transmit some control commands to complete SD card operations, such as reading and writing.
PA5: Connected to the clock (SCLK) signal line of the STM32 internal interface SPIl. The SPI clock frequency can be set to adjust the speed of reading SD card data.
PA6: Connected to the master input slave output (MISO) signal line of the STM32 internal interface SPIl. The data transmission direction is from the SD card to the STM32, mainly returning some states of the SD card, internal register values, etc.
PCI2: used to detect whether the SD card is fully inserted. When the SD card is fully inserted, PCl2 is low level, otherwise it is high level.
3.2 Connection between VSl003 and STM32
The system uses the STM32 internal interface SP12 to communicate with VSl003. The following describes its pin connection.
PA3: Interrupt request pin of VSl003. When the internal data of VSl003 has been processed and new data is required, DREQ is pulled high. STM32 sends a new data stream to VSl003 based on this signal.
PBl3: The clock (SCLK) signal line connected to the STM32 internal interface SPI2.
PBl4: The master input slave output (MISO) signal line connected to the STM32 internal interface SPI2. Here STM32 is the master device and VSl003 is the slave device. The data stream is transmitted from VSl003 to STM32. Mainly used to read some states and internal register values ​​of VSl003, such as the value of the internal register returned by the register test.
PBl5: Connected to the master output slave input (MOSI) signal line of the STM32 internal interface SPl2. Here STM32 is the master device and VSl003 is the slave device. The data flow direction is from STM32 to VSl003, mainly transmitting some control commands, MP3/WMA data streams, etc. to VSl003.

PA1: Low level is valid. If this pin is pulled low, the control signal is transmitted through SPI. The control signal includes reading and writing the internal registers of VSl003, initializing VSl003, setting the volume of left and right channels, etc. PA2: Low level is valid. If this pin is pulled low, the data signal is transmitted through SPI. For example, this pin needs to be pulled low when transmitting MP3/WMA data stream to VSl003.
PA0: Low level is valid. Pulling this pin low will reset VSl003 by hardware. [page]


4 System software design
The software of this system is developed by the integrated development tool RealView MDK Professional Edition, which has powerful compiling, linking and debugging functions. The software structure is shown in Figure 3. The working process of this system is roughly as follows: STM32 reads MP3/WMA files from the SD card through SPI1, and sends the read data stream to the VS1003 decoder through SPl2 for playback; the PC can read and write the contents of the SD card through the USB bus, and transfer MP3/WMA and other files; the LCD display is used to display the file name and playback status of the MP3. The five-dimensional joystick is shaken left and right to control the previous/next song, shaken up and down to control the volume, and pressed to control play/pause.

Since the speed of SPI1 reading SD card files is much faster than the speed of VS1003 playing data streams, SPI1 can read the data required for the next playback from the SD card while VS1003 is playing the data stream from SPI2, and there will be no discontinuous sound. Since two SPI interfaces are used, there is no interference between them, and the efficiency of the file system is improved, so this system can obtain very high-quality music.
Due to space limitations, only two core modules of the software are introduced below.
4.1 SD module
The SD module mainly provides SD card drivers and functions for operating the FAT file system. The FAT file system supports long file names. This module mainly contains two files, msd.c and fat16.c. The functions of their main functions are introduced below.
4.1.1 msd.c
This file is used to provide SD card drivers and mainly includes the following functions.
SPI_Config: Configure SPI1 and related GPIOs connected to the SD card.
MSD_Init: Initialize SD card communication.
Get_Medium_Characteristics: Get relevant information such as the capacity and block size of the SD card.
MSD_GoIdleState: Put the SD card in idle state.
MSD_SendCmd: Send a command to the SD card.
MSD_GetResponse: Get a response from the SD card.
MSD_GetStatus: Get the status of the SD card.
MSD_WriteBlock: Write 1 block of data to the SD card.
MSD_ReadBlock: Read 1 block of data from the SD card.
The following is the implementation of the function MSD_ReadBlock:


4.1.2 fat16.c
This file provides support for FAT16 file system, mainly including the following functions.
ReadMBR: Read MBR data structure.
ReadBPB: Read BPB data structure.
ReadFAT: Read the specified item of file allocation table.
ReadBloek: Read a sector of SD card.
FAT_Init: Get the basic information of FAT16 file system.
DirStartSec: Get the starting sector number of root directory.
DataStartSec: Get the starting sector number of data area.
ClusConvLBA: Get the starting sector number of a cluster.
LBAConvClus: Convert the relationship between sector number and cluster number.
GetFileName: Get the first sector number of the specified file.
ListDateTime: List the date and time when the file or subdirectory is created.
SearchFoler: Search for files or subdirectories in the specified range.
ListDir: List files or subdirectories and related information in the specified range.
FAT_FileOpen: Open the specified file.
FAT_FileRead: Read file data.
4.2 VSl003 module
The VSl003 module mainly provides the driver for the decoding chip VSl003, and provides a basic interface for the application layer to play audio data, control volume channels, etc. This module mainly contains the file vsl003.c. The functions of its main functions are as follows.
The vsl003.c file mainly provides the driver for the VSL003 chip, including the following main functions.
VSL003_Config: Configure the relevant pins connected between STM32 and VSl003, including SPl2, PA0, PA1, PA2, and PA3.
SPIGetChar: Read 1 byte from VSl003 via SPI.
SPIPutChar: Write 1 byte to VSl003 via SPI. If it is an MP3/WMA data stream, VSl003 will start decoding and playing.
Mp3ReadRegister: Read the value of the VSl003 register.
Mp3WriteRegister: Write the VSl003 register.
Mp3Reset: Reset VSl003, including software reset and hardware reset.
Mp3SoftReset: VSl003 software reset, set the clock, sampling rate, emphasis, volume, stereo and other parameters. Generally, a software reset is required between two songs.
VsSineTest: Play sine sound waves to test whether the connection between VSl003 and STM32 is intact.

Conclusion
This article proposes a design scheme for an MP3 player based on STM32, and uses the ARM development tool RealView MDK to implement a prototype of the scheme. Although this scheme cannot be used as a general MP3 solution, it has a certain reference value for industrial control, automotive electronics, medical electronics and other solutions that require certain audio. In addition, this system uses multiple peripheral interfaces of the STM32 processor, which can also be used as a reference for readers.

正文块 end
Keywords:Cortex-M3  STM32 Reference address:Design of MP3 player based on Cortex-M3

Previous article:Design of Embedded Web Server Based on Cortex-M3 Core Processor
Next article:Research on the Exception Handling Mechanism of Cortex-M3

Recommended ReadingLatest update time:2024-11-16 23:43

When configuring the STM32 clock, pay attention to setting the FLASH wait cycle
        I wrote the register definition of reset and clock control (RCC) with great enthusiasm. I didn't have a nap, but I was sweating profusely. It seemed that this was a thankless task. I really wanted to use the ready-made header files of others. In the end, I gritted my teeth and wrote it myself, at least I could
[Microcontroller]
STM32 serial port prints ADC collection voltage
ADC is a single-chip microcomputer and one of the commonly used functions of STM32 in industrial control. It is used to collect voltage, temperature, etc. as indicators and provide them to other parts for corresponding operations. It is very convenient to configure it using the 32 firmware library. Here, the collected
[Microcontroller]
STM32 serial port prints ADC collection voltage
STM32 learning record 14 serial port interrupt in ucosii
First, let’s look at what Teacher Shao wrote in his book. It says: In μC/OS, the interrupt service subroutine must be written in assembly language. However, if the C language compiler used by the user supports online assembly language, the user can directly put the interrupt service subroutine code in the C langu
[Microcontroller]
STM32 learning record 14 serial port interrupt in ucosii
Installation and cracking of keil software (can be used for both STM32 and C51)
Teach you how to install and crack Keil software (this article takes Keil4 software as an example) Step 1: Run the mdk.exe software and keep clicking on the default You can modify the path here Step 2: After clicking next, this dialog box will appear. You can enter any number in the first name and email fields.
[Microcontroller]
Installation and cracking of keil software (can be used for both STM32 and C51)
STM32 HAL library timed interrupts and encoding input
It takes a lot of time to watch videos on these basic things, and those who have some basic knowledge may not be very clear about the library when learning. I hope that the usage of the library I summarized can save everyone's time. void TIM3_Init(u16 arr,u16 psc) {       TIM3_Handler.Instance=TIM3; //General timer
[Microcontroller]
About the difference between i2c and spi protocols for debugging stm32 and stm8 (51 microcontroller)
When debugging the STM32's i2c and io ports to simulate the spi protocol, I found that timing is critical. STM32 can implement i2c or spi protocols at 72M, but it does not mean that the same code will run successfully on a 51 microcontroller, because the 51 microcontroller has a maximum speed of 8M, so there will be ma
[Microcontroller]
The principle and source program of using IDLE interrupt to receive indefinite length data in STM32 serial port
Today, let's talk about how to receive indefinite length byte data on the STM32 microcontroller. Since the STM32 microcontroller has an IDLE interrupt, you can use this interrupt to receive indefinite length byte data. Since the STM32 is an ARM microcontroller, the method in this article is also suitable for other ARM
[Microcontroller]
The principle and source program of using IDLE interrupt to receive indefinite length data in STM32 serial port
Remap of STM32
Many built-in peripheral input and output pins in STM32 have the function of remapping. This article explains some of the problems encountered when using pin remapping. We know that each built-in peripheral has several input and output pins. Generally, the output pins of these pins are fixed. In order to allow design e
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号