[求助]ch375讀u盤,第0扇區(qū)怎么總是讀到u盤說明信息?

第一句總是:KingstonDataTravelerMiniPMAP,而不是boot。這可能是什么原因引起的?下面是我讀第1扇區(qū)得到的信息:

55 53 42 20 43 68 65 63 6B 65 72 20 49 6E 20 44 65 76 6C 6F 70 69 6E 67 21 0D 0A 00 00 00 01 1F 00 00 00 4B 69 6E 67 73 74 6F 6E 44 61 74 61 54 72 61 76 65 6C 65 72 4D 69 6E 69 50 4D 41 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF 04 FF FF 04 FF FF 04 00 00 00 8C 00 00 00 01 00 00 50 00 01 FF FF FF FF FF

讀一扇區(qū)代碼如下: void ReadDiskOneSector(UINT32 LBA,UINT8 *buffer) { UINT8 cnt = 8; BOOL retry = TRUE; while(retry) { Ch375WriteCommand(CMD_DISK_READ); Ch375WriteData((UINT8)LBA); Ch375WriteData((UINT8)(LBA>>8)); Ch375WriteData((UINT8)(LBA>>16)); Ch375WriteData((UINT8)(LBA>>24)); Ch375WriteCommand(1); while(cnt--) { if(WaitInterrupt() != USB_INT_DISK_READ) break; ReadUsbData(buffer); Ch375WriteCommand(CMD_DISK_RD_GO); } if(cnt != 0xff) { InitialUsbDisk(); } else { retry = FALSE; } } }


熱門產(chǎn)品 : USB3.0 HUB控制器:CH634

// 從CH37X讀出數(shù)據(jù)塊 void ReadUsbData( UINT8 *buf ) { UINT8 i, len; Ch375WriteCommand(CMD_RD_USB_DATA); /* 從CH375的端點(diǎn)緩沖區(qū)讀取接收到的數(shù)據(jù) */ len=Ch375ReadData(); /* 后續(xù)數(shù)據(jù)長度 */ for ( i=0; i { *buf++=Ch375ReadData(); } }


Ch375WriteCommand(1); ??? 扇區(qū)數(shù)怎么能通過命令口寫呢!應(yīng)為:Ch375WriteData(1)


寫成如下,一樣的結(jié)果!瘋了! //CH375讀一個(gè)扇區(qū) void ReadDiskOneSector(UINT32 LBA,UINT8 *buffer) { UINT8 cnt; BOOL retry = TRUE; UINT8 rstatus; while(retry) { cnt = 9; Ch375WriteCommand(CMD_DISK_READ); Ch375WriteData((UINT8)LBA); Ch375WriteData((UINT8)(LBA>>8)); Ch375WriteData((UINT8)(LBA>>16)); Ch375WriteData((UINT8)(LBA>>24)); Ch375WriteData(1); while(--cnt) { rstatus = WaitInterrupt(); if(rstatus != USB_INT_DISK_READ) { PrintRS232char(rstatus); break; } ReadUsbData(buffer); Ch375WriteCommand(CMD_DISK_RD_GO);

} if(cnt == 0) retry = FALSE; else InitialUsbDisk(); } }


換了一個(gè)u盤,讀到如下結(jié)果: 68 65 72 20 6D 65 64 69 61 2E FF 0D 0A 44 69 73 6B 20 65 72 72 6F 72 FF 0D 0A 50 72 65 73 73 20 61 6E 79 20 6B 65 79 20 74 6F 20 72 65 73 74 61 72 74 0D 0A 00 00 00 00 00 AC CB D8 00 00 55 AA 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF 04 FF FF 04 00 FF 04 FF FF 04 00 2E 20 00 03 04 00 00 00 00 00 02 00 01


