资源描述:
《微机原理课程设计——交通灯.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、80868259和82538255LED部分138地址译码程序:STACKSEGMENTSTACK'STACK'DW32DUP(0)STACKENDSDATASEGMENTTCOUNTDB18GREENDB30;绿灯30秒YELLOWDB5;黄灯5秒DATAENDSCODESEGMENTSTARTPROCFARASSUMESS:STACK,CS:CODE,DS:DATAPUSHDSMOVAX,0PUSHAXMOVES,AXMOVAX,DATAMOVDS,AXMOVAX,OFFSETTIMER;装入中断向量表MOVES:
2、20H,AXMOVAX,SEGTIMERMOVES:22H,AXMOVAL,36HOUT00H,AL;8253定时器0初始化,16位,方式3MOVAL,0;装入初值OUT00H,ALMOVAL,0OUT00H,ALMOVAL,80H;8255初始化方式0OUT07H,ALMOVAL,13H;8259初始化,单片,边沿触发OUT08H,ALMOVAL,8H;中断类型码为08H~0FHOUT09H,ALMOVAL,0DHOUT09H,ALSYS_ON:INAL,09H;开中断IRQ0ANDAL,0FEHOUT09H,ALM
3、OVAL,01H;开13方向绿灯,24方向红灯,关黄灯OUT06H,ALNEGALOUT04H,ALMOVAL,03HOUT05H,ALGRE_30:JMP$;等待计时中断DECGREEN;等待绿灯亮30秒JNZGRE_30MOVBX,OFFSETGREEN;复位计数器MOV[BX],30MOVAL,03H;关绿灯,开黄灯OUT06H,ALMOVAL,01HOUT05H,ALYEL_5:JMP$;等待计时中断MOVAL,01HMOVAH,03HSUBAH,ALXORAL,AH;黄灯状态取反OUT05H,ALDECYEL
4、LOW;每一秒改变一次状态,共5秒JNZYEL_5MOVBX,OFFSETYELLOW;复位计数器MOV[BX],5MOVAL,01H;点亮红灯OUT04H,ALMOVBX,OFFSET01HMOV[BX],AHMOVAL,03H;熄灭黄灯OUT05H,ALMOVAL,01H;24边绿灯亮OUT06H,ALJMPSYS_ON;循环RETTIMER:DECTCOUNT;是否计数18次JNZOVERMOVBX,OFFSETTCOUNT;复位计数器MOV[BX],18POPAXINCAXINCAXPUSHAXOVER:IRE
5、TSTARTENDPCODEEDNSENDSTART