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

More than 2 pwm channels per instance

Hi,

I am trying to fade out 5 LEDs over the course of 500ms simultaneously. I am using soft device s110 but am happy to pause everything for the half a second while the LEDs fade (ie make the pwm blocking).

Is this possible to do? Each of the LEDs is connected to a separate GPIO. If so, how?

Thanks,

Parents
  • Thank you for your calrification. With the PWM library, you can create 4xPWMs, as done here. There is also a pwm example here with softdevice.

    It is not possible to create more than 4 independent PWMs with hardware, i.e. with TIMER -> PPI -> GPIOTE. There are only 4 GPIOTE channels available so that is the limiting factor. The fifth PWM must be created with with timer interrupts where the CPU toggles the fifth PWM channel.

    My first question is, what is your softdevice schedule when you are dimming the leds? If you have connection interval of 1 second, you could use radio notifications to notify the application when a BLE radio event completes, and start the led dimming then when the CPU is fully available. The CPU is only periodically available during a BLE radio event. The same could be applied if you are advertising with long advertising interval. When dimming leds, it is probably sufficient to dim the led with 50-100 Hz frequency, where an app_timer is adequate to generate the timer interrupts.

Reply
  • Thank you for your calrification. With the PWM library, you can create 4xPWMs, as done here. There is also a pwm example here with softdevice.

    It is not possible to create more than 4 independent PWMs with hardware, i.e. with TIMER -> PPI -> GPIOTE. There are only 4 GPIOTE channels available so that is the limiting factor. The fifth PWM must be created with with timer interrupts where the CPU toggles the fifth PWM channel.

    My first question is, what is your softdevice schedule when you are dimming the leds? If you have connection interval of 1 second, you could use radio notifications to notify the application when a BLE radio event completes, and start the led dimming then when the CPU is fully available. The CPU is only periodically available during a BLE radio event. The same could be applied if you are advertising with long advertising interval. When dimming leds, it is probably sufficient to dim the led with 50-100 Hz frequency, where an app_timer is adequate to generate the timer interrupts.

Children
No Data
Related