From a7e2182bb088ac0ad66c83ad46cee1401d56df8e Mon Sep 17 00:00:00 2001 From: Jue Date: Tue, 22 Nov 2022 19:15:31 +0100 Subject: [PATCH] cpu/nrf5x/timer: run task SHUTDOWN instead of STOP This is a workaround for errata 78 that causes increased current consumption even in the stopped state. --- cpu/nrf5x_common/periph/timer.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/cpu/nrf5x_common/periph/timer.c b/cpu/nrf5x_common/periph/timer.c index 2ad3559d88..056ef64b30 100644 --- a/cpu/nrf5x_common/periph/timer.c +++ b/cpu/nrf5x_common/periph/timer.c @@ -165,7 +165,29 @@ void timer_start(tim_t tim) void timer_stop(tim_t tim) { - dev(tim)->TASKS_STOP = 1; + /* Errata: [78] TIMER: High current consumption when using + * timer STOP task only + * + * # Symptoms + * + * Increased current consumption when the timer has been running and the + * STOP task is used to stop it. + * + * # Conditions + * The timer has been running (after triggering a START task) and then it is + * stopped using a STOP task only. + * + * # Consequences + * + * Increased current consumption. + * + * # Workaround + * + * Use the SHUTDOWN task after the STOP task or instead of the STOP task + * + * cf. https://infocenter.nordicsemi.com/pdf/nRF52833_Engineering_A_Errata_v1.4.pdf + */ + dev(tim)->TASKS_SHUTDOWN = 1; } static inline void irq_handler(int num)