各位哥哥妹妹,初学者编程,遇到如下问题,请帮忙解决啊,看一看程序报错在哪里?#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
#define control P3 //步进电机策略控制,正反转,启停,几步转动
#define MotorData P0 //步进电机控制数据传输sfr P0M0=0x94;
sfr P0M1=0x93;
sfr P1M0=0x92;
sfr P1M1=0x91;
sfr P2M0=0x96;
sfr P2M1=0x95;
sfr P3M0=0xB2;
sfr P3M1=0xB1; //IO口管脚类型定义uchar full_step[4]={0xcc,0xc4,0x44,0x4c};
uchar half_step[8]={0xcc,0xf0,0xc4,0x07,0x44,0x70,0x4c,0x0f};
uchar quarter_step[16]={0xcc,0xea,0xf0,0xe2,0xc4,0xa6,0x07,0x26,0x44,0x62,0x70,0x6a,0x4c,0x2e,0x0f,0xae};
uchar one_eighth_step[]={0xcc,0xdb,0xea,0xf9,0xf0,0xf1,0xe2,0xd3,0xc4,0xb5,0xa6,0x97,0x07,0x17,0x26,0x35,0x44,0x53,0x62,0x71,0x70,0x79,0x6a,0x5b,0x4c,0x4c,0x3d,0x2e,0x1f,0x0f,0x9f,0xae,0xbd};
//4个IO口管脚用于电机控制策略定义,2^4=32种
void Delay_xms(int t)
{
while(--t);
} //ms延迟函数
void Motor_full_step(void)
{
uchar i;
for(i=0;i<4;i++)
{MotorData=full_step;
Delay_xms(4);//转速调整设置
}
} //整步转动
void Motor_full_step_opposite(void)
{
uchar i;
for(i=0;i<4;i++)
{MotorData=full_step[3-i];
Delay_xms(4);//转速调整设置
}
} //整步反向转动
void Motor_half_step(void)
{
uchar i;
for(i=0;i<8;i++)
{
MotorData=half_step;
Delay_xms(4);
}
} //half step转动
void Motor_half_step_opposite(void)
{
uchar i;
for(i=0;i<8;i++)
{
MotorData=half_step[7-i];
Delay_xms(4);
}
} //half step反向转动
void Motor_quarter_step(void)
{
uchar i;
for(i=0;i<16;i++)
{
MotorData=quarter_step;
Delay_xms(4);
}
} //quarter step转动
void Motor_quarter_step_opposite(void)
{
uchar i;
for(i=0;i<16;i++)
{
MotorData=quarter_step[15-i];
Delay_xms(4);
}
} //quarter step反向转动
void Motor_one_eighth_step(void)
{
uchar i;
for(i=0;i<32;i++)
{
MotorData=one_eighth_step;
Delay_xms(4);
}
} //one eighth step转动
void Motor_one_eighth_step_opposite(void)
{
uchar i;
for(i=0;i<32;i++)
{
MotorData=one_eighth_step[31-i];
Delay_xms(4);
}
} //one eighth step反向转动
void MOtorStop(void)
{
MotorData=0x00;
} //电机停止转动
void main(){
unsigned char P0M0=0X00;
unsigned char P0M1=0X00;
unsigned char P1M0=0X00;
unsigned char P1M1=0X00;
unsigned char P2M0=0X00;
unsigned char P2M1=0X00;
unsigned char P3M0=0X00;
unsigned char P3M1=0X00;
unsigned char control=0x00;
unsigned char a;
while(1)
{
a=control & 0xf0; void Motor_full_step(); if(a!=0x00)
{ void Delay_xms(10);
if(a!=0x00)
{
switch(a)
{
case 0x80:
Motor_full_step_opposite();
break;
case 0xc0:
Motor_half_step_opposite();
break;
case 0x40:
Motor_half_step();
break;
case 0xa0:
Motor_quarter_step_opposite();
break;
case 0x20:
Motor_quarter_step();
break;
case 0x90:
Motor_one_eighth_step_opposite();
break;
case 0x10:
Motor_one_eighth_step();
break;
} } } else
Motor_full_step();
}}
程序报错如下:compiling stepper_motor_main.c...
STEPPER_MOTOR_MAIN.C(153): error C141: syntax error near 'void'
STEPPER_MOTOR_MAIN.C(156): error C141: syntax error near '10'
stepper_motor_main.c - 2 Error(s), 0 Warning(s).
一周热门 更多>