Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

PWM driver accuracy

Hello everyone

first if all, im not an expert in PWM, but doing my best to understand everything

I have successfully created and tested a project using the pwm_driver example.

 nrf_drv_pwm_config_t const config0 =
    {
        .output_pins =
        {
            OUTPUT_PIN_1 | NRF_DRV_PWM_PIN_INVERTED,             // channel 0
            OUTPUT_PIN_2 | NRF_DRV_PWM_PIN_INVERTED,             // channel 1
            OUTPUT_PIN_3 | NRF_DRV_PWM_PIN_INVERTED,             // channel 2
            NRF_DRV_PWM_PIN_NOT_USED                             // channel 3
        },
        .irq_priority = APP_IRQ_PRIORITY_LOWEST,
        .base_clock   = NRF_PWM_CLK_1MHz,
        .count_mode   = NRF_PWM_MODE_UP,
        .top_value    = 100,
        .load_mode    = NRF_PWM_LOAD_INDIVIDUAL,
        .step_mode    = NRF_PWM_STEP_AUTO
    };

in this piece of code, the top value is set to 100. 
I understand that I have an accuracy of 0 to 100, so its actually just a percentage

Now i would like to have an accuracy of 0 to 65535 ( actually just a 16-bit integer )

I have already tried playing around with the top value but it seems to only go around 30 000.
I have been looking around and my guess is that I have to change the base_clock, but i don't really know what I'm doing at ths point.

Is this even possible to achieve? If not, whats the maximum top value then?

Thanks in advance

Maxime Mylle

Parents Reply Children
No Data
Related