【037】多位数码管动态显示定时器中断实现2007-05-05 16:23:00
【评论】
【打印】
【字体:大 中 小】
本文链接:http://blog.pfan.cn/wentao/25591.html
org 0000h
ajmp start
org 000bh
ajmp time0
org 0030h
start: mov 30h,#0
mov 31h,#0xfe
mov p2,#0xff
mov dptr,#table
mov tmod,#00000001b
mov th0,#0xfc
mov tl0,#0x18
setb ea
setb et0
setb tr0
ajmp $
time0:
clr ea
push acc
push psw
mov a,30h
movc a,@a+dptr
mov p0,a
mov p2,31h
mov a,31h
rl a
mov 31h,a
inc 30h
anl 30h,#0x07
mov th0,#0xfc
mov tl0,#0x18
pop psw
pop acc
setb ea
reti
table: db 0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8
db 0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e
end
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
uchar code dis_code[16] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
uchar data i = 0x00;
uchar data j = 0xfe;
void main()
{
P2 = 0xff;
TMOD = 0x01;
TH0 = 0xfc;
TL0 = 0x18;
EA = 1;
ET0 = 1;
TR0 = 1;
while(1);
}
void time0(void) interrupt 1
{
P2 = j;
P0 = dis_code[i];
j = _crol_(j,1);
i++;
i &= 0x07;
TH0 = 0xfc;
TL0 = 0x18;
}
阅读(6654) | 评论(1)
版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!
评论