1、简介
3、SD卡协议
1.x:小于2GB的卡(但通过相关的软件,可以模拟实现大于2GB)
2.0: 2 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 mode.) 【真正的数据走这几条线,数据位是可以配置:1~4】 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是保留的) 广播命令(bc,bcr)——广播命令发送给所有SD卡,有些命令需要响应。 寻址(点对点)命令 (ac,adtc) —— 寻址命令只发送给具有相应地址的卡,并 需要从卡返回一个响应。
ACMD: Application Sepcific command:
ACMD41 =cmd55 + cmd41,组合命令,CMD55是前导命令,提醒卡后面的CMD41是一个特殊的命令
命令的类型
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 sent
as 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