目录
问题背景
步进电机是将电脉冲信号转换为角位移或线位移的开环控制元件,只是由于驱动器的作用,使其步进化、数字化。在不超载的情况下,步进电机的转速、停止的位置,只取决于脉冲信号的频率和脉冲数,而不受负载的限制。步进电机的启动运行直接影响到数字控制的稳定性和准确性,因此在对步进电机控制的过程中必须有效过渡加速度运行阶段,以保证电机精准高效运行。目前的步进电机驱动技术主要采用了斩波恒流控制和正弦脉宽调制技术进行电机控制,极大限度的提高了电机的运行速度和运行精度。
基于步进电机的诸多优点,它已在工业自动化装备、办公自动化设备等许多领域得到广泛应用,如数控机床的横纵向走刀、内圆切片机的径向进给、办公用品的打印等。随着科学技术的不断发展,对步进电机的控制技术也提出了更高的要求,因此探索更全面、精度更高的步进电机控制方法已成为科学技术发展的不争事实。
功能模块图
电路原理图
系统功能描述
步进电机控制系统将4*4键盘作为输入端口,从键盘读取命令后,通过8255A口输出,以使步进电机转动,电机转动频率由8253的输出脉冲提供。电机转动后,74LS273向LCD输出,使LCD显示步进电机的工作状态。按下1-9键可实现不同挡位之间的切换,按下A和B键可实现电机转动方向的切换,按下C键可使电机停止转动,按下D键可使LCD清屏。
系统算法设计
本实验旨在实现用键盘实现对步进电机更加精准的控制。首先启动系统对8255初始化,设置FLAG标志,用来选择转动方向(开始把FLAG置为0,默认逆时针转动)然后测试是否有键按下,当0键按下时,对8253初始化,输入控制字,选择通道0和通道1,两个通道级联,并且都选择方式3,然后对两个通道设置计数初值。当按下1-9键时,将BUF置为33H,使得步进电机能够转动起来,然后重置两个通道的计数初值。1-9键对应不同的计数初值,使得8253能产生各种不同频率的脉冲。接着8255A端口输出BUF使步进电机启动。每转动一步74LS273就向LCD输出数据,使LCD显示步进电机的当前工作状态。然后测试是否有键按下,如果按下挡位键则可以通过向8253重置计数初值实现换挡,按方向键之后可以实现转动方向的切换。当按下C键时,清空8253控制字,电机停转。按下D键时,LCD清屏。
程序流程图
步进电机模块
LCD模块
运行截图
功能测试
模块 | 测试输入 | 预期结果 | 实测结果 |
键盘控制步进电机转动 | 按下0键 | 步进电机启动 | 与预期结果一致 |
按下1键 | 步进电机缓慢转动 | 与预期结果一致 | |
按下3键 | 步进电机以较慢速转动 | 与预期结果一致 | |
按下5键 | 步进电机中速转动 | 与预期结果一致 | |
按下7键 | 步进电机以较高速转动 | 与预期结果一致 | |
按下9键 | 步进电机高速转动 | 与预期结果一致 | |
按下A键 | 步进电机逆时针转动 | 与预期结果一致 | |
按下B键 | 步进电机顺时针转动 | 与预期结果一致 | |
按下C键 | 步进电机停止转动 | 与预期结果一致 | |
LCD显示步进电机工作状态 | 按下0键 | LCD显示电机状态为运行中 | 与预期结果一致 |
按下1键 | LCD显示电机转速为1挡 | 与预期结果一致 | |
按下2键 | LCD显示电机转速为2挡 | 与预期结果一致 | |
按下3键 | LCD显示电机转速为3挡 | 与预期结果一致 | |
按下4键 | LCD显示电机转速为4挡 | 与预期结果一致 | |
按下5键 | LCD显示电机转速为5挡 | 与预期结果一致 | |
按下6键 | LCD显示电机转速为6挡 | 与预期结果一致 | |
按下7键 | LCD显示电机转速为7挡 | 与预期结果一致 | |
按下8键 | LCD显示电机转速为8挡 | 与预期结果一致 | |
按下9键 | LCD显示电机转速为9挡 | 与预期结果一致 | |
按下A键 | LCD显示电机转向为逆时针 | 与预期结果一致 | |
按下B键 | LCD显示电机转向为顺时针 | 与预期结果一致 | |
按下C键 | LCD显示电机状态为停止 | 与预期结果一致 | |
按下D键 | LCD清屏 | 与预期结果一致 |
汇编源代码
PORT_A EQU 280H
PORT_B EQU 281H
PORT_C EQU 282H
PORT_CTL1 EQU 283H
PORT_L0 EQU 288H
PORT_L1 EQU 289H
PORT_L2 EQU 28AH
PORT_CTL2 EQU 28BH
PORT_273 EQU 298H
DATA SEGMENT
BUF DB 0
FLAG DB 0
; 0 1 2 3 4 5 6 7
TABLE DB 77H,7BH,7DH,7EH,0B7H,0BBH,0BDH,0BEH
; 8 9 A B C D E F
DB 0D7H,0DBH,0DDH,0DEH,0E7H,0EBH,0EDH,0EEH
HZ_ADR DB 00H ;存放显示行起始端口地址
INIT_WELCOME DW 0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H
DW 0A1A0H,0A1A0H,0BBB6H,0D3ADH,0CAB9H,0D3C3H,0A1A0H,0A1A0H
DW 0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H
DW 0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H
SHOW DW 0B2BDH,0BDF8H,0B5E7H,0BBFAH,0A1A0H,0A1A0H,0A1A0H,0A1A0H
DW 0A1A0H,0D7B4H,0CCACH,0A3BAH,0CDA3H,0D6B9H,0A1A0H,0A1A0H
DW 0A1A0H,0D7AAH,0CBD9H,0A3BAH,0A3B0H,0B5B2H,0A1A0H,0A1A0H
DW 0A1A0H,0D7AAH,0CFF2H,0A3BAH,0C4E6H,0CAB1H,0D5EBH,0A1A0H
CLEAR1 DW 0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H
DW 0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H
DW 0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H
DW 0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H,0A1A0H
DATA ENDS
STACKS SEGMENT
DB 2560 DUP(?)
STACKS ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACKS,ES:DATA
;-------------------LCD12864控制命令宏OK------------------------
CMD_SETUP MACRO ; LCD命令设置
MOV DX,PORT_C ; 指向8255控制端口C
NOP
MOV AL,00000000B ; PC1置0,pc0置0 (LCD W端=0,I端=0)
OUT DX, AL
NOP
MOV AL,00000100B ; PC2置1 (LCD E端=1)
OUT DX, AL
NOP
MOV AL,00000000B ; PC2置0,(LCD E端=0)
OUT DX, AL
NOP
ENDM
;-------------------LCD12864写数据宏OK------------------------
DATA_SETUP MACRO ; LCD写数据
MOV DX,PORT_C ; 指向8255控制端口C
MOV AL,00000001B ; PC1置0,PC0=1 (LCD I端=1)
OUT DX,AL
NOP
MOV AL,00000101B ; PC2置1 (LCD E端=1)
OUT DX,AL
NOP
MOV AL,00000001B ; PC2置0,(LCD E端=0)
OUT DX,AL
NOP
ENDM
;-------------------LCD12864显示字符OK------------------------
STRING_SHOW MACRO INT_N
LOCAL CONTINUE1
;一行显示几个汉字,INT_N为参数
MOV CL,INT_N
CONTINUE1:
PUSH CX
MOV AL,HZ_ADR
MOV DX, PORT_273 ;第一次,pa0=0
OUT DX, AL
CMD_SETUP ; 设定DDRAM地址命令
MOV AX,[BX]
PUSH AX
MOV AL,AH ; 先送汉字编码高位
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP ; 输出汉字编码高字节
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP ; 输出汉字编码低字节
INC BX
INC BX ; 修改显示内码缓冲区指针
INC BYTE PTR HZ_ADR ; 修改LCD显示端口地址 HZ_ADR是字节单元
POP CX
DEC CL
JNZ CONTINUE1
ENDM
START:
MOV AX,DATA
MOV DS,AX
MOV DX,PORT_CTL1
MOV AL,8AH
OUT DX,AL
MOV AL,00H
MOV FLAG,AL
CALL BEGIN
CALL DELAY3
CALL DELAY3
CALL DELAY3
CALL DELAY3
CALL DELAY3
CALL DELAY3
CALL DELAY3
CALL DELAY3
CALL DELAY3
CALL DELAY3
CALL DELAY3
CALL NEXT
MOV DX,PORT_CTL2
MOV AL,37H
OUT DX,AL
MOV AL,77H
OUT DX,AL
MOV DX,PORT_L0
MOV AL,20H
OUT DX,AL
MOV AL,00H
OUT DX,AL
MOV DX,PORT_L1
MOV AL,20H
OUT DX,AL
MOV AL,00H
OUT DX,AL
KEY:
MOV DX,PORT_A
MOV AL,00H
OUT DX,AL
MOV DX,PORT_B
WAIT_OPEN:
IN AL,DX
AND AL,0FH
CMP AL,0FH
JNE WAIT_OPEN
WAIT_PRES:
IN AL,DX
AND AL,0FH
CMP AL,0FH
JE STE1
MOV CX,00EAH
DELAY:LOOP DELAY
IN AL,DX
AND AL,0FH
CMP AL,0FH
JE STE1
MOV AL,0FEH
MOV CL,AL
NEXT_ROW:
MOV DX,PORT_A
OUT DX,AL
MOV DX,PORT_B
IN AL,DX
AND AL,0FH
CMP AL,0FH
JNE ENCODE
ROL CL,01
MOV AL,CL
JMP NEXT_ROW
ENCODE:
MOV BX,000FH
IN AL,DX
NEXT_TRY:
CMP AL,TABLE[BX]
JE DONE
DEC BX
JNS NEXT_TRY
MOV AH,01
JMP EXIT
DONE:
MOV AL,BL
MOV AH,00
JMP KEY_TEST
EXIT:HLT
STE1:
JMP FLAG_TEST
KEY_TEST:
CMP AL,00H
JZ ST0
CMP AL,01H
JZ ST1
CMP AL,02H
JZ ST2
CMP AL,03H
JZ ST3
CMP AL,04H
JZ ST4
CMP AL,05H
JZ ST5
CMP AL,06H
JZ ST6
CMP AL,07H
JZ ST7
CMP AL,08H
JZ ST8
CMP AL,09H
JZ ST9
CMP AL,0AH
JZ STA
CMP AL,0BH
JZ STB
CMP AL,0CH
JZ STC1
CMP AL,0DH
JZ STD1
ST3:
JMP KEY_3
ST4:
JMP KEY_4
ST7:
JMP KEY_7
ST8:
JMP KEY_8
ST9:
JMP KEY_9
STA:
JMP KEY_A
STB:
JMP KEY_B
STC1:
JMP KEY_C
ST5:
JMP KEY_5
ST6:
JMP KEY_6
ST2:
JMP KEY_2
STD1:
JMP KEY_D
ST0:
JMP KEY_0
ST1:
JMP KEY_1
FLAG_TEST:
MOV AL,FLAG
TEST AL,01H
JNZ FLAG_1
JMP FLAG_0
FLAG_0:
MOV AL,BUF
ROR AL,1
MOV BUF,AL
MOV AL,9CH
MOV DX, PORT_273
OUT DX, AL
CMD_SETUP
CALL DELAY4
MOV AX,0C4E6H
PUSH AX
MOV AL,AH
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP
CALL DELAY4
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP
CALL DELAY4
JMP OUT1
FLAG_1:
MOV AL,BUF
ROL AL,1
MOV BUF,AL
MOV AL,9CH
MOV DX, PORT_273
OUT DX, AL
CMD_SETUP
CALL DELAY4
MOV AX,0CBB3H
PUSH AX
MOV AL,AH
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP
CALL DELAY4
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP
CALL DELAY4
JMP OUT1
OUT1:
MOV AL,BUF
MOV DX,PORT_A
OUT DX,AL
MOV DX,PORT_C
TEMP:
IN AL,DX
TEST AL,80H
JZ TEMP
JMP KEY
KEY_0:
MOV AL,94H
MOV DX, PORT_273
OUT DX, AL
CMD_SETUP
CALL DELAY4
MOV AX,0D4CBH
PUSH AX
MOV AL,AH
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP
CALL DELAY4
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP
CALL DELAY4
MOV AL,95H
MOV DX, PORT_273
OUT DX, AL
CMD_SETUP
CALL DELAY4
MOV AX,0D0D0H
PUSH AX
MOV AL,AH
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP
CALL DELAY4
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP
CALL DELAY4
MOV AL,96H
MOV DX, PORT_273
OUT DX, AL
CMD_SETUP
CALL DELAY4
MOV AX,0D6D0H
PUSH AX
MOV AL,AH
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP
CALL DELAY4
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP
CALL DELAY4
JMP FLAG_TEST
KEY_1:
MOV AL,33H
MOV BUF,AL
MOV DX,PORT_L0
MOV AL,80H
OUT DX,AL
MOV AL,00H
OUT DX,AL
MOV DX,PORT_L1
MOV AL,00H
OUT DX,AL
MOV AL,10H
OUT DX,AL
MOV AL,8CH
MOV DX, PORT_273
OUT DX, AL
CMD_SETUP
CALL DELAY4
MOV AX,0A3B1H
PUSH AX
MOV AL,AH
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP
CALL DELAY4
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP
CALL DELAY4
JMP FLAG_TEST
KEY_2:
MOV AL,33H
MOV BUF,AL
MOV DX,PORT_L0
MOV AL,60H
OUT DX,AL
MOV AL,00H
OUT DX,AL
MOV DX,PORT_L1
MOV AL,00H
OUT DX,AL
MOV AL,10H
OUT DX,AL
MOV AL,8CH
MOV DX, PORT_273
OUT DX, AL
CMD_SETUP
CALL DELAY4
MOV AX,0A3B2H
PUSH AX
MOV AL,AH
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP
CALL DELAY4
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP
CALL DELAY4
JMP FLAG_TEST
KEY_3:
MOV AL,33H
MOV BUF,AL
MOV DX,PORT_L0
MOV AL,40H
OUT DX,AL
MOV AL,00H
OUT DX,AL
MOV DX,PORT_L1
MOV AL,00H
OUT DX,AL
MOV AL,10H
OUT DX,AL
MOV AL,8CH
MOV DX, PORT_273
OUT DX, AL
CMD_SETUP
CALL DELAY4
MOV AX,0A3B3H
PUSH AX
MOV AL,AH
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP
CALL DELAY4
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP
CALL DELAY4
JMP FLAG_TEST
KEY_4:
MOV AL,33H
MOV BUF,AL
MOV DX,PORT_L0
MOV AL,20H
OUT DX,AL
MOV AL,00H
OUT DX,AL
MOV DX,PORT_L1
MOV AL,00H
OUT DX,AL
MOV AL,10H
OUT DX,AL
MOV AL,8CH
MOV DX, PORT_273
OUT DX, AL
CMD_SETUP
CALL DELAY4
MOV AX,0A3B4H
PUSH AX
MOV AL,AH
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP
CALL DELAY4
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP
CALL DELAY4
JMP FLAG_TEST
KEY_5:
MOV AL,33H
MOV BUF,AL
MOV DX,PORT_L0
MOV AL,10H
OUT DX,AL
MOV AL,00H
OUT DX,AL
MOV DX,PORT_L1
MOV AL,00H
OUT DX,AL
MOV AL,10H
OUT DX,AL
MOV AL,8CH
MOV DX, PORT_273
OUT DX, AL
CMD_SETUP
CALL DELAY4
MOV AX,0A3B5H
PUSH AX
MOV AL,AH
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP
CALL DELAY4
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP
CALL DELAY4
JMP FLAG_TEST
KEY_6:
MOV AL,33H
MOV BUF,AL
MOV DX,PORT_L0
MOV AL,08H
OUT DX,AL
MOV AL,00H
OUT DX,AL
MOV DX,PORT_L1
MOV AL,00H
OUT DX,AL
MOV AL,10H
OUT DX,AL
MOV AL,8CH
MOV DX, PORT_273
OUT DX, AL
CMD_SETUP
CALL DELAY4
MOV AX,0A3B6H
PUSH AX
MOV AL,AH
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP
CALL DELAY4
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP
CALL DELAY4
JMP FLAG_TEST
KEY_7:
MOV AL,33H
MOV BUF,AL
MOV DX,PORT_L0
MOV AL,06H
OUT DX,AL
MOV AL,00H
OUT DX,AL
MOV DX,PORT_L1
MOV AL,00H
OUT DX,AL
MOV AL,10H
OUT DX,AL
MOV AL,8CH
MOV DX, PORT_273
OUT DX, AL
CMD_SETUP
CALL DELAY4
MOV AX,0A3B7H
PUSH AX
MOV AL,AH
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP
CALL DELAY4
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP
CALL DELAY4
JMP FLAG_TEST
KEY_8:
MOV AL,33H
MOV BUF,AL
MOV DX,PORT_L0
MOV AL,05H
OUT DX,AL
MOV AL,00H
OUT DX,AL
MOV DX,PORT_L1
MOV AL,00H
OUT DX,AL
MOV AL,10H
OUT DX,AL
MOV AL,8CH
MOV DX, PORT_273
OUT DX, AL
CMD_SETUP
CALL DELAY4
MOV AX,0A3B8H
PUSH AX
MOV AL,AH
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP
CALL DELAY4
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP
CALL DELAY4
JMP FLAG_TEST
KEY_9:
MOV AL,33H
MOV BUF,AL
MOV DX,PORT_L0
MOV AL,04H
OUT DX,AL
MOV AL,00H
OUT DX,AL
MOV DX,PORT_L1
MOV AL,00H
OUT DX,AL
MOV AL,10H
OUT DX,AL
MOV AL,8CH
MOV DX, PORT_273
OUT DX, AL
CMD_SETUP
CALL DELAY4
MOV AX,0A3B9H
PUSH AX
MOV AL,AH
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP
CALL DELAY4
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP
CALL DELAY4
JMP FLAG_TEST
KEY_A:
MOV AL,00H
MOV FLAG,AL
JMP FLAG_TEST
KEY_B:
MOV AL,01H
MOV FLAG,AL
JMP FLAG_TEST
KEY_C:
MOV DX,PORT_CTL2
MOV AL,10H
OUT DX,AL
MOV AL,50H
OUT DX,AL
MOV AL,94H
MOV DX, PORT_273
OUT DX, AL
CMD_SETUP
CALL DELAY4
MOV AX,0CDA3H
PUSH AX
MOV AL,AH
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP
CALL DELAY4
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP
CALL DELAY4
MOV AL,95H
MOV DX, PORT_273
OUT DX, AL
CMD_SETUP
CALL DELAY4
MOV AX,0D6B9H
PUSH AX
MOV AL,AH
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP
CALL DELAY4
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP
CALL DELAY4
MOV AL,96H
MOV DX, PORT_273
OUT DX, AL
CMD_SETUP
CALL DELAY4
MOV AX,0A1A0H
PUSH AX
MOV AL,AH
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP
CALL DELAY4
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP
CALL DELAY4
MOV AL,8CH
MOV DX, PORT_273
OUT DX, AL
CMD_SETUP
CALL DELAY4
MOV AX,0A3B0H
PUSH AX
MOV AL,AH
MOV DX,PORT_273
OUT DX,AL
DATA_SETUP
CALL DELAY4
POP AX
MOV DX,PORT_273
OUT DX, AL
DATA_SETUP
CALL DELAY4
JMP FLAG_TEST
KEY_D:
CALL ENDING
JMP STOP
DELAY3 PROC NEAR
MOV AL,BL
MOV BL,0FFH
DELAY1: MOV CX,0FFFFH
DELAY2: LOOP DELAY2
DEC BL
JNZ DELAY1
MOV AL,BL
RET
DELAY3 ENDP
DELAY4 PROC NEAR
MOV AL,BL
MOV BL,01H
DELAY5: MOV CX,000FH
DELAY6: LOOP DELAY6
DEC BL
JNZ DELAY5
MOV AL,BL
RET
DELAY4 ENDP
BEGIN PROC
MOV AX, DATA
MOV DS, AX
;----------------LCD清屏,显示欢迎界面--------------------
CALL CLEAR
MOV AL,0CH ; 显示
MOV DX,PORT_273
OUT DX,AL
CMD_SETUP ; 启动LCD执行命令
CALL LCD_DISP_INIT
; CALL DRAW_QR_CODE
CALL DELAY3
RET
BEGIN ENDP
NEXT PROC
MOV AX, DATA
MOV DS, AX
;----------------LCD清屏,显示欢迎界面--------------------
CALL CLEAR
MOV AL,0CH ; 显示
MOV DX,PORT_273
OUT DX,AL
CMD_SETUP ; 启动LCD执行命令
CALL LCD_SHOW
; CALL DRAW_QR_CODE
CALL DELAY3
RET
NEXT ENDP
;--------------------------LCD清屏函数------------------------------
CLEAR PROC
MOV AL,00000001B ; 清除控制字
MOV DX,PORT_273
OUT DX,AL
CMD_SETUP ; 启动LCD执行命令
RET
CLEAR ENDP
;--------------------------LCD初始化欢迎函数-------------------------
LCD_DISP_INIT PROC
CALL CLEAR
MOV AX,DATA
LEA BX, INIT_WELCOME ; 加载欢迎界面
MOV BYTE PTR HZ_ADR, 80H ; 第一行起始端口地址
STRING_SHOW 8
MOV BYTE PTR HZ_ADR, 90H ; 第二行起始端口地址
STRING_SHOW 8
MOV BYTE PTR HZ_ADR, 88H ; 第三行起始端口地址
STRING_SHOW 8
MOV BYTE PTR HZ_ADR, 98H ; 第四行起始端口地址
STRING_SHOW 8
RET
LCD_DISP_INIT ENDP
LCD_SHOW PROC
CALL CLEAR
MOV AX,DATA
LEA BX, SHOW ; 加载显示界面
MOV BYTE PTR HZ_ADR, 80H ; 第一行起始端口地址
STRING_SHOW 8
MOV BYTE PTR HZ_ADR, 90H ; 第二行起始端口地址
STRING_SHOW 8
MOV BYTE PTR HZ_ADR, 88H ; 第三行起始端口地址
STRING_SHOW 8
MOV BYTE PTR HZ_ADR, 98H ; 第四行起始端口地址
STRING_SHOW 8
RET
LCD_SHOW ENDP
LCD_CLEAR PROC
CALL CLEAR
MOV AX,DATA
LEA BX, CLEAR1 ; 加载显示界面
MOV BYTE PTR HZ_ADR, 80H ; 第一行起始端口地址
STRING_SHOW 8
MOV BYTE PTR HZ_ADR, 90H ; 第二行起始端口地址
STRING_SHOW 8
MOV BYTE PTR HZ_ADR, 88H ; 第三行起始端口地址
STRING_SHOW 8
MOV BYTE PTR HZ_ADR, 98H ; 第四行起始端口地址
STRING_SHOW 8
RET
LCD_CLEAR ENDP
ENDING PROC
MOV AX, DATA
MOV DS, AX
;----------------LCD清屏,显示欢迎界面--------------------
CALL CLEAR
MOV AL,0CH ; 显示
MOV DX,PORT_273
OUT DX,AL
CMD_SETUP ; 启动LCD执行命令
CALL LCD_CLEAR
; CALL DRAW_QR_CODE
CALL DELAY3
RET
ENDING ENDP
STOP:
JMP STOP
CODE ENDS
END START