在创建动态数码管的工程中,跟着视频教程编写好了动态数码管的程序,将.c文件加入工程后系统提示出错惹,无法创建Target.
试了一下,如果不把程序的.c文件加入工程,就可以创建hex文件,就是会有没有芯片的警告。跪求大神教教这是怎么回事
这是错误提示:
Build target 'Target 1'
compiling 动态4.c...
动态4.C(24): error C221: non-constant case/dim expression
动态4.C(26): error C221: non-constant case/dim expression
动态4.C(28): error C221: non-constant case/dim expression
动态4.C(30): error C221: non-constant case/dim expression
动态4.C(32): error C221: non-constant case/dim expression
动态4.C(34): error C221: non-constant case/dim expression
动态4.C(36): error C221: non-constant case/dim expression
动态4.C(38): error C221: non-constant case/dim expression
Target not created
程序如下:
- #include<reg52.h>
- typedef unsigned char u8;
- typedef unsigned int u16;
- sbit LSA=P2^2;
- sbit LSB=P2^3;
- sbit LSC=P2^4;
- u8 code smgduan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
- 0x7f,0x6f,0x77,0x7b,0x39,0x5e,0x79,0x71} ;
- void delay(u16 i)
- {
- while(i--);
- }
- void DisDisplay()
- {
- u8 i ;
- for(i=0;i<8;i++)
- {
- switch(i)
- {
- case(i=0):
- LSA=0;LSB=0;LSC=0;break;
- case(i=1):
- LSA=1;LSB=0;LSC=0;break;
- case(i=2):
- LSA=0;LSB=1;LSC=0;break;
- case(i=3):
- LSA=1;LSB=1;LSC=0;break;
- case(i=4):
- LSA=0;LSB=0;LSC=1;break;
- case(i=5):
- LSA=1;LSB=0;LSC=1;break;
- case(i=6):
- LSA=0;LSB=1;LSC=1;break;
- case(i=7):
- LSA=1;LSB=1;LSC=1;break;
- }
- P0=smgduan[i];
- delay(100);
- P0=0x00;
-
- }
- }
- void main()
- {
-
- while(1)
- {
- DisDisplay() ;
- }
-
-
- }
复制代码
新手心累,求解。多谢大嘎了。
|