1、簡介
MMC卡: MultiMedia card,有 7 個觸點( 引腳),分為兩種操作模式,分別為 MMC模式與SPI 模式,兩種模式對引腳的定義是不同的。SPI 模式只有 Host 具有SPI 接口時才能使用。MMC只具有存儲功能,不像SD卡還具有加密功能。
SD卡: Security Digtial card,共有9 個觸點( 引腳),多余的 2 個引腳為數據線,但使用與 MMC卡兼容的模式時,這兩個多余的引腳沒有起到作用。SD卡除了存儲功能外,還有一種加密功能,但加密功能是收費的(所以開源的linux中只包含mmc的驅動目錄),因為當初SD卡聯盟中(索尼)就是發明這種卡就是用來存儲音樂(淘汰卡帶),并使用加密特性,防止拷貝。
TF卡:軟件上SD卡一致,只是在硬件的體積上比SD卡西小,所以市場上很多的TF卡的SD外形卡套
SDIO卡:
3、SD卡協議
1.x:小于2GB的卡(但通過相關的軟件,可以模擬實現大于2GB)
2.0: 2<SD卡<32 GB
3.0: >32GB
4、SD卡通信接口
SD卡有9個pin:1個VDD,2個VSS(GND),CLK,CMD,DATA0-DATA3, 【DATA3可以作為卡檢測腳】
SD卡可以使用SD總線接口,也可以使用SPI通信接口;
SD總線接口描述:
CMD:Command is a bi-directional signal. (Host and card drivers are operating in push pull mode.) 【命令與響應都是走這條線】
DAT0-3:Data lines are bi-directional signals. (Host and card drivers are operating in push pull
CLK:Clock is a host to cards signal. (CLK operates in push pull mode.)
VDD:VDD is the power supply line for all cards.
VSS[1:2]:VSS are two ground lines.
SPI接口描述:
CS:Host to card Chip Select signal.
CLK:Host to card clock signal.
DataIn:Host to card data signal.
DataOut:Card to host data signal.
5、SD卡內部結構
上電初始化需要1ms或者74 CLOCK(SD卡的clock,400KHZ)兩者大致,SD卡的電壓上到2.0V,SD卡開始工作,此時支持的命令非常有限(其中最主要支持ACMD41命令,sd host問卡的操作電壓時多少? 卡就會從它的OCR寄存器里面讀出SD卡出廠就燒錄在里面的卡的操作電壓值返回給sd host),當電壓調整到它要求的VDD時候(SD卡的工作電壓在2.7~3.6V,常見3.3V),同時SD的CLK從400KHZ調整到更高頻率(比如25MHZ),這時卡就完全正常的工作了。接下來可以去獲取卡的生產廠家,容量等信息。
最多支持64個命令: CMD0~CMD63,(其中CMD57~63是保留的)
ACMD: Application Sepcific command:
ACMD41 =cmd55 + cmd41,組合命令,CMD55是前導命令,提醒卡后面的CMD41是一個特殊的命令
命令的類型
廣播命令(bc,bcr)——廣播命令發送給所有SD卡,有些命令需要響應。
尋址(點對點)命令
(ac,adtc)
——
尋址命令只發送給具有相應地址的卡,并
需要從卡返回一個響應。
R1 (standard response): response length 48 bit
R1b is identical to R1 with an optional busy signal transmitted on the data line
R2 (CID, CSD register): response length 136 bits. The content of the CID register is sent as a response to CMD2 and CMD10. The content of the CSD register is sentas a response to CMD9.
R3 (OCR register): response length 48 bits. The contents of the OCR register are sent as a response to ACMD41.
R4~R5: responses are not supported.
R6:(Published RCA response): code length 48-bit, response to CMD3
