我在主程序中開中斷了。FPGA通過給CH341的int#腳一個上升沿脈沖,使CH341發(fā)生中斷。但是CH341捕捉到前幾個中斷后便不再發(fā)生中斷。 但是我通過CH341GetStatus(iIndex,Status)函數(shù)卻可以每次都能捕捉到INT#腳的上升沿變化。 請問這是怎么回事?難道是驅(qū)動函數(shù)漏掉了一些中斷?
下面是測試程序:通過D0產(chǎn)生上升沿 #include #include #include #include #include
#include "CH341DLL.H" // CH341的動態(tài)鏈接庫
static int count=0;
void CALLBACK InterruptEvent(void) //設(shè)備0中斷通知消息 { count++; //中斷次數(shù)記數(shù) printf("interrupt times=%d\n",count); }
//程序入口 void main ( ) {
printf( "\nCH341 Interrupt Test Program V1.0 , Copyright (C) S.zk 2008.7\n" );
// 需要使用DLL則需要先加載 printf( "*** Load DLL: CH341DLL.DLL \n" ); if ( LoadLibrary( "CH341DLL.DLL" ) == NULL ) return; // 加載DLL失敗,可能未安裝到系統(tǒng)中
printf( "*** CH341OpenDevice: 0# \n" ); if ( CH341OpenDevice( 0 ) == INVALID_HANDLE_VALUE ) return; /* 使用之前必須打開設(shè)備 */
if( CH341SetIntRoutine( 0, InterruptEvent) == NULL ) return; /* 指定中斷服務(wù)程序 */
do{ CH341Set_D5_D0( 0, 0x01, 0); CH341Set_D5_D0( 0, 0x01, 1); }while(count < 1000);//D0產(chǎn)生上升沿
if( CH341SetIntRoutine( 0, NULL) == NULL ) return; /* 取消中斷服務(wù) */ printf( "*** CH341CloseDevice: 0 \n" ); CH341CloseDevice( 0 );
printf( "\nExit.\n" ); getch(); }