-
Notifications
You must be signed in to change notification settings - Fork 259
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
[2/3] Timer abstraction: add OneShotTimer
/PeriodicTimer
drivers, Timer
trait
#1570
[2/3] Timer abstraction: add OneShotTimer
/PeriodicTimer
drivers, Timer
trait
#1570
Conversation
Solution to the systimer periodic timer problem seems to be this: i.e. this seems to fix it for me (tested on C6 only for now) fn load_value(&self, value: MicrosDurationU64) {
....
if auto_reload {
// Period mode
systimer
.target_conf(CHANNEL as usize)
.modify(|_, w| unsafe { w.period().bits(ticks as u32) });
#[cfg(not(esp32s2))]
systimer
.comp_load(CHANNEL as usize)
.write(|w| w.load().set_bit());
// Clear and then set SYSTIMER_TARGETx_PERIOD_MODE to configure COMPx into period mode
systimer.target_conf(CHANNEL as usize).modify(|_,w| w.period_mode().clear_bit());
systimer.target_conf(CHANNEL as usize).modify(|_,w| w.period_mode().set_bit());
} else {
// Target mode
..... 5 is still printed immediately but not 4 |
fb8bb3c
to
b302f62
Compare
bb14ffd
to
b37bde9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - Thanks!
This is still a bit messy overall, but I plan to clean things up in the next and final PR in this series. Refactoring and documentation will be improved in said PR.
At this time
OneShotTimer
is working correctly both when backed byTIMGx
andSYSTIMER
.PeriodicTimer
is working when backed byTIMGx,
however there is one small issue remaining when backed bySYSTIMER
.Given the following example:
Both
5
and4
are immediately printed, and then the countdown continues as expected from there. Not sure why the first iteration is clearing right away, still looking into it.