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

Way to cancel TASK_STOP (PWM driver)

Hi there,

I'm using nRF52840 dev kit board and v15.2 SDK.

I've set up a PWM using the PWM driver and is working well. 

I'm frequently stopping and starting the PWM and I'm stopping the pwm by calling nrf_drv_pwm_stop. My PWM is running at around 1kHz so sometimes stop event takes long time after calling nrf_drv_pwm_stop.

The problem is, occasionally I can see that my code tries to enable PWM before stop event interrupt is called and this causes a problem because my code enables the PWM but TASK_STOP is already triggered so it stops the PWM after it has just been enabled. 

I have tried nrf_pwm_event_clear(my_pwm.p_registers, NRF_DRV_PWM_EVT_STOPPED) but this is only clearing the stop event to trigger ISR. The actual stopping task still seems to happen and I was wondering if we could somehow cancel the already triggered TASKS_STOP.

I've tried writing 0 to my_pwm.p_registers->TASKS_STOP but this does not seem to have any effect.

Please someone help!

Thanks,

AOF

Parents
  • I've tried writing 0 to my_pwm.p_registers->TASKS_STOP but this does not seem to have any effect.

     After triggering the STOP TASK, i do not see anyway of stopping this. I strongly recommend you not to pursue this direction.

    The problem seems to be that your application logic is starting the new PWM action before the previous one stop has completed. In this scenario, the proper way, according to me, is to fix your application logic, that it could wait until the STOP_TASK has finished its work and the interrupt is triggered for EVENT_STOP.  

Reply
  • I've tried writing 0 to my_pwm.p_registers->TASKS_STOP but this does not seem to have any effect.

     After triggering the STOP TASK, i do not see anyway of stopping this. I strongly recommend you not to pursue this direction.

    The problem seems to be that your application logic is starting the new PWM action before the previous one stop has completed. In this scenario, the proper way, according to me, is to fix your application logic, that it could wait until the STOP_TASK has finished its work and the interrupt is triggered for EVENT_STOP.  

Children
Related