ch374 初始化0x81錯誤

你好,請問一下,ch374 初始化0x81錯誤,用以下程序測試的時候,發(fā)現(xiàn)得出下面結果,請問對不對 測試用程序:

printf("Read 0x04 Register is %02x.\n",CH374_READ_REGISTER(0x04)); delay_nms( 100 ); CH374_WRITE_REGISTER(0x40,0x48); delay_nms( 100 ); CH374_WRITE_REGISTER(0x41,0x49); delay_nms( 100 ); CH374_WRITE_REGISTER(0x42,0x50); delay_nms( 100 ); CH374_WRITE_REGISTER(0x43,0x51); delay_nms( 100 ); printf("Read 0x05 Register is %02x.\n",CH374_READ_REGISTER(0x05)); delay_nms( 100 ); printf("Read 0x06 Register is %02x.\n",CH374_READ_REGISTER(0x06)); delay_nms( 100 ); printf("Read 0x07 Register is %02x.\n",CH374_READ_REGISTER(0x07)); delay_nms( 100 ); printf("Read 0x08 Register is %02x.\n",CH374_READ_REGISTER(0x08)); delay_nms( 100 ); printf("\n"); printf("Read 0x40 Register is %02x.\n",CH374_READ_REGISTER(0x40)); delay_nms( 100 ); printf("Read 0x41 Register is %02x.\n",CH374_READ_REGISTER(0x41)); delay_nms( 100 ); printf("Read 0x42 Register is %02x.\n",CH374_READ_REGISTER(0x42)); delay_nms( 100 ); printf("Read 0x43 Register is %02x.\n",CH374_READ_REGISTER(0x43));

測試結果:

Start Read 0x04 Register is 59fa. Read 0x05 Register is fa. Read 0x06 Register is fa. Read 0x07 Register is f0fa. Read 0x08 Register is fa.

Read 0x40 Register is 48fa. Read 0x41 Register is 49fa. Read 0x42 Register is 50fa. Read 0x43 Register is 51fa. Error: 81

讀取的數(shù)據(jù)肯定不正確,請檢查下單片機和我們芯片的硬件連線以及芯片是否正常工作


可是我在應用EXAM\HOST \host.c的時候 能夠響應以下東西,請問,對不對。如果對的話能不能說明硬件沒有問題?

Reset Device Start Full-Speed Device GetDeviceDescr: 12 01 10 01 00 00 00 40 04 02 25 60 00 01 01 02 03 01 SetUsbAddress: GetConfigDescr: 09 02 20 00 01 01 00 80 32 09 04 00 00 02 08 06 50 00 07 05 01 02 40 00 01 07 05 81 02 40 00 00 SetUsbConfig: USB device ready now do something, read / write ...... Wait Device Out


那肯定你軟件移植上面出了問題,或者你的I/O定義上面出了問題。建議你去仔細查下你的硬件以及移植的軟件有什么區(qū)別。


但是還有一點問題,在在應用EXAM\HOST \host.c的時候加入 printf("Read 0x04 Register is %02x.\n",CH374_READ_REGISTER(0x04)); delay_nms( 100 ); CH374_WRITE_REGISTER(0x40,0x48); delay_nms( 100 ); CH374_WRITE_REGISTER(0x41,0x49); delay_nms( 100 ); CH374_WRITE_REGISTER(0x42,0x50); delay_nms( 100 ); CH374_WRITE_REGISTER(0x43,0x51); delay_nms( 100 ); printf("Read 0x05 Register is %02x.\n",CH374_READ_REGISTER(0x05)); delay_nms( 100 ); printf("Read 0x06 Register is %02x.\n",CH374_READ_REGISTER(0x06)); delay_nms( 100 ); printf("Read 0x07 Register is %02x.\n",CH374_READ_REGISTER(0x07)); delay_nms( 100 ); printf("Read 0x08 Register is %02x.\n",CH374_READ_REGISTER(0x08)); delay_nms( 100 ); printf("\n"); printf("Read 0x40 Register is %02x.\n",CH374_READ_REGISTER(0x40)); delay_nms( 100 ); printf("Read 0x41 Register is %02x.\n",CH374_READ_REGISTER(0x41)); delay_nms( 100 ); printf("Read 0x42 Register is %02x.\n",CH374_READ_REGISTER(0x42)); delay_nms( 100 ); printf("Read 0x43 Register is %02x.\n",CH374_READ_REGISTER(0x43));

