keil c 的错误error C141: syntax error near '='、 ')' 希望知道如何解决的大佬指点一下,谢谢啦!!!
#include<reg52.h>#include<intrins.h>typedefunsignedintu16;#defineucharunsignedchar#de...
#include <reg52.h>
#include <intrins.h>
typedef unsigned int u16;
#define uchar unsigned char
#define uint unsigned int
#define out P0
uchar code seg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x01};
uchar PWM_T = 0;
sbit SW1=P2^0;
sbit IN1=P2^1;
sbit IN2=P2^2;
sbit PWM_OUT=P2^3;
sbit PWM_ADD=P2^4;
sbit PWM_DEC=P2^5;
sbit START=P2^6;
sbit STOP=P2^7;
int i = 0;
void Timer1_ISR() interrupt 3
{
static char j = 0;
TH1=0x4C;
TL1=0x00;
if(++j == 20)
{
j = 0;
i = (TH0 << 8) | TL0;
i=i/4;
TH0 = 0;
TL0 = 0;
}
}
void delay(u16 i)
{
while(i--);
}
void keypros()
{
if(PWM_ADD==0)
{
delay(1000);
if(PWM_ADD==0&&PWM_T<10)
{
PWM_T+=1;
}
while(PWM_ADD!=1);
}
if(PWM_DEC==0)
{
delay(1000);
if(PWM_DEC==0&&PWM_T>0)
{
PWM_T-=1;
}
while(PWM_DEC!=1);
}
if(START==0)
{
delay(1000);
if(START == 0&&PWM_T =0)
{
PWM_T+=1;
}
while(START!=1);
}
if(STOP==0)
{
delay(1000);
if(STOP==0)
{
PWM_T=0;
}
while(STOP!=1);
}
if(SW1==0&&IN1==1&&IN2=0)
{
IN1=0;
IN2=1;
}
if(SW1==0&&IN1==0&&IN2=1)
{
IN1=1;
IN2=0;
}
}
void main(void)
{
int j;
TMOD=0x15;
TH0=0;
TL0=0;
TH1=0x4C;
TL1=0x00;
TR0=1;
TR1=1;
IE=0x88;
PWM_OUT=1;
IN1=1;
IN2=0;
keypros();
while(1)
{
keypros();
out = seg[i/100];
P1 = 0x01;
for(j=0;j<100;j++);
out = seg[i%100/10];
P1 = 0x02;
for(j=0;j<100;j++);
out = seg[i%10];
P1 = 0x04;
for(j=0;j<100;j++);
}
}
提示如下错误:
EXP6_PWM发生器实验\P_C\MAIN.C(64): error C141: syntax error near '='
EXP6_PWM发生器实验\P_C\MAIN.C(64): error C141: syntax error near ')'
EXP6_PWM发生器实验\P_C\MAIN.C(79): error C141: syntax error near '='
EXP6_PWM发生器实验\P_C\MAIN.C(79): error C141: syntax error near ')'
EXP6_PWM发生器实验\P_C\MAIN.C(84): error C141: syntax error near '='
EXP6_PWM发生器实验\P_C\MAIN.C(84): error C141: syntax error near ')'
EXP6_PWM\P_C\main.c - 6 Error(s), 0 Warning(s). 展开
#include <intrins.h>
typedef unsigned int u16;
#define uchar unsigned char
#define uint unsigned int
#define out P0
uchar code seg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x01};
uchar PWM_T = 0;
sbit SW1=P2^0;
sbit IN1=P2^1;
sbit IN2=P2^2;
sbit PWM_OUT=P2^3;
sbit PWM_ADD=P2^4;
sbit PWM_DEC=P2^5;
sbit START=P2^6;
sbit STOP=P2^7;
int i = 0;
void Timer1_ISR() interrupt 3
{
static char j = 0;
TH1=0x4C;
TL1=0x00;
if(++j == 20)
{
j = 0;
i = (TH0 << 8) | TL0;
i=i/4;
TH0 = 0;
TL0 = 0;
}
}
void delay(u16 i)
{
while(i--);
}
void keypros()
{
if(PWM_ADD==0)
{
delay(1000);
if(PWM_ADD==0&&PWM_T<10)
{
PWM_T+=1;
}
while(PWM_ADD!=1);
}
if(PWM_DEC==0)
{
delay(1000);
if(PWM_DEC==0&&PWM_T>0)
{
PWM_T-=1;
}
while(PWM_DEC!=1);
}
if(START==0)
{
delay(1000);
if(START == 0&&PWM_T =0)
{
PWM_T+=1;
}
while(START!=1);
}
if(STOP==0)
{
delay(1000);
if(STOP==0)
{
PWM_T=0;
}
while(STOP!=1);
}
if(SW1==0&&IN1==1&&IN2=0)
{
IN1=0;
IN2=1;
}
if(SW1==0&&IN1==0&&IN2=1)
{
IN1=1;
IN2=0;
}
}
void main(void)
{
int j;
TMOD=0x15;
TH0=0;
TL0=0;
TH1=0x4C;
TL1=0x00;
TR0=1;
TR1=1;
IE=0x88;
PWM_OUT=1;
IN1=1;
IN2=0;
keypros();
while(1)
{
keypros();
out = seg[i/100];
P1 = 0x01;
for(j=0;j<100;j++);
out = seg[i%100/10];
P1 = 0x02;
for(j=0;j<100;j++);
out = seg[i%10];
P1 = 0x04;
for(j=0;j<100;j++);
}
}
提示如下错误:
EXP6_PWM发生器实验\P_C\MAIN.C(64): error C141: syntax error near '='
EXP6_PWM发生器实验\P_C\MAIN.C(64): error C141: syntax error near ')'
EXP6_PWM发生器实验\P_C\MAIN.C(79): error C141: syntax error near '='
EXP6_PWM发生器实验\P_C\MAIN.C(79): error C141: syntax error near ')'
EXP6_PWM发生器实验\P_C\MAIN.C(84): error C141: syntax error near '='
EXP6_PWM发生器实验\P_C\MAIN.C(84): error C141: syntax error near ')'
EXP6_PWM\P_C\main.c - 6 Error(s), 0 Warning(s). 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询