CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Help Error message:"A numeric expression must to appear

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
navi5



Joined: 12 Apr 2012
Posts: 2

View user's profile Send private message

Help Error message:"A numeric expression must to appear
PostPosted: Thu Apr 12, 2012 1:23 pm     Reply with quote

Hi, I need your your help. I can't find the problem with the following code. I tried to put {} because I read that someboody do this but it doesn't work. Its a program for control a robotic arm with PAP motors, that is activated with push-buttons. Well here is it:
Code:

void mp1d(void);
void mp1i(void);                   //here i declare the motors//
void mp2d(void);
void mp2i(void);
void mp3d(void);
void mp3i(void);
void m4d(void);
void m4i(void);
void m5d(void);
void m5i(void);

void inicializar(void)
{
set_tris_A(0b111111);
set_tris_B(0b00000000);
set_tris_C(0b10000000);
set_tris_D(0b00000000);
set_tris_E(0b111);

void main (void)   <----------this is the body of the program
{                                       and here its the error.
inicializar();
while(TRUE){
if (RA0==1){
mp1d();
}
else
{ mp1i();
}
if (RA1==1)
{mp1i();}
if (RA2==1)
{mp2d();}
if (RA3==1)
{mp2i();}
if (RA4==1)
{mp3d();}
if (RA5==1)
{mp3i();}

if (RE0==1)
{m4d();}
if (RE1==1)
{m4i();}
if (RE2==1)
{m4d();}
if (RC0==1)
{m4i();}

}
}
}
------------------------------these are the functions-----------------------
void mp1d(void)  //motor a pasos 1 derecha//
{
while(RA0==1){
RB0==1;
delay_ms(500);
RB1==1;
delay_ms(500);
RB2==1;
delay_ms(500);
RB3==1;
delay_ms(500);           
}}

void mp1i(void)  //motor a pasos 1 izquierda//
{
while(RA1==1){
RB3==1;
delay_ms(500);
RB2==1;
delay_ms(500);
RB1==1;
delay_ms(500);
RB0==1;
delay_ms(500);           
}}

void mp2d(void)  //motor a pasos 2 derecha//
{
while(RA2==1){
RB4==1;
delay_ms(500);
RB5==1;
delay_ms(500);
RB6==1;
delay_ms(500);
RB7==1;
delay_ms(500);           
}}

void mp2i(void)  //motor a pasos 2 izq//
{
while(RA3==1){
RB7==1;
delay_ms(500);
RB6==1;
delay_ms(500);
RB5==1;
delay_ms(500);
RB4==1;
delay_ms(500);           
}}

void mp3d(void)  //motor a pasos 3 derecha//
{
while(RA4==1){
RC4==1;
delay_ms(500);
RC5==1;
delay_ms(500);
RC6==1;
delay_ms(500);
RC7==1;
delay_ms(500);           
}}

void mp3i(void)  //motor a pasos 3 izq//
{
while(RA5==1){
RC7==1;
delay_ms(500);
RC6==1;
delay_ms(500);
RC5==1;
delay_ms(500);
RC4==1;
delay_ms(500);
}}

void m4d(void)
{
RD4==1;
}

void m4i(void)
{
RD5==1;
}

void m5d(void)
{
RD6==1;
}

void m5i(void)
{
RD7==1;
}

I hope you can help me.
Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Thu Apr 12, 2012 2:14 pm     Reply with quote

Code:

void inicializar(void)
{
set_tris_A(0b111111);
set_tris_B(0b00000000);
set_tris_C(0b10000000);
set_tris_D(0b00000000);
set_tris_E(0b111); //At this point, you have not ended the declaration
//of the function 'inicializar' - no close bracket

void main (void)   <----------this is the body of the program
{                                       and here its the error.
//You now try to declare 'main' _inside_ the already declared function.
//Of course the compiler complains.....


Best Wishes
navi5



Joined: 12 Apr 2012
Posts: 2

View user's profile Send private message

PostPosted: Thu Apr 12, 2012 8:38 pm     Reply with quote

Worked perfect thanks for helping
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group