This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

error C141: syntax error near 'unsigned'

hi there, i have struct with the problem.in the multiplexing of the 7-segment display. as i complited the 7-segment display multiplexing. prog.is working properly. but when i moved to the next some advance step it give's the above msg. i think the problem is in the variable passing between function. because as i try to pass the local data to globle side

can any one explain me the passing the value's between two function. the function returning the value is in the main function
and
the function which recive's the value is out of the main function

the function which recive's the value is out of the main function is the part of the interrupt routine


the function which sending or returning the value is the part of main function

Parents Reply Children
  • /*interrupt setting (routine)***/

    void TMR_0(void) interrupt 1
         {
         TF0  = 0;
             TR0  = 0;
             TH0  = 0xAA;
    
         disp(unsigned int);  at this point
    
             TL0  = 0x00;
             TR0  = 1;
         }
    </prr>
    
    
    

  • Well, the error should be obvious!

    But we've all been at that point of staring at a piece of code for so long that we can no longer see the wood for the trees!

    So, back to basics: how do you call a function in 'C'?
    How do you supply parameters when you call a fucntion in 'C' - what should go within the parentheses...?

    What is the value or variable that you actually want to pass to the display() function at this point...?

  • unsigned int go()
         {
    /***shift key press identification *********/
    
             if(KEY2_SFT == 0)
               {
               sft++;
               sft_wait();
                KEY2_SFT = 1;
               if(sft > 4)
                 {sft = 1;}
                a = sft; i want to pass this value
                return(a);
               }
    


    /*********************************************/

    disp(unsigned int);  at this point
    

  • OK, let's take this one step at a time.

    How do you pass a parameter to a function when you call it?

    Insert an appropriate call to my_function in the code below, passing fred as its parameter:

    void my_function( unsigned int x ); // function prototype
    
    void main( void )
    {
       unsigned int fred;
    
       // Insert a call here
    
    }
    

  • void disp(unsigned int a);
    //it going to used in the interrupt
    
    unsigned int go (void);
    //going to used in main function
    
    
    void main()
         {
             P0   = 0x3f; /* initial  port setting */
             P1   = 0xff;
             P2   = 0xf8;
             P3   = 0xff;
    
             IE   = 0x82;/*timer and interrept setting*/
             TMOD = 0x01;
              TH0  = 0xAA;
               TL0  = 0x00;
             TR0 =  1;
    
         while(1)
                 {
                 unsigned int go();
                 }
        }
    
    
    void my_function( unsigned int x ); // function prototype
    
    
    void main( void ) { unsigned int fred;
    my_function(unsigned int);// Inserted a call here
    }

  • OK. you are struggling with the basics of calling a function in 'C'.

    You need to set aside your code, and concentrate just on the basic concept of calling a function - any function - and passing a parameter to it.

    There is no point in trying to go any further before you have mastered this fundamental concept.

    Hint: Look-up "formal" and "actual" parameters in your 'C' textbook.

    Then try the exercise again:

    Insert an appropriate call to my_function in the code below, passing fred as its parameter:

    void my_function( unsigned int x ); // function prototype
    
    void main( void )
    {
       unsigned int fred;
    
       // Insert a call here
    
    }
    


  • Insert an appropriate call to my_function in the code below, passing fred as its parameter:

    then

    void my_function( unsigned int x ); // function prototype
    void main( void )
    {
    unsigned int fred;
    my_function(unsigned int fred);// Inserted a call here
    }
    
    
    

  • here the "actual" parameter is fred

    and the "formal" parameter is x

  • Did you compile it?
    What did the compiler say?

    What does your 'C' text book say about calling functions?
    Specifically, what should go inside the brackets?

  • "here the 'actual' parameter is fred
    and the 'formal' parameter is x"

    Yes - good!

    Now, what should go inside the brackets in the call to the function?

  • as far as this e.g. concern the value assigned to fred is going to used in the my_function.i.e. it passing to through the basket and used by the function

  • "the value assigned to fred is going to used in the my_function"

    Yes, so if you want the value of 'fred' to be passed through to the function, what do you put inside the brackets in the function call?

    Hint: the type of 'fred' has already been defined in the line

    unsigned int fred;
    

    So the compiler already knows what type 'fred' is - you don't have to specify it again, do you...?

  • as far as this e.g. concern the value assigned to fred is going to used in the my_function.i.e. it passing to through the basket and used by the function

  • void my_function( unsigned int x ); // function prototype
    void main( void )
    {
    unsigned int fred;
    my_function(fred);// it is ok now 
    }
    

    but now it genrates warnning, and not going to execute the which executes before the change's

     while(1)
     {
     unsigned int go();this function of the code
     }
    
    
    

    WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS

  • Correct!

    Do you now understand what the problem was?

    "but now it genrates warnning"

    That is actually progress!
    Before, it didn't even compile - now it does compile, but gives this warning.

    You need to post the full text of the message (remember: copy-and-paste) - it will include the name of the segment that is "uncalled"