容量等级
SD容量有8MB、16MB、32MB、64MB、128MB、256MB、512MB、1GB、2GB
SDHC容量有2GB 、4GB、8GB、16GB、32GB
SDXC容量有32GB、48GB、64GB、128GB、256GB、512GB、1TB、2TB
SD卡寄存器
命令格式
所有命令均遵守此格式,总共48位。一个起始位,一个方向位,6个命令位,32位参数(有些命令需要),CRC 7位校验,1个停止位
Command Classes
注:
命令详细解释见SD卡2.0协议
部分命令
应答
应答格式有多种,以R1举例
初始化流程
以SPI模式举例
典型初始化流程
1.使能SPI时钟
2.使能GPIO端口时钟
3.初始化GPIO,配置引脚模式
4.初始化SPI
5.使能SPI
6.SPI读写数据7.上电延时(>74个CLK)
8.复位卡(CMD0),进入idle状态
9.发送CMD8,检查是否支持2.0协议
10.取消片选,发多 8 个CLK,结束初始化
11.读写数据