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

use one PWM drive multi IOs

We want to use 52832 to control 6 LEDs. it is easy to use 6 IO pins to make them on and off. but we need these LED to blink. so we want to use one PWM module to generate 1 Hz PWM with 50% duty cycle. we need PWM output AND with the IO output control. is there a easy way to do this?

thanks,

David Sun

  • Hi David

    It sounds a bit overkill to use the PWM for such a low frequency, unless you need extremely accurate blinking.

    For blinking LED's I would suggest using an app_timer instead, and simply toggle the LED's manually from the app_timer callback.

    If you use the GPIO registers directly it is possible to set or clear multiple pins in a single instruction, like this:

    NRF_GPIO->OUTSET = (1 << pin1_num) | (1 << pin2_num) | ... | (1 << pinN_num);
    NRF_GPIO->OUTCLR = (1 << pin1_num) | (1 << pin2_num) | ... | (1 << pinN_num);

    Best regards
    Torbjørn

Related