cpu/atmega_common/periph_timer: fix spurious IRQs#18978
cpu/atmega_common/periph_timer: fix spurious IRQs#18978maribu merged 1 commit intoRIOT-OS:masterfrom
Conversation
cpu/atmega_common/periph/timer.c
Outdated
| ctx[tim].dev->OCR[channel] = (uint16_t)value; | ||
| *ctx[tim].flag &= ~(1 << (channel + OCF1A)); | ||
| /* clear spurious IRQs, if any */ | ||
| *ctx[tim].flag |= (1 << (channel + OCF1A)); |
There was a problem hiding this comment.
| *ctx[tim].flag |= (1 << (channel + OCF1A)); | |
| *ctx[tim].flag = (1 << (channel + OCF1A)); |
I think this should also work. @kfessel: You're the AVR expert, do I read the datasheet correctly?
There was a problem hiding this comment.
In fact, "would also work" is incorrect: The current version would unset all flags and is buggy.
There was a problem hiding this comment.
i was about to write that:
doc tmega328p:
"Alternatively, can be cleared by writing a logic one to its bit location."
so if you flags = flags it will clear all flags that are 1.
*ctx[tim].flag |= (1 << (channel + OCF1A)); will clear all flags that are read as 1 and OCF1A in any case.
but the compiler should make *ctx[tim].flag |= (1 << (channel + OCF1A)); work anyway since all flags are placed in io-address-space -> it will become SBI <FLAGSioaddres>, (channel + OCF1A) writing a one to that specific bit location.
7d4815f to
787884a
Compare
|
Thx :) |
|
Backport provided in #18981 |
Contribution description
As the tile says
Testing procedure
tests/periph_timerfrom #18963 andtests/periph_timer_periodicshould pass. (They do on thearduino-mega2560.)Issues/PRs references
#18976