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 for improper use of a function in ccs

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



Joined: 02 Jul 2010
Posts: 30
Location: italy

View user's profile Send private message

help for improper use of a function in ccs
PostPosted: Tue Jul 13, 2010 7:24 pm     Reply with quote

Hello to everyone, i have a problem with this code, i use ccs compiler and i use a pic 18f4525... i can not resolve this errors
thank to all!

Code:

 
void get_packet() {
int i;
for(i=0;i<80;i++){    THIS "FOR" IS THE PROBLEM, THE COMPILER GENERATE THIS 2 ERROR:1 improper of a function identifier, 2 expect ;
bte=0xFF;
}
numbyte=0;                  //reset numbyte
#if 1
while (cbyte != 0x7e){           //find the first flag
shift_right(&cbyte,1,bitin());     //add a new bit to the left of cbyte,
discard right bit
}  //end of while //244=824   243 = 831.0
output_high(DCD_LED);
#endif
cbyte = 0x7e;
While (cbyte == 0x7e){           //find the other flags
for(i=0;i<8;i++){         //repeat this 8 times //244=834.6  243=831.2
shift_right(&cbyte,1,bitin());    //add a new bit to the left of cbyte,
discard right bit
}               //end of for
}                  //end of while  -- now at end of all the flags
bte[0] = cbyte;             //you've now got the first address byte
numbyte++;                 //we already collected 1 byte
while (test != 1){                 //do this until the flag at the end of
the packet
for(i=0;i<8;i++){             //collect 8 bits
newbit = bitin();          //get a bit
if (newbit == 1) (ones++);         //increment the ones counter
else (ones = 0);          //if bit is a zero, reset the ones counter
if (ones == 5) {           //removes bit stuffing
test = bitin();           //get the next bit but don't add it to cbyte
ones = 0;          //reset the ones counter
}
shift_right(&cbyte,1,newbit);                  //append the new bit to cbyte
}                  //end of for
if (test==0 ){
bte[numbyte] = cbyte;         //add cbyte to the array
numbyte++;            //increment the number of received bytes
}
}//end of while
output_low(DCD_LED);
}//end get_packet()
 
albe01



Joined: 02 Jul 2010
Posts: 30
Location: italy

View user's profile Send private message

PostPosted: Tue Jul 13, 2010 7:26 pm     Reply with quote

Crying or Very sad

Last edited by albe01 on Wed Jul 14, 2010 5:56 am; edited 1 time in total
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Tue Jul 13, 2010 7:33 pm     Reply with quote

Code:
int numbyte,cbyte=0,ones; int1 test=0,newbit;
//---------------------------------------------
int1 bitin(){                  //function to read a bit
static int oldstate;          //oldstate retained between runs of this function
int k;
for (k=0;k<244;k++){          //this loop allows 838 us to go by. If no state change, bit is 1
if (input(rcvPin) != oldstate){       //if state has changed
oldstate = input(rcvPin);          //update oldstate
delay_us(430);                    // move to halfway thru the next bit
return 0;                        //return 0 if state changed
}                           //end of if
}                          //end of for
return 1;                 //return 1 if state did not change

                 <===*** What do you not see that should be here? ***

//end of bitin()   
//-------------------------------------------------
void get_packet() {
int i;
for(i=0;i<80;i++){
bte=0xFF;
}
numbyte=0;                  //reset numbyte



What is the point of the next part? 1 will always be 1 ....

Code:
numbyte=0;                  //reset numbyte
#if 1
while (cbyte != 0x7e){           //find the first flag
shift_right(&cbyte,1,bitin());     //add a new bit to the left of cbyte, discard right bit
}  //end of while //244=824   243 = 831.0
output_high(DCD_LED);
#endif

_________________
Google and Forum Search are some of your best tools!!!!
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Tue Jul 13, 2010 11:49 pm     Reply with quote

dyeatman wrote:
What is the point of the next part? 1 will always be 1 ....
Code:
numbyte=0;                  //reset numbyte
#if 1
while (cbyte != 0x7e){           //find the first flag
shift_right(&cbyte,1,bitin());     //add a new bit to the left of cbyte, discard right bit
}  //end of while //244=824   243 = 831.0
output_high(DCD_LED);
#endif

Some people use #if 1 syntax as a way of turning blocks of code on and off. It's an alternative to commenting out.
_________________
Read the label, before opening a can of worms.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Jul 15, 2010 12:33 pm     Reply with quote

Code:
void get_packet() {
int i;
for(i=0;i<80;i++){    THIS "FOR" IS THE PROBLEM, THE COMPILER GENERATE THIS 2 ERROR:1 improper of a function identifier, 2 expect ;
bte=0xFF;
}
My guess is the error is in the line just before this function. That is, in the part of code not posted here...
The CCS compiler is not always very good in pointing to the real error.
icesynth



Joined: 03 Sep 2007
Posts: 32
Location: Edmonton, Alberta

View user's profile Send private message Visit poster's website

PostPosted: Wed May 11, 2011 11:52 pm     Reply with quote

Agreed, this error is usually caused by a curly bracket missing in the previous function.
_________________
Programming for the the real world.
--Chris Burchett
Sylver Technologies Inc.
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