Skip to content

Commit

Permalink
Merge pull request #18527 from dylad/pr/fix_sam0_timer_stop
Browse files Browse the repository at this point in the history
cpu/sam0/timer: supply all clocks before accessing any regs
  • Loading branch information
benpicco authored Aug 30, 2022
2 parents 62c8ac3 + 950a7d5 commit c9bbac8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cpu/sam0_common/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,6 @@ int timer_init(tim_t tim, uint32_t freq, timer_cb_t cb, void *arg)
return -1;
}

/* make sure the timer is not running */
timer_stop(tim);

sam0_gclk_enable(cfg->gclk_src);
#ifdef MCLK
GCLK->PCHCTRL[cfg->gclk_id].reg = GCLK_PCHCTRL_GEN(cfg->gclk_src) | GCLK_PCHCTRL_CHEN;
Expand All @@ -158,6 +155,9 @@ int timer_init(tim_t tim, uint32_t freq, timer_cb_t cb, void *arg)
PM->APBCMASK.reg |= cfg->pm_mask;
#endif

/* make sure the timer is not running */
timer_stop(tim);

/* reset the timer */
dev(tim)->CTRLA.bit.SWRST = 1;
while (dev(tim)->CTRLA.bit.SWRST) {}
Expand Down

0 comments on commit c9bbac8

Please sign in to comment.