【024】定时器和硬计数器实现1个LED隔1s闪一次2007-05-02 12:38:00
【评论】
【打印】
【字体:大 中 小】
本文链接:http://blog.pfan.cn/wentao/25460.html
org 0000h
ajmp start
org 000bh
ajmp time0
org 001bh
ajmp cout1
org 0030h
start: clr p1.0
mov tmod,#01100001b
mov th0,#0x3c
mov tl0,#0xb0
mov th1,#0xf6
mov tl1,#0xf6
mov ip,#00001000b
setb ea
setb et0
setb et1
setb tr0
setb tr1
lop: ajmp lop
time0:
push acc
push psw
setb p1.1
clr p1.1
mov th0,#0x3c
mov tl0,#0xb0
pop psw
pop acc
reti
cout1:
push acc
push psw
cpl p1.0
pop psw
pop acc
reti
end
#include <reg51.h>
sbit P10 = P1^0;
sbit P11 = P1^1;
main()
{
P10 = 0;
TMOD = 0x61;
TH0 = 0x3c;
TL0 = 0xb0;
TH1 = 0xf6;
TL1 = 0xf6;
IP = 0x08;
EA = 1;
ET0 = 1;
ET1 = 1;
TR0 = 1;
TR1 = 1;
while(1);
}
void time0_int(void) interrupt 1
{
P11 = 1;
P11 = 0;
TH0 = 0x3c;
TL0 = 0xb0;
}
void count1_int(void) interrupt 3
{
P10 = !P10;
}

阅读(3809) | 评论(1)
版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!
评论