单片机课程设计报告 交通灯控制.docx
- 文档编号:3865345
- 上传时间:2022-11-26
- 格式:DOCX
- 页数:16
- 大小:390.62KB
单片机课程设计报告 交通灯控制.docx
《单片机课程设计报告 交通灯控制.docx》由会员分享,可在线阅读,更多相关《单片机课程设计报告 交通灯控制.docx(16页珍藏版)》请在冰豆网上搜索。
单片机课程设计报告交通灯控制
ORG0H;入口地址
LJMPMAIN
ORG0013H
LJMPINT
MAIN:
SETBEA;开中断
SETBEX1;外部中断1
SETBPX1
SETBIT1;允许定时器T1
MOVTMOD,#10H;设置工作方式
LOOP31:
MOVR3,#2DH
MOVR1,#00H
MOVDPTR,#TAB
MOVA,R1
MOVCA,@A+DPTR;查表
MOVR5,#05H
MOVR4,#00H
MOV7AH,R5;显示缓冲区首地址
MOV79H,R4
MOVP1,A;P1口显示
LCALLDISP;显示程序
LOOP:
LCALLDISP
MOVR2,#0AH
LOOP2:
LCALLDISP
MOVTH1,#3CH;设置计数初值
MOVTL1,#0B0H
SETBTR1;启动
LOOP1:
LCALLDISP
JNBTF1,LOOP1
CLRTF1
DJNZR2,LOOP2;1s定时
MOVA,R4
MOVR7,A
INCR7
DECR4
DJNZR7,LOOP40
MOVR4,#09H
DECR5
LOOP40:
MOV7AH,R5;数码管显示
MOV79H,R4
LCALLDISP
DJNZR3,LOOP
INCR1
MOVA,R1
MOVDPTR,#TAB
MOVCA,@A+DPTR
MOVP1,A;黄灯亮数码管显示5s
MOVR5,#00H
MOVR4,#05H
MOV7AH,R5
MOV79H,R4
LCALLDISP
LCALLDISP
MOVR2,#0AH
LOOP20:
LCALLDISP;100ms定时
MOVTH1,#3CH
MOVTL1,#0B0H
LOOP3:
LCALLDISP
JNBTF1,LOOP3
CLRTF1
DJNZR2,LOOP20;1s定时
MOVR5,#00H;
MOVR4,#04H
MOV7AH,R5
MOV79H,R4
LCALLDISP
INCR1
MOVA,R1
MOVDPTR,#TAB
MOVCA,@A+DPTR
MOVP1,A;黄灯闪烁
MOVR2,#0AH
LOO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OVR4,#09H
DECR5
LOOP41:
MOV7AH,R5
MOV79H,R4
LCALLDISP
DJNZR3,LOOP25;50递减至45
INCR1
MOVA,R1
MOVDPTR,#TAB
MOVCA,@A+DPTR
MOVP1,A;黄灯亮
MOVR5,#00H;
MOVR4,#05H
MOV7AH,R5
MOV79H,R4
LCALLDISP
MOVR2,#0AH
LOOP26:
LCALLDISP
MOVTH1,#3CH
MOVTL1,#0B0H
LOOP10:
LCALLDISP
JNBTF1,LOOP10
CLRTF1
DJNZR2,LOOP26
INCR1
MOVA,R1;黄灯闪烁
MOVDPTR,#TAB
MOVCA,@A+DPTR
MOVP1,A
MOVR5,#00H;
MOVR4,#04H
MOV7AH,R5
MOV79H,R4
LCALLDISP
MOVR2,#0AH
LOOP27:
LCALLDISP
MOVTH1,#3CH
MOVTL1,#0B0H
LOOP11:
LCALLDISP;1s定时,黄灯亮显示3s
JNBTF1,LOOP11
CLRTF1
DJNZR2,LOOP27
INCR1
MOVA,R1
MOVDPTR,#TAB
MOVCA,@A+DPTR
MOVP1,A
MOVR5,#00H;
MOVR4,#03H
MOV7AH,R5
MOV79H,R4
LCALLDISP
MOVR2,#0AH
LOOP28:
LCALLDISP
MOVTH1,#3CH
MOVTL1,#0B0H
LOOP12:
LCALLDISP;定时1s黄灯交替闪烁
JNBTF1,LOOP12
CLRTF1
DJNZR2,LOOP28
INCR1
MOVA,R1
MOVDPTR,#TAB
MOVCA,@A+DPTR
MOVP1,A
MOVR5,#00H;
MOVR4,#02H
MOV7AH,R5
MOV79H,R4
LCALLDISP;数码管显示
MOVR2,#0AH
LOOP29:
LCALLDISP
MOVTH1,#3CH
MOVTL1,#0B0H
LOOP13:
LCALLDISP
JNBTF1,LOOP13
CLRTF1
DJNZR2,LOOP29;1s定时
INCR1
MOVA,R1
MOVDPTR,#TAB
MOVCA,@A+DPTR
MOVP1,A
MOVR5,#00H;
MOVR4,#01H
MOV7AH,R5
MOV79H,R4
LCALLDISP;显示
MOVR2,#0AH
LOOP30:
LCALLDISP
MOVTH1,#3CH
MOVTL1,#0B0H
LOOP14:
LCALLDISP
JNBTF1,LOOP14
CLRTF1
DJNZR2,LOOP30
INCR1
MOVA,R1
MOVDPTR,#TAB
MOVCA,@A+DPTR
MOVP1,A
MOVR5,#00H;
MOVR4,#00H
MOV7AH,R5
MOV79H,R4
LCALLDISP
LJMPLOOP31
TAB:
DB0CH,14H,04H,14H,04H,14H,21H,22H,20H,22H,20H,22H;P1口控制
INT:
MOVA,P1
ZT:
JBP3.0,HF;开关控制
MOVP1,#24H
SJMPZT
HF:
MOVP1,A
RETI
DISP:
MOVDPTR,#0FF20H;命令口
MOVA,#03H
MOVX@DPTR,A
MOVR6,#01H
MOVR0,#79H
MOVA,@R0
MOVDPTR,#TAB1
MOVCA,@A+DPTR
MOVDPTR,#0FF22H;段选
MOVX@DPTR,A
MOVDPTR,#0FF21H
MOVA,R6
MOVX@DPTR,A;位选
LCALLDELL
INCR0
MOVA,@R0
MOVDPTR,#TAB1
MOVCA,@A+DPTR
MOVDPTR,#0FF22H
MOVX@DPTR,A
MOVDPTR,#0FF21H
MOVA,R6
RLA
MOVX@DPTR,A
LCALLDELL
RET
DELL:
MOV32H,#0FFH;延时程序
LOOP36:
DJNZ32H,LOOP36
RET
TAB1:
DB0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H
END
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 单片机课程设计报告 交通灯控制 单片机 课程设计 报告 交通灯 控制