Design of sound player based on 8-bit single chip microcomputer and flash memory

Publisher:Blissful5Latest update time:2011-09-10 Keywords:EPG323l Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

A method for using large-capacity NAND Flash memory in a single-chip microcomputer system is proposed. Compared with the general method, the programmer who writes the application program does not need to master the specifications of the computer file system. He only needs to operate the NAND Flash according to the timing of reading, writing, and erasing, and treat the NAND Flash as NOR Flash or SRAM. In this way, the physical address of the memory is transparent to the programmer, and he only needs to skip the block when encountering a bad block.

This method reduces the difficulty and cost of using NAND Flash memory, and is not only applicable to EPG3231, but can also be extended to general 8-bit single-chip computer systems.

In the teaching of single-chip microcomputers, students are more interested in production projects with sound and display. Therefore, in the learning process, this interest often allows them to complete the project, gain a sense of accomplishment, and learn more.

At present, the sound storage is mostly in large-capacity NAND Flash, but it is generally stored in the form of a file system, which is somewhat difficult for students. The sound files of this sound player are stored in NAND Flash in a non-file manner, so that without much background knowledge, it is relatively simple to use large-capacity NAND Flash memory, reducing the difficulty and cost of using NAND Flash memory.

1 Overall design of the sound player

The overall design block diagram of the sound player is shown in Figure 1. The memory is used to store sound files. The microcontroller displays the sound file name in the memory on the display, and selects the sound file to be played according to the key. The data of the sound file is sent from the memory to the internal D/A converter, and the output of the D/A is amplified by the power amplifier and sent to the speaker to play the sound.


Among them, when selecting the memory, it should meet the conditions of large capacity, non-volatile, and low price. According to the above conditions, NAND Flash is the best choice. Here, K9G8G08 NAND Flash is selected, and its capacity is 1 G byte. For voice information in WAV format, 8 bit, 22.05 kHz, and mono are sufficient to meet general needs, and for music (songs), a sampling frequency of 44.1 kHz can also achieve good results. Therefore, the device can store about 800 minutes of voice or 400 minutes of music; the display uses a 122x32 LCM, and the built-in controller is SEDl520, which can display 14 Chinese characters or 28 English characters; the buttons mainly include play/pause, stop, flip up, flip down, etc., and use independent buttons; the single-chip microcomputer uses ELAN's EPG3231, which is similar to the 5l series single-chip microcomputer.

The key to designing a sound player is to consider: what format and how the sound data is loaded into K9G8G08. One way is to use a USB flash drive to download the data to K9G8G08 through a computer, and the sound data is stored in the form of a file. However, in this way, the interface connection with the USB flash drive must be completed in the microcontroller, and the computer file format must be familiar, which is difficult for microcontroller beginners. Another way is to store the sound data in K9G8G08 in sequence (just skip it when encountering a bad block), so that the physical address of the data storage is transparent to the developer, and then the sound data can be loaded into K9G8G08 using the downloader. If the downloader and the sound player are made together, data can also be downloaded online.

2 Sound Player Hardware Circuit Design

2.1 Introduction to K9G8G08

K9G8G08 is a 1 Gx8 bit NAND Flash memory produced by Samsung. Its operating voltage is 2.7 to 3.6 V, and its internal storage structure is (2 K+64) bytes/page × 128 pages/block × 4096 blocks. The external circuit accesses its command register, address register and data register in time-sharing through the shared 8-bit I/O port to implement operations such as reading, writing and erasing the device. The naming method of its memory can be found in the literature. K9G8G08 uses a 48-pin TSOP package, and its pin configuration is shown in Figure 2.


2.2 Introduction to EPG3231

EPG3231 is an 8-bit RISC microcontroller from ELAN. It has 11 8-bit parallel ports, 1 8-bit current output D/A, 1 10-bit successive approximation A/D, 1 universal asynchronous receiver/transmitter UART, 1 8, 16, 24-bit serial peripheral interface SPI, 3 timers, etc. It has rich hardware resources and supports handwriting recognition, speech recognition, ADPCM encoding and decoding, etc. In addition, EPG3-231 is fast. When the clock frequency is 16 MHz, the instruction cycle is 125 ns.

2.3 Circuit connection between EPG3231 and K9G8G08

Figure 3 is the circuit connection diagram of EPG3231 and K9G8G08. K9G8G08 is not shown in the figure, only the basic circuit of EPG3231 and the connection pins with K9G8G08 marked with network numbers are shown. Pin 19 of K9G8G08 is write-protected, and in the actual circuit it is connected to +3.3 V (not protected). It should be noted that the D/A output of EPG3231 is pin 48 (PB1), which outputs current signals. Its output needs to be converted into voltage signals and then sent to the subsequent power amplifier. Among them, the simplest and feasible method is to connect a resistor between PB1 and ground to complete the conversion between current and voltage. The key is the value of the resistor. If the resistance value is large, the upper part of the output waveform will be limited and distorted; if the resistance value is small, the dynamic range of D/A cannot be maximized. Therefore, the method to determine the resistance value is: first connect an adjustable resistor, write a test program, repeatedly and continuously send values ​​00~FFH to the D/A, observe the PBl output through an oscilloscope, and adjust the adjustable resistor to make the output an undistorted sawtooth wave with the highest point of 3.3 V (that is, the reference power supply VREX (pin 70) voltage).


