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

[bug report] pwm_state is inconsistent, causing an ASSERT to fail

Hi,

I believe there's a minor bug in low_power_pwm.c regarding pwm_state.

The routine low_power_pwm_start sets the pwm_state to NRF_DRV_STATE_POWERED_ON; but it then calls pwm_timeout_handler, which immediately sets the state back to NRF_DRV_STATE_INITIALIZED.

This triggers this ASSERT when calling low_power_pwm_stop, because the state is no longer in the NRF_DRV_STATE_POWERED_ON state:

ASSERT(p_pwm_instance->pwm_state == NRF_DRV_STATE_POWERED_ON);

Thus, calling low_power_pwm_start then low_power_pwm_stop always asserts.

The pwm_timeout_handler probably shouldn't be setting the state to NRF_DRV_STATE_INITIALIZED.

Related