完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我试图连接一个微型SD卡到PIC32控制器。PCB是自己设计的,不是某种标准的开发板。目前,我正在使用SPI协议来与卡进行通信。(在不久的将来,我将使用正确的引脚使用真正的SPI,但现在我必须使用这个解决方案)。长话短说:我能够初始化卡并为所有命令获得正确的响应,但是当我尝试发布CMD 17命令时,它响应0x01(空闲)而不是0x00(就绪),并且任何后续读取所有返回0xFF。预期的令牌0xFE永远不会到来。我已经尝试了很多不同的领域作为CMD 17的论证,但这并没有什么区别。这些是初始化的命令和响应:除了最后一个之外,它们看起来都很好。(BTW,我总是使用正确的CRC,即使我知道它不是必要的)。这让我觉得我的设置基本上是正确的。卡是3.3V供电的。当访问卡时,电压不会下降。除了CLK外,所有的线路都有100K的上拉电阻。(BIT)时钟频率约为145千赫。这对读命令有什么影响吗?我相信它必须低于400千赫在初始化。但是对阅读和写作还有什么要求吗?我还没有找到。CMD 17没有给出正确答案的原因是什么?
以上来自于百度翻译 以下为原文 I'm trying to connect a micro-SD card to a PIC32 controller. The PCB is own design, not some kind of standard development board. At the moment I'm bitbanging the SPI protocol to communicate with the card. (In the near future I will use the proper pins to use real SPI, but for now I have to use this solution). Long story short: I am able to initialise the card and get correct responses for all commands, but when I try to issue the cmd 17 command, it responds with 0x01 (idle) instead of 0x00 (ready) and any subsequent reads all return 0xFF. The expected token 0xFE never comes. I've tried a lot of different sectors as argument for cmd 17, but that doesn't make a difference. These are the commands and responses for initialisation: >> (0) 40 00 00 00 00 95 << (0) 01 >> (8) 48 00 00 01 AA 87 << (8) 01 00 00 01 AA >> (55) 77 00 00 00 00 65 << (55) 01 >> (41) 69 40 00 00 00 77 << (41) 01 >> (58) 7A 00 00 00 00 FD << (58) 01 40 FF 80 00 >> (16) 50 00 00 02 00 15 << (16) 01 >> (17) 51 00 00 00 00 55 << (17) 01 They all look good to me, except the last one. (BTW, I'm always using the correct CRC even though I'm aware that it's not neccesary). This makes me think that my setup is basically correct. The card is powered with 3.3V. The voltage doesn't drop when accessing the card. All lines excepct clk have a 100k pullup resistor. The (bit-banged) clock frequency is about 145 kHz. Could this have any influence on the read command? I believe it has to be below 400 kHz at initialisation. But are there any further requirements for reading/writing? I haven't found any. What could be the reason for cmd 17 not giving the correct response? |
|
相关推荐
3个回答
|
|
初始化速度慢,然后占用10MHZ.Read块,17为我工作,我有单独的SD卡、扇区和簇库。这里是我使用的序列(非DMA版本)1如果一个HD卡,地址必须由左移9(x 512)2发送Read块3,如果响应是0xFF ErrRoR1L00和L,则得到R1 4。如果期望是00(接受)5得到R1 6,如果响应是0xFF ErrRoR1RFEFE & lt;-预期FE(TokKyStand)7::循环512::8个SETM SPIXBUF 9,而不是SPIXSTAT位SIPBF & lt;-WaIT10[缓冲器++]=SPIXBF11下一个ROLK12ErrRoOrthOK
以上来自于百度翻译 以下为原文 Initialize at slow speed then take up to 10MHz. READ_BLOCK, 17 Works for me, I have separate sdcard, sector and cluster libraries. Here is the sequence I use (non-dma version) 1 If an HD card, the address must by left shifted by 9 (x 512) 2 send READ_BLOCK 3 Get R1 4 if response is 0xff ERROR_R1_00 <-- expect 00 (ACCEPT) 5 get R1 6 if response is 0xff ERROR_R1_FE <-- expect FE (TOKEN_START) 7 ::loop 512:: 8 setm SPIxBUF 9 while not SPIxSTAT bit SPIRBF <-- wait 10 [buffer++] = SPIxBUF 11 next loop 12 ERROR_OK |
|
|
|
你从来没有说过它是高清卡还是SD卡。使用魔术数字对william hill官网
没有帮助。即(16)应该编写StIB BulkKLIN
以上来自于百度翻译 以下为原文 You never said if it was an HD card or SD card. Using magic numbers is not helpful on forums. i.e. (16) you should write SET_BLOCKLEN |
|
|
|
谢谢你的回复,问题已经解决了。它不是在实际的读取命令中,而是在初始化中。ACMD 41(SDAppApopopyCOND)的响应应该是“就绪”而不是“空闲”。我必须在初始化程序中重试这个命令,直到收到期望的结果。然后所有的后续反应也会“准备就绪”而不是“空闲”。在这种情况下,CMD17(Read SythLyBug块)将返回令牌0xFE和扇区内容。我猜我被SD卡NoMunalTura弄糊涂了。对我来说,“准备”和“空闲”的意思差不多,也谢谢你的提示。
以上来自于百度翻译 以下为原文 Thanks for your replies. The problem had been solved. It was not in the actual read command but in the initialisation. The response on ACMD 41 (SD_APP_OP_COND) should be 'ready' instead of 'idle'. I had to retry this command in the initialisation routine until the desired result was recieved. Then all subsequent responses will also return 'ready' instead of 'idle'. And CMD17 (READ_SINGLE_BLOCK) will in that case return the token 0xFE and the sector contents. I guess I was confused bu the SD card nomencaltura. To me 'ready' and 'idle' mean more or less the same. Also thanks for your hint about the address! |
|
|
|
只有小组成员才能发言,加入小组>>
5250 浏览 9 评论
2037 浏览 8 评论
1958 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3218 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2266 浏览 5 评论
788浏览 1评论
680浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
609浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
685浏览 0评论
582浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-29 01:32 , Processed in 1.463825 second(s), Total 50, Slave 44 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (威廉希尔官方网站 图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号