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,
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.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.
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
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.
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.
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.
Previous article:Analysis of Coin-operated Circuit of PIC16C71 Single-Chip Microcomputer
Next article:Design and implementation of frequency source based on AD9911
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Use one data line to control full-color LED lights! Single bus LED usage guide
- 【Portable Programmable Meter】Sliding Rheostat Arrived
- How to connect the reed switch sensor to the microcontroller
- ssh network login
- What can damage the dp83848 chip? The reset pin is always low and the chip cannot start.
- The 200-meter line signal has irregular jumps after the op amp output
- 【GD32F307E-START】+ Completed driving LCD19264 display
- ESP32 port adds support for ESP32-S3
- TMS320C6000 Pipeline Overview
- Will the GaN RF market become more and more popular?