设计要求:
控制一个数码管循环显示0~9
硬件电路图连接
程序
#include<reg52.h>
unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; //共阴段码表
unsigned char count,timer;
void t0_init()
{
TMOD = 0x01; //软件启动定时器T0,方式1 0000 0001
IE = 0x82; //EA=1,ET0=1,开总中断,开启定时器T0中断 1000 0001
TR0 = 1; //使能定时器T0中断
TH0 = 0x3c;
TL0 = 0xb0; //单次定时初值为50ms
}
void main()
{
t0_init();
count = 0;
timer = 0;
while(1);
}
void t0_func() interrupt 1
{
TH0 = 0x3c; //预置初值
TL0 = 0xb0;
if(