用定时器让静态数码管一次亮
时间:10-02
整理:3721RD
点击:
定时器好像时间特别长,不知道哪错了,大神给看看吧
#include<reg51.h>
unsigned char code table[]={~0x3F,~0x06,~0x5B,~0x4F,~0x66,~0x6D,~0x7D,~0x07,~0x7F,~0x6F,~0x77,~0x7C,~0x39,~0x5E,~0x79,~0x71};
void main()
{ num=0;
tt=0;
TMOD=0x01;
TH0 =(65536-50000)/256;
TL0 =(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
P0=table[0];
while(1)
{
if(tt==20)
{ tt=0;
num++;
if(num==16)
num=0;
P0=table[num];
}
}
}
void timer0() interrupt 0
{
TH0 =(65536-50000)/256;
TL0 =(65536-50000)%256 ;
tt++;
}
#include<reg51.h>
unsigned char code table[]={~0x3F,~0x06,~0x5B,~0x4F,~0x66,~0x6D,~0x7D,~0x07,~0x7F,~0x6F,~0x77,~0x7C,~0x39,~0x5E,~0x79,~0x71};
void main()
{ num=0;
tt=0;
TMOD=0x01;
TH0 =(65536-50000)/256;
TL0 =(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
P0=table[0];
while(1)
{
if(tt==20)
{ tt=0;
num++;
if(num==16)
num=0;
P0=table[num];
}
}
}
void timer0() interrupt 0
{
TH0 =(65536-50000)/256;
TL0 =(65536-50000)%256 ;
tt++;
}
定时器T0 1