您的位置:控制工程论坛网论坛 » 教程与手册 » 拉幕式数码显示技术

xilinxue

xilinxue   |   当前状态:在线

总积分:16186  2024年可用积分:0

注册时间: 2008-06-26

最后登录时间: 2020-03-22

空间 发短消息加为好友

拉幕式数码显示技术

xilinxue  发表于 2008/9/20 13:15:42      642 查看 0 回复  [上一主题]  [下一主题]

手机阅读

DISPBUF         EQU 30H
DISPCNT         EQU 38H
DISPBIT         EQU 39H
T1CNTA          EQU 3AH
T1CNTB          EQU 3BH
CNT             EQU 3CH

                ORG 00H
;*******************************************************************************************
;程序开始
;******************************************************************************************* 
             LJMP START
                ORG 0BH
;*******************************************************************************************
;定时器T0中断服务程序入口
;*******************************************************************************************
                LJMP INT_T0
;*******************************************************************************************
;主程序开始
;*******************************************************************************************
START:          MOV DISPCNT,#8
                MOV A,#10
                MOV R1,#DISPBUF
LP:             MOV @R1,A
                INC R1                                                    
                DJNZ DISPCNT,LP                                         ;DISPBUF为首的存储区初始化
                MOV DISPBIT,#00H
                MOV T1CNTA,#00H
                MOV T1CNTB,#00H
                MOV CNT,#00H
                MOV TMOD,#01H                                           ;定时器T0工作在方式1
                MOV TH0,#(65536-1000) / 256
                MOV TL0,#(65536-1000) MOD 256                           ;装定时器T0初值
                SETB TR0                                                ;允许定时器T0计数                                            
                SETB ET0                                                ;允许定时器T0中断  
                SETB EA                                                 ;开中断   
                SJMP $

;*******************************************************************************************
;定时器T0中断服务程序
;*******************************************************************************************
INT_T0:
                MOV TH0,#(65536-1000) / 256
                MOV TL0,#(65536-1000) MOD 256
                MOV A,DISPBIT
                ADD A,#DISPBUF
                MOV R0,A
                MOV A,@R0
                MOV DPTR,#TABLE
                MOVC A,@A+DPTR
                MOV P0,A                                                ;通过查表方式,获得显示代码送入P0
                MOV A,P1
                ANL A,#0F8H
                ADD A,DISPBIT
                MOV P1,A               
                INC DISPBIT
                MOV A,DISPBIT
                CJNE A,#08H,NEXT
                MOV DISPBIT,#00H
NEXT:           INC T1CNTA
                MOV A,T1CNTA
                CJNE A,#50,LL1
                MOV T1CNTA,#00H
                INC T1CNTB
                MOV A,T1CNTB
                CJNE A,#8,LL1
                MOV T1CNTB,#00H
                INC CNT                                                 ; 0.4秒定时到了,则CNT加1
                MOV A,CNT
                CJNE A,#9,LLX
                MOV CNT,#00H
                MOV A,CNT
LLX:            CJNE A,#01H,NEX1
                MOV 30H,#1
LL1:            LJMP DONE
NEX1:           CJNE A,#02H,NEX2
                MOV 31H,#1
                MOV 30H,#2
                LJMP DONE
NEX2:           CJNE A,#03H,NEX3
                MOV 32H,#1
                MOV 31H,#2
                MOV 30H,#3
                LJMP DONE
NEX3:           CJNE A,#04H,NEX4
                MOV 33H,#1
                MOV 32H,#2
                MOV 31H,#3
                MOV 30H,#4
                LJMP DONE
NEX4:           CJNE A,#05H,NEX5
                MOV 34H,#1
                MOV 33H,#2
                MOV 32H,#3
                MOV 31H,#4
                MOV 30H,#5
                LJMP DONE
NEX5:           CJNE A,#06H,NEX6
                MOV 35H,#1
                MOV 34H,#2
                MOV 33H,#3
                MOV 32H,#4
                MOV 31H,#5
                MOV 30H,#6
                LJMP DONE
NEX6:           CJNE A,#07H,NEX7
                MOV 36H,#1
                MOV 35H,#2
                MOV 34H,#3
                MOV 33H,#4
                MOV 32H,#5
                MOV 31H,#6
                MOV 30H,#7
                LJMP DONE
NEX7:           CJNE A,#08H,NEX8
                MOV 37H,#1
                MOV 36H,#2
                MOV 35H,#3
                MOV 34H,#4
                MOV 33H,#5
                MOV 32H,#6
                MOV 31H,#7
                MOV 30H,#8
                LJMP DONE
NEX8:           CJNE A,#00H,DONE
                MOV 37H,#10
                MOV 36H,#10
                MOV 35H,#10
                MOV 34H,#10
                MOV 33H,#10
                MOV 32H,#10
                MOV 31H,#10
                MOV 30H,#10
LL:             LJMP DONE
DONE:           RETI
TABLE:          DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH,00H
                END
;*******************************************************************************************
;在进行数码显示的时候,要对显示单元开辟8个显示缓冲区,每个显示缓冲区装有显示的不同数据即可。
;*******************************************************************************************

1楼 0 0 回复