正確應(yīng)該是: EB 58 90 4D 53 44 4F 53 35 2E 30 00 02 02 26 00 02 00 00 00 00 F8 00 00 3F 00 FF 00 00 00 00 00 00 E8 03 00 E1 03 00 00 00 00 00 00 02 00 00 00 01 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 29 4A F0 50 0C 4E 4F 20 4E 41 4D 45 20 20 20 20 46 41 54 33 32 20 20 20 33 C9 8E D1 BC F4 7B 8E C1 8E D9 BD 00 7C 88 4E 02 8A 56 40 B4 08 CD 13 73 05 B9 FF FF 8A F1 66 0F B6 C6 40 66 0F B6 D1 80 E2 3F F7 E2 86 CD C0 ED 06 41 66 0F B7 C9 66 F7 E1 66 89 46 F8 83 7E 16 00 75 38 83 7E 2A 00 77 32 66 8B 46 1C 66 83 C0 0C BB 00 80 B9 01 00 E8 2B 00 E9 48 03 A0 FA 7D B4 7D 8B F0 AC 84 C0 74 17 3C FF 74 09 B4 0E BB 07 00 CD 10 EB EE A0 FB 7D EB E5 A0 F9 7D EB E0 98 CD 16 CD 19 66 60 66 3B 46 F8 0F 82 4A 00 66 6A 00 66 50 06 53 66 68 10 00 01 00 80 7E 02 00 0F 85 20 00 B4 41 BB AA 55 8A 56 40 CD 13 0F 82 1C 00 81 FB 55 AA 0F 85 14 00 F6 C1 01 0F 84 0D 00 FE 46 02 B4 42 8A 56 40 8B F4 CD 13 B0 F9 66 58 66 58 66 58 66 58 EB 2A 66 33 D2 66 0F B7 4E 18 66 F7 F1 FE C2 8A CA 66 8B D0 66 C1 EA 10 F7 76 1A 86 D6 8A 56 40 8A E8 C0 E4 06 0A CC B8 01 02 CD 13 66 61 0F 82 54 FF 81 C3 00 02 66 40 49 0F 85 71 FF C3 4E 54 4C 44 52 20 20 20 20 20 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0D 0A 52 65 6D 6F 76 65 20 64 69 73 6B 73 20 6F 72 20 6F 74 68 65 72 20 6D 65 64 69 61 2E FF 0D 0A 44 69 73 6B 20 65 72 72 6F 72 FF 0D 0A 50 72 65 73 73 20 61 6E 79 20 6B 65 79 20 74 6F 20 72 65 73 74 61 72 74 0D 0A 00 00 00 00 00 AC CB D8 00 00 55 AA

把前面的數(shù)據(jù)丟了! 請(qǐng)?zhí)崾疽幌?,可能是什么原因?/p>


數(shù)了一下,丟了七塊*端點(diǎn)大小(64Byte),只讀了最后一塊。


應(yīng)該是程序上的原因,建議您下載CH375EVT.ZIP,用..\PUB\MCS51C\MISCELL目錄下的示例程序試試


128M優(yōu)盤沒有問題了,可新買的2GB的愛國者 MiniUsb不行,1G的kingston也不行。用的是ch375B. 讀u盤大小時(shí),就死了 //初始化U盤 void InitialUsbDisk(void) { UINT8 rstatus; UINT32 size; UINT8 temp; PrintRS232FlashStr("Wait Usb disk Insert..."); while(TestConnect() == USB_INT_DISCONNECT); PrintRS232FlashStr("Find Usb Disk! "); PrintRS232FlashStr("Reset Usb Disk... "); ResetUsbBus(); PrintRS232FlashStr("Reset Ok! "); PrintRS232FlashStr("Initial Usb Disk..."); while(TRUE) { Ch375WriteCommand(CMD_DISK_INIT); rstatus = WaitInterrupt(); if(rstatus == USB_INT_SUCCESS) break; } PrintRS232FlashStr("Initial Ok! "); PrintRS232FlashStr("Read Usb Disk Size... "); PrintRS232FlashStr("Usb disk Size: "); size = ReadDiskSize(); size = size >> 20; temp = (UINT8)(size / 1000); PrintRS232char(temp + 0x30); size -= 1000*(UINT32)temp; temp = (UINT8)(size / 100); PrintRS232char(temp + 0x30); size -= 100*(UINT32)temp; temp = (UINT8)(size / 10); PrintRS232char(temp+0x30); size -= 10*(UINT32)temp; PrintRS232char((UINT8)size + 0x30); PrintRS232FlashStr("MB"); }


請(qǐng)各位幫忙分析一下。


