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

Low-power PWM library: PWM doesnt stop if low_power_pwm_stop is called from handler. Is this a bug?

I am using SDK 12.0.0.

I am working with low_power_pwm_init() to initialise the pwm and I have passed a handler while initialising. I want to stop the pwm from the handler hence I am calling low_power_pwm_stop() from the handler. I observe that the pwm doesnt stop.

I tried to investigate the reason for this and found that pwm_timeout_handler() in low_power_pwm.c is restarting the pwm. Below is the snippet that is suspect.

if (p_pwm_instance->pwm_state == NRF_DRV_STATE_INITIALIZED)
{
    p_pwm_instance->pwm_state = NRF_DRV_STATE_POWERED_ON;
    err_code = app_timer_start(*p_pwm_instance->p_timer_id, p_pwm_instance->timeout_ticks, p_pwm_instance);
    APP_ERROR_CHECK(err_code);
}

In low_power_pwm_stop(), p_pwm_instance->pwm_state is assigned NRF_DRV_STATE_INITIALIZED and in the above snippet the timer is started if the driver state is NRF_DRV_STATE_INITIALIZED, causing the pwm to be ON again.

Is this a bug?

Parents Reply Children
No Data
Related