RT 上位机只能接受到一次端点1传来的数据48,意图是循环接收。 下位机用的8051,程序如下: 。。。。 void mCh375Interrupt( ) interrupt 0 { 。。。。。。 else if ( InterruptStatus == USB_INT_EP1_IN ) { CH375_WR_CMD_PORT(CMD_UNLOCK_USB); FLAG_INT_WAIT = 0; } void LoadIntData( unsigned char c1 ) { unsigned int i; for ( i=1000; i!=0; i-- ) { if ( FLAG_INT_WAIT == 0 ) break; } EX0 = 0; CH375_WR_CMD_PORT(CMD_WR_USB_DATA5); Delay_us(2); CH375_WR_DAT_PORT(1); FLAG_INT_WAIT = 1; CH375_WR_DAT_PORT(c1); EX0 = 1; } main( ) { unsigned char c,i; WDTCN = 0xde; //关闭看门狗 WDTCN = 0xad; OSCILLATOR_Init(); //振荡器,端口设置 PORT_Init(); Delay_ms(50); CH375_PORT_INIT(); CH375_Init(); FLAG_INT_WAIT = 0; EA = 1; LoadIntData( 0x30 ); while (1); { Delay_ms(50); LoadIntData( 0x40 ); } }
上位机程序: 。。。。。 VOID CALLBACK mInterruptEvent( PUCHAR iBuffer ) { printf("interrupt receive success %d \n",iBuffer[0]); } void main ( ) { 。。。。。 printf( "*** Load DLL: CH375DLL.DLL \n" ); if ( LoadLibrary( "CH375DLL.DLL" ) == NULL ) return; printf( "*** CH375OpenDevice: 0# \n" ); if ( CH375OpenDevice( 0 ) == INVALID_HANDLE_VALUE ) return; CH375SetIntRoutine(0,mInterruptEvent); Sleep(50); while(1); }