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

CODE for Call void function with parameter?

void PWM_Config(uint8_t TIM_PERIOD, uint8_t TIM_PULSE)
{
.
.
.
}

int main()
{

PWM_Config();   // THIS LINE SHOWS AN ERROR

.
.
.
}

ERROR LIST:

main.c(251): error: #165: too few arguments in function call PWM_Config();

BUT, If I write the program below, there is an no error

void PWM_Config()
{
.
.
.
}

int main()
{

PWM_Config();   // NO ERROR

.
.
.
}

KINDLY HELP!

Parents
  • I normally don't like responding to posts from consultants.

    Now this shows an error. I want to know the exact reason.

    The reason is simple. You're stating that the function PWM_Config takes two parameters. Then you attempt to call it with none.

    If you want to call it from main (or anywhere else), you MUST supply two arguments to go with it.

    Example:

    int main()
    {
    
      PWM_Config(1,2)
    
      .
      .
      .
    
    }
    

    This is basic C!

Reply
  • I normally don't like responding to posts from consultants.

    Now this shows an error. I want to know the exact reason.

    The reason is simple. You're stating that the function PWM_Config takes two parameters. Then you attempt to call it with none.

    If you want to call it from main (or anywhere else), you MUST supply two arguments to go with it.

    Example:

    int main()
    {
    
      PWM_Config(1,2)
    
      .
      .
      .
    
    }
    

    This is basic C!

Children