7 years, 10 months ago.

Why do the SAMD21 targets run only at 8MHz

Hi

I think that the SAMD21 targets like the Atmel ATSAMD21-XPRO run only on 8 MHz and not at the 48 MHz they could.

I checked the frequency by calling:

printf("system_cpu_clock_get_hz = %lu\n", system_cpu_clock_get_hz());

which prints: system_cpu_clock_get_hz = 8000000

I found the [conf_clocks.h|https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_Atmel/TARGET_SAM_CortexM0P/config/TARGET_SAMD21/conf_clocks.h] and saw that the External 32KHz crystal/clock oscillator (CONF_CLOCK_XOSC32K_ENABLE) and the Digital Frequency Locked Loop (CONF_CLOCK_DFLL_ENABLE) are disabled:

/* SYSTEM_CLOCK_SOURCE_XOSC32K configuration - External 32KHz crystal/clock oscillator */
#  define CONF_CLOCK_XOSC32K_ENABLE               false

/* SYSTEM_CLOCK_SOURCE_DFLL configuration - Digital Frequency Locked Loop */
#  define CONF_CLOCK_DFLL_ENABLE                  false

and the Internal 8MHz oscillator is used for the Main Clock

/* Configure GCLK generator 0 (Main Clock) */
#  define CONF_CLOCK_GCLK_0_ENABLE                true
#  define CONF_CLOCK_GCLK_0_RUN_IN_STANDBY        false
#  define CONF_CLOCK_GCLK_0_CLOCK_SOURCE          SYSTEM_CLOCK_SOURCE_OSC8M
#  define CONF_CLOCK_GCLK_0_PRESCALER             1
#  define CONF_CLOCK_GCLK_0_OUTPUT_ENABLE         false

Is this a bug that SAMD21 targets run at only 8 MHz?

Or is there a way in mbed to configure the SAMD21 targets to run at the 48MHz?

Regards Franz

What happens if you print SystemCoreClock variable? (Or maybe that is what you did). I checked their source code, but they decided to completely ignore the normal organisation of the source code, so it already took me too long to find the clock setup files. Which in the end seem to just set the clock to the 1MHz internal oscillator: https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_Atmel/TARGET_SAM_CortexM0P/utils/cmsis/TARGET_SAMD21/source/system_samd21.c

posted by Erik - 31 Jan 2017

Hi Erik, the SystemCoreClock variable Prints 1000000, but I think the SAMD21 targets do not use or update SystemCoreClock variable. I aslo added some more details to my question.

posted by Schnyder Franz 01 Feb 2017
Be the first to answer this question.