[求助]用CH375讀取U盤的0扇區(qū)錯(cuò)誤

hcn老大,

請(qǐng)問(wèn)我用CH375讀取U盤的0扇區(qū)時(shí)為什么給我返回錯(cuò)誤的信息呢,以下為返回的0扇區(qū)的信息:

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 3C 8C E8 00 00 00 01 01 00 06 3F 20 7D 20 00 00 00 E0 E7 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA

好像就是最后2個(gè)字節(jié)是正確的,而其它的都不對(duì),這是為什么?

以下為我用來(lái)讀扇區(qū)的部分程序,是根據(jù)《USB 芯片CH375 的評(píng)估板說(shuō)明及應(yīng)用參考》中的例子程序修改的:

unsigned char ReadSector(unsigned long iLbaStart) { unsigned char mIntStatus; unsigned char *mBufferPoint; unsigned int mBlockCount; unsigned char mLength,tmp; unsigned char temp[] = "Sector0:";

Write_COM_Sentence(temp);

CH375A_CMD_Write( CMD_DISK_READ ); //send disk read request CH375A_DATA_Write( (unsigned char)iLbaStart ); //send the lowest 8 bits of the sector address CH375A_DATA_Write( (unsigned char)( iLbaStart >> 8 ) ); //send the second low 8 bits of the sector address CH375A_DATA_Write( (unsigned char)( iLbaStart >> 16 ) ); //send the second high 8 bits of the sector address CH375A_DATA_Write( (unsigned char)( iLbaStart >> 24 ) ); //send the highest 8 bits of the sector address CH375A_DATA_Write( 1 ); //sends the number of sectors mBufferPoint = dataBuffer; //points to the data buffer // for ( mBlockCount = iSectorCount * 8; mBlockCount != 0; mBlockCount -- )

for ( mBlockCount = 8; mBlockCount != 0; mBlockCount -- ) { mIntStatus = WaitInt(); //waits for the interrupts if ( mIntStatus == USB_INT_DISK_READ ) //if the data is available from CH375A { CH375A_CMD_Write(CMD_RD_USB_DATA ); //reads the data from CH375A mLength = CH375A_DATA_Read(); //first reads the length of the data while (mLength) { tmp = CH375A_DATA_Read(); Write_COM_Byte1(tmp); *mBufferPoint = tmp; //reads the data and save it the databuffer mBufferPoint ++; mLength --; } CH375A_CMD_Write( CMD_DISK_RD_GO ); //continue reading the data } else break; // break from the loop if there is error } if ( mBlockCount == 0 ) { mIntStatus = WaitInt( ); if ( mIntStatus == USB_INT_SUCCESS ) return( 0 ); //read success } return( mIntStatus ); //read fails and return the reason }


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

hcn老大,

請(qǐng)問(wèn)我用CH375讀取U盤的0扇區(qū)時(shí)為什么給我返回錯(cuò)誤的信息呢,以下為返回的0扇區(qū)的信息:

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 3C 8C E8 00 00 00 01 01 00 06 3F 20 7D 20 00 00 00 E0 E7 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA

好像就是最后2個(gè)字節(jié)是正確的,而其它的都不對(duì),這是為什么?

以下為我用來(lái)讀扇區(qū)的部分程序,是根據(jù)《USB 芯片CH375 的評(píng)估板說(shuō)明及應(yīng)用參考》中的例子程序修改的:

unsigned char ReadSector(unsigned long iLbaStart) { unsigned char mIntStatus; unsigned char *mBufferPoint; unsigned int mBlockCount; unsigned char mLength,tmp; unsigned char temp[] = "Sector0:";

Write_COM_Sentence(temp);

CH375A_CMD_Write( CMD_DISK_READ ); //send disk read request CH375A_DATA_Write( (unsigned char)iLbaStart ); //send the lowest 8 bits of the sector address CH375A_DATA_Write( (unsigned char)( iLbaStart >> 8 ) ); //send the second low 8 bits of the sector address CH375A_DATA_Write( (unsigned char)( iLbaStart >> 16 ) ); //send the second high 8 bits of the sector address CH375A_DATA_Write( (unsigned char)( iLbaStart >> 24 ) ); //send the highest 8 bits of the sector address CH375A_DATA_Write( 1 ); //sends the number of sectors mBufferPoint = dataBuffer; //points to the data buffer // for ( mBlockCount = iSectorCount * 8; mBlockCount != 0; mBlockCount -- )

for ( mBlockCount = 8; mBlockCount != 0; mBlockCount -- ) { mIntStatus = WaitInt(); //waits for the interrupts if ( mIntStatus == USB_INT_DISK_READ ) //if the data is available from CH375A { CH375A_CMD_Write(CMD_RD_USB_DATA ); //reads the data from CH375A mLength = CH375A_DATA_Read(); //first reads the length of the data while (mLength) { tmp = CH375A_DATA_Read(); Write_COM_Byte1(tmp); *mBufferPoint = tmp; //reads the data and save it the databuffer mBufferPoint ++; mLength --; } CH375A_CMD_Write( CMD_DISK_RD_GO ); //continue reading the data } else break; // break from the loop if there is error } if ( mBlockCount == 0 ) { mIntStatus = WaitInt( ); if ( mIntStatus == USB_INT_SUCCESS ) return( 0 ); //read success } return( mIntStatus ); //read fails and return the reason }

不好意思,剛才發(fā)完帖才發(fā)現(xiàn)忘了在數(shù)據(jù)中間加回車了,不好看,現(xiàn)在我給修改一過(guò)來(lái)。


那你用工具看下你的U盤的第0扇區(qū)是不是這個(gè)數(shù)據(jù),你這個(gè)數(shù)據(jù)好象是第1扇區(qū)的數(shù)據(jù),不像第0扇區(qū)的數(shù)據(jù)


沒(méi)有錯(cuò),你讀第32扇區(qū)試試看。


謝謝啦,我試試


嗯,第32扇區(qū)果然是扇區(qū)0,但是為什么扇區(qū)0跑到扇區(qū)32了呢?那我讀的扇區(qū)0是什么?


哈哈,跟我一樣困擾


物理上面的第0扇區(qū)實(shí)際上相當(dāng)于硬盤的主引導(dǎo)扇區(qū)(MBR),只是針對(duì)有的U盤,而有些U盤則沒(méi)有這個(gè)


哦,原來(lái)如此


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

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