十字路口电子交警的设计与功能实现学院:计算机与控制工程学院指导老师:邱秀芹时间:2012.12.18一、设计内容:设计十字路口交通灯及撞红灯报警控制系统,并实现两种功能。二、设计要求:①用8255A驱动三种颜色的发光二极管,模拟十字路口交通灯的功能。②当某一方向的红灯亮吋,若该方向有车辆通过,则通过扬声器发声报警,告警声音要有所区别。③通过LED显示倒计时。三、程序流程图:1.流程总图开始初始化8255,初始化8259是是否有屮断?执行交通灯交替程执行响铃中断序和倒计时显示程子程序序2.交通灯与倒计吋程序流程图南北亮红灯,东两亮绿灯,标志位为1十次软件延时与数码灯S示南北亮黄灯,东西亮黄灯,标志位为2,南北壳绿灯,东西壳红灯,标志位为3十次软件延时与数码灯显示南北亮黄灯,东西亮黄灯,标志位为2,3.响铃中断子程序等于1或3?初始化8254,执行响铃程序BEGINY返出中断初始化8254,执行响铃程序BEGIN四、硬件接线图1.8255与LED连线开关及LEC显示中元D15DO•••PAOD7•■PA7AOA1PBO•礬•WRPB7RDcs8255中元-------0--------O--------0--------0-——O-XDXA1XA2IOW^IOR:I0Y1系统总线2.8255与数码管连线键盘及数码符显1•小节元GDP12345601234567012345BBBBB.BBBAAAAAApppppppppppppp8255申元DOI.SAOAlwRDcs-O--------0XDO拳•系统eXD7XA1总XA2线IOW舞IOR^IOYI-------O--------O--------O--------O--------O-3.中断出发连线申次咏冲单元KK1系统总XIIR7线主82594.8254响铃连线DO•嚳響瞻GATEO丄D7CLKOA0■A1OTrrn_____o_______o—WR—RD—CS8254单元|vccCLK系统总线SPK电千发声中元五、程序代码SSTACKSEGMENTSTACKDW32DUP(?)SSTACKENDSDATASEGMENTDTABLEDB6FH,7FH,07H,7DH,6DH,66H,4FH,5BH,06H,3FHCOUNTDB?FREQ_LISTDW475TIME_LISTDB4FREQ_LDW221DATAENDSCODESEGMENTASSUMECS:CODE,DS:DATASTART:MOVAX,DATAMOVDS,AXMOVDX,0646HMOVAL,80H//初始化8255工作方式,输出a,b,cOUTDX,ALPUSHDSMOVAX,0000HMOVDS,AXMOVAX,OFFSETMIR7;収屮断入丨1地址;中断矢量地址;填IRQ7的偏移矢最;段地址MOVSI,003EHMOV[SI],AX:填IRQ7的段地址矢量CLIPOPDS;初始化主片8259MOVAL,11HOUT20H,AL;ICW1MOVAL,OSHOUT21H,ALMOVAL,04H;ICW2OUT21H,ALMOVAL,01H;ICW3OUT21H,AL;ICW4MOVAL,6FHOUT21H,ALSTI;OCWAA1:MOVCOUNT,1MOVDX,0640HMOVAL,82HOUTDX,ALPUSHDXMOVSI,003CHMOV[SI1,AXMOVAX,CSPUSHBXMOVDX,0644HMOVAL,11111110BOUTDX,ALMOVDX,0642HMOVBX,OFFSETDTABLEMOVAL,DS:[BX]OUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYMOVAL,DS:[BX]OUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYMOVAL,DS:[BX]OUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYMOVAL,DS:[BX]OUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYMOVAL,DS:LBXJOUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYMOVAL,DS:[BX]OUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYMOVAL,DS:[BX1OUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYMOVAL,DS:[BX]OUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYMOVAL,DS:[BX]OUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYMOVAL,DS:LBXJOUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYPOPBXPOPDXAA2:MOVCOUNT,2MOVDX,0640HMOVAL,18HOUTDX,ALCALLDELAYCALLDELAYCALLDELAYAA3:MOVCOUNT,3MOVDX,0640HMOVAL,44HOUTDX,ALPUSHDXPUSHBXMOVDX,0644HMOVAL’lllllllOBOUTDX,ALMOVDX,0642HMOVBX,OFFSETDTABLEMOVAL,DS:[BX]OUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYMOVAL,DS:LBXJOUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYMOVAL,DS:[BX]OUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYMOVAL,DS:[BX1OUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYMOVAL,DS:[BX]OUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYMOVAL,DS:[BX]OUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYMOVAL,DS:IBXJOUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYMOVAL,DS:[BX]OUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYMOVAL,DS:[BX1OUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYMOVAL,DS:[BX]OUTDX,ALINCBXCALLDELAYCALLDELAYCALLDELAYPOPBXPOPDXAA4:MOVCOUNT,4MOVDX,...