完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
HI AALI正在构建一个围绕PIC18F2420的项目,以读取SD卡(SPI模式),并通过MIDI模式中的USAT将内容(适当定时和格式化)传送到数字键盘。我曾多次使用过USAT,但这是我第一次进入SPI。我在汇编程序中进行编码(由于各种原因集中在时间上),并且在SPI前线遇到了一些奇怪的行为。我使用的时钟速度为250kHz。我已经成功地初始化了4GB超越SDHC卡,并且尝试使用CMD17单块读取操作读取数据。但是,我发现需要在SDIC传输操作和PIC内部的数据检索命令之间插入一个延迟来获得正确的数据。以下是相关代码:MOVLW H'FF;启动SPI字节读取MOVWF SSPBUFBCF PIR1,SSPIF;清除SPI中断标志…BTFSS PIR1,SSPIF;并等待它被设置为胸罩$- 02;DEFF Delt,f;强制DelayBNZ $ 02;MOVFSSPBUF,PASCUN2;用于分析无中断的传输检索字节是活动的。这里所示的延迟增加了近800μs到读取周期时间,并且导致正确的数据被存储在由FSR2指向的阵列中。如果延迟时间减少到大约200秒,则存储一些数据…几乎就像一些通过和一些不。删除延迟例程完全导致一个流的'HFF '被存储。不幸的是,我没有太多的方式的分析工具,除了一个旧的示波器,但我可以说,时钟是干净的,并响应的长度为CED Delayas预计延长时钟脉冲串之间的周期。我的理解是,(i)传输在加载SSPBUF时立即开始(如规范所述),并且在数据被成功读取之后延迟执行。或者(ii)在加载SSPBUF和发送的时钟之间存在很大的延迟。我不知道哪一个是正确的,但在这两种情况下,我都不明白为什么延迟是必要的,或者需要什么来进行。我在其他页面上读到MOVFF是双循环指令,并且可以得到“拆分”。但是正如我前面所说的,没有主动中断可以通过不完成来自SSPBUF的内部传输来“丢失”数据。我有更多的事情要看,如果我能确定事情的进展,但我想我会把这个问题放在这个论坛的权力,以防我错过了显而易见的。
以上来自于百度翻译 以下为原文 Hi all I'm building a project centred around a PIC18F2420 to read an SD card (in SPI mode) and transfer the content (suitably timed and formatted) to a digital keyboard via the USART in MIDI mode. I've used the USART many times this way, but this is my first foray into SPI. I'm coding in assembler (for various reasons centred around timing), and have come across some strange behaviour on the SPI front. I'm using a clock speed of 250kHz throughout. I've successfully initialised the 4GB Transcend SDHC card, and am attempting to read data using the CMD17 single-block-read operation. However, I've found that I need to insert a delay between the SD transfer operation and the data-retrieval command inside the PIC to get the correct data out. Here's the relevant code: MOVLW h'FF' ; initiate SPI byte read MOVWF SSPBUF BCF PIR1, SSPIF ; clear SPI interrupt flag ... BTFSS PIR1, SSPIF ; ... and wait for it to be set BRA $-02 ; DECF DELT, F ; FORCED DELAY BNZ $-02 ; MOVFF SSPBUF, POSTINC2 ; transfer retrieved byte for analysis No interrupts are active. The delay as shown here adds almost 800us to the read-cycle time, and results in the correct data being stored in the array pointed to by FSR2. If the delay time is reduced to around 200us, some data is stored ... almost as though some gets through and some doesn't. Removing the delay routine altogether results in a stream of h'FF' being stored. Unfortunately, I don't have much in the way of analysis tools except an old oscilloscope, but I can say that the clock is clean, and responds to the length of the forced delay as expected by extending the period between clock bursts. My reading of this is that either (i) the transfer is initiated immediately on loading SSPBUF (as the spec says), and the delay is executing AFTER the data has been successfully read ... or (ii) there's a massive delay between loading SSPBUF and the clocks being sent. I have no way of telling which of these is true, but in either case, I don't understand why the delay is necessary, or what can be happening to require it. I've read on other pages that MOVFF is a dual-cycle instruction, and can get "split" ... but as I said earlier, there are no active interrupts which can do this and "lose" data by not completing the internal transfer from SSPBUF. I have a few more things to try to see if I can pin down what's going on, but I thought I'd put the issue to the power of this forum in case I've missed the obvious. TIA for any tips, ideas, or advice. |
|
相关推荐
3个回答
|
|
我已经部分解决了这个问题…我拼凑了一个十六进制阅读器,发现一个H'FF坐在H'FE(CMD17读令牌)前面。不幸的是,说明书并没有说这可能会发生。如果读速度足够慢(1KB每秒),卡显然是及时准备好的,它不需要PAD字节,一切都有意义。假设我现在可以全速工作,我的下一个问题是获得CMD18(多块读)工作。我的狡猾规范说它和CMD17是一样的协议…所以我发布H’52’,0, 0, 0,0, 1来读取块0(它是一个未格式化的卡)。但我得到的只是HFF——甚至不是一个令牌——所以很明显,这个命令没有被接受。谁能为我解释这件事?蒂亚再次…
以上来自于百度翻译 以下为原文 I've partially solved this ... I cobbled together a hex reader, and found a h'FF' sitting in front of the h'FE' (CMD17 read token). Unfortunately, the specification didn't say this could happen. If the read speed were slow enough (1kB per second), the card was obviously ready in time that it didn't need the pad byte, and everything made sense. Assuming I can now get his working at full speed, my next issue is to get CMD18 (multiple block read) working. My dodgy specification say that it's the same protocol as CMD17 ... so I issue h'52', 0, 0, 0, 0, 1 to read block 0 (it's an unformatted card). But all I get back is h'FF' - not even a token - so clearly the command isn't being accepted. Can anyone shed any light on this for me? TIA again ... |
|
|
|
我不确定它是否是相关的,但是有许多与MSSP模块相关的勘误表,并且根据硅的修订而变化。我并没有费心去看它们(我不知道你有哪一个硅版本),但是快速的看一下,有些与检测到传输完成时的情况有关。可能会快速检查苏珊。
以上来自于百度翻译 以下为原文 I'm not sure if it is relevant but there are a number of errata relating to the MSSP module and varying depending on the silicon revision. I've not bothered to look at them all (and I'm not sure which silicon revision you have) but a quick glance shows that some relate to the detection of when a transfer is complete. Might be work a quick check. Susan |
|
|
|
谢谢苏珊。我想你指的是PIC的修订而不是卡片?我依赖于PIC的SSPIF标志来指示事务的结束,但是我注意到一些脚本使用缓冲区满(BF)标志来代替。我相信我使用的规格是当前的(它的日期是2008),而且在这件事上肯定是模糊的!然而,奇怪的是,CMD17和CMD18的算法根据我读到的每条卡规范都是相同的——发出命令、地址(到目前为止的所有情况为0)和(虚拟)CRC,并等待令牌H'FE。就PIC而言,它期望从两个方面得到完全相同的响应。为什么一个人工作而不是另一个人工作?这不是一个修辞问题-我欢迎你的任何想法。坦白说,我感到困惑-我认为一旦我获得CMD17工作,CMD18将是微不足道的。TBH,我的怀疑是更多的是与SD卡比PIC。如果我从其他各种各样的资源中了解到关于初始化这些事情的建议,那就是在整个过程中没有达成一致意见。芯片启用是一个很好的例子-一些来源说它可以被捆绑在低,其他人说,它必须断言和重新断言之间的命令交易,否则卡不会初始化。我决定使它更容易通过限制我自己的单一类型的卡从一个单一的制造业。R(至少在开始),但我不禁要问,如果CMD18根本不工作的一些实现…我已经看到了很多关于围绕多块操作的论坛的评论。我可能不得不写超越,以获得最终的规格在我的卡类型…
以上来自于百度翻译 以下为原文 Thanks Susan. I presume you're referring to the PIC revision rather than the card? I'm relying on the PIC's SSPIF flag to signal the end of the transaction, but I've noted that some scripts use the Buffer Full (BF) flag instead. I believe the spec I'm using is current (it's dated 2008), and it's definitely vague on this matter! However, the odd thing is that the algorithms for CMD17 and CMD18 are the same according to every card specification I've read - issue the command, the address (0 in all cases so far), and a (dummy) CRC, and wait for the token h'FE'. So far as the PIC is concerned, it expects exactly the same response from both ... why should one work and not the other? That's not a rhetorical question - I welcome any ideas you have. Frankly, I'm bewildered - I thought that once I got CMD17 working, CMD18 would be trivial. TBH, my suspicion is that it's more to do with the SD card than the PIC. If I've learned nothing else from perusing the various sources for advice on initialising these things, it's that there's no agreement on the full process. The chip enable is a good case in point - some sources say it can be tied low, others say that it MUST be de-asserted and re-asserted between command transactions otherwise the card won't initialise. I decided to make it easier by restricting myself to a single type of card from a single manufacturer (at least at the start), but I can't help wondering if CMD18 simply doesn't work on some implementations ... I've seen a lot of commentary on the problem forums specifically surrounding multi-block operations. I may have to write to Transcend to get the definitive specification on my card type ... |
|
|
|
只有小组成员才能发言,加入小组>>
5242 浏览 9 评论
2031 浏览 8 评论
1955 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3207 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2256 浏览 5 评论
778浏览 1评论
669浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
597浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
679浏览 0评论
577浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-24 04:32 , Processed in 1.400158 second(s), Total 80, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号