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
  • her is the full code with warnning

    #include<reg52.h>
    #include<define.h>
    #include<intrins.h>
    
    /*function declaration*/
    
    void blink(void);
    void disp_wait(void);
    void disp_inc_wait(void);
    void sft_wait(void);
    void disp(unsigned int a);
    void blink(void);
    unsigned int go (void);
    
    /*************************/
    
    unsigned char number_code[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
    unsigned int i,j,k,l,a;
    unsigned int sft;//  = 1;
    
    
    /* interrupt setting (routine)*/
    
    void TMR_0(void) interrupt 1
         {
         TF0  = 0;
             TR0  = 0;
             TH0  = 0xAA;
    
         disp(a);
    
             TL0  = 0x00;
             TR0  = 1;
         }
    
    void disp(unsigned int a)
         {
         sft = a;
         DECOD1 = 0;/**** 7-segment 1st display *******/
         DECOD2 = 0;
         DECOD3 = 0;
    
         P0 = number_code[i];
             if(sft != 1)
               {disp_wait();}
             blink();
    
    
         DECOD1 = 1;/*** 7-segment 2nd display *******/
         DECOD2 = 0;
         DECOD3 = 0;
    
         P0 = number_code[j];
         if(sft != 2)
               {disp_wait();}
             blink();
    
    
         DECOD1 = 0;/* 7-segment 3rd display ****/
         DECOD2 = 1;
         DECOD3 = 0;
    
         P0 = number_code[k];
         if(sft != 3)
               {disp_wait();}
             blink();
    
    
         DECOD1 = 1;/** 7-segment 4th display *****/
         DECOD2 = 1;
         DECOD3 = 0;
    
         P0 = number_code[l];
         if(sft != 4)
               {disp_wait();}
             blink();
    
            }
    
    
    /***dly routine's*************/
    
    
    void disp_wait()
             {
             unsigned int w1 = 0;
             unsigned int w2 = 0;
             for(w1 = 1;w1<=2;w1++)
                {
                    for(w2 = 1;w2<=200;w2++)
                    {}
                    }
         }
    
    void disp_inc_wait()
         {
             unsigned int w1 = 0;
             unsigned int w2 = 0;
             for(w2 = 1;w2 <=60;w2++)
            {
                    for(w1 = 1;w1 <=800;w1++)
                       {
                       _nop_();
                       }
                    }
         }
    
    void sft_wait()
        {
        unsigned int w1 = 0;
            unsigned int w2 = 0;
            for(w2 = 1;w2 <=100;w2++)
            {
                    for(w1 = 1;w1 <=800;w1++)
                       {_nop_();}
                    }
            }
    
    /****blink char(dly)******/
    
    void blink()
        {
            unsigned int w1 = 0;
            unsigned int w2 = 0;
            for(w2 = 1; w2<=20; w2++)
            {
             sft_wait();
                }
         }
    
    /****** main prog******/
    
    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();WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
    
                 }
    }
    
    unsigned int go()
         {
    /*shift key press identification ****/
    
             if(KEY2_SFT == 0)
                       {
                       sft++;
                       sft_wait();
               KEY2_SFT = 1;
                       if(sft > 4)
                         {sft = 1;}
               }
    /* opration on shift char ***/
             switch(sft)
                   {
                  case 1: /****** 7-segment 1st *******/
                       if(KEY1_INC == 0)
                         {
                          i++;
                         if(i > 9)
                           {i = 0;}
                          disp_inc_wait();
                         KEY1_INC = 1;
                         }
                         break;
    
                        case 2:
              if(KEY1_INC == 0)        /* 7-segment 2nd */
               {
               j++;
               if(j > 9)
                   {j = 0;}
               disp_inc_wait();
                KEY1_INC = 1;
               }
               break;
    
             case 3:
              if(KEY1_INC == 0)/* 7-segment 3rd ***/
                {
                k++;
                 if(k > 9)
                  {k = 0;}
                disp_inc_wait();
                KEY1_INC = 1;
                }
             break;
    
            case 4:
               if(KEY1_INC == 0)/* 7-segment 4th */
                 {
                 l++;
                  if(l > 9)
                  {l = 0;}
                 disp_inc_wait();
                 KEY1_INC = 1;
                 }
                 break;
           }
             a = sft;
         return(a);
             }
    

