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

please help debugging error 53: expecting function name

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



Joined: 25 Aug 2009
Posts: 5
Location: philippines

View user's profile Send private message

please help debugging error 53: expecting function name
PostPosted: Tue Aug 25, 2009 5:10 am     Reply with quote

*** Error 53 "D:\backup ni jepoy\MPLAB\Clanguage\7segment\Counting 0-999\incrementdecrementdo.c" Line 30(10,15): Expecting function name 1 Errors, 2 Warnings.
Halting build on first failure as requested.
BUILD FAILED: Tue Aug 25 17:42:03 2009



this is my program,please help me to debug the error above:




#include <16F877A.h>
#include <string.h>
#fuses HS, NOWDT, NOPROTECT, NOLVP
#use delay (clock=20000000)
#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7)

#include <stdio.h>

main()
{
int a;
int array[10]={0x7B,0xA,0xB3,0x9B,0xCA,0xD9,0xF9,0xB,0xFB,0xDB};
int *i;
i=&array[i];
while(true)
for (i=0;i<=9;i++)
a=0;
{
if (!input(PIN_E0)) array[i]--,i<=9,i--;
else
{
output_b(array(a)); /*<<<<<<<<the error is here!!
delay_ms(1000);
}
}
return 0;
}

"im trying to make a program using c language that is incrementing from 0 to 9 and when you are pressing the button switch(which is PIN_E0/B0) it will decrement all over again from its recent number when the time you press it, then if you release the button it will increment all over again starting from its recent number when the time you pressed it....pls help!..and also 0-99 incrementing and decrementing program , same scenario.."
ckielstra



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

View user's profile Send private message

PostPosted: Tue Aug 25, 2009 5:46 am     Reply with quote

A fun school assignment. Tempting to hand you the solution but there is a lot to be learnt here so I'll only give you some hints.

Code:
output_b(array(a)); /*<<<<<<<<the error is here!!
Use '[]' instead of '()' for the array index.

Code:
if (!input(PIN_E0)) array[i]--,i<=9,i--;
An inventive construction. Some people say the comma operator in the C language should never have been allowed as it makes the code difficult to read. In fact, I have no clue as to what the code is doing and I'm sure it is not doing what you want it to do.
Don't write more than one instruction at a line. The compiler is smart enough to generate optimized code even when you type longer lines.

Code:
i=&array[i];
The value here assigned to i is never used in the code. Delete this line.

Code:
int *i;
In the for-loop variable i is used as an integer, not as a pointer to an integer. Change to:
Code:
int i;


Code:
#include <string.h>
...
#use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7)

#include <stdio.h>
These three lines have no use in this program and can be removed.

Code:
for (i=0;i<=9;i++)
a=0;
{
Because you inserted the line 'a=0' before the '{' character the program flow has changed. Now your program will execute 10 times the line 'a=10' instead of looping the sequence between '{' and '}'.

Tip: use the 'code' buttons when posting program code to keep the formatting intact. This makes for easier reading. Easier reading gives you more and quicker responses.

Code:
return 0;
In the PIC processor there is no Operating System to return to so a return value is only wasting code space. This line can be left out (don't forget to change the program declaration to 'void').

Post a new and improved version and we'll help you further.
j3p0y



Joined: 25 Aug 2009
Posts: 5
Location: philippines

View user's profile Send private message

PostPosted: Tue Aug 25, 2009 11:14 pm     Reply with quote

Very Happy wow!tnx for the reply!it really helps me to build without error any more!!now this is my new program...

void main()
{
int array[10]={0x7B,0xA,0xB3,0x9B,0xCA,0xD9,0xF9,0xB,0xFB,0xDB};
int i;
int a;
while(true)
for (i=0;i<=9;i++)
{
if (!input(PIN_E0)) i--; /* i try to change this to "if (!input(PIN_E0)) array[i]--;"
else
{
output_b(array[i]);
delay_ms(1000);
}
}
}

my question is about the statement the one with bold letters..i want my counting to decrement continuously while i press and hold the button longer (which is "PIN_E0" the trigger) then if i release the button it will increment all over again..
.....after i fix the program the way you taught me...there is an output incrementing from 0-9 in my 7 segment display but there is no output when i press and hold the button that it must be decrementing. then if i change it to "array[i]--" (like this " if (!input(PIN_E0)) array[i]--")the output is not a number in 7 segment display or maybe it is a binary output..what should i do?
ckielstra



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

View user's profile Send private message

PostPosted: Thu Aug 27, 2009 1:40 pm     Reply with quote

Like I said, It makes for easier reading when you use the Code buttons when posting code. People in this forum tend to give faster and more response when your program is easy to read.

I have posted your program with the correct layout and added a few more '{}' symbols.
I also added a '#device *=16' to allow the compiler to access all RAM in your processor. In your small program this has no effect but it is good coding practice and will avoid problems when the program gets larger.

Code:
#include <16F877A.h>
#fuses HS, NOWDT, NOLVP, NOPROTECT
#device *=16
#use delay (clock=20000000)

void main()
{
  int array[10]={0x7B,0xA,0xB3,0x9B,0xCA,0xD9,0xF9,0xB,0xFB,0xDB};
  int i;

  while(TRUE)
  {
    for (i=0;i<=9;i++)
    {
      if (!input(PIN_E0))
      {
        i--;
      } 
      else
      {
        output_b(array[i]);
        delay_ms(1000);
      }
    }
  }
}


Code:
i--; /* i try to change this to "if (!input(PIN_E0)) array[i]--;"
The 'array[i]--' is wrong, it will not count down but will corrupt the value written to the 7-segment display.

You are close to the final solution. For learning exercise it is best when I don't just give the answer but you give it another try yourself.
Have another good look at your program, especially the situation when you press the button and when it is released. What is different here? And why is that a problem?
Guest








PostPosted: Fri Aug 28, 2009 12:18 am     Reply with quote

Code:

#include <16F877A.h>
#fuses HS, NOWDT, NOLVP, NOPROTECT
#device *=16
#use delay (clock=20000000)

void main()
{
  int array[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
  int i;
 
  while(TRUE)
  {
    for (i=0;i<=9;i++)
    {
      if (!input(PIN_E0))
      {
      --i;
      [b]for (--i;i>=9;i--); [/b]
         {
          output_b(array[i]);
           delay_ms(1000);
          }
      }   
     else 
      {
        output_b(array[i]);
        delay_ms(1000);
      }
    }
  }
}

The bold letter is my only problem now. It only decrement from 8-0 instead 9-0.
Then when I change the statement like these:
Code:

for (--i;i>=10;i--);

It will stop decrementing in 9.
I think the problem is I have a lack of looping statement and I don't know where I should put it or if there's a correction again in my program. Rolling Eyes
Guest








PostPosted: Fri Aug 28, 2009 2:20 am     Reply with quote

Anonymous wrote:
Code:
#include <16F877A.h>
#fuses HS, NOWDT, NOLVP, NOPROTECT
#device *=16
#use delay (clock=20000000)

void main()
{
  int array[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
  int i;
 
  while(TRUE)
  {
    for (i=0;i<=9;i++)
    {
      if (!input(PIN_E0))
      {
      --i;
      for (--i;i>=9;i--);
         {
          output_b(array[i]);
           delay_ms(1000);
          }
      }   
     else 
      {
        output_b(array[i]);
        delay_ms(1000);
      }
    }
  }
}



only prob now(typographical error i thought it can be bold)..it only decrement from 8-0 instead 9-0.
then when i change the statement like these:
Code:

for (--i;i>=10;i--);

it will stop decrementing in 9..
i think the prob is i have a lack of looping statement and i dont know where should i put it or theres a correction again in my program.. Rolling Eyes
ckielstra



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

View user's profile Send private message

PostPosted: Fri Aug 28, 2009 8:48 am     Reply with quote

Adding the delay_ms and output_b to the other half of the if-statement was correct. You went wrong by adding a second for-loop.

Problem with the for-loop in your assignment is that a for-loop always goes from the start value till the end value. You want to be able to stop anywhere in the sequence and go the other direction.

Hint: remove all the for-loops. You don't need them for this assignment.
j3p0y



Joined: 25 Aug 2009
Posts: 5
Location: philippines

View user's profile Send private message

PostPosted: Fri Sep 04, 2009 2:00 am     Reply with quote

Its done!! You're the man!! I keep in trial and error the program and I figure it out, but still there is a "for loop" in my program! Sorry for my late reply because we are currently making a prototype clock timer project.

Here's my program, if there's anything I should change I'll try it also:
Code:

#include <16F877A.h>
#fuses HS, NOWDT, NOLVP, NOPROTECT
#device *=16
#use delay (clock=20000000)

void main()
{
  int array[10]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10};
  int i;
  while(TRUE)
  {
    for (i=0;i<=10;i++)
   
   {
      if (!input(PIN_E0))
      {
      --i;
      for (i--;i>=10;i--);
      }   
   else 
   if(i==10)i=0;     
     {
      delay_ms(1000);
        output_d(array[i]);
       
      }
    }
  }    
}



This is the missing statement that makes my counter loop from 0:
Code:
if(i==10)i=0;


I have a question. How should I put another program in a program. For example we are making a clock timer. I have now a program for 24hours clock. Then we want to add a features in the clock like adjusting or setting the time. How should we put the program for this features of the clock?

And I am having a problem in making a program in multiplexing the 7 segment because we are using 4 seven segment display and I am running out of ports in p16f877a. My professor said we need multiplexing to minimize the use of many ports? Do you have any site recommendation where could I learn it? Thanks so much and I highly appreciated it.
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