Application of MMC in portable data acquisition system

This article refers to the address: http://

At present, the more common data acquisition and processing system is a fully functional microcomputer system. Although such a system can analyze and process the monitored signals relatively quickly, it is often used only in a fixed position, and is cumbersome and inconvenient in the field and in the case of movement. In particular, field data collection operations often require large amounts of data to be collected and recorded over a long period of time. Data acquisition and processing instruments that are small in size, light in weight, and large in storage capacity are required. In recent years, with the development of non-volatile memory technology and the continuous improvement of the performance of processors (such as embedded systems and DSPs), the power consumption and volume of signal acquisition and storage systems have been reduced, meeting the requirements of portable. However, its read and write speed is not as good as MMC. The multimedia card MMC (Multimedia Card) is a versatile, small and large-capacity flash memory card jointly developed by SANDISK and Siemens AG in 1997. MMC's development goals are mainly for mobile phones, digital cameras, digital video cameras, MP3 music, PDAs, e-books, toys and other products.
MMC has improved the shortcomings of CF card reading and writing to a certain extent, and its volume is light, impact resistance is strong, and it can be read and written 300,000 times. The MMC 4.0 standard provides a wider data bandwidth and faster transfer rates, and supports dual voltage operation modes. The MMC also has the memory area error correction capability and low power consumption. If the system control command word is not received within 5ms, the MMC will automatically go to sleep state, and it also supports hot plug operation. It can be seen that the application of MMC to a large-capacity portable data acquisition system is a good choice.
1 MMC structure and working principle [1]
1.1 MMC pins and functions

MMC is often designed as a low-cost data platform and communication medium with a storage capacity of up to 2GB. The interface design of the MMC is very simple, as shown in Figure 1. It uses a 7-pin interface, a low-cost serial bus, and a clock frequency of up to 20MHz. The MMC operates at 2.7 to 3.6V and has a read/write current of only 23mA and 27mA. The MMC minimum data transfer unit is a block, and the block size default value is defined as 512B. MMC's read and write modes include streaming mode, multi-block mode, and single block mode.


The MMC read/write interface works under both the MMC protocol and the SPI communication protocol. The MMC protocol is a high-performance three-wire communication protocol developed by the MMCA Association. It can address 64 000 MMC multimedia cards and supports sequential read/write operations and single/multiple block read/write operations. Table 1 shows the pin definitions when the MMC uses the SPI protocol.


1.2 MMC internal logic structure and function
The internal logic structure of the MMC can be divided into four parts: SPI/MMC communication protocol interface, single chip controller, data flash module, control line and data line. The SPI/MMC interface implements communication with the host controller, and the single-chip controller performs functions such as interface protocol, data storage retrieval, error correction code algorithm, fault judgment processing, power management, and clock control. The data flash module realizes single-byte access of the entire memory space, and the control line and the data line realize access and data transmission of the single-chip controller and the data flash module.
1.3 SPI/MMC communication protocol
The MMC protocol is the default communication protocol of the MMC. The SPI protocol is a subset of the MMC protocol and is an optional protocol of the MMC protocol. Although its working efficiency is not as strong as the MMC protocol, the SPI protocol is simple and easy to use, has good compatibility, and is easy to connect with the MCU, and can minimize the design cost. The SPI protocol is mainly applied to systems where the MMC requires a small amount and the data transmission rate is not too high.
After the MMC is powered on, it will enter the MMC protocol mode by default; if you want to switch to the SPI protocol mode, you need to switch the corresponding protocol mode; if you want to switch from the SPI protocol mode to the MMC protocol mode, just turn off the power and then power on again. That is, you can enter by default. This design uses the SPI communication protocol mode.
1.4 MMC file system
The MMC file format definition is not included in the system specification. In order to improve the interchangeability of data, MMC defines three basic file systems, in addition to the DOS-FAT file system without partitions and file systems with similar hard disk partitions, developers can also define their own unique file system. These definitions make MMC also supported by a wide range of operating system platforms (such as DOS systems, Windows systems, and Linux systems).
2 MMC SPI protocol
2.1 SPI interface and communication mode
The SPI interface is a general-purpose synchronous serial interface bus used to communicate with external devices with a word length of 8 bits. The SPI interface uses the three lines CLK, DataIn, and DataOut for data read and write operations. Among them, CLK is a clock signal, which is provided by an external controller; DataIn and DataOut are data input and output lines. Is the chip select signal line of MMC, during the entire SPI operation, Must always be active low.
2.2 CRC check of MMC command <br> In order to ensure the accuracy of data storage, MMC uses CRC check word in data processing. The CRC of the MMC is divided into two types: CRC7 and CRC16. CRC7 is suitable for almost all commands of MMC (except that the response signal format is R3), and the algorithm expression of CRC7 is: G(x)=x7+x3+1. The CRC16 is used for the protection processing of the data block transmission mode, and its algorithm expression is: G(x)=x16+x12+x5+1.
2.3 MMAC command response signal format <br> All MMC command words are 6 bytes long, the transmission starts from the high bit and contains a CRC check word. The format of the command word is shown in Table 2.


