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

Regarding PWM

Dear nordic,

I have some doubts regarding PWM. i want two PWM out both are working different frequency and also i need softdevice. I think PWM can make two ways one is using timer and other is using PWM driver is it right?

1. which is better method for my application( i want 2 PWM out and softdevice)?

2. Is it possible to change PWM frequency(not duty cycle) while in running?

Parents Reply Children
  • Hi

    The PWM hardware modules are not very convenient if you want to change the frequency dynamically. They are setup to load duty cycle changes directly from RAM, but will need to be re-initialized every time you want to change the frequency. 

    For that reason you might consider the timer approach instead. Set up the GPIOTE module to set and clear your pin, and connect a TIMER module to the GPIOTE output through the PPI. 

    One compare register in the TIMER can set the pin while another compare register clears the pin, and then you just change the values of these registers to change the duty cycle and frequency of the output. 

    For an example of how to set this up you can refer to this example.

    Best regards
    Torbjørn

Related