阅读:2249回复:9
各抒己见!大家都来谈谈51+d12+三星Flash做U盘的体会
前段时间本人做了一个MP3播放器,内存为64M(k9f1208u0m),USB芯片为CY7C68001,
由于USB芯片价格过高,所以现在采用D12 方案:C51+32K(SRAM)+D12+K9F1208U0M+STA013+CS4334(MP3解码芯片+DA输出) 在调试D12 USB时一路酸甜苦辣,现在谈一下自己的心得 D12 USB硬件电路一般都很成熟,第一次插上USB后电脑一点反映都没有,连GOOD LINK指示灯都不亮一下,还以为是硬件问题,对照原理图,查了半天,还是没有发现错误,软件也不停的修改,就是不行,后来干脆从网上下载了徐光余大侠高度调试成功的代码,将它移植到自己的代码中,居然电脑能够发现新硬件,终于来了一点安慰,这说明我的硬件没有问题,然后我将D12枚举类型改成了MASS STORAGE,终于可以到GET MAX LUN了,回了0后,就看到了期待已久的CBW包,按照SCSI协议办事,终于在电脑上看到盘符,也可以看到一些U盘里的文件,心中狂喜,以为应该没有问题了,可是接下来的问题,是我一直没有预料到的,连续搞了3天都没有一点进展,就是文件的写! 我采用32K做缓冲,刚好有两个BLOCK,由于此FLASH的特点,擦除需擦除一个BLOCK,这就意味着擦除之前需要将不被覆盖的数据读出放到SRAM相应的位置备份起来,然后和要写的数据整合为一个BLOCK,在擦除FLASH中的BLOCK,然后将数据写入,这个过程必然要浪费很多的时间,至少擦除一个BLOCK需要2ms 然后写入一页的时间为900US,何况要写16页,根本无法及时响应USB,开始以为是我的程序有问题,用BusHound发现传输过程中USB BUS RESET,经常是发生在PC传了64字节后,经过反复验证,最后将写FLASH的程序MARSK起来,下面只是接收,发现能够将完整的文件收下来,这就表明是CPU写FLASH数据时间过长无法及时响应USB,出现超时或无响应现象.仔细分析代码发现已经没有改善的余地, 请问各位高手,采用这种USB方案你们有做成功的吗?贴出来大家共享,共同交流一下.... |
|
|
沙发#
发布于:2005-07-13 09:40
哥们,我现在刚开始作,和你的方案差不多,只是我不用mp3,我是在u盘的基础上加数据采集,我想问一下,SRAM,D12,Flash,你是怎么复用8位地址/数据线的,是不是用IO来模拟读写线和控制不同的片选?我的mail:rainjetpcb@126.com
|
|
板凳#
发布于:2005-07-13 20:10
|
|
|
地板#
发布于:2005-07-13 20:11
|
|
|
地下室#
发布于:2005-07-13 20:13
|
|
|
5楼#
发布于:2005-07-15 21:52
在公司用繁体系统,连发几次都看不到内容.
用总线方式呀,这样速度才不会受到影响,可以接一个74HC138译码器进行片选,很容易的. 网上不是很多网友做这种方案吗? 难到没有人做成功过? 各位多发表意见呀! |
|
|
6楼#
发布于:2005-07-18 22:10
难道真的没得救了吗?
大虾们怎么只是看看而已呀? 我再顶一下.....看有没有得救. |
|
|
7楼#
发布于:2009-06-18 17:56
把帖子顶起来,看不懂,不过也想研究
|
|
8楼#
发布于:2009-07-20 18:01
楼主:可以试验一下在没有接收完时发送一个CSW包给PC,然后PC会继续将剩余的包发送给USB DEVICE,这样相当于避免了时间过长!
另我有一个问题问一下楼住: |
|
9楼#
发布于:2009-07-20 18:21
另我有一个问题问一下楼住:我的USB DEVICE在发送数据的时候不稳定,有时候发送一部分数据就不发了,然后PC给了下一个CBW的包,导致错误。用USB分析仪抓了以下数据发现是在发送的时候有连续的IN包出现,不知道什么原因!
数据如下 Device Phase Data Description Time ------ ----- ------------------------------------------------------------------------------------------------------ ---------------- ------------ 27.0 CTL 80 06 00 01 00 00 12 00 GET DESCRIPTOR 10:04:40.309 27.0 LEN 12 00 00 00 18 10:04:40.313 27.0 DI 12 01 10 01 00 00 00 10 71 04 66 06 00 01 00 00 00 01 ........q.f..... 27.0 CTL 80 06 00 02 00 00 09 00 GET DESCRIPTOR 10:04:40.313 27.0 LEN 09 00 00 00 9 10:04:40.317 27.0 DI 09 02 2e 00 01 01 00 80 32 ........2 10:04:40.317 27.0 CTL 80 06 00 02 00 00 2e 00 GET DESCRIPTOR 10:04:40.317 27.0 LEN 2e 00 00 00 46 10:04:40.323 27.0 DI 09 02 2e 00 01 01 00 80 32 09 04 00 00 04 08 06 50 00 07 05 81 03 10 00 0a 07 05 01 03 10 00 0a 07 05 02 02 40 00 01 07 05 82 02 40 00 00 ....@......@.. 27.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG 10:04:40.323 27.0 CTL 01 0b 00 00 00 00 00 00 SET INTERFACE 10:04:40.396 27.0 CTL a1 fe 00 00 00 00 01 00 GET MAX LUN 10:04:40.466 27.0 LEN 01 00 00 00 1 10:04:40.469 27.0 DI 00 . 10:04:40.469 27.2 LEN 1f 00 00 00 31 10:04:40.471 27.2 DO 55 53 42 43 a8 18 d6 83 24 00 00 00 80 00 06 12 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00 27.2 LEN 24 00 00 00 36 10:04:40.474 27.2 DI 00 80 00 01 1f 00 00 00 55 53 42 31 2e 30 20 20 46 6c 61 73 68 20 44 69 73 6b 20 20 20 20 20 20 31 2e 31 31 27.2 LEN 0d 00 00 00 13 10:04:40.476 27.2 DI 55 53 42 53 a8 18 d6 83 00 00 00 00 00 USBS......... 10:04:40.476 27.2 LEN 1f 00 00 00 31 10:04:40.478 27.2 DO 55 53 42 43 58 e3 34 86 fc 00 00 00 80 00 0a 23 00 00 00 00 00 00 00 fc 00 00 00 00 00 00 00 27.2 LEN 0c 00 00 00 12 10:04:40.480 27.2 DI 00 00 00 08 00 02 00 00 02 00 02 00 ............ 10:04:40.480 27.2 LEN 0d 00 00 00 13 10:04:40.481 27.2 DI 55 53 42 53 58 e3 34 86 00 00 00 00 00 USBSX.4...... 10:04:40.481 28 LEN 24 00 00 00 36 10:04:40.509 28 DI 00 80 00 01 1f 00 00 00 55 53 42 31 2e 30 20 20 46 6c 61 73 68 20 44 69 73 6b 20 20 20 20 20 20 31 2e 31 31 27.2 LEN 1f 00 00 00 31 10:04:40.511 27.2 DO 55 53 42 43 f8 1a 27 86 08 00 00 00 80 00 0a 25 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 27.2 LEN 08 00 00 00 8 10:04:40.513 27.2 DI 00 01 ff ff 00 00 02 00 ........ 10:04:40.513 27.2 LEN 0d 00 00 00 13 10:04:40.515 27.2 DI 55 53 42 53 f8 1a 27 86 00 00 00 00 00 USBS..'...... 10:04:40.515 28 LEN 08 00 00 00 8 10:04:40.515 28 DI 00 01 ff ff 00 00 02 00 ........ 10:04:40.515 27.2 LEN 1f 00 00 00 31 10:04:40.517 27.2 DO 55 53 42 43 f8 1a 27 86 00 02 00 00 80 00 0a 28 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 27.2 LEN 80 00 00 00 128 10:04:40.523 27.2 DI ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 10:04:40.523 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 27.2 LEN 1f 00 00 00 31 10:04:41.024 27.2 DO 55 53 42 43 f8 1a 27 86 00 02 00 00 80 00 0a 28 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 27.2 LEN 40 00 00 00 64 10:04:41.029 27.2 DI ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 10:04:41.029 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 27.2 LEN 1f 00 00 00 31 10:04:41.530 27.2 DO 55 53 42 43 f8 1a 27 86 00 02 00 00 80 00 0a 28 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 27.2 LEN 80 01 00 00 384 10:04:41.543 27.2 DI ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 10:04:41.543 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 27.2 LEN 1f 00 00 00 31 10:04:42.045 27.2 DO 55 53 42 43 f8 1a 27 86 00 02 00 00 80 00 0a 28 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 27.2 LEN 40 00 00 00 64 10:04:42.049 27.2 DI ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 10:04:42.049 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 27.2 LEN 1f 00 00 00 31 10:04:42.550 27.2 DO 55 53 42 43 f8 1a 27 86 00 02 00 00 80 00 0a 28 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 27.2 LEN 80 00 00 00 128 10:04:42.555 27.2 DI ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 10:04:42.555 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................ 27.2 LEN 1f 00 00 00 31 10:04:42.743 27.2 DO 55 53 42 43 a8 40 87 83 c0 00 00 00 80 00 06 1a 00 1c 00 c0 00 00 00 00 00 00 00 00 00 00 00 27.2 LEN 0c 00 00 00 12 10:04:42.744 27.2 DI 0b 00 00 08 00 03 e3 11 00 00 08 00 ............ 10:04:42.744 27.2 LEN 0d 00 00 00 13 10:04:42.745 27.2 DI 55 53 42 53 a8 40 87 83 00 00 00 00 01 USBS.@....... 10:04:42.745 27.2 LEN 1f 00 00 00 31 10:04:42.747 27.2 DO 55 53 42 43 a8 40 87 83 12 00 00 00 80 00 0c 03 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 27.2 LEN 12 00 00 00 18 10:04:42.749 27.2 DI 70 00 05 00 00 00 00 0c 00 00 00 00 24 00 00 00 00 00 p...........$... 27.2 LEN 0d 00 00 00 13 10:04:42.751 27.2 DI 55 53 42 53 a8 40 87 83 00 00 00 00 00 USBS.@....... 10:04:42.751 27.2 LEN 1f 00 00 00 31 10:04:42.753 27.2 DO 55 53 42 43 f8 1a 27 86 c0 00 00 00 80 00 06 1a 00 3f 00 c0 00 00 00 00 00 00 00 00 00 00 00 27.2 LEN 0c 00 00 00 12 10:04:42.755 27.2 DI 0b 00 00 08 00 03 e3 11 00 00 08 00 ............ 10:04:42.755 27.2 LEN 0d 00 00 00 13 10:04:42.756 27.2 DI 55 53 42 53 f8 1a 27 86 00 00 00 00 00 USBS..'...... 10:04:42.756 28 LEN 0c 00 00 00 12 10:04:42.756 28 DI 0b 00 00 08 00 03 e3 11 00 00 08 00 ............ 10:04:42.756 我给PC返回的值都为FF,这个是为了尝试通信是否正确! |
|