标题:
求大神帮改改,这样显错 中断.C(25): error C247: non-address/-constant in...
[打印本页]
作者:
新手小张
时间:
2019-5-27 15:51
标题:
求大神帮改改,这样显错 中断.C(25): error C247: non-address/-constant in...
#include<reg52.h>
unsigned char i=0;
unsigned char cnt=0;
unsigned int sec=0;
unsigned char smg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,};
unsigned char wx[]={0xfe,0xfd,0xfb,0xf7,};
void disp()
{
unsigned int i;
unsigned char smgbuff[]={smg[sec%10],smg[(sec/10)%10] ,smg[(sec/100)%10],smg[(sec/1000)],};
while(1)
{
P0=0XFF;
P1=wx[i];
P0=smgbuff[i];
i++;
if(i>=4)
{
i=0;
}
}
}
void main()
{
TMOD=0X01;
TH0=0XFC; //1ms
TL0=0X67;
TR0=1;
EA=1;
ET1=1;
while(1)
{
disp();
}
}
void zd() interrupt 1
{
TH0=0XFC;
TL0=0X67;
cnt++;
if(cnt>=1000)
{
cnt=0;
sec++;
}
}
作者:
wulin
时间:
2019-5-27 21:14
错误不止这一处。
#include <AT89X52.H>
//unsigned char i=0;
unsigned int cnt=0;
unsigned int sec=0;
unsigned char smg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,};
unsigned char wx[]={0x01,0x02,0x04,0x08};
unsigned char smgbuff[]={0xc0,0xc0,0xc0,0xc0};
bit flag=0;
void disp()
{
static unsigned char i=0;
P0=0xff;
P2=wx[i];
P0=smgbuff[i];
i++;
if(i>=4)
i=0;
}
void main()
{
TMOD=0X01;
TH0=0XFC; //1ms
TL0=0X67;
TR0=1;
EA=1;
ET0=1;
while(1)
{
if(flag==1)
{
flag=0;
sec++;
if(sec>=10000)
sec=0;
smgbuff[0]=smg[sec%10];
smgbuff[1]=smg[sec/10%10];
smgbuff[2]=smg[sec/100%10];
smgbuff[3]=smg[sec/1000%10];
}
}
}
void zd() interrupt 1
{
TH0=0xfc;
TL0=0x67;
cnt++;
if(cnt>=1000)
{
cnt=0;
flag=1;
}
disp();
}
复制代码
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1