低功耗PWM库:如果处理程序调用low

系统教程 行业动态 更新时间:2024-06-14 16:54:47
低功耗PWM库:如果处理程序调用low_power_pwm_stop,PWM不会停止。(Low-power PWM library: PWM doesnt stop if low_power_pwm_stop is called from handler. Is this a bug?)

我正在使用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.

更多推荐

本文发布于:2023-04-08 12:34:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/a0646a379730a7f45adb31c159a48686.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:低功耗   程序   PWM

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!