How to change the frequency of PWM after initializing PWM

Dear Support Team

I would like to change the frequency of PWM after the PWM initializing. How could I change the frequency of PWM If I have initialized the PWM by calling the app_pwm_init()?

  • The frequency (or period which the API use) is only provided in the configuration to app_pwm_init(), and is used there to calculate the timer frequency and configure the timer, and calculate and number of ticks in each period. When changing the period this has to be done again, and the only way to do this is to uninitialize using app_pwm_uninit() and then reinitialize the app_pwm library with app_pwm_init().

    (You could of course work to re-write the library to support changing frequency without reinitializing, but you would still have to do most of what app_pwm_init() already does).

Related