拆字定时跑马灯.docx
《拆字定时跑马灯.docx》由会员分享,可在线阅读,更多相关《拆字定时跑马灯.docx(14页珍藏版)》请在冰豆网上搜索。
拆字定时跑马灯
拆字
ORG0000H
AJMPMAIN
MAIN:
MOVSP,#60H
MOVDPTR,#0E100H
MOVA,#3
MOVX@DPTR,A
MOV20H,#34H
MOVA,20H
ACALLDIY
LOOP:
MOVR0,#10H
MOVR1,#6
MOVR2,#1
ACALLDISPLAY
AJMPLOOP
DISPLAY:
MOVA,@R0;读显示数
MOV0FH,#8;164移位次数
ACALLP164;字形码输出子程序
ACALLPBIT;字位码输出子程序
ACALLDELAY;延时2ms
MOVA,#0;熄灭显示
MOVX@DPTR,A
INCR0;指向下一位显示数
DJNZR1,DISPLAY;没有显示完继续
RET
P164:
MOVDPTR,#TAB
MOVCA,@A+DPTR
P164_1:
RRCA
MOVR3,A
MOVACC.0,C
ANLA,#0FDH
MOVDPTR,#0E102H
MOVX@DPTR,A
ORLA,#0FEH
MOVX@DPTR,A
MOVA,R3
DJNZ0FH,P164_1
MOV0FH,#8
RET
PBIT:
MOVDPTR,#0E101H
MOVA,R2
MOVX@DPTR,A
RLA
MOVR2,A
RET
DELAY:
MOVR6,#4
DEL:
MOVR7,#250
DJNZR7,$
DJNZR6,DEL
RET
TAB:
DB0FCH,60H,0DAH,0F2H,66H,0B6H,0BEH,0E0H
DB0FEH,0F6H,0EEH,3EH,9CH,7AH,9EH,8EH
DIY:
MOVB,#10H
DIVAB
MOV10H,#9
MOV11H,#0
MOV12H,#3
MOV13H,#0
MOV14H,#2
MOV15H,#1
RET
END
定时程序
实现1ms定时,跑马灯
ORG0000H
AJMPMAIN
ORG001BH
AJMPINT_1
ORG0030H
MAIN:
MOVSP,#60H
MOVTMOD,#10H
MOVTH1,#4BH
MOVTL1,#0FDH
MOVR1,#20
SETBET1
SETBEA
SETBTR1
MOVDPTR,#TAB
MOVR2,#0
AJMP$
INT_1:
MOVTH1,#4BH
MOVTL1,#0FDH
DJNZR1,EXTI
MOVR1,#20
MOVA,R2
MOVCA,@A+DPTR
MOVP1,A
INCR2
CJNER2,#8,EXTI
MOVR2,#0
EXTI:
RETI
TAB:
DB0FFH,0FAH,0F5H,0AFH,5FH,55H,0AAH,00H
END
0.25M8分频计数并口显示81c55计数器0计数接线为p3.4verygood!
ORG0000H
AJMPMAIN
ORG001BH
AJMPINT_1
ORG0030H
MAIN:
MOVSP,#60H
MOVDPTR,#0E110H
MOVA,#3
MOVX@DPTR,A
MOVTMOD,#15H
MOVTH1,#4BH
MOVTL1,#0FDH
MOVR4,#20
MOVTH0,#0
MOVTL0,#0
SETBET1
SETBEA
SETBTR1
SETBTR0
LOOP:
MOVR0,#10H
MOVR1,#4
MOVR2,#1
ACALLDISPLAY
AJMPLOOP
INT_1:
MOVTH1,4BH
MOVTL1,0FDH
DJNZR4,EXIT
MOVR4,#20
PUSHACC
MOVA,TL0
MOVTL0,#0
MOVB,#10H
DIVAB
MOV10H,B
MOV11H,A
MOVA,TH0
MOVTH0,#0
MOVB,#10H
DIVAB
MOV12H,B
MOV13H,A
POPACC
EXIT:
RETI
DISPLAY:
MOVA,@R0;读显示数
MOV0FH,#8;164移位次数
ACALLP164;字形码输出子程序
ACALLPBIT;字位码输出子程序
ACALLDELAY;延时2ms
MOVA,#0;熄灭显示
MOVX@DPTR,A
INCR0;指向下一位显示数
DJNZR1,DISPLAY;没有显示完继续
RET
P164:
MOVDPTR,#TAB
MOVCA,@A+DPTR
P164_1:
RRCA
MOVR3,A
MOVACC.0,C
ANLA,#0FDH
MOVDPTR,#0E102H
MOVX@DPTR,A
ORLA,#0FEH
MOVX@DPTR,A
MOVA,R3
DJNZ0FH,P164_1
MOV0FH,#8
RET
PBIT:
MOVDPTR,#0E101H
MOVA,R2
MOVX@DPTR,A
RLA
MOVR2,A
RET
DELAY:
MOVR6,#4
DEL:
MOVR7,#250
DJNZR7,$
DJNZR6,DEL
RET
TAB:
DB0FCH,60H,0DAH,0F2H,66H,0B6H,0BEH,0E0H
DB0FEH,0F6H,0EEH,3EH,9CH,7AH,9EH,8EH
END
实验四串并转换
显示A接线p1.0接DINp1.1接CLK,没有消隐,后三位有的显示乱码!
Verygood!
ORG0000H
AJMPMAIN
ORG0030H
MAIN:
MOVSP,#60H
MOVA,#0EEH
MOVR4,#8
ACALLS164
AJMP$
S164:
RRCA
MOVP1.0,C
CLRP1.1
SETBP1.1
DJNZR4,S164
RET
END
第一位显示A后三位数码管不显示verygood!
此程序消隐了的,后三位不显示
ORG0000H
AJMPMAIN
ORG0030H
MAIN:
MOVSP,#60H
/*MOVA,#7AH//D
MOVR4,#8
ACALLS164
MOVA,#9CH//C
MOVR4,#8
ACALLS164
MOVA,#3EH//B
MOVR4,#8
ACALLS164*/
CLRC
MOVA,#0
MOVR4,#24
ACALLS164
MOVA,#0EEH//A
MOVR4,#8
ACALLS164
AJMP$
S164:
RRCA
MOVP1.0,C
CLRP1.1
SETBP1.1
DJNZR4,S164
RET
END
前三个显示黑的第四个显示A
先让四个数码管都显示A,然后将前三位清零
ORG0000H
AJMPMAIN
ORG0030H
MAIN:
MOVSP,#60H
/*MOVA,#7AH//D
MOVR4,#8
ACALLS164
MOVA,#9CH//C
MOVR4,#8
ACALLS164
MOVA,#3EH//B
MOVR4,#8
ACALLS164*/
MOVR2,#4
MOVR3,#3
LOOP:
MOVA,#0EEH//显示A
MOVR4,#8
ACALLS164
DJNZR2,LOOP
LOOP1:
CLRC
MOVA,#0
MOVR4,#8
ACALLS164
DJNZR3,LOOP1
AJMP$
/*CLRC
MOVA,#0
MOVR4,#24
ACALLS164
AJMP$
/*MOVA,#0EEH//A
MOVR4,#24
ACALLS164*/
/*
CLRC
MOVA,#0
MOVR4,#8
ACALLS164
CLRC
MOVA,#0
MOVR4,#8
ACALLS164*/
S164:
RRCA
MOVP1.0,C
CLRP1.1
SETBP1.1
DJNZR4,S164
RET
END
四要求:
用定时器T1定时每隔一秒循环显示0—F之间的数串口显示verygood!
ORG0000H
AJMPMAIN
ORG001BH
AJMPINT_1
ORG0030H
MAIN:
MOVSP,#60H
MOVTMOD,#10H
MOVTH1,#4BH
MOVTL1,#0FDH
MOVR1,#20
MOVR5,#0
SETBET1
SETBEA
SETBTR1
MOVDPTR,#TAB
AJMP$
INT_1:
MOVTH1,#4BH
MOVTL1,#0FDH
DJNZR1,EXTI
MOVR1,#20
CLRC
MOVA,#0
MOVR4,#24
ACALLS164
MOVA,R5
MOVCA,@A+DPTR
MOVR4,#8
ACALLS164
//MOVR2,#4
//MOVR3,#3
/*LOOP:
MOVR4,#8
ACALLS164
DJNZR2,LOOP
CLRC
MOVA,#0
MOVR4,#24
ACALLS164*/
INCR5
CJNER5,#16,EXTI
MOVR5,#0
EXTI:
RETI
S164:
RRCA
MOVP1.0,C
CLRP1.1
SETBP1.1
DJNZR4,S164
RET
TAB:
DB0FCH,60H,0DAH,0F2H,66H,0B6H,0BEH,0E0H
DB0FEH,0F6H,0EEH,3EH,9CH,7AH,9EH,8EH
END
第一位和第四位显示0——FVERYGOOD!
ORG0000H
AJMPMAIN
ORG001BH
AJMPINT_1
ORG0030H
MAIN:
MOVSP,#60H
MOVTMOD,#10H
MOVTH1,#4BH
MOVTL1,#0FDH
MOVR1,#20
MOVR5,#0
SETBET1
SETBEA
SETBTR1
MOVDPTR,#TAB
AJMP$
INT_1:
MOVTH1,#4BH
MOVTL1,#0FDH
DJNZR1,EXTI
MOVR1,#20
MOVA,R5//在第四个数码管显示
MOVCA,@A+DPTR
MOVR4,#8
ACALLS164
CLRC//将二三个数码管清零
MOVA,#0
MOVR4,#16
ACALLS164
MOVA,R5//第一个数码管显示
MOVCA,@A+DPTR
MOVR4,#8
ACALLS164
//MOVR2,#4
//MOVR3,#3
/*LOOP:
MOVR4,#8
ACALLS164
DJNZR2,LOOP
CLRC
MOVA,#0
MOVR4,#24
ACALLS164*/
INCR5
CJNER5,#16,EXTI
MOVR5,#0
EXTI:
RETI
S164:
RRCA
MOVP1.0,C
CLRP1.1
SETBP1.1
DJNZR4,S164
RET
TAB:
DB0FCH,60H,0DAH,0F2H,66H,0B6H,0BEH,0E0H
DB0FEH,0F6H,0EEH,3EH,9CH,7AH,9EH,8EH
END