mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-30 08:51:19 +01:00
cpu/stm32/periph/timer: fix clobered IRQ flag
The STM32 periph_timer driver reads the timer's status flags, then clears them all. It is possible that a timer interrupt could occur between reading the flag and clearing it. This would lead to a lost interrupt. The timer's status flags can be cleared by software, but can only be set by the hardware. This patch takes advantage of this by only clearing the flags it knows are set. The rest of the flags are set, which doesn't actually change their state.
This commit is contained in:
parent
993e539651
commit
dea25437c7
@ -267,7 +267,12 @@ static inline void irq_handler(tim_t tim)
|
||||
{
|
||||
uint32_t top = dev(tim)->ARR;
|
||||
uint32_t status = dev(tim)->SR & dev(tim)->DIER;
|
||||
dev(tim)->SR = 0;
|
||||
|
||||
/* clear interrupts which we are about to service */
|
||||
/* Note, the flags in the SR register can be cleared by software, but
|
||||
* setting them has no effect on the register. Only the hardware can set
|
||||
* them. */
|
||||
dev(tim)->SR = ~status;
|
||||
|
||||
for (unsigned int i = 0; status; i++) {
|
||||
uint32_t msk = TIM_SR_CC1IF << i;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user