This article refers to the address: http://
introduction
With the popularity of mp3 players as consumer products, MP3 is increasingly designed and produced. In the current MP3 player, there are generally the following design options:
1 MCU built-in hard decoding module. Typical chips are Atmel's AT89C51SNDI and other chips.
2 External independent MP3 hard decoding chip. The advantage of this solution is that you can use a large number of MCUs, which can be arbitrarily chosen as needed. The hard decoding chip typically has VS1011B, STA013 and other chips.
3 Use a powerful MCU for soft decoding, such as using DSP or high-performance ARM. This kind of scheme is more flexible, and the product upgrade can be realized through software upgrade.
The storage medium of the MP3 player generally uses a flash memory chip. With
With the development of USB technology and flash memory technology, USB flash drives have become widely used as popular electronic products, but USB flash drives are generally only used as mobile storage for PCs. One solution studied in this paper is to expand the excellent disk read/write circuit on the basis of the above MP3 design scheme 2, so that the storage medium uses an ordinary USB flash drive. This can solve the problem that the commonly used USB flash drive can only be used as a PC peripheral to store data, so that the U disk can be extended to MP3. The greater significance is that this paper proposes a design scheme for using USB flash drives as data storage in consumer electronic products or industrial products with embedded systems and MCUs as the core, for microcomputer measurement and control systems and instrumentation. The addition of USB peripheral functions in products such as paperless data loggers and digital cameras provides a useful reference.
1 hardware design
The S3C44B0X is a low-cost, high-performance ARM7TMDI core processor developed by Samsung to provide embedded devices with a maximum operating frequency of 66 MHz. The SL811HS is an embedded Host/Slave USB chip that complies with the USB1.1 protocol from Cypress; it can support low-speed and high-speed modes, and can automatically detect low-speed mode 1. 5 Mbps devices and high-speed mode 12 Mbps full-speed devices. Thanks to the support of the 8-bit data bus, the chip can be connected to the microcontroller relatively simply. The interface between the SL811HS chip and the S3C44B0X is relatively simple. The block diagram of the ARM read/write USB flash drive in this system is shown in Figure 1.
![USB disk read / write circuit block diagram]()
The control commands and data of the SL811HS are transmitted through D0~D7, and A0 is the data or address selection line. When A0 is set low, the address of the SL811HS on-chip register is transmitted on D0~D7; otherwise, the data transmitted when A0 is set to high level. nWR, nRD, nCS, and nRST0 are the write control line, the read control line, the chip select line, and the reset line, respectively. The S3C44B0X performs read, write, chip select, and reset operations on the SL811HS on-chip buffer through these control lines. INT is the interrupt request signal line of the SL811HS. When the SL811HS detects the insertion or removal of the USB flash drive, it notifies the S3C44B0X by pulling the INT line high. The S3C44B0X can be used to query whether the USB flash drive is inserted or removed by querying the SL811HS on-chip status register. Writing to the status register clears the interrupt, but it is important to note the structural nature of the ARM. ARM internally uses the Little Endian mode to store and use 4-byte alignment [1], and when using a 16-bit data bus, the address line ADDR0 is invalid [2]. In this system, the A811 end of the SL811HS chip is connected to ADDR1.
VS1011B is a single-chip MP3 decoder chip, which has a great influence on international MP3 amateurs, integrating decoding, A/D conversion, audio amplification and other functions. The interface between VS1011B and S3C44B0X is SPI interface, and the block diagram of the connection circuit is shown in Figure 2.
![VS1011B control circuit block diagram]()
The control and data transmission of VS1011B is completed through the SPI interface. DREQ, xDCS, xCS, and nRST1 are data request port, digital chip select signal line, chip select line, and reset line, respectively. In the new mode of VS1001B, SDI (Serial Data Interface) data and SCI (Serial Command Interface) data transmission can share an SPI interface of ARM; while in compatibility mode, SDI data transmission uses DCLK, SDATA serial interface, SCI Data transmission uses SPI interface. In order to simplify the circuit, a new mode is selected here.
2 software design
2.1 Implementation of USB flash drive software
The USB organization defines specifications for mass storage classes. This class specification includes four separate subclass specifications: USB Mass Storage Class Control/Bulk/Interrupt (CBI) Transport, USB Mass Storage Class BulkOnly Transport, USB Mass Storage Class ATA Command Block, USB Mass Storage Class UFI Command Specification. Among them, the USB flash drive is a mass storage device, which follows the bulkonly transmission protocol, and the subclass uses the UFI command set. The overall structure of the design software is shown in Figure 3. The part between the two dotted lines is the software structure of the read/write USB flash drive.
2.1.1 Implementation of USB Physical Layer Protocol
 This part implements the S3C44B0X read and write of the direct underlying data of the SL811HS chip, including the initialization of the SL811HS and the function of reading/writing a byte. Due to space limitations, only the initialization procedure for the SL811HS chip is listed here:
