SPI总线协议

原文:SanDisk Secure Digital Card - Product Manual Version 2.2 (Document No. 80-13-00169 September 2004)第5章 SPI总线协议译者:醇酒。请尊重我的劳动,勿抄袭和修改本文中的内容,若文中翻译有不妥之处,请Email:chunjiu○a263处指正,不胜感激!
SD卡规格书第五章  SPI总线协议
译者注:
回转窑烧嘴
SPI总线协议目录
5.1.  SPI总线协议
5.1.1. 模式选择
5.1.2. 总线传送保护
5.1.3. 数据的读取
5.1.4. 数据写入
5.1.5. 擦除和写保护处理
5.1.
6. 读取CID/CSD寄存器
5.1.7. 复位顺序
5.1.8.  时钟控制
5.1.9.  错误条件
5.1.9.1.  CRC和无效指令
5.1.9.2.  读取、写入和擦除的超时情形
5.1.10.存储器阵列分布
5.1.11. 卡的锁定/解锁
5.1.12. 特殊用途的命令
5.1.13. 版权保护命令集
5.2.  SPI命令设置
5.2.1. 命令格式
5.2.2. 命令类
5.2.2.1. 详细的命令描述
5.2.3.应答
5.2.3.1 R1 的格式
5.2.3.2. R1b的格式
5.2.3.3. R2的格式
投币器
5.2.3.4. R3 的格式
5.2.3.5. 数据应答
5.2.4. 数据标记
5.2.5.数据错误标记
5.2.
5182铝合金
6. 清除状态位
5.3.  卡寄存器
5.4.  SPI总线时序图解
5.4.1.  命令 / 应答
5.4.2. 数据读取
5.4.3. 数据写入
5.4.4. 时钟数值
5.5.  SPI 电气接口
5.6.  SPI总线操作条件(环境)
5.7.总线时钟
附录:
英文特殊命令表
英文通用命令表
存储器阵列图
产品规格表
主控制器设计参考(简介,无实际内容)
5.1. SPI Bus Protocol
5.1. SPI总线协议
While the SD Card channel is based on command and data bit-streams, which are initiated by a start bit and terminated by a stop bit, the SPI channel is byte oriented. Every command or data block is built of eight bit bytes and is byte aligned (multiples of eight clocks) to the CS signal.
当SD卡通道是基于命令和数据位流模式上时,通常是开始于一个“起始位”和终止于一个“停止位”,这个SPI通道是用字节作为单位的。CS信号上的每个命令或数据块都是8bit的字节和字节队列(就是8个时钟的倍数)。
Similar to the SD Bus protocol, the SPI messages are built from command, response and data-block tokens. All communication between host and cards is controlled by the host (master). The host starts every bus transaction by asserting the CS signal low.
相似SD总线模式,这个SPI信息是建立在命令、应答和数据块标记上的。所有的主控制器和SD卡之间的通
讯都是受控于主控制器。而主控制器的每次总线处理都是从拉低CS的信号电平开始的。
The response behavior in SPI Bus mode differs from the SD Bus mode in the following three ways:
* The selected card always responds to the command.
* An eight or 16-bit response structure is used.
* When the card encounters a data retrieval problem, it will respond with an error response (which replaces the expected data block) rather than time-out as in the SD Bus mode.
SPI总线协议和SD总线协议的应答行为有下列三处的不同点:
sata连接器1.被选中的卡总是对命令做出应答;
2.使用的应答结构是8或16位的;
3.当这个卡碰到一个数据检索问题,它将用一个错误应答来回答(取代了原先期望的数据块)而不是SD总
线协议模式下的超时。
In addition to the command response, every data block sent to the card during write operations will be responded with a special data response token. A data block may be as big as one card write block (WRITE_BL_LEN) and as small as a single byte(NOTE1).
除了命令的应答之外,每个数据块发送到SD卡后,在写操作的期间将用一个特别的数据应答标记来应答。一个数据块可以大到卡的写入块长度(WRITE_BL_LEN)或小到一个单字节的大小(注意1)。
NOTE1: The default block length is as specified in the CSD (512 bytes). A set block length of less than 512 bytes will cause a write error. The only valid write set block length is 512 bytes. CMD16 is not mandatory if the default is accepted.
注意1:缺省的块长度定义在CSD寄存器内(512字节)。设定块的的长度小于512字节将会导致写入错误。唯一合法的块写入长度只能定为512字节。若此缺省值可接受,则无需使用CMD16命令,它不是必要的。
5.1.1. Mode Selection
5.1.1.模式选择
The SD Card wakes up in the SD Bus mode. It will enter SPI mode if the CS signal is asserted (negative) during the reception of the reset command (CMD0). If the card recognizes that the SD Bu
s mode is required it will not respond to the command and remain in the SD Bus mode. If SPI mode is required, the card will switch to SPI mode and respond with the SPI mode R1 response.
激光发射器SD卡启动时处在SD总线模式下。它将在CS信号有效(低电平)时接收一个复位命令(CMD0)来进入SPI 总线模式。如果这个卡认为必须停留在SD总线模式,那么它将不应答这个命令并继续保持在SD总线模式。如果可以转换到SPI总线模式,则它会转换到SPI总线模式并用SPI模式的R1应答来作回应。
The only way to return to the SD Bus mode is by power cycling the card. In SPI mode, the SD Card protocol state machine is not observed. All the SD Card commands supported in SPI mode are always available.
而唯一让卡返回SD总线模式的办法是用电源周期(即电源关开一次)。在SPI总线模式下,SD卡的保护状态机将不会被遵守了。SD卡所有能支持的命令在SPI模式下总是可以使用的。
The default command structure/protocol for SPI mode is that CRC checking is disabled. Since the card powers up in SD Bus mode, CMD0 must be followed by a valid CRC byte (even though the command is sent using the SPI structure). Once in SPI mode, CRCs are disabled by default.
SPI总线模式下,默认的命令结构/协议CRC检查是失效的。由于卡在电源开启时总是处于SD总线模式,CMD0命令必须跟随一个合法的CRC字节(即使这个命令使用了SPI结构来发送)。一旦进入SPI总线模式,CRC就被默认为失效的了。
CMD0 is a static command and always generates the same 7-bit CRC of 4Ah. Adding the “1,” end bit (bit 0) to the CRC creates a CRC byte of 95h. The following hexadecimal sequence can be used to send CMD0 in all situations for SPI mode, since the CRC byte (although required) is ignored once in SPI mode. The entire CMD0 sequence appears as 40 00 00 00 00 95 (hexadecimal).
CRC字节(“尽管还是必须的”。译者注:原文的意思是指这个CRC字节所占的位置还是不可省略掉)会在SPI模式里被忽略。这个完整的CMD0命令是40 00 00 00 00 95 (十六进制系列)。
5.1.2. Bus Transfer Protection
5.1.2.总线传送保护
Every SD Card token transferred on the bus is protected by CRC bits. In SPI mode, the SD Card offers a non protected mode which enables systems built with reliable data links to exclude the hardware or firmware required for implementing the CRC generation and verification functions.
在总线上传送的每个SD卡标志都是用CRC的校验位来保护的。在SPI模式里,SD卡提供了一个可靠
的非保护模式的连接方式,它排除了用硬件或固件来产生CRC作为校验功能的必要性。
In the non-protected mode the CRC bits of the command, response and data tokens are still required in the tokens however, they are defined as “don’t care” for the transmitters and ignored by the receivers.
在这个非保护模式的命令、应答、和数据标记中的CRC特征位仍然是需要的,然而,它们的含意为:发送方“无需关注”和由接收方忽略掉。
The SPI interface is initialized in the non-protected mode. The host can turn this option on and off using CRC_ON_OFF command (CMD59).
这个SPI接口是初始化成非保护模式的,而主控制器可以通过使用CRC_ON_OFF命令(CMD59)来切换它的开、关状态。(译者注:根据本人的实际使用情况来看,SPI传输非常可靠,没必要使用CRC来自麻烦。)
The CRC7/CRC16 polynomials are identical to that used in SD Bus mode. Refer to this section in the SD Bus mode chapter.
此CRC7/CRC16多项式是和SD总线模式相同的。请参考SD总线模式的这些章节描述。
5.1.3. Data Read
5.1.3. 数据的读取
SPI mode supports single block and multiple block read operations (SD Card CMD17 or CMD18). Upon reception of a valid read command the card will respond with a response token followed by a data token in the length defined in a previous SET_BLOCK_LENGTH (CMD16) command (see Figure 5-1).
SPI模式可支持单个块和多个块的读操作(SD卡的CMD17或CMD18)。在接收到一个合法的读取命令后,这个卡将用一个应答标志来应答,随后的就是一个数据块,它的长度是先前定义在SET_BLOCK_LENGTH (CMD16)命令中的(请看图表 5-1)。
图表 5-1 单个数据块的读取操作
A valid data block is suffixed with a 16-bit CRC generated by the standard CCITT polynomial:
一个有效的数据块的尾缀是16bit的CRC,它是用符合CCITT标准的多项式产生的:
X^16 + X^12 + X^5 + 1.
The maximum block length is 512 bytes as defined by READ_BL_LEN (CSD parameter). Block lengths can be any number between 1 and READ_BL_LEN.增高减肥鞋
这个最大的块长度是512字节,由READ_BL_LEN (CSD参数)定义的。块的长度可以是1到READ_BL_LEN 之间的任何一个数值。
The start address can be any byte address in the valid address range of the card. Every block, however, must be contained in a single physical card sector.
在数据接收错误时(译者注:这里应该是指SD卡接收到的读取命令中包含了错误的参数,例如“块长度”或
“地址”参数使用了SD卡规定之外的格式),这个卡将不传送任何数据。替代的将是一个报告数据错误的标记被
发送到主控制器。图表 5-2 显示了一个数据的读操作,结果由于一个错误标记而终止,而不是期待的一个数据块。
图表 5-2.  读取操作 - 数据错误
In the case of a Multiple Block Read operation, every transferred block has a 16-bit CRC suffix. The Stop Transmission command (CMD12) will actually stop the data transfer operation (the same as in SD Bus mode).
在多块数据的读取操作情况下,每个被传送的块都有一个16bit的CRC后缀。而停止发送命令(CMD12)将会终止这个数据传送操作(和SD总线模式是相同的)。
图表 5-3.  多个块的读取操作
5.1.4. Data Write
5.1.4. 数据写入
In SPI mode, the SD Card supports single block or multiple block write operations. Upon reception of a valid write command (SD Card CMD24 or CMD25), the card will respond with a response token and will wait for a data block to be sent from the host. CRC suffix and start address restrictions are identical to the read operation (see Figure 5-4). The only valid block length, however, is 512 bytes. Setting a smaller block length will cause a write error on the next write command.
在SPI模式下,SD卡支持单块的或多块的写操作。在接收到一个合法的写命令时(SD卡命令CMD24或CMD25),SD卡将响应一个应答标记和等待主控制器发送这个数据块。CRC后缀和起始地址的限制和读操作是一样的(参看图表5-4)。唯一合法的块长度是512字节。如果设置了一个小于此值的块长度,将会导致下一条写入命令产生错误。

本文发布于:2024-09-22 15:27:12,感谢您对本站的认可!

本文链接:https://www.17tex.com/tex/1/123971.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:总线   命令   模式   数据   应答   字节   错误   标记
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议