Analysis of MultiMediacard and its interface with single-chip microcomputer

Publisher:朝霞暮雨Latest update time:2018-03-18 Source: eefocusKeywords:MultiMediacard Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

 Abstract: MultiMediaCard is a large-capacity serial Flash memory card launched by Sandisc. Its dimensions are 32mm%24mm%1.4mm, its mass is less than 2g, and it has 7 pins, which is convenient for the development and design of small mobile digital devices. This article focuses on the interface between this type of memory and the PIC microcontroller, and gives practical circuit design and software code examples. Keywords: MultiMediaCard Serial Flash memory card PIC microcontroller interface 1 Overview MultiMediaCard (MMC), a large-capacity serial Flash memory product launched by Sandisc, is usually called a multimedia card. It is smaller than SmartMedia,

1.jpg

    It is not afraid of shocks and can read and write records repeatedly for 300,000 times. The driving voltage is 2.7-3.6V, and the variable clock frequency range is 0-20M Hz . The current common capacity is 64MB/128MB. ATP Ele CTR ionics has taken the lead in launching a 1GB high-capacity MMC. In addition to the characteristics of small size, long life, and large capacity, it also has the advantages of storage area error correction capability; low power consumption; automatically enters sleep state after not receiving a command word within 5ms; and supports hot plugging . MMC can be formatted as a FAT file system for easy reading and writing by the host computer. 2 Introduction to MMC 2.1 Pin arrangement and function According to the different storage capacities, MMC has two construction technologies: SMDB and SDMJ. SMDB is binary NAND technology (Binary NAND), and 16MB and 32MB MMC cards use this technology. The currently commonly used 64MB and 128MB MMCs use SDMJ, that is, MLC (Multi Level Cell) NAND technology. MMC cards of different capacities have the same dimensions and pin arrangement, as shown in Figure 1. The MMC read-write interface can work under both MMC and SPI communication protocols. MMC is a high-performance three-wire communication protocol developed by the MMCA Association, namely CMD, CLK, and DAT lines. It can address up to 64,000 MMC cards, and a single physical address can stack 30 cards. It supports sequential read and write and single/multiple data block read and write operations, and is the default communication protocol for MMC cards. The SPI protocol is an optional protocol, and its working efficiency is not as good as the MMC protocol; but the SPI protocol is simple and easy to use, has good compatibility, and is easy to connect to the microcontroller. This design uses the SPI communication protocol, which will be introduced in detail below.

2.jpg

    2.2 Internal Logical Structure The internal logical structure of the MMC card can be divided into four parts: MMC/SPI interface, single-chip controller, data flash memory module, control line and data line. The MMC/SPI interface realizes communication with the main controller.

3.jpg

    The single-chip controller completes the interface protocol, data storage retrieval, error correction code algorithm, fault diagnosis processing, power management and clock control functions. The data memory module can realize single-byte access in the entire storage space. It is not a simple word array, but is divided into multiple structures. 512 bytes constitute a sector. According to the different capacities of the MMC card, 16 or 32 sectors constitute an erase group. 32 erase groups constitute a write protect group. This design makes the MMC operation flexible and easy to use. The control line and data line realize the access to the data storage area. Its internal logic structure is shown in Figure 2. 3 MMC/SPI communication protocol After the MMC card is powered on, it enters the MMC mode by default. If it is switched to the SPI mode, the mode switching is required. The SPI mode setting process is shown in Figure 3. If you need to switch from SPI mode to MMC mode, you can only cut off the power supply, re-power it on, and enter the default MMC mode. From the perspective of practical application, the SPI mode is simple in design and easy to operate, but the data transmission rate is inferior to the MMC mode. Based on the design requirements, the author adopted the SPI communication protocol. 4 Memory read and write interface 4.1 SPI interface and operation mode The SPI interface is a universal synchronous serial interface bus with a word length of 8 bits, which is used to communicate with external devices. The SPI interface uses three lines: CLK, DataIn and DataOut to read and write data. Among them, CLK is the clock signal provided by an external controller; Datain and DataOut are data input and output lines. CS is the MMC chip select signal line, and a low-level valid signal must be maintained throughout the SPI operation. The SPI interface has four operation modes, namely 0, 1, 2 and 3. The SPI operation mode determines the clock phase and polarity when the device receives and sends data, that is, it determines the relationship between the rising and falling edges of the clock signal and the direction of data flow, as shown in Figure 4. This design uses mode 3. 4.2 MMC card command and reply signals

4.jpg

    All MMC card command words are 6 bytes long, transmission starts from the high bit, and contains a CRC check word. The command word index is encoded in binary . For example, the index bit of CMD0 is 000000, and the index bit of CMD39 is 100111. MMC card command words are divided into 10 command groups, each group consists of multiple command words to complete the MMC card function settings. Sandisc MMC cards in SPI mode support 6 of these command groups, which can realize basic settings, data block read, data block write, erase, write protection, and MMC card lock functions. MMC cards have multiple response signal formats, and transmission starts from the high bit. In SPI mode, there are 5 response signal formats, namely R1, R2, R3, Busy, and R1b. After receiving each command, the MMC card sends a response signal in the format of R1, except for the card status query command word CMD13. This response signal occupies 1 byte, the highest bit is 0, and the lower 7 bits are error flags. If a bit is 1, it means that there is a corresponding error. The Busy response signal length is multiple bytes. All bits are 0, indicating that the card is busy. The presence of a non-zero bit indicates that the card is ready to receive the next command.

5.jpg

    The length of the R2 format response signal is 2 bytes, which is used to reply to the card status query command word CMD13. The format of the first byte is the same as R1, and the second byte indicates the error type. The length of the R3 format response signal is 5 bytes, which replies to the card OCR gap read command CMD58. The format of the first byte is the same as R1, and the remaining 4 bytes are the OCR gap content. The R1b format response signal includes two parts, the R1 format part and the Busy format optional additional part. 4.3 MMC transmission timing in SPI mode The read and write timing of MMC under the SPI protocol is shown in Figure 5. The main controller sends a read/write command, and when the correct response signal is received on the OUT transmission line, the OUT/IN transmission line starts the read/write operation.

6.jpg

    5 Example of MMC card and microcontroller interface 5.1 Hardware circuit design Figure 6 shows a part of the portable data acquisition system designed by the author using a 32MB MMC card from Sandisc. The microcontroller is PIC16F73B launched by MicroChip of the United States. The operating frequency of the microcontroller is 4MHZ, and the hardware SPI interface of Port C is used for reading and writing operations of the MMC card. 5.2 Software design Before accessing the storage unit of the MMC card, it is necessary to set the access block length. The default length is 512 bytes. This design is to write to the cache chip FM24CL64, and transfer it to the main memory MMC after reaching 512 bytes (the hardware circuit diagram should be modified accordingly), so the read and write length is no longer set. After the MMC is formatted into the structure of the FAT file system, the data is read by the host computer in the form of a file. The software design process of the MMC interface part is shown in Figure 7. 5.3 MMC card SPI initialization and write subroutine Because MMC can work under two protocols and the default is the MMC operation mode, it must be initialized before it can work in SPI mode.


Keywords:MultiMediacard Reference address:Analysis of MultiMediacard and its interface with single-chip microcomputer

Previous article:Analysis of Coin-operated Circuit of PIC16C71 Single-Chip Microcomputer
Next article:Design and implementation of frequency source based on AD9911

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号