For the MMC command, the MMC has multiple response signal formats, and the transmission direction of the response signal also starts from the high position. In SPI protocol mode, there are five types of response signals: R1, R2, R3, Busy, and R1b.
Usually, after receiving each command word, MMC will send an acknowledgement signal with the format R1 (except for the card status query command word CMD13). The response signal is 1 byte, the highest bit is 0, and the other bits are error flags. as shown in Table 3.


The Busy format response signal has a length of multiple bytes. When all of them are 0, it means that the MMC is busy; if there is a non-zero bit, it indicates that the MMC is ready to receive the next command.
The R2 format response signal has a length of 2 bytes and is used to reply to the card status query command word CMD13. The first byte is the same as R1, and the second byte indicates the error type, as shown in Table 4.


The R3 format response signal has a length of 5 bytes and is used to reply to the OCR register in the card. The first byte of R3 is the same as R1, and the remaining 4 bytes are the contents of the OCR register.
The R1b format response signal consists of two parts: the R1 format part and the optional additional part of the Busy format.
3 MMC commands
The MMC command word is divided into 10 command groups. The SPI protocol mode supports 6 command groups, which can realize the basic settings of the MMC system, data block read, data block write, erase, write protection and MMC lock. . Take the stack check management command CIM_CHECK_STACK as an example, which is one of the basic setting commands in the command group. It mainly reads the MMC information by the command SEND_CSD (CMD9) and then compares it with the information of the interface card entering the system stack table. If it is not the previous card, it is determined whether the timeout and the limited number of cards are exceeded, thereby determining whether the card has entered the system. The stack inspection management command flow chart is shown in Figure 2.


4 MMC interface with large-capacity portable data collector composed of embedded system chips
4.1 Hardware Interface Design of MMC and Embedded Chips
Figure 3 shows the hardware interface between MMC and embedded system chip PIC16F73B. In the figure, the FM24CL64 is a cache chip, and the hardware and SPI interface of Port C is used to read and write the MMC card [2][3] .


4.2 Software Interface Design of MMC and Embedded Chip
Part of the software flow of the MMC interface with the embedded chip is shown in Figure 4.


Before accessing the MMC storage unit, you need to first set the length of the access block. The default access block length is 512 bytes, which is completed by the write cache chip FM24CL64. When the written data reaches 512 bytes, it is transferred to the MMC main memory, so the read and write length does not need to be reset. After the MMC is formatted into the FAT file system structure, the data is saved in the form of a file, which facilitates the reading of the MMC main memory by the host computer. The following is part of the program code for the embedded system to write files to the MMC card:
Void file_write(DIR_tag *file_tag,char*){
U16 j.offset=file_tag.StartCluster*2;
Mmc_read_block(&sdc,fat1_addr+offset/512,mmc-buffer);
Mmc_buffer[offset%512]=0xff;
Mmc_buffer[offset%512+1]=0xff;
Mmc_write_block (&sdc,fat1_addr+offset/512,mmc_buffer);
Mmc_write_block (&sdc,fat2_addr+offset/512,mmc_buffer);
For (j=0;j
Mmc_write_block(&sdc,519+(file_tag.StartCluster-2),mmc_buffer);
}
The embedded system chip PIC16F73B and MMC are used to build a hardware platform for signal acquisition, using only a few external logic circuits. The entire system can be powered by a single 3.3V low voltage supply, and the power supply circuit is very simple. In the system software implementation, the alternate double buffering mechanism can be used to store the collected data in the data buffer (FM24CL64 in Figure 3). When the data buffer is full, an overflow interrupt is issued, and then the MMC is burst-written. When the write operation is completed, a command can be sent to immediately put the MMC into a sleep state to minimize power consumption. Thus, during most of the time the data acquisition system is in operation, the MMC is in a sleep state and the operating current is low. The system is suitable for data acquisition and storage in the field (such as geological, petroleum, etc.), data files can be read by the card reader in the Windows environment, which facilitates further analysis and processing of data, and has low power consumption and portability. Convenience, high performance and price.
references
[1] Multimedia card product manual rev 5.1[S].SANDISK CORPORATION, 2002.
[2] Sun Fang, Yan Guozheng, Wang Wenxing.Multimedia Card and its interface with single chip microcomputer[J].Microcontrollers & Embedded Systems,2004,(6).
[3] Li Xuehai. PIC microcontroller practical tutorial [M]. Beijing: Beijing University of Aeronautics and Astronautics Press, 2002.
[4] Zhang Kai, Jiang Xijun, Chen Lei et al. MMC file system and its implementation method [J]. Microcontroller and Embedded Systems Application, 2006, (5).

TFT LCD Monitor

TFT LCD Monitor,TFT LCD,TFT Display

ESEN Optoelectronics Technology Co., Ltd, , https://www.esenlcd.com