我用PIC MCU控制CH375,读取U盘中的MP3数据到VS1003中解码播放,在播放中途出现数据读取错误,经过仿真跟踪,发现CH375无法产生中断信号,CH375的中断处理采用查询方式.请问这种情况是什么原因,该怎么解决呢? 相关的程序如下: /******************************************* 函数名称:Ch375WaitInt() 作 用:等待CH375中断 入 口:无; 出 口:中断状态 *******************************************/ 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 ); /* 产生操作完成中断,获取中断状态 */ return( Ch375RdDatPort( ) ); }
/******************************************* 函数名称:CH375WriteSector() 作 用:CH375扇区写入 入 口:扇区号LBA,缓冲区地址 出 口:返回状态; *******************************************/ 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 ); //写一个扇区 for( blockcnt=8; blockcnt>0; blockcnt--) { cnt = Ch375WaitInt(); if( cnt == USB_INT_DISK_WRITE ) { Ch375WrCmdPort( CMD_WR_USB_DATA7 ); Ch375WrDatPort( 64 ); //写入64字节 for( cnt=64 ; cnt>0; cnt--) { Ch375WrDatPort( *buff ); buff++; } Ch375WrCmdPort( CMD_DISK_WR_GO ); } else { break; } } if( blockcnt == 0 ) { return( Ch375WaitInt() ); } else { return(cnt); } }