Your potential,My passion!!!

//C51单片机+8155+数码显示 //两组红绿灯,红灯显示30s,绿灯显示25s,黄灯显示5s并闪烁. org 0100h ajmp main main: mov sp,#30h setb p3.2 acall INIT8155 mov tmod,#1 mov th0,#0h mov tl0,#0h mov ie,#0 setb tr0 mm: mov r1,#1eh mov r2,#19h mov p1,#0f3h //11110011 setb p3.2 mov r3,#19h m1: acall delay1 djnz r3,m1 acall INIT mov r2,#05h mov r1,#05h mov p1,#0f5h setb p3.2 mov r3,#05h m2: acall delay1 cpl p1.1 djnz r3,m2 acall INIT mov p1,#0feh clr p3.2 mov r1,#19h mov r2,#1eh mov r3,#19h m3: acall delay1 djnz r3,m3 mov p1,#0eeh setb p3.2 mov r1,#05h mov r2,#05h mov r3,#05h m4: acall delay1 cpl p1.4 djnz r3,m4 ajmp mm delay1: jnb tf0,$ clr tf0 acall compute mov 2bh,#047h loop: mov dptr,#table mov a,r5 movc a,@a+dptr mov r0,#0feh acall display mov a,r4 mov dptr,#table movc a,@a+dptr mov r0,#0fdh acall display mov a,r7 mov dptr,#table movc a,@a+dptr mov r0,#0fbh acall display mov a,r6 mov dptr,#table movc a,@a+dptr mov r0,#0f7h acall display djnz 2bh,loop dec r1 dec r2 ret compute: mov a,r1 mov b,#0ah div ab mov r4,a mov a,b mov r5,a mov a,r2 mov b,#0ah div ab mov r6,a mov a,b mov r7,a ret display: mov 2ah,#0ffh mov 2ch,a dis1:mov a,2ch mov dptr,#0f102h movx @dptr,a mov dptr,#0f101h mov a,r0 movx @dptr,a djnz 2ah,dis1 ret INIT:mov th0,#0h mov tl0,#0h ret INIT8155: mov dptr,#0f100h mov a,#03h movx @dptr,a ret table:db 3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh,77h,7ch end
阅读更多
文章标签: delay div table ie
下一篇键盘控制:
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