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

Related