From 491e2974188a170ea03d5de5ceade66b7415470d Mon Sep 17 00:00:00 2001 From: Marco Widmer Date: Mon, 17 Mar 2025 15:38:32 +0100 Subject: [PATCH] drivers: counter: nrfx_timer: Use shutdown task if available Add a workaround for NRF52 anomaly 78: "High current consumption when using timer STOP task only". Use the SHUTDOWN task instead. For consistency, CLEAR the timer timer after STOPPING on devices that lack the SHUTDOWN task. This also aligns the behavior with nrfx_timer_disable(). For devices with the SHUTDOWN task, this restores the behavior previous to e92323f. Fixes #87224 Signed-off-by: Marco Widmer --- drivers/counter/counter_nrfx_timer.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/counter/counter_nrfx_timer.c b/drivers/counter/counter_nrfx_timer.c index c5c0da812c1..52e525717a9 100644 --- a/drivers/counter/counter_nrfx_timer.c +++ b/drivers/counter/counter_nrfx_timer.c @@ -110,7 +110,13 @@ static int stop(const struct device *dev) { const struct counter_nrfx_config *config = dev->config; +#if NRF_TIMER_HAS_SHUTDOWN + nrf_timer_task_trigger(config->timer, NRF_TIMER_TASK_SHUTDOWN); +#else nrf_timer_task_trigger(config->timer, NRF_TIMER_TASK_STOP); + nrf_timer_task_trigger(config->timer, NRF_TIMER_TASK_CLEAR); +#endif + #ifdef COUNTER_ANY_FAST struct counter_nrfx_data *data = dev->data;