找回密码
 注册
搜索
查看: 1315|回复: 4

[讨论] mmc/sd 进入SPI mode前74个时钟问题

[复制链接]
发表于 2007-5-30 21:42:10 | 显示全部楼层 |阅读模式
我查了很多资料,在发cmd0命令之前都要等74个时钟,为什么等待74个时钟的编程是这样的:
Write_Byte_MMC(0xff);//74 clock at least
不明白的是,为什么在等待的时候向data_in引脚上发数据?(上面那个函数包含了
发数据的操作)。我直接编个小函数等74个时钟不可以吗?
发表于 2007-5-31 11:16:45 | 显示全部楼层
主要是为了给sd卡clock信号。不能等74个时钟,这样就没有时钟输入[br]<p align=right><font color=red>+3 RD币</font></p>
点评回复

使用道具 举报

 楼主| 发表于 2007-5-31 15:45:03 | 显示全部楼层
多谢 ~~~

那如果我只向SD卡的CLK引脚发时钟,而不向data引脚发数据的话,可不可以?

另外,Write_Byte_MMC(0xff);里面的0xff是不是随便写一个数代替都可以?
点评回复

使用道具 举报

发表于 2007-6-21 11:49:11 | 显示全部楼层
这里的等待74个SPI时钟,可以是这样的一句:“SD_SPIDely(25);”

SD_SPIDelay的函数原形如下:

void SD_SPIDelay(INT8U value)
{
    INT8U i;

    for (i = 0; i < value; i++)
        SPI_SendByte(0xFF);       
}

通过查看SPI协议我们可以知道,通过SPI发送一个字节数据的时候,SPI_CLK发送8个SPI时钟(每位对应一个SPI_CLK)。SD_SPIDely(25)实际发送了200个。

至于发送数据是否一定要是0xff的问题,参考SD spec,其中有一段是这样的:After power up, the host starts the clock and sends the initializing sequence on the CMD line. This sequence is a contiguous stream of logical ‘1’s[/COLOR]. The sequence length is the maximum of 1msec, 74 clocks or the supply-ramp-uptime; the additional 10 clocks[/COLOR] (over the 64 clocks after what the card should be ready for communication) is provided to eliminate power-up synchronization problems.

从中可以看出:
1、必须向SPI总线发送0xff,就是连续的全“1”
2、至少是74个SPICLK的“1”
3、并不是单纯为了延时或者发送SPICLK,所以,直接编个小函数等74个时钟不可以,也并不是单纯给sd卡clock信号。


[br]<p align=right><font color=red>+5 RD币</font></p>
点评回复

使用道具 举报

 楼主| 发表于 2007-6-27 20:50:19 | 显示全部楼层
真是感谢楼上的耐心回答!多谢
点评回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

Archiver|手机版|小黑屋|52RD我爱研发网 ( 沪ICP备2022007804号-2 )

GMT+8, 2024-10-2 17:22 , Processed in 0.047811 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表