/*********************************
Function name: SL811_Init
Function: Initialize SL811HS chip Input parameters: None Return value: None *********************************/
Void SL811_Init(void){
/ / Initialize the U disk is not inserted state bFlags.bits.SLAVE_ONLINE = FALSE;
bFlags.bits.SLAVE_FOUND = FALSE;
bFlags.bits.SLAVE_REMOVED = FALSE;
bFlags.bits.SLAVE_ENUMERATED = FALSE;
bFlags.bits.SLAVE_IS_ATTACHED = FALSE;
/ / Allow hardware to generate SOF (Start of Frame)
SL811Write(CtrlReg, 0x04);
DelayMs(100);
SL811Write(CtrlReg, 0x01);
/ / Set SOF, 1 ms interrupt SL811Write (cDATASet, 0xe0);
/ / Set to the host working mode SL811Write (cSOFcnt, 0xae);
SL811Write(EP0Status, 0x50);
//Address is set to 0
SL811Write(EP0Counter,0);
/ / Allow data transmission
SL811Write (EP0Control, 0x01);
SL811Write(IntEna, 0x20);
//Clear interrupt SL811Write(IntStatus, INT_CLEAR);
}
2.1.2 Implementation of the protocol layer of the USB device
This part implements direct reading and writing to the USB flash drive sector. Two important functions are Bulkin and Bulkout. Only the implementation of the Bulkin function is listed here:
/**********************************
Function name: epB
ulkRcv
Function: Implement the Bulkin function input parameters in the bulkonly protocol: pBuffer is the address of the data, and len is the length of the data. Return value: TRUE is successful, FALSE is failed ****************** ******************/
Unsigned char epBulkRcv(unsigned char *pBuffer,unsigned int len){
Usbstack.usbaddr=0x1;
Usbstack.endpoint=usbstack.epbulkin;
Usbstack.pid=PID_IN;
/ / Set the package length to 64
usbstack.wPayload=64;
usbstack.wLen=len;
Usbstack.buffer=pBuffer;
If(usbstack.wLen){
If(!usbXfer())
Return FALSE;
}
Return TRUE;
}
2.1.3 Implementation of FAT16/FAT32 file format
This part of the program is based on the structure of the FAT16/FAT32 file system, which implements operations such as reading, writing, creating, and deleting files. The data on the USB flash drive can be roughly divided into five parts according to its different characteristics and functions: MBR area (master boot record area), DBR area (system boot record area), FAT area (file allocation table area), FDT area (file directory) Table area) and DATA area (data area).
When the file is read/written, the location of the FAT table is first found according to the size of the MBR area and the DBR area, and then the data location of the corresponding file is found according to the FAT table, and the file can be processed accordingly. The specific implementation involves the structure of the FAT file system and will not be described in detail here.
2.2 VS1011B control and music file data input
The implementation principle of the mp3 player of the solution is that the controller reads the MP3 file data from the USB flash drive. When the data buffer of the VS1011B needs data, the data is sent to the VS1011B for decoding. The VS1011B uses a serial interface and has two interface modes:
Native Modes (Complete Modes) and Compatibility;
Mode (compatible mode). When the SM_SDINEW bit of the MODE register with address 0x0 is 1, it is the new mode; otherwise, it is the compatibility mode. The default is the new mode at power-on.
Before playing music, you first need to initialize the VS1011B, then enter the music file to play the song. The control steps are as follows: [3]
1 Pull down nRST1.
2 Wait for the DREQ pin signal to go high.
3 write the parameters of the register MODE, package
The SM_SDINEW and SM_SDISHARED bits are set correctly.
4 If the clock rate is not 24.576 MHz, set SCI_CLOCKF.
5 If you use a multiplier clock and attempt to operate directly by changing SCI_CLOCKF, you should write the appropriate sample rate to the SCI_AUDATA register and wait for at least 11 000 clocks before operating the high-speed SPI communication.
6 Set the volume register SCI_VOL.
7 If you wish to enhance the bass, set the register SCI_BASS.
8 Read an MP3 song file from the USB flash drive and start transferring music data. Should pay attention to the rules of data transmission, the DREQ signal is used to indicate whether the MP3 data buffer of VS1011B needs data. When the data buffer of the VS1011B can receive another 32 bytes of data, the DREQ pin goes high. When the software queries that the pin level is high, 32 bytes of MP3 music data is sent.
9 The song is finished playing, read the next MP3 song, and go to step 8.
Conclusion This article describes the design of an MP3 player that uses a USB flash drive to store MP3 song files, where software design is more difficult. In addition to VS1011B support MP3 format music files, but also support WAV format, etc., change the software to play WAV file format music. If the MP3 player is designed with a liquid crystal screen, real-time lyrics display and other functions can be realized by storing the corresponding song lyrics on the USB flash drive.
Although only one application example of the USB flash drive in the embedded system is given here, it is easy to evolve other functions based on this. For example, if you change the system slightly, you can replace the USB flash drive with a USB mobile hard disk, which can have a larger storage capacity. On the basis of such a large storage capacity, it is possible to design an MP4 player, a hard disk camera, and the like that require a large storage capacity. In addition, the design ideas of this paper can also be applied to many other industrial or consumer electronic products with embedded core, such as data acquisition and storage, digital cameras, etc., to facilitate data exchange with PC.
references:
[1] Yang Jie, Xu Zhihua. U disk reading and writing method of ARM7-based paperless recorder[J].自动化仪表, 2006,27(1): 22-24.
[2] Liu Yibo, Zhu Xinhua. Application of SL811H/S in ARM7-based embedded hardware platform[J]. Measurement & Control Technology, 2006, 25(10): 74:77.
[3]
[4] Samsung Electronics.S3C44B0X UserManual.[EB/OL].http://,2000.4.13/2005.10.20.
[5] Cypress Semiconductor Corporation. SL811 Embedded USB Host/Slave Controller Data Sheet, 2002.
[6] VLSI Solution Corporation. VS1011B User Manual. Version 1.01, 2004.
[7] Liao Rikun, Li Ningyu, et al. Research and design of MP3 player based on DSP technology [J]. Measurement and Control Technology, 2004, 32 (supplement): 193194.
Digital Signage For Office
Digital Sign Boards,Workplace Digital Signage,Conference Room Digital Signage,Commercial Digital Signage
Guangdong Elieken Electronic Technology Co.,Ltd. , https://www.elieken.com