This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

PWM Update_function

Dear Nordic Team

I have changed pwm driver example as you see in bellow . i also observed the codes which you linked for pwm. Bellow code works without the effect of update_pwm and working well. But the problem is that i can not control the duty cycle by void update_pwm function. Kindly please help me.

Kind regards

Parents
  • Hi,

    The duty cycle is generally the ratio between the top_value and seq_value.

    With the code you uploaded, the PWM will go from 100% duty, and slowly go to 0%, and then up again to 100% duty, giving the LED1 a fading effect.

    If you just want to set a simple duty cycle, here is some code example on how to do that:

    Snippet:

  • Hi

    Thank you for replying. I tried your code but by changing the pwm_update_duty_cycle(50); nothing happened!

    for example i changed 50 to zero and it must be turn of the led but led still on!

  • for example i changed 50 to zero and it must be turn of the led but led still on

    The LEDs on the DK are active low. I have inverted the PWM in this code:

  • Thank you for answering. Now it works by one pin. I connected one RGB led to three pins and updated the duty cycle for 3 color. But i have still another problem and RGB led remains off. Could you please check the bellow code?

     

Reply
  • Thank you for answering. Now it works by one pin. I connected one RGB led to three pins and updated the duty cycle for 3 color. But i have still another problem and RGB led remains off. Could you please check the bellow code?

     

Children
  • You can have 4 PWM channels for each instance, so you only need to create 1 instance.

    Snippet:

  • Thank you for answering. it works.