adafruit/Adafruit_ZeroTimer

misleading comment wrt GCLK use.

Opened this issue · 2 comments

This is cosmetic...
The code that sets the GCLK for the timer has a comment that is incorrect (copied from analogWrite() code?)
It says "use clock generator 0" when it's quite clearly setting GCLK1...

#if defined(__SAMD51__)
  GCLK->PCHCTRL[inst_gclk_id[instance]].reg =
      GCLK_PCHCTRL_GEN_GCLK1_Val |
      (1 << GCLK_PCHCTRL_CHEN_Pos); // use clock generator 0
#else

https://github.com/adafruit/Adafruit_ZeroTimer/blob/master/Adafruit_ZeroTimer.cpp#L140

On SAMD51, GCLK0 is 120MHz, and GCLK1 is 48MHz, so using CLK1 makes the SAMD51 and SAMD21 "compatible."

kk - pleaes submit a PR, since its a comment we will be able to merge it easily!

OK; done.
I'm slightly worried by the fact that it doesn't say anywhere in the TimerZero code that it's running the timers at 48MHz, although uses seem to assume that (ie https://github.com/adafruit/Adafruit_LvGL_Glue/blob/master/Adafruit_LvGL_Glue.cpp#L370 )