Skip to content

Commit

Permalink
cpu/stm32/periph_timer: fix spurious IRQs
Browse files Browse the repository at this point in the history
  • Loading branch information
maribu committed Nov 24, 2022
1 parent 93c5755 commit 20fc71d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cpu/stm32/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ int timer_set_absolute(tim_t tim, int channel, unsigned int value)
}
#endif

/* clear spurious IRQs */
dev(tim)->SR &= ~(TIM_SR_CC1IF << channel);

/* enable IRQ */
dev(tim)->DIER |= (TIM_DIER_CC1IE << channel);
irq_restore(irqstate);

Expand Down Expand Up @@ -166,6 +170,11 @@ int timer_set_periodic(tim_t tim, int channel, unsigned int value, uint8_t flags
}

TIM_CHAN(tim, channel) = value;

/* clear spurious IRQs */
dev(tim)->SR &= ~(TIM_SR_CC1IF << channel);

/* enable IRQ */
dev(tim)->DIER |= (TIM_DIER_CC1IE << channel);

if (flags & TIM_FLAG_RESET_ON_MATCH) {
Expand Down

0 comments on commit 20fc71d

Please sign in to comment.