Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sam0_common/periph/rtt: Interrupt flags are not correctly cleared #10351

Closed
jcarrano opened this issue Nov 8, 2018 · 2 comments · Fixed by #12188
Closed

sam0_common/periph/rtt: Interrupt flags are not correctly cleared #10351

jcarrano opened this issue Nov 8, 2018 · 2 comments · Fixed by #12188
Labels
Area: cpu Area: CPU/MCU ports Area: drivers Area: Device drivers Area: timers Area: timer subsystems State: don't stale State: Tell state-bot to ignore this issue Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Comments

@jcarrano
Copy link
Contributor

jcarrano commented Nov 8, 2018

Description

The INTFLAGS register is cleared by writing a 1 to the corresponding interrupt flag bit. Flags that must not be cleared should be written as zero. This is a pretty common behaviour for interrupt flag registers.

This RTT driver is using or-equal to clear the flags, which means it can possibly clear other interrupts. There's a small chance that one event is missed if it happens very close to another event.

see:

rtcMode0->INTFLAG.reg |= RTC_MODE0_INTFLAG_CMP0;

and

rtcMode0->INTFLAG.reg |= RTC_MODE0_INTFLAG_OVF;

The correct thing to write is: rtcMode0->INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0;

References

From the samr21's manual:

Writing a zero to this bit has no effect.
Writing a one to this bit clears the Compare 0 interrupt flag.

@jcarrano jcarrano added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Area: drivers Area: Device drivers Area: timers Area: timer subsystems Area: cpu Area: CPU/MCU ports labels Nov 8, 2018
@stale
Copy link

stale bot commented Aug 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions.

@stale stale bot added the State: stale State: The issue / PR has no activity for >185 days label Aug 10, 2019
@stale stale bot closed this as completed Sep 10, 2019
@jcarrano
Copy link
Contributor Author

This is still a bug, and it is now in sam0_common:

RTC->MODE0.INTFLAG.reg |= RTC_MODE0_INTFLAG_OVF;

RTC->MODE0.INTFLAG.reg |= RTC_MODE0_INTFLAG_CMP0;

@jcarrano jcarrano reopened this Sep 10, 2019
@stale stale bot removed the State: stale State: The issue / PR has no activity for >185 days label Sep 10, 2019
@jcarrano jcarrano changed the title samd21/periph/rtt: Interrupt flags are not correctly cleared sam0_common/periph/rtt: Interrupt flags are not correctly cleared Sep 10, 2019
@jcarrano jcarrano added the State: don't stale State: Tell state-bot to ignore this issue label Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: cpu Area: CPU/MCU ports Area: drivers Area: Device drivers Area: timers Area: timer subsystems State: don't stale State: Tell state-bot to ignore this issue Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant