发表于:2011/1/6 22:19:57
#0楼
程序如下:请大家帮忙仿真一下!
ORG 0000H
LJMP MAIN
org 002BH
Ljmp comreti
ORG 0100H
comreti:
reti
MAIN:
mov R7,#01H
mydelay: ;等检测
lcall usbdelay
djnz r7, mydelay
MOV SP,#60H ;设置堆栈指针
MOV TMOD,#20H ;计数器1工作在方式2
MOV TH1,#0FAH ;晶振频率为11.0592MHZ,波特率为9600
MOV TL1,#0FAH
mov ie,#90H
MOV PCON,#80H ;smod为1
SETB TR1 ;启动计时
MOV SCON,#40H
mov DPTR,#Detect
MOV r7,#66 ;发送66个字节数据
MOV R0,#00H ;计数
usbLOOP:
CLR A
MOV A,R0
MOVC A,@A+DPTR ;查表得到要发送的数据
MOV SBUF,A ;发送数据
NOP
NOP
NOP
NOP
usbWAIT:
JBC TI,usbCONT ;等待发送完毕
SJMP usbWAIT
usbCONT:
INC R0
DJNZ r7,usbLOOP
RET
;====================================================
; 延时子程序
;====================================================
usbDELAY: mov R6,#06H
usbloop3: MOV R5,#0FFH
usbLOOP2: MOV R4,#0FFH
usbLOOP1: NOP
DJNZ R4,usbLOOP1
DJNZ R5,usbLOOP2
djnz r6,usbloop3
RET
;====================================================
Detect: ;检测u盘命令
DB 0AAH,0BBH,01H
DB 20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H
DB 20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H
DB 20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H
DB 20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H
END
http://www.tudou.com/programs/view/CW_8DwTkv0Y/
这是使用伟福6000进行仿真时的录像
ORG 0000H
LJMP MAIN
org 002BH
Ljmp comreti
ORG 0100H
comreti:
reti
MAIN:
mov R7,#01H
mydelay: ;等检测
lcall usbdelay
djnz r7, mydelay
MOV SP,#60H ;设置堆栈指针
MOV TMOD,#20H ;计数器1工作在方式2
MOV TH1,#0FAH ;晶振频率为11.0592MHZ,波特率为9600
MOV TL1,#0FAH
mov ie,#90H
MOV PCON,#80H ;smod为1
SETB TR1 ;启动计时
MOV SCON,#40H
mov DPTR,#Detect
MOV r7,#66 ;发送66个字节数据
MOV R0,#00H ;计数
usbLOOP:
CLR A
MOV A,R0
MOVC A,@A+DPTR ;查表得到要发送的数据
MOV SBUF,A ;发送数据
NOP
NOP
NOP
NOP
usbWAIT:
JBC TI,usbCONT ;等待发送完毕
SJMP usbWAIT
usbCONT:
INC R0
DJNZ r7,usbLOOP
RET
;====================================================
; 延时子程序
;====================================================
usbDELAY: mov R6,#06H
usbloop3: MOV R5,#0FFH
usbLOOP2: MOV R4,#0FFH
usbLOOP1: NOP
DJNZ R4,usbLOOP1
DJNZ R5,usbLOOP2
djnz r6,usbloop3
RET
;====================================================
Detect: ;检测u盘命令
DB 0AAH,0BBH,01H
DB 20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H
DB 20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H
DB 20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H
DB 20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H,20H
END
http://www.tudou.com/programs/view/CW_8DwTkv0Y/
这是使用伟福6000进行仿真时的录像