CLK001 equivalent in XMC lib

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User8819
Level 4
Level 4
Hello,

Is there a equivalent of CLK001 app from DAVE3 in new DAVE4 xmc lib? I mean I am looking for functions to initialize CCU, WDT, USB, RTC clock. What do you recommend? I don't want to use APPs anymore. Do system_XMC4500.c routines equivalent job?

Examples to initialize clocks with XMC libs are missing!

Thanks

rum
0 Likes
1 Reply
Not applicable
HI Rum,

CLOCK_XMC4 is the equivalent to CLK001 in DAVE v4.1.2.

In DAVE v4.1.2, the APPs are now built on top of the XMC Lib, our XMC low level drivers. This means that the code is more readable and it is easier for you to customize your project. In fact, it is now easier to create the configurations using the APP. You can use the APP to select the settings that you require to generate the appropriate clock configuration structures. If you decide to use only XMCLib in your code, you can extract the required settings from the generated code folder.

Simply go to your project folder under Dave/Generated/CLOCK_XMC4/clock_xmc4_conf.c

Here's the configuration structure and the API:

const XMC_SCU_CLOCK_CONFIG_t CLOCK_XMC4_0_CONFIG =
{
.syspll_config.n_div = 80U,
.syspll_config.p_div = 2U,

.syspll_config.k_div = 6U,

.syspll_config.mode = XMC_SCU_CLOCK_SYSPLL_MODE_NORMAL,
.syspll_config.clksrc = XMC_SCU_CLOCK_SYSPLLCLKSRC_OSCHP,
.enable_oschp = true,

.enable_osculp = false,

.calibration_mode = XMC_SCU_CLOCK_FOFI_CALIBRATION_MODE_FACTORY,
.fstdby_clksrc = XMC_SCU_HIB_STDBYCLKSRC_OSI,
.fsys_clksrc = XMC_SCU_CLOCK_SYSCLKSRC_PLL,
.fsys_clkdiv = 1U,
.fcpu_clkdiv = 1U,
.fccu_clkdiv = 1U,
.fperipheral_clkdiv = 1U
};

/**********************************************************************************************************************
* API IMPLEMENTATION
**********************************************************************************************************************/
/**
* @brief Function to initialize the Clock Tree based on UI configuration
* @note -
* @param None
* @retval None
*/
void SystemCoreClockSetup(void)
{

/* Initialize the SCU clock */
XMC_SCU_CLOCK_Init(&CLOCK_XMC4_0_CONFIG);
/* RTC source clock*/
XMC_SCU_HIB_SetRtcClockSource(XMC_SCU_HIB_RTCCLKSRC_OSI);

/* USB/SDMMC source clock*/
XMC_SCU_CLOCK_SetUsbClockSource(XMC_SCU_CLOCK_USBCLKSRC_USBPLL);
XMC_SCU_CLOCK_SetUsbClockDivider(4U);

XMC_SCU_CLOCK_StartUsbPll(2U, 64U);

XMC_SCU_CLOCK_SetWdtClockSource(XMC_SCU_CLOCK_WDTCLKSRC_OFI);
XMC_SCU_CLOCK_SetWdtClockDivider(1U);

XMC_SCU_CLOCK_SetEbuClockDivider(1U);

}

In the APP, the Function to initialize the Clock Tree based on UI configuration is created to replace the _WEAK definition in the system_XMC4500.c.

Hope this helps.

Regards,
Daryl 🙂
0 Likes