大優(yōu)盤初始化讀u盤大小時(shí)就出錯(cuò): UINT32 ReadDiskSize(void) { UINT8 buffer[8]; UINT32 temp1,temp2; UINT8 rstatus; while(TRUE) { Ch375WriteCommand(CMD_DISK_SIZE); rstatus = WaitInterrupt(); if(rstatus != USB_INT_SUCCESS) { PrintRS232char(rstatus);//大優(yōu)盤這里返回的是0x1F,而不是期待的0x1D. DelayNms(100); } else break; } ReadUsbData(buffer); temp1 = (UINT32)buffer[0]<<24; temp1 += (UINT32)buffer[1]<<16; temp1 += (UINT32)buffer[2]<<8; temp1 += (UINT32)buffer[3]<<0; temp2 = (UINT32)buffer[4]<<24; temp2 += (UINT32)buffer[5]<<16; temp2 += (UINT32)buffer[6]<<8; temp2 += (UINT32)buffer[7]<<0; temp1 = temp1*temp2; return temp1; }


調(diào)試窗口如下: Now check Ch375 Chip: Find Ch375 Chip Now Initial UsbDisk Wait Usb disk Insert... Find Usb Disk! Reset Usb Disk... Reset Ok! Initial Usb Disk... Initial Ok! Read Usb Disk Size... Usb disk Size: 死在這里,收到的全部都是: 0x1F 0x1F

但使用愛國者1G優(yōu)盤沒有問題。


Now Initial UsbDisk Wait Usb disk Insert... Find Usb Disk! Reset Usb Disk... Reset Ok! Initial Usb Disk... Initial Ok! Read Usb Disk Size... Usb disk Size: 0967MB


出現(xiàn)上面的問題一般都是前面沒有做好: mDelaymS( 200 ); set_usb_mode( 6 ); /* 設(shè)置USB主機(jī)模式 */ while ( wait_interrupt()!=USB_INT_CONNECT ); set_usb_mode( 7 ); /* 復(fù)位USB設(shè)備,CH375向USB信號(hào)線的D+和D-輸出低電平 */ mDelaymS( 10 ); /* 復(fù)位時(shí)間不少于1mS,建議為10mS */ set_usb_mode( 6 ); /* 結(jié)束復(fù)位 */ mDelaymS( 100 ); while ( wait_interrupt()!=USB_INT_CONNECT ); /* 等待復(fù)位之后的設(shè)備端再次連接上來 */ mDelaymS( 200 ); /* 有些USB設(shè)備要等待數(shù)百毫秒才能正常工作 */

.......進(jìn)行枚舉操作 上述延時(shí)是比較正確的,根據(jù)自己硬件時(shí)鐘進(jìn)行修改,但是延時(shí)不必太長,在極少數(shù)情況下可能會(huì)設(shè)備掛起.


void InitialUsbDisk(void) { UINT8 rstatus; UINT32 size; UINT8 temp; PrintRS232FlashStr("Wait Usb disk Insert..."); while(TestConnect() == USB_INT_DISCONNECT); PrintRS232FlashStr("Find Usb Disk! "); PrintRS232FlashStr("Reset Usb Disk... "); ResetUsbBus(); //復(fù)位保持時(shí)間不少于1MS建議10MS mDelaymS( 100 ); PrintRS232FlashStr("Reset Ok! "); //再次檢測(cè)設(shè)備連接 while ( wait_interrupt()!=USB_INT_CONNECT ); /* 等待復(fù)位之后的設(shè)備端再次連接上來 */ PrintRS232FlashStr("Initial Usb Disk..."); //延時(shí)200MS mDelaymS( 200 ); while(TRUE) { Ch375WriteCommand(CMD_DISK_INIT); rstatus = WaitInterrupt(); if(rstatus == USB_INT_SUCCESS) break; } PrintRS232FlashStr("Initial Ok! "); PrintRS232FlashStr("Read Usb Disk Size... "); PrintRS232FlashStr("Usb disk Size: "); size = ReadDiskSize(); size = size >> 20; temp = (UINT8)(size / 1000); PrintRS232char(temp + 0x30); size -= 1000*(UINT32)temp; temp = (UINT8)(size / 100); PrintRS232char(temp + 0x30); size -= 100*(UINT32)temp; temp = (UINT8)(size / 10); PrintRS232char(temp+0x30); size -= 10*(UINT32)temp; PrintRS232char((UINT8)size + 0x30); PrintRS232FlashStr("MB"); } U盤的時(shí)序相差很大,兼容性想做好確實(shí)很不容易,要進(jìn)行大批量的測(cè)試,不知道您用的是什么單片機(jī)?為何不選用我們的文件系統(tǒng)進(jìn)行操作呢?


謝謝您。我等等試驗(yàn)。我用的是avr,因?yàn)槲疫€要處理sd卡,已經(jīng)有了fat系統(tǒng)。不想再加一套fat.


只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

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