test的作用是什么? 他是自動(dòng)上傳和下傳數(shù)據(jù)的嗎?我沒有上傳和下傳,且每次數(shù)據(jù)不一樣。 單片機(jī)程序使用frm框架可以嗎? 如果以上是對的,為什么我使用debug372點(diǎn)下傳一個(gè)字節(jié)10后,再點(diǎn)上傳就沒反應(yīng)了?
PC先下傳數(shù)據(jù)到單片機(jī),單片機(jī)然后取反上傳給PC,參考TEST\MCU里的例子,這是TEST的操作流程,debug372點(diǎn)下傳一個(gè)字節(jié)10后,點(diǎn)上傳應(yīng)該會(huì)讀到數(shù)據(jù)!沒反映就是沒讀到數(shù)據(jù),檢查你的單片機(jī)程序。
我現(xiàn)在直接在下傳中斷中上傳一個(gè)字節(jié)數(shù)據(jù),還是收不到
需要看下你單片機(jī)程序是怎么寫的,是否可以把中斷函數(shù)部分貼出來看下
void CH375_Init( void ) { UINT8 i;
#ifdef MY_USB_VENDOR_ID #ifdef MY_USB_PRODUCT_ID CH375_WR_CMD_PORT( CMD_SET_USB_ID ); CH375_WR_DAT_PORT( (UINT8)MY_USB_VENDOR_ID ); CH375_WR_DAT_PORT( (UINT8)(MY_USB_VENDOR_ID>>8) ); CH375_WR_DAT_PORT( (UINT8)MY_USB_PRODUCT_ID ); CH375_WR_DAT_PORT( (UINT8)(MY_USB_PRODUCT_ID>>8) ); #endif #endif CH375_WR_CMD_PORT( CMD_SET_USB_MODE ); CH375_WR_DAT_PORT( 2 ); for ( i=100; i!=0; i-- ) if ( CH375_RD_DAT_PORT( ) == CMD_RET_SUCCESS ) break; if ( i == 0 )P1=0x03;
#ifdef ENABLE_USB_SUSPEND CH375_WR_CMD_PORT( CMD_CHK_SUSPEND ); CH375_WR_DAT_PORT( 0x10 ); CH375_WR_DAT_PORT( 0x04 ); #endif #ifdef __C51__ IT0 = 0; IE0 = 0; EX0 = 1; #endif }
UINT8 UsbLength; UINT8 UsbBuffer[ CH375_MAX_DATA_LEN ];
void mCH375Interrupt( void ) interrupt 0 using 1 { UINT8 IntStatus; UINT8 cnt; PUINT8 buf; *buf=0; CH375_WR_CMD_PORT( CMD_GET_STATUS ); IntStatus = CH375_RD_DAT_PORT( ); /* IE0 = 0; switch( IntStatus ) { case USB_INT_EP2_OUT: CH375_WR_CMD_PORT( CMD_RD_USB_DATA ); UsbLength = cnt = CH375_RD_DAT_PORT( ); if ( cnt ) { buf = UsbBuffer; do { *buf = CH375_RD_DAT_PORT( ); P1=*buf; buf ++; } while ( -- cnt ); } else break; CH375_WR_CMD_PORT( CMD_WR_USB_DATA7 ); cnt = UsbLength; if ( cnt ) { CH375_WR_DAT_PORT( cnt ); buf = UsbBuffer; do { CH375_WR_DAT_PORT(~*buf ); buf ++; } while ( -- cnt ); } else break; break; case USB_INT_EP2_IN: CH375_WR_CMD_PORT( CMD_UNLOCK_USB ); break; case USB_INT_EP1_IN: CH375_WR_CMD_PORT( CMD_UNLOCK_USB ); break; case USB_INT_EP1_OUT: CH375_WR_CMD_PORT( CMD_UNLOCK_USB ); break; #ifdef ENABLE_USB_SUSPEND case USB_INT_USB_SUSPEND: CH375_WR_CMD_PORT( CMD_UNLOCK_USB ); CH375_WR_CMD_PORT( CMD_ENTER_SLEEP ); break; case USB_INT_WAKE_UP: CH375_WR_CMD_PORT( CMD_UNLOCK_USB ); break; #endif default: CH375_WR_CMD_PORT( CMD_UNLOCK_USB ); break; } }
初始化中不能返回初始化成功命令,單片機(jī)P1口為03.D0~D7口為高。這是什么原因
好好檢查你的硬件。 CH375_RD_DAT_PORT(),CH375_WR_CMD_PORT,CH375_WR_DAT_PORT這幾個(gè)函數(shù)是怎么寫的?