我用PIC MCU控制CH375,讀取U盤中的MP3數(shù)據(jù)到VS1003中解碼播放,在播放中途出現(xiàn)數(shù)據(jù)讀取錯誤,經(jīng)過仿真跟蹤,發(fā)現(xiàn)CH375無法產(chǎn)生中斷信號,CH375的中斷處理采用查詢方式.請問這種情況是什么原因,該怎么解決呢? 相關(guān)的程序如下: /******************************************* 函數(shù)名稱:Ch375WaitInt() 作 用:等待CH375中斷 入 口:無; 出 口:中斷狀態(tài) *******************************************/ unsigned char Ch375WaitInt( void ) { unsigned long x; x = 0x3fffff; while( USBINT>0 ) { // 查詢等待CH375操作完成中斷(INT#低電平) USBINT_T = 1; x--; if( x == 0 ) { break; } } if(x == 0) { return USB_INT_DISK_ERR; }
Ch375WrCmdPort( CMD_GET_STATUS ); /* 產(chǎn)生操作完成中斷,獲取中斷狀態(tài) */ return( Ch375RdDatPort( ) ); }
/******************************************* 函數(shù)名稱:CH375WriteSector() 作 用:CH375扇區(qū)寫入 入 口:扇區(qū)號LBA,緩沖區(qū)地址 出 口:返回狀態(tài); *******************************************/ unsigned char CH375WriteSector( unsigned long lba, unsigned char *buff ) { unsigned char blockcnt,cnt; Ch375WrCmdPort( CMD_DISK_WRITE ); Ch375WrDatPort( (unsigned char)(lba&0xff) ); Ch375WrDatPort( (unsigned char)((lba>>8)&0xff) ); Ch375WrDatPort( (unsigned char)((lba>>16)&0xff) ); Ch375WrDatPort( (unsigned char)((lba>>24)&0xff) ); Ch375WrDatPort( 1 ); //寫一個扇區(qū) for( blockcnt=8; blockcnt>0; blockcnt--) { cnt = Ch375WaitInt(); if( cnt == USB_INT_DISK_WRITE ) { Ch375WrCmdPort( CMD_WR_USB_DATA7 ); Ch375WrDatPort( 64 ); //寫入64字節(jié) for( cnt=64 ; cnt>0; cnt--) { Ch375WrDatPort( *buff ); buff++; } Ch375WrCmdPort( CMD_DISK_WR_GO ); } else { break; } } if( blockcnt == 0 ) { return( Ch375WaitInt() ); } else { return(cnt); } }