单片机问题??
单片机问题??#include<reg52.h>sbitLSA=P2^2;sbitLSB=P2^3;sbitLSC=P2^4;unsignedinta=0;unsigne...
单片机问题??#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
为什么会出错?? 不懂啊 展开
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
为什么会出错?? 不懂啊 展开
展开全部
#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;
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询