__SYSTEM_CLOCK is wrong in system_samd20.c

Discussions around product based on ARM Cortex M0+ core.

Moderator: nferre

pozz
Posts: 67
Joined: Fri Jun 13, 2014 2:55 pm

__SYSTEM_CLOCK is wrong in system_samd20.c

Sat Jun 21, 2014 9:29 am

I wanted to configure SysTick with SysTick_Config() CMSIS function:

Code: Select all

SysTick_Config(SystemCoreClock / 1000);
It didn't work because SystemCoreClock is assigned __SYSTEM_CLOCK value defined in system_samd20.c:

Code: Select all

/**
 * Initial system clock frequency. The System RC Oscillator (RCSYS) provides
 *  the source for the main clock at chip startup.
 */
#define __SYSTEM_CLOCK    (115000)
I think RCSYS clock source is present on other Cortex-M micro by Atmel, but isn't present in SAM D20. __SYSTEM_CLOCK should be defined as 1000000, because it is the startup clock (internal 8MHz oscillator divided by 8 ).

I could fix that value in system_samd20.c, but I don't understand how to change SystemCoreClock value at run-time if I use a different clock source (for example, the internal 8MHz oscillator without prescaler).

There is the function SystemCoreClockUpdate(), but it is defined as:

Code: Select all

/**
 * Update SystemCoreClock variable
 *
 * @brief  Updates the SystemCoreClock with current core Clock
 *         retrieved from cpu registers.
 */
void SystemCoreClockUpdate(void)
{
	// Not implemented
	SystemCoreClock = __SYSTEM_CLOCK;
	return;
}
Not implemented!!! Aaaarghhhh!!!

Return to “SAM D20 Cortex-M0+ MCU”

Who is online

Users browsing this forum: No registered users and 1 guest