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

Is it possible to creat a pwm with 1sec period

Dear All :

Is it possible to creat a pwm with 1sec period? Since the lowest frequency of the base clock is 125kHz,the top count of the pwm with 1sec period will be 125000(for case of up counter)。But the top count is a uint16_t integer that the maximum value is 65536。

Besides, I find the available base clock frequency can be 0 - 16 MHz 1 - 8 MHz 2 - 4 MHz 3 - 2 MHz 4 - 1 MHz 5 - 500 kHz 6 - 250 kHz 7 - 125 MHz in PWM_DEFAULT_CONFIG_BASE_CLOCK.

But I can not find the base clock frequency below 125kHz in the structure nrf_pwm_clk_t (in the example pwm deiver); How can I use a base_clock frequency below 125kHz (Is it possible to change the pwm_clock? )

Thank you for your comment and suggestion。 Best Wishes!

  • Hi Kaochin,

    The BASE_CLOCK is just a wrap over of the pwm clock prescaler. So 125kHz is prescaler div 128.

    You can't get lower frequency.

    In your case I would suggest to use RTC instead of PWM. You can use RTC and PPI to connect to a GPIO pin. This way you can handle the 1 second period easily and still have low power consumption.

    But be careful if you change the duty cycle dynamically, to avoid glitch on corner cases.

    You can refer to the PWM driver we have for the nRF51 (where we don't have hardware PWM) as the reference.

Related