hcn老大,
请问我用CH375读取U盘的0扇区时为什么给我返回错误的信息呢,以下为返回的0扇区的信息:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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个字节是正确的,而其它的都不对,这是为什么?
以下为我用来读扇区的部分程序,是根据《USB 芯片CH375 的评估板说明及应用参考》中的例子程序修改的:
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 }