#include"reg51.h"
unsigned char num=0,count=0;
unsigned char s[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0xff,0x7f};
void inittimer()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
ET0=1;
EA=1;
TR0=1;
}
void display()
{
P2=s[num];
if(num==10)
{
num=0;
}
}
void main()
{
inittimer();
while(1)
{
display();
}
}
void timer_isr() interrupt 1//中断服务函数
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
count++;
if(count==20)
{
num++;
count=0;
}
}
定时器keil代码
最新推荐文章于 2024-05-07 00:07:28 发布