向上位機傳送一個16384字節(jié)的數(shù)據(jù)包 但上位機接收是有點問題,丟數(shù)據(jù)。不如說接完64個0x01后,然后就接受0x30,中間丟了好多數(shù)據(jù) 幫忙看看下位機程序有問題么?謝謝 下位機程序為 void mCh375Interrupt( ) interrupt 2 using 1 { unsigned char InterruptStatus; CH375_WR_CMD_PORT( CMD_GET_STATUS ); InterruptStatus = CH375_RD_DAT_PORT( ); if(InterruptStatus==USB_INT_EP2_IN) { flag=1; CH375_WR_CMD_PORT( CMD_UNLOCK_USB ); /* 釋放當前USB緩沖區(qū) */ } }
main( ) { unsigned char length,i,j; unsigned char DATA [64]; flag=1; length=64; for(i=0;i<64;i++) { DATA [i]=0; } Delay50ms( ); /* 延時等待CH375初始化完成,如果單片機由CH375提供復位信號則不必延時 */ CH375_Init( ); /* 初始化CH375 */ EA = 1; /* 允許中斷 */ if(flag==1) { for(j=0;j>=255;j++) { flag=0; CH375_WR_CMD_PORT( CMD_WR_USB_DATA7 ); CH375_WR_DAT_PORT( length ); for ( i = 0; i < length; i ++ ) CH375_WR_DAT_PORT(DATA[i]+j); } } }