得出如下結果


Start CH374 Host Read 0x04 Register is c900. Read 0x05 Register is 4000. Read 0x06 Register is 5000. Read 0x07 Register is 300. Read 0x08 Register is 00.

Read 0x40 Register is 4800. Read 0x41 Register is 4900. Read 0x42 Register is 5000. Read 0x43 Register is 5100.

Reset Device Start Full-Speed Device GetDeviceDescr: 12 01 10 01 00 00 00 40 04 02 25 60 00 01 01 02 03 01 SetUsbAddress: GetConfigDescr: 09 02 20 00 01 01 00 80 32 09 04 00 00 02 08 06 50 00 07 05 01 02 40 00 01 07 05 81 02 40 00 00 SetUsbConfig: USB device ready now do something, read / write ...... Wait Device Out


還有就是我在仿真狀態(tài)下能夠進入Wait Udisk,然后不管拔插U盤都無響應,在插入U盤時中斷引腳為低電平,但是就是不響應


1、用printf輸出一個8位數(shù)據(jù),格式有誤,應為:printf( "%02x\n", ( unsinged short )dat ); 2、按讀寫寄存器的結果,與374的通訊是正常的 3、0x81是CH374LibInit返回的吧?換一個板子試試呢 4、檢測不到U盤插拔,檢查一下中斷線定義


....汗,看起來想是我的測試程序,我用的沒問題,0x81肯定是讀寫時序不對,或是速度快了,或是虛焊,別的就沒了


謝謝大家關心,找到問題了,確實是硬件以及移植的軟件有區(qū)別的,修改就好了 不過現(xiàn)在出現(xiàn)新的問題的,就是在仿真狀態(tài)下能過建立文件,但是燒些進芯片就是0x81錯誤,郁悶 我用的芯片是SST89E516RD


仍然是這種問題,還需要你自己查找,我們只能給您提供一個解決問題的方向


仿真和硬件的區(qū)別在于延時以及RAM的分配不一樣,還需要你去查下這2個方面就可以了。


問題以解決,復位的時候時序有點問題,現(xiàn)在在仿真和燒寫后都可以識別U盤了,能夠創(chuàng)建文件 但又出現(xiàn)了新問題,對文件的讀寫不正確,能夠創(chuàng)建文件。


你是按照扇區(qū)方式讀寫U盤還是字節(jié)的方式?建議你先去按照字節(jié)方式讀寫U盤,還有你說讀寫不正確是讀取到的數(shù)據(jù)內容不正確還是其他方面不正確,請詳細說明。


我是的51單片機只有768個外部RAM,所以只能用字節(jié)的方式讀寫。 我更改my_buffer的時候得出不同結果(當CH374HFT.C里面數(shù)據(jù)為abcdefg) UINT8X my_buffer[ 4]; /* 外部RAM的文件數(shù)據(jù)緩沖區(qū) */ Start Wait Udisk Ready? Open Read Size=7,Len=4,Sec=0 Close line 1: Create Write Modify Close Take out

當UINT8X my_buffer[ 10];的時候 Start Wait Udisk Ready? Open Read Size=7,Len=47,Sec=1 就不動了


我們的數(shù)據(jù)是存在一個結構體變量里面的,調用字節(jié)讀寫數(shù)據(jù)應該是在這個里面:mCmdParam.ByteRead.mByteBuffer


只有登錄才能回復,可以選擇微信賬號登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频