Reply
  • her is the full code with warnning

    #include<reg52.h>
    #include<define.h>
    #include<intrins.h>
    
    /*function declaration*/
    
    void blink(void);
    void disp_wait(void);
    void disp_inc_wait(void);
    void sft_wait(void);
    void disp(unsigned int a);
    void blink(void);
    unsigned int go (void);
    
    /*************************/
    
    unsigned char number_code[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
    unsigned int i,j,k,l,a;
    unsigned int sft;//  = 1;
    
    
    /* interrupt setting (routine)*/
    
    void TMR_0(void) interrupt 1
         {
         TF0  = 0;
             TR0  = 0;
             TH0  = 0xAA;
    
         disp(a);
    
             TL0  = 0x00;
             TR0  = 1;
         }
    
    void disp(unsigned int a)
         {
         sft = a;
         DECOD1 = 0;/**** 7-segment 1st display *******/
         DECOD2 = 0;
         DECOD3 = 0;
    
         P0 = number_code[i];
             if(sft != 1)
               {disp_wait();}
             blink();
    
    
         DECOD1 = 1;/*** 7-segment 2nd display *******/
         DECOD2 = 0;
         DECOD3 = 0;
    
         P0 = number_code[j];
         if(sft != 2)
               {disp_wait();}
             blink();
    
    
         DECOD1 = 0;/* 7-segment 3rd display ****/
         DECOD2 = 1;
         DECOD3 = 0;
    
         P0 = number_code[k];
         if(sft != 3)
               {disp_wait();}
             blink();
    
    
         DECOD1 = 1;/** 7-segment 4th display *****/
         DECOD2 = 1;
         DECOD3 = 0;
    
         P0 = number_code[l];
         if(sft != 4)
               {disp_wait();}
             blink();
    
            }
    
    
    /***dly routine's*************/
    
    
    void disp_wait()
             {
             unsigned int w1 = 0;
             unsigned int w2 = 0;
             for(w1 = 1;w1<=2;w1++)
                {
                    for(w2 = 1;w2<=200;w2++)
                    {}
                    }
         }
    
    void disp_inc_wait()
         {
             unsigned int w1 = 0;
             unsigned int w2 = 0;
             for(w2 = 1;w2 <=60;w2++)
            {
                    for(w1 = 1;w1 <=800;w1++)
                       {
                       _nop_();
                       }
                    }
         }
    
    void sft_wait()
        {
        unsigned int w1 = 0;
            unsigned int w2 = 0;
            for(w2 = 1;w2 <=100;w2++)
            {
                    for(w1 = 1;w1 <=800;w1++)
                       {_nop_();}
                    }
            }
    
    /****blink char(dly)******/
    
    void blink()
        {
            unsigned int w1 = 0;
            unsigned int w2 = 0;
            for(w2 = 1; w2<=20; w2++)
            {
             sft_wait();
                }
         }
    
    /****** main prog******/
    
    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();WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
    
                 }
    }
    
    unsigned int go()
         {
    /*shift key press identification ****/
    
             if(KEY2_SFT == 0)
                       {
                       sft++;
                       sft_wait();
               KEY2_SFT = 1;
                       if(sft > 4)
                         {sft = 1;}
               }
    /* opration on shift char ***/
             switch(sft)
                   {
                  case 1: /****** 7-segment 1st *******/
                       if(KEY1_INC == 0)
                         {
                          i++;
                         if(i > 9)
                           {i = 0;}
                          disp_inc_wait();
                         KEY1_INC = 1;
                         }
                         break;
    
                        case 2:
              if(KEY1_INC == 0)        /* 7-segment 2nd */
               {
               j++;
               if(j > 9)
                   {j = 0;}
               disp_inc_wait();
                KEY1_INC = 1;
               }
               break;
    
             case 3:
              if(KEY1_INC == 0)/* 7-segment 3rd ***/
                {
                k++;
                 if(k > 9)
                  {k = 0;}
                disp_inc_wait();
                KEY1_INC = 1;
                }
             break;
    
            case 4:
               if(KEY1_INC == 0)/* 7-segment 4th */
                 {
                 l++;
                  if(l > 9)
                  {l = 0;}
                 disp_inc_wait();
                 KEY1_INC = 1;
                 }
                 break;
           }
             a = sft;
         return(a);
             }
    

Children