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 }