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

timer that pwm opens can not be closed

Hi,all~

I got a question about pwm's timer. Here is my working environment: SDK 10.0, SD8.0, IC VERSION: qfabc0.

I use timer1 as clock of pwm. APP_PWM_INSTANCE(PWM1,1);
When I run app_pwm_enable(),the current goes to 3.6 mA. And then I run app_pwm_disable(), but the current still remains 3.6 mA.

Then I try to figure out where the current comes from, so I comment the code: nrf_drv_timer_enable(p_instance->p_timer); in app_pwm_enable(), then the current can be colsed normally.

So it seems like the timer cannot be closed after pwm open it. But I also have tried timer2 to generate a gpiote task to toggle a port, and its current is only 500uA and can be closed normally, so why not here?

Thanks a lot!

Parents
  • app_pwm_disable() turns off the pwm, app_pwm_uninit() calls app_pwm_disable and deallocates the resources (timer, gpiote channels, ppi channels).

    3.6mA does not sound like the CPU is on since this will require 4.1mA (running from flash) + HFCLK current, and it is too high for any other peripheral (other than the radio, for that it is too low). Are you sure the code is working and not running into some error condition and constantly resetting? Could you try to define DEBUG and see if the code stops executing? See this post.

Reply
  • app_pwm_disable() turns off the pwm, app_pwm_uninit() calls app_pwm_disable and deallocates the resources (timer, gpiote channels, ppi channels).

    3.6mA does not sound like the CPU is on since this will require 4.1mA (running from flash) + HFCLK current, and it is too high for any other peripheral (other than the radio, for that it is too low). Are you sure the code is working and not running into some error condition and constantly resetting? Could you try to define DEBUG and see if the code stops executing? See this post.

Children
  • Hi, I am using sdk10 with softdevice enabled. My CPU is going into low power ON mode (~300uA) but after running NRF_TIMER1 for PWM application, the HFCLK seems to be left ON as the current goes to ~4.2mA and remains there.

    I have done deinit of PWM and also shutdown the timer writing 1 to timer register->SHUTDOWN.

    What my guess is that once a peripheral starts the NRF_TIMER1 (which mostly accesses the PCLK1M/PCLK16M), the HFCLK is not getting shutdown and hence it consumes this much current. Any solutions to this ?

  • 4.2 mA is too much for timer alone, this current indicates that the CPU is not going to sleep. You need to figure out why. It sounds like you are manipulating the registers while using the pwm library (app_pwm), this is not recommended as it will lead to undetermined behavior. Why can't you use app_pwm_disable() or app_pwm_uninit()?

Related