利用Keil uVision4编程程序,在Proteus 8 Professional中创建仿真电路
仿真电路
程序代码
#include<reg51.h>
code unsigned char seven_seg[10] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char cp,i;
void timer0_isr(void) interrupt 1
{
TL0 = 0x78;
TH0 = 0xEC;
cp++;
if(cp >= 200)
{cp = 0;i++;}
if(i == 10)i = 0;
P0 = seven_seg[i];
}
void timer0_init(void)
{
TMOD = 0x01;
TL0 = (65536 - 5000) % 256;
TH0 = (65536 - 5000) / 256;
EA = 1;
ET0 = 1;
TR0 = 1;
}
void main(void)
{
timer0_init();
P2 = 0;
while(1);
}
资源链接
链接:https://pan.baidu.com/s/1HO6tiqHpjFBlTBN5m-dVNg?pwd=9999
提取码:9999