From 41e8a57960a770e2e2148fd22977a8964cffc8d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Gandra=C3=9F?= Date: Mon, 13 Dec 2021 12:08:38 +0100 Subject: [PATCH] cpu/atmega_common: Remember CTC mode with timer_periodic --- cpu/atmega_common/periph/timer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cpu/atmega_common/periph/timer.c b/cpu/atmega_common/periph/timer.c index 375dd7260b..81fb145c18 100644 --- a/cpu/atmega_common/periph/timer.c +++ b/cpu/atmega_common/periph/timer.c @@ -219,11 +219,12 @@ int timer_set_periodic(tim_t tim, int channel, unsigned int value, uint8_t flags if (channel == 0) { if (flags & TIM_FLAG_RESET_ON_MATCH) { /* enable CTC mode */ - ctx[tim].dev->CRB |= (1 << 3); + ctx[tim].mode |= (1 << 3); } else { /* disable CTC mode */ - ctx[tim].dev->CRB &= (1 << 3); + ctx[tim].mode &= (1 << 3); } + ctx[tim].dev->CRB = ctx[tim].mode; } else { assert((flags & TIM_FLAG_RESET_ON_MATCH) == 0); res = -1;