In addition, in Figure 3, the D port (PD0~PD7) of EPG3231 is connected to the I/O port of K9G8G08. This port must be bidirectional. Other bidirectional ports can also be used, but do not use the J port and K port. These two ports are suitable for key input/output (scan output when using a matrix keyboard). The speed is relatively slow and cannot be used for communication with K9G8G08. It should also be noted that since the encoding in the WAV file is an unsigned number (that is, OOH is the lowest level and FFH is the highest level), and the D/A input of EPG3231 is a signed number (that is, 80H is the lowest level and 7FH is the highest level), the highest bit of the WAV sound data should be inverted and sent to the D/A in the program.

3 Sound player software design

Before designing the sound player software, the format in which data is stored in K9G8G08 should be determined.

First, the format of the address. The address of the internal storage unit of K9G8G08 is sent out in 5 bytes, so the format of the address is best arranged according to these 5 bytes, as shown in Table 1.


Secondly, according to the characteristics of NAND Flash, there may be bad blocks (BAD BLOCK) inside it, but BLOCK 0 must be a valid block (VALID BL13CK), so the bad block information is stored in BLOCK 0. The number of valid blocks of K9G8G08 is between 3 99* 096, that is, the number of bad blocks is not more than 100. The block address is determined by A19~A30. To facilitate program writing, the block address is stored in 3 bytes. The arrangement of each address bit is the same as the 3rd, 4th, and 5th bytes in Table 1, and A12~A18 bits are set to 0. The bad block information storage area occupies a maximum of 300 bytes.

Third, the directory of the sound file is also stored in BLOCK O. Each record in the directory occupies 64 bytes, of which the first 5 bytes are the starting address of the sound file. To facilitate program writing, the address bits contained in each byte are consistent with Table 1; the following 59 bytes are the name of the sound, such as the song name, etc., and 0 indicates the end, as shown in Table 2. As can be seen from Table 2, the directory area has a maximum of 4,088 records, which should be able to meet general needs.


The most critical part of software design is the operation of K9G8G08. In this sound player, the program only needs to read K9G8G08. Figure 4 shows the software design process of reading K9G8G08.


The program for reading K9G8G08 is called in the timer interrupt. For 22.05 kHz or 44.1 kHz WAV files, the timer interrupt period is 45.4μs or 22.7μs respectively. For monophonic, 8-bit WAV files, the frequency can be obtained from the 18H and 19H bytes of the file header. For 22.05 kHz and 44.1 kHz WAV files, the values ​​of these two bytes are 22H, 56H and 44H, ACH respectively, and the sound information starts from the 2CH byte. It should be noted that: 1) The operation of writing commands includes sending command words and generating a falling edge on the write (WE) control line; 2) The operation of writing 5-byte addresses requires writing 5 bytes of addresses to K9G8G08 in the order in Table 1. The writing of each address includes sending the address and generating a falling edge on the write (WE) control line; 3) The operation of inputting data includes generating a rising edge on the read (RE) control line and reading in data.

4 Conclusion

Since the operation of different types of NAND Flash may be slightly different, if the player is to support multiple NAND Flash at the same time, the device ID should be read in the program, and different NAND Flash reading programs should be selected according to its ID. For the ID of Samsung NAND Flash, please refer to the literature. This sound player has the playback function of a cassette recorder and a repeater. If the recording function is added, it can completely replace the cassette recorder and repeater, because it has the advantages of not using tapes and not having a complex and easily damaged mechanical structure, which is incomparable to the former two. It is just that the quantization resolution of 8 bits is slightly lower, which is reflected in the "humming" noise when playing a low-volume voice. This is caused by the quantization error. The method of using 16-bit WAV files in the player can be used to solve this problem, but this will double the amount of data. It can also be solved by using MP3 files. In this case, it is an MP3 player, but an MP3 decoder needs to be added (or decoded by software). The method of using NAND Flash proposed here is simple and easy, basically similar to the use of NOR Flash or SRAM. The physical address of the memory is transparent to the programmer and easy to understand and control.

Keywords:EPG323l Reference address:Design of sound player based on 8-bit single chip microcomputer and flash memory

Previous article:Performance and application of OV5017 image sensor chip
Next article:APD bias control/optical power monitoring circuit technology designed by ADL5317

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号