How to Use MMC/SDC

Started by tha, May 28, 2022, 09:34:51 AM

Previous topic - Next topic

tha

http://elm-chan.org/docs/mmc/mmc_e.html
ต้องขอขอบคุณทางทีมงานเว็บไซส์นี้ ที่ให้ความรู้เรามาไว้ ณ ที่นี้ด้วยครับ

How to Use MMC/SDC

The Secure Digital Memory Card (SDC below) เป็น the de facto standard memory card สำหรับ mobile equipments. The SDC ถูกพัฒนาให้เข้ากันได้แบบสูงกว่ากับ Multi Media Card (MMC ด้านล่าง). SDC compleant equipments สามารถใช้ MMCs ในกรณีส่วนใหญด้วย. มี reduced size versions ด้วย, อย่างเช่น RS-MMC, miniSD and microSD, ที่มี the same function. The MMC/SDC มี a microcontroller ในมัน. The flash memory controls (block size translation, การปรับระดับการสึกหรอและการแก้ไขข้อผิดพลาด - รู้จักกันในชื่อ FTL) เสร็จสมบูรณ์ ภายใน the memory card. The data ถูกส่งถ่ายระหว่าง the memory card and the host controller เป็น data blocks ในหน่วยของ 512 bytes, ดังนั้นมันสามารถถูกมองเห็นเป็น a block device เหมือน a generic harddisk drive จากมุมมองของ upper level layers.

หน้านี้อธิบายความรู้พื้นฐานและเรื่องเบ็ดเตล็ดที่ฉันรู้เกี่ยวกับการใช้ MMC/SDC กับระบบฝังตัวขนาดเล็ก ฉันเชื่อว่าข้อมูลนี้จะต้องเป็นประโยชน์ในการเริ่มต้น บันทึกย่อสำหรับผู้ที่กำลังจะใช้ MMC/SDC บน the electronics handiwork projects.




tha

Pinout

ภาพขวาแสดง the contact surface of the SDC/MMC. The MMC มี 7 contact pads. The SDC มี 9 contact pads ซึ่งมีหน้าสัมผัสเพิ่มเติมอีก 2 กับ the MMC. The three of the contacts ถูกระบุสำหรับ power supply, ดังนั้น the number of effective signals คือ 4 (MMC) และ 6 (SDC). ดังนั้น the data transfer ระหว่าง the host and the card ถูกทำโดยทาง a synchronous serial interface.

The working supply voltage range ถูกแสดงให้เห็นโดย the operation conditions register (OCR) และมันควรถูกอ่านและยืนยัน the operating voltage range ตอน card initialization. อย่างไรก็ตาม, the supply voltage ยังสามารถถูกกำหนดไว้ที่ 3.0 ถึง 3.3 volts โดยไม่มีการยืนยันใดๆเนื่องจาก the all MMC/SDCs ทำงานที่ 2.7 ถึง 3.6 volts เป็นอย่างน้อย. ห้ามจ่ายไฟ 5.0 volts ให้กับ the card, มิฉะนั้น the card จะพังทันที. The current consumption ที่ write operation สามารถถึงสูงถึง 100 miliamperes, ดังนั้น the host system ควรพิจารณาเพื่อจ่ายไฟ 100 miliamperes ให้กับ tha card เป็นอย่างน้อย.







tha

SPI Mode

เอกสารนี้อธิบายเกี่ยวกับ SPI mode เพื่อควบคุม the MMC/SDCs. The SPI mode เป็น an alternative operating mode ที่กำหนดให้ใช้ the MMC/SDCs โดยไม่มี a native host interface. The communication protocol of the SPI mode เรียบง่ายเล็กน้อยเมื่อเทียบกับ native operating mode ของมัน. The MMC/SDC สามารถถูกแนบติดกับ the most microcontrollers โดยทาง a generic SPI interface หรือบาง GPIO ports. ดังนั้น the SPI mode เหมาะสำหรับ low cost embedded applications ที่ไม่มี native host interface ให้ใช้งาน. มี 4 SPI modes ที่แตกต่างกัน, 0 ถึง 3, ขึ้นอยู่กับ clock phase and polarity. The SPI mode 0 ถูกกำหนดสำหรับ SDC. สำหรับ the MMC, มันไม่เป็น the SPI spec, ทั้ง latch และ shift operations ถูกกำหนดด้วย rising edge of the SCLK, แต่มันดูเหมือนการทำงานที่ mode 0 ที่ the SPI mode. ดังนั้น the SPI mode 0 (CPHA=0, CPOL=0) จึงเป็นการตั้งค่าที่เหมาะสมเพื่อควบคุม MMC/SDC, แต่ mode 3 (CPHA=1, CPOL=1) ก็ทำงานได้เช่นกันในหลายกรณี. A pull-up บน the DO ไม่สามารถถูกละเว้น, มิฉะนั้นบาง cards จะล้มเหลว initialization process.



tha

Command and Response

ใน SPI mode, the data direction บน the signal lines ถูกคงที่และ the data ถูกส่งถ่ายใน byte oriented serial communication. The command frame จาก host ไปยัง card เป็น a fixed length packet ที่แสดงข้างล่าง. The card พร้อมที่จะรับ a command frame เมื่อมันขับ DO high. หลังจาก a command frame ถูกส่งไปยัง the card, a response ต่อ the command (R1, R2, R3 or R7) ถูกส่งกลับจาก the card. เนื่องจาก the data transfer ถูกขับโดย serial clock ที่สร้างขึ้นโดย host controller, the host controller ต้องต่อเนื่องการอ่าน data, ส่ง a 0xFF และรับ received byte, จนกระทั่ง a valid response ถูกตรวจพบ. The DI signal ต้องอยู่ในระดับ high ในระหว่าง read transfer (ส่ง a 0xFF และ the received data). The response ถูกส่งกลับภายใน command response time (NCR), 0 ถึง 8 bytes สำหรับ SDC, 1 ถึง 8 bytes สำหรับ MMC. The CS signal ต้องถูกขับจาก high เป็น low ก่อนการส่ง a command frame และยึดมัน low ในระหว่าง the transaction (command, response and data transfer ถ้ามีอยู่). The CRC feature เป็นตัวเลือกใน SPI mode. CRC field ใน the command frame จะไม่ถูกเช็คโดย the card.


tha

SPI Command Set

แต่ละ command ถูกแสดงเป็นตัวย่ออย่าง GO_IDLE_STATE หรือ CMD<n>, <n> คือ the number of the command index และd the value สามารถเป็น 0 ถึง 63. Following table อธิบายเฉพาะ commands ที่มักจะถูกใช้สำหรับ generic read/write และ card initialization. สำหรับรายละเอียดเกี่ยวกับทุก commands, โปรดดูที่ spec sheets จาก MMCA and SDA.



tha

SPI Response

มีบาง command response formats, R1, R2, R3 and R7, ขึ้นอยู่กับ the command index. A byte of response, R1, ถูกส่งคืนกลับสำหรับ commands ส่วนใหญ่. The bit field of the R1 response ถูหแสดงในรูปด้านขวา, the value 0x00 หมายถึงสำเร็จลง. เมื่อ any error เกิดขึ้น, corresponding status bit ใน the response จะถูกเซ็ต. The R3/R7 response (R1 + ต่อท้าย 32-bit data) สำหรับเฉพาะ CMD58 and CMD8.

บาง commands ใช้เวลานานกว่า NCR และมันตอบสนอง R1b. มันคือ an R1 response ตามด้วย busy flag (DO ถูกขับเป็น low ตราบเท่าที่ internal process กำลังดำเนินการอยู่). The host controller ควรรอสำหรับ end of the process จนกว่า DO เป็น high (a 0xFF ถูกรับ).


tha

Initialization Procedure for SPI Mode

หลังจาก a power-up sequence, MMC/SDC เข้าสู่ native operating mode ของมัน. เพื่อกำหนดมันให้เป็น SPI mode, ขบวนการต่อไปนี้ต้องถูกดำเนินการตาม flow นี้.

Power ON or card insersion

หลังจาก supply voltage ขึ้นถึงเกิน 2.2 volts, รอเป็นเวลา one millisecond เป็นอย่างน้อย. เซ็ต SPI clock rate ระหว่าง 100 kHz and 400 kHz. เซ็ต DI and CS เป็น high และใช้พัลส์นาฬิกา 74 พัลส์ขึ้นไปให้กับ SCLK. The card จะเข้าสู่ native operating mode ของมันและพร้อมที่จะยอมรับ native command.

tha

Software reset

ส่ง a CMD0 โดยที่ CS เป็น low เพื่อรีเซ็ต the card. The card สุ่มตรวจ CS signal ตอนที่ a CMD0 ถูกรับเรียบร้อยแล้ว. ถ้า the CS signal เป็น low, the card เข้าสู่ SPI mode และ responds R1 ที่มี In Idle State bit set (0x01). เนื่องจาก the CMD0 ต้องถูกส่งเป็น a native command, the CRC field ต้องมี a valid value. เมื่อทันทีที่ the card เข้าสู่ SPI mode, the CRC feature ถูกปิดใช้งานและ the command CRC และ data CRC ไม่ถูกเช็คโดย the card, ดังนั้น command transmission routine สามารถถูกเขียนด้วย the hardcorded CRC value ที่ใช้ได้สำหรับเฉพาะ CMD0 and CMD8 ที่ใช้ใน the initialization process. The CRC feature สามารถถูกสลับ on/off ด้วย CMD59 ได้ด้วย.