0

SAMD51 (CM4) and ZeroTimer library...
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

SAMD51 (CM4) and ZeroTimer library...

by westfw on Wed Jan 09, 2019 1:23 am

I have the ZeroTimer library serving as a pulse generator on an Metro M4 with the SAMD51 processor, and I have a couple of questions about the clocking:
  1. The timers seem to be running with a 48MHz input clock, despite the main CPU clock being 120MHz. Is that intentional? (It's nicely compatible with the SAMD21 boards.)
  2. The comment in this code (from ZeroTimer)
    Code: Select all | TOGGLE FULL SIZE
    #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
    Says clock generator zero, but the constant being loaded is ...GCLK1? (https://github.com/adafruit/Adafruit_ZeroTimer/blob/master/Adafruit_ZeroTimer.cpp#L115
  1. SAMD51 apparently has a separate MCLK for running the CPU itself instead of running it off of GCLK0? Or not? I'm not quite understanding the datasheet or code, and I've run into things before where some things run off arbitrary GCLKs, some things run off of specific GCLK, and some things run off of "other" clocks (notably, the RTC runs directly from a 32kHz oscillator, except on SAMD10 (where it runs off of a gclk.)
  2. Is there a nice documented list somewhere showing which clocks are running which things, at which frequencies? ( guess this is close: https://github.com/adafruit/ArduinoCore-samd/blob/master/cores/arduino/startup.c#L25
User avatar
westfw
 
Posts: 1507
Joined: Fri Apr 27, 2007 1:01 pm
Location: SF Bay area

Re: SAMD51 (CM4) and ZeroTimer library...

by Adafruit_UMjT7KxnxP8YN8 on Wed Jan 09, 2019 11:19 am

I found Chapter 13 of the processor datasheet to be useful in this regard. http://ww1.microchip.com/downloads/en/D ... 01507B.pdf

Adafruit_UMjT7KxnxP8YN8
 
Posts: 24
Joined: Tue Jul 17, 2018 1:28 pm

Re: SAMD51 (CM4) and ZeroTimer library...

by adafruit2 on Wed Jan 09, 2019 1:58 pm

we don't have any more details or docs for that library - but yes we like to keep it SAMD21 compatible. if you have any updates, send a PR - the library is not well supported right now, we don't advertize it or anything :)

adafruit2
Site Admin
 
Posts: 18047
Joined: Fri Mar 11, 2005 7:36 pm

Please be positive and constructive with your questions and comments.