adafruit / Adafruit_ZeroTimer

happy wrappers for TC modules 3,4,5 on SAMD21
MIT License
31 stars 25 forks source link

misleading comment wrt GCLK use. #17

Open WestfW opened 4 years ago

WestfW commented 4 years ago

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."

ladyada commented 4 years ago

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

WestfW commented 4 years ago

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 )