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

chips: apollo3: Allow a few tries to set the stimer #1988

Merged
merged 1 commit into from
Jul 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions chips/apollo3/src/stimer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,15 @@ impl<'a> hil::time::Alarm<'a> for STimer<'a> {
// Enable interrupts
regs.stminten.modify(STMINT::COMPAREA::SET);

// Set the delta
regs.scmpr[0].set(tics - regs.sttmr.get());
// Set the delta, this can take a few goes
// See Errata 4.14 at at https://ambiqmicro.com/static/mcu/files/Apollo3_Blue_MCU_Errata_List_v2_0.pdf
let timer_delta = tics - regs.sttmr.get();
let mut tries = 0;

alistair23 marked this conversation as resolved.
Show resolved Hide resolved
while regs.scmpr[0].get() != tics && tries < 5 {
regs.scmpr[0].set(timer_delta);
tries = tries + 1;
}

// Enable the compare
regs.stcfg.modify(STCFG::COMPARE_A_EN::SET);
Expand Down