单片机问题??

单片机问题??#include <reg52.h>

sbit LSA = P2^2;
sbit LSB = P2^3;
sbit LSC = P2^4;

unsigned int a = 0;
unsigned int i = 0;
unsigned int SMG[]= {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}

void timer_0()
{
TMOD = 0X02;
ET0 = 1;
EA = 1;
TL0 = 0X37;
TH0 = 0X37;
TR0 = 1;
}

void SMG1(int x)
{
unsigned int a,b,c,d,e,f;
a = x%10;
b = x/100;
switch(0)
{
case 0:LSA = 1;LSB = 1;LSC = 1;P0 = SMG[a];P0 = 0X00;
case 1:LSA = 0;LSB = 1;LSC = 1;P0 = SMG[b];P0 = 0X00;
}
}

void main()
{
while(1)
{
timer_0();
SMG1(a);
}
}

void LQZ() interrupt 1
{
i++;
if(i == 5000)
{
a++;
i = 0;
}
}

Build target 'Target 1'
compiling 测试文件.c...
测试文件.C(11): error C141: syntax error near 'void'
测试文件.C(12): error C141: syntax error near '{'
测试文件.C(13): error C231: 'TMOD': redefinition
测试文件.C(13): error C231: 'TMOD': redefinition
测试文件.C(14): error C231: 'ET0': redefinition
测试文件.C(14): error C231: 'ET0': redefinition
测试文件.C(15): error C231: 'EA': redefinition
测试文件.C(15): error C231: 'EA': redefinition
测试文件.C(16): error C231: 'TL0': redefinition
测试文件.C(16): error C231: 'TL0': redefinition
测试文件.C(17): error C231: 'TH0': redefinition
测试文件.C(17): error C231: 'TH0': redefinition
测试文件.C(18): error C231: 'TR0': redefinition
测试文件.C(18): error C231: 'TR0': redefinition
测试文件.C(19): error C141: syntax error near '}'
Target not created

为什么会出错?? 不懂啊

数组初值后面要有;号追问

哇 就这个小问题 卡了我大半个钟 无语

追答

其实第一个错误提示就能看出来了

温馨提示:答案为网友推荐,仅供参考
第1个回答  2018-01-11
#include <reg52.h>

sbit LSA = P2^2;
sbit LSB = P2^3;
sbit LSC = P2^4;

unsigned int a = 0;
unsigned int i = 0;
unsigned int SMG[]= {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};

void timer_0()
{
TMOD = 0X02;
ET0 = 1;
EA = 1;
TL0 = 0X37;
TH0 = 0X37;
TR0 = 1;
}

void SMG1(int x)
{
unsigned int a1,b1;
a1 = x%10;
b1 = x/100;
switch(0)
{
case 0:LSA = 1;LSB = 1;LSC = 1;P0 = SMG[a1];P0 = 0X00;
case 1:LSA = 0;LSB = 1;LSC = 1;P0 = SMG[b1];P0 = 0X00;
}
}

void main()
{
while(1)
{
timer_0();
SMG1(a);
}
}

void LQZ() interrupt 1
{
i++; 
if(i == 5000)
{
a++;
i = 0;
}
}

本回答被网友采纳
相似回答