mm_pk1
Newbie level 6
I have written the following code to run the stepper motor forward and backward. I am using MikroC V8.0. But after build process, following error appears:
Undeclared identifier [PORTB] in expression
At line36, ')' expected but ; found . And many more errors, can someone help plz.
Complete Project is also attached:
#define Switch PORTC.F0; // Switch for Stepper Motor
#define X1 PORTB.F0;
#define X2 PORTB.F1;
#define X3 PORTB.F2;
#define X4 PORTB.F3;
//I have also tried with the following
//sbit Switch at RC0_bit; // Switch for Stepper Motor
//sbit X1 at RB0_bit;
//sbit X2 at RB1_bit;
//sbit X3 at RB2_bit;
//sbit X4 at RB3_bit;
//But both ways are not working fine
//Following error appears during build all process:
// Undeclared identifier [PORTB] in expression
// At line36, ')' expected but ; found
// and many more errors, can someone help plz
void MoveX_F(void); // Move Motor Forward
void MoveX_B(void); // Move Motor Backward
void main(void)
{
TRISB = 0x00;
TRISC = 0xFF;
P0RTB = 0x00;
PORTC = 0x00;
while(1)
{
if(Switch == 0);
MoveX_F();
else
MoveX_B();
}
}
void MoveX_F(void)
{ //Start Move X Motor to Forward Direction
unsigned int j;
X1=1;
for(j=0;j<1500;j++);
X1=0;
X2=1;
for(j=0;j<1500;j++);
X2=0;
X3=1;
for(j=0;j<1500;j++);
X3=0;
X4=1;
for(j=0;j<1500;j++);
X4=0;
} //End Move X Motor Forward
void MoveX_B(void)
{ //Start Move X Motor to Bacrkward Direction
unsigned int j;
X4=1;
for(j=0;j<1500;j++);
X4=0;
X3=1;
for(j=0;j<1500;j++);
X3=0;
X2=1;
for(j=0;j<1500;j++);
X2=0;
X1=1;
for(j=0;j<1500;j++);
X1=0;
} //End Move X Motor Backward
Undeclared identifier [PORTB] in expression
At line36, ')' expected but ; found . And many more errors, can someone help plz.
Complete Project is also attached:
#define Switch PORTC.F0; // Switch for Stepper Motor
#define X1 PORTB.F0;
#define X2 PORTB.F1;
#define X3 PORTB.F2;
#define X4 PORTB.F3;
//I have also tried with the following
//sbit Switch at RC0_bit; // Switch for Stepper Motor
//sbit X1 at RB0_bit;
//sbit X2 at RB1_bit;
//sbit X3 at RB2_bit;
//sbit X4 at RB3_bit;
//But both ways are not working fine
//Following error appears during build all process:
// Undeclared identifier [PORTB] in expression
// At line36, ')' expected but ; found
// and many more errors, can someone help plz
void MoveX_F(void); // Move Motor Forward
void MoveX_B(void); // Move Motor Backward
void main(void)
{
TRISB = 0x00;
TRISC = 0xFF;
P0RTB = 0x00;
PORTC = 0x00;
while(1)
{
if(Switch == 0);
MoveX_F();
else
MoveX_B();
}
}
void MoveX_F(void)
{ //Start Move X Motor to Forward Direction
unsigned int j;
X1=1;
for(j=0;j<1500;j++);
X1=0;
X2=1;
for(j=0;j<1500;j++);
X2=0;
X3=1;
for(j=0;j<1500;j++);
X3=0;
X4=1;
for(j=0;j<1500;j++);
X4=0;
} //End Move X Motor Forward
void MoveX_B(void)
{ //Start Move X Motor to Bacrkward Direction
unsigned int j;
X4=1;
for(j=0;j<1500;j++);
X4=0;
X3=1;
for(j=0;j<1500;j++);
X3=0;
X2=1;
for(j=0;j<1500;j++);
X2=0;
X1=1;
for(j=0;j<1500;j++);
X1=0;
} //End Move X Motor Backward