我正在使用SDK 12.0.0。
我正在使用low_power_pwm_init()来初始化pwm,并在初始化时传递了一个处理程序。 我想停止处理程序的pwm,因此我正在从处理程序调用low_power_pwm_stop() 。 我观察到pwm不停止。
我试图调查此原因,并发现pwm_timeout_handler()正在重新启动pwm。 以下是可疑的片段。
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); }在low_power_pwm_stop() ,为p_pwm_instance->pwm_state分配了NRF_DRV_STATE_INITIALIZED并且在上面的片段中,如果驱动器状态为NRF_DRV_STATE_INITIALIZED ,则启动定时器,导致pwm再次打开。
这是一个错误?
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?
最满意答案
我在北欧的devzone上发布了这个问题,下面是我从北欧员工那里得到的答案 。
嗨,
我可以看到情况会是这样,并会在内部报告。
您可以在事件处理程序中设置一个标志,并在main中调用停止例程。
奥勒
所以我想这是北欧sdk代码中的一个错误。
I had posted this question on nordic's devzone and below is the answer that I got from a nordic employee.
Hi,
I can see that this will be the case and will report it internally.
You can set a flag in the event handler and call the stop routine in main.
Ole
So I guess this is a bug in nordic's sdk code.
更多推荐
发布评论