Skip to content

Commit 6673c3a

Browse files
committed
cpu/stm32/periph_timer: fix spurious IRQs
(cherry picked from commit 20fc71d)
1 parent ad0ad00 commit 6673c3a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cpu/stm32/periph/timer.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ int timer_set_absolute(tim_t tim, int channel, unsigned int value)
136136
}
137137
#endif
138138

139+
/* clear spurious IRQs */
140+
dev(tim)->SR &= ~(TIM_SR_CC1IF << channel);
141+
142+
/* enable IRQ */
139143
dev(tim)->DIER |= (TIM_DIER_CC1IE << channel);
140144
irq_restore(irqstate);
141145

@@ -166,6 +170,11 @@ int timer_set_periodic(tim_t tim, int channel, unsigned int value, uint8_t flags
166170
}
167171

168172
TIM_CHAN(tim, channel) = value;
173+
174+
/* clear spurious IRQs */
175+
dev(tim)->SR &= ~(TIM_SR_CC1IF << channel);
176+
177+
/* enable IRQ */
169178
dev(tim)->DIER |= (TIM_DIER_CC1IE << channel);
170179

171180
if (flags & TIM_FLAG_RESET_ON_MATCH) {

0 commit comments

Comments
 (0)