Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

dimming continuously using pwm library

Hi,

From the pwm driver, there is a function that use sequence that control the dimming while not blocking other task in the program, may i ask if there are any function work like this in the pwm library? If none, could you give me the guideline to achieve the task? my current SDK version is v15.1.0.

Parents Reply Children
  • I suggest you take a look at demo2() in examples\peripheral\pwm_driver\

    This example has some different demos. demo1() uses the CPU every time it changes intencity (demo1_handler()), demo 2 is only initialized and started with a loop flag. 

    Note that demo2() has two different sequences played after one another. First, in seq0 the LEDs will dim from off to on, and then seq1 will blink the LEDs.

    As you see, if you don't want any CPU interrupts (so that it is not blocking other tasks), you must set all the variables in an array (seq0_values[]).

    Note that it is possible to slowly dim without blocking, using the solution that suggested. But then you need to use the CPU every time you want to update the duty cycle. In the PWM driver example, the PWM peripheral can change duty cycles without interrupting the CPU.

    You can read about the PWM peripheral here.

    Best regards,

    Edvin

Related