This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Changing PWM frequency (period)

I have 2 PWMs working with the version 8 softdevice on an nRF51422, and it's straightforward enough to change the duty cycle with app_pwm_channel_duty_set() in the app_pwm library. However, I would like to be able to change the period on-the-fly, as well. Does anyone have a suggestion for the best way to do this, other than uninitializing the PWMs and reinitializing them with the new period? Thanks in advance for any advice.

  • I can do this only through : uninit pwm module, init pwm module with necessary period, enable pwm module, set duty cycle, start....

  • With the SDK driver you have to uninitialize and reinitialize the PWM. You could make your own driver that allows for varying frequency, but this can be very difficult (if not impossible) to achieve without the risk of getting an inverted PWM signal (a common issue on the nRF51).

    If you go for the SDK driver, make sure to use the SDK 10 version as this has fixed problems related to the uninit function in previous SDKs.

Related