为什么仿真软件秒表不能正常运行?
时间:10-02
整理:3721RD
点击:
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
#define ulong unsigned long
uchar code num[]={0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x90};
uchar a[6];
uchar counter=0;
sbit A1=P2^5;
sbit A2=P2^4;
sbit A3=P2^3;
sbit A4=P2^2;
sbit A5=P2^1;
sbit A6=P2^0;
void t1_int()
{
TMOD |=0X10;
TMOD &=0xdf;
TH1=0xfc;
TL1=0x67;
TR1=1;
}
void int_init()
{
ET1=1;
EA=1;
}
void refresh()
{
static uchar j=0;
switch(j)
{
case 0:A1=0;A2=0;A3=0;A4=0;A5=0;A6=1;j++;P0=num[a[0]]; break;
case 1:A1=0;A2=0;A3=0;A4=0;A5=1;A6=0;j++;P0=num[a[1]]; break;
case 2:A1=0;A2=0;A3=0;A4=1;A5=0;A6=0;j++;P0=num[a[2]]; break;
case 3:A1=0;A2=0;A3=1;A4=0;A5=0;A6=0;j++;P0=num[a[3]]; break;
case 4:A1=0;A2=1;A3=0;A4=0;A5=0;A6=0;j++;P0=num[a[4]]; break;
case 5:A1=1;A2=0;A3=0;A4=0;A5=0;A6=0;j=0;P0=num[a[5]]; break;
default:break;
}
}
void main()
{
t1_int();
int_init();
while(1);
}
void t1()interrupt 3
{
static ulong sec=0;
TH1=0xfc;
TL1=0x67;
counter++;
if(counter==1000)
{
sec++;
counter=0;
a[0]=sec%10;
a[1]=sec/10%10;
a[2]=sec/100%10;
a[3]=sec/1000%10;
a[4]=sec/10000%10;
a[5]=sec/100000%10;
}
refresh();
}
#define uint unsigned int
#define uchar unsigned char
#define ulong unsigned long
uchar code num[]={0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x90};
uchar a[6];
uchar counter=0;
sbit A1=P2^5;
sbit A2=P2^4;
sbit A3=P2^3;
sbit A4=P2^2;
sbit A5=P2^1;
sbit A6=P2^0;
void t1_int()
{
TMOD |=0X10;
TMOD &=0xdf;
TH1=0xfc;
TL1=0x67;
TR1=1;
}
void int_init()
{
ET1=1;
EA=1;
}
void refresh()
{
static uchar j=0;
switch(j)
{
case 0:A1=0;A2=0;A3=0;A4=0;A5=0;A6=1;j++;P0=num[a[0]]; break;
case 1:A1=0;A2=0;A3=0;A4=0;A5=1;A6=0;j++;P0=num[a[1]]; break;
case 2:A1=0;A2=0;A3=0;A4=1;A5=0;A6=0;j++;P0=num[a[2]]; break;
case 3:A1=0;A2=0;A3=1;A4=0;A5=0;A6=0;j++;P0=num[a[3]]; break;
case 4:A1=0;A2=1;A3=0;A4=0;A5=0;A6=0;j++;P0=num[a[4]]; break;
case 5:A1=1;A2=0;A3=0;A4=0;A5=0;A6=0;j=0;P0=num[a[5]]; break;
default:break;
}
}
void main()
{
t1_int();
int_init();
while(1);
}
void t1()interrupt 3
{
static ulong sec=0;
TH1=0xfc;
TL1=0x67;
counter++;
if(counter==1000)
{
sec++;
counter=0;
a[0]=sec%10;
a[1]=sec/10%10;
a[2]=sec/100%10;
a[3]=sec/1000%10;
a[4]=sec/10000%10;
a[5]=sec/100000%10;
}
refresh();
}
编译hex文件了吧
好的
用过了,没有错误,没有警报。