從PC機(jī)端發(fā)送數(shù)據(jù)到CH372時(shí),全部都正確,
可是PC端要求接收CH372的數(shù)據(jù)時(shí),接收不到數(shù)據(jù),線程一直在等待。
我的單片機(jī)程序是這樣的。 麻煩WCH的工程師們幫看一下好嗎?謝謝!
;*******向CH372寫命令操作******************** ORDER: MOV P2,A SETB P0.3 CLR P0.5 MOV P2,A NOP SETB P0.5 mov p2,#0ffh RET ;----------------------------------------------------
;*******向CH372寫數(shù)據(jù)操作************************** WRITE: MOV P2,A CLR P0.3 CLR P0.5 MOV P2,A NOP SETB P0.5 mov p2,#0ffh RET ;--------------------------------------------------
;*******向CH372讀數(shù)據(jù)操作************************* READ: MOV P2,#0FFH CLR P0.3 CLR P0.4 MOV A,P2 NOP SETB P0.4 mov p2,#0ffh RET ;------------- ;*******端點(diǎn)2 批量數(shù)據(jù)上傳子程序******************** BULKUP: MOV A,#CMD_WR_USB_DATA7 ;寫入上傳命令 ACALL ORDER nop nop nop MOV A,LEN ;先寫入數(shù)據(jù)長(zhǎng)度 mov r2,a jz int_unlk ACALL WRITE MOV R1,#BUFFER BULKSEND:MOV A,@R1 ;發(fā)送數(shù)據(jù) ACALL WRITE INC R1 DJNZ r2,BULKSEND INT_UNLK:MOV A,#CMD_UNLOCK_USB ;發(fā)送完畢,解開(kāi)緩沖區(qū)鎖 ACALL ORDER nop RET ;-----------------------------------------------------------
;*******端點(diǎn)2 批量數(shù)據(jù)下傳子程序************* BULKDOWN:MOV A,#CMD_RD_USB_DATA ;寫入下傳數(shù)據(jù)命令 ACALL ORDER NOP NOP ACALL READ ;讀取數(shù)據(jù)長(zhǎng)度 MOV R2,A JZ OUTDOWN MOV LEN,A MOV R1,#BUFFER BULKDS: ACALL READ ;接收下傳數(shù)據(jù) MOV @R1,A INC R1 DJNZ R2,BULKDS mov a,r1 clr c subb a,#05h mov lenend,a OUTDOWN:NOP RET