标题: 求大神帮改改,这样显错 中断.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
错误不止这一处。
  1. #include <AT89X52.H>
  2. //unsigned char i=0;
  3. unsigned int cnt=0;
  4. unsigned int sec=0;
  5. unsigned char smg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,};
  6. unsigned char wx[]={0x01,0x02,0x04,0x08};
  7. unsigned char smgbuff[]={0xc0,0xc0,0xc0,0xc0};
  8. bit flag=0;

  9. void disp()
  10. {       
  11.         static unsigned char i=0;       
  12.         P0=0xff;
  13.         P2=wx[i];
  14.         P0=smgbuff[i];
  15.         i++;
  16.         if(i>=4)
  17.                 i=0;
  18. }

  19. void main()
  20. {
  21.         TMOD=0X01;
  22.         TH0=0XFC;   //1ms
  23.         TL0=0X67;
  24.         TR0=1;
  25.         EA=1;
  26.         ET0=1;
  27.         while(1)
  28.         {       
  29.                 if(flag==1)
  30.                 {
  31.                         flag=0;
  32.                         sec++;
  33.                         if(sec>=10000)
  34.                                 sec=0;
  35.                         smgbuff[0]=smg[sec%10];
  36.                         smgbuff[1]=smg[sec/10%10];
  37.                         smgbuff[2]=smg[sec/100%10];
  38.                         smgbuff[3]=smg[sec/1000%10];
  39.                 }
  40.         }       
  41. }
  42. void zd() interrupt 1
  43. {
  44.         TH0=0xfc;
  45.         TL0=0x67;
  46.         cnt++;
  47.         if(cnt>=1000)
  48.         {
  49.                 cnt=0;
  50.                 flag=1;
  51.         }
  52.         disp();
  53. }
复制代码





欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1