|
最近做了一个控制直溜电机的设备,在编程时有个问题,在keil中显示错误是没有相应的数与之匹配,请教高手改改!程序附下:
电机的正反转程序:
ORG 0000H
MIAN: MOV DPTR,#PORT2 ;0832地址
MOV A,80H
MOVX @DPTR,A
INC DPTR
MOVX @DPTR,A ;启动D/A转换
MOV P1,#FFH
MOV A,P1 ;读入开关状态
JB ACC.0,Z1 ;正向四个Z1/Z2/Z3/Z4
JB ACC.1,Z2
JB ACC.2,Z3
JB ACC.3,Z4
JB ACC.4,F1 ;反向四个F1,F2,F3,F4
JB ACC.5,F2
JB ACC.6,F3
JB ACC.7,F4
SJMP MAIN
ZZ4: MOV R3,#80H ;80H对应0伏
MOV A,#30H ;脉宽
MOV R2,A
Z42: DJNZ R3,Z42 ;这期间输出0伏
MOV A,#0FFH ; 对应+5伏电平
MOV DPTR,PORT2 ;送0832地址
MOVX @DPTR, A
INC DPTR
MOVX @DPTR ;启动D/A
Z43: DJNZ R2,Z43 ;延时期间输出+5伏脉冲
SJMP MAIN
Z3: MOV R3,#80H
MOV A,#40H ;不同脉宽
MOV R2,A
SJMP Z42
Z2: MOV R3,#80H ;注意R2和R3对应的输出
MOV A,#60H
MOV R2,A
SJMP Z42
Z1: MOV R3,#80H
MOV A,#80H
MOV R2,A
SJMP Z42
F1: MOV R3,#80H
MOV A,#20H
MOV R2,A
F11: DJNZ R2,F11 ;延时输出0
MOV A ,#00H
MOV DPTR,#PROT2
MOVX @DPTR,A ;输出5伏
INC DPTR,A ;启动D/A
MOVX @DPT
F12: DJNZ R3 F12 ;输出-5伏
LJMP MAIN
F2: MOV R3,#60H ;这一段是装反转参数共四种
MOV A,#80H
MOV R2,A
SJMP F11
F3: MOV R3,#40H
MOV A,#80H
MOV R2,A
SJMP F11
F1: MOV R3,#30H
MOV A, #80H ;这是用R2,R3传送参数
MOV R2,A
SJMP F11 ;装参数后转处理
END
|
|