XMC_CCU8_EnableClock vs. XMC_CCU8_SetModule Clock + XMC_SCU_CLOCK_Init

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

cross mob
Not applicable
Hi all,

I am working with XMC4700 Relax Kit Series board, and currently trying to modify a simpler PWM program into a more complex one. The question I have is regarding clock and peripherals configuration with and without implicitly configuring the SCU clock-specific registers. Namely, here are two different variations of code that, in my understanding, would yield similar functionality of the CCU8 module. The following peripheral clock initialization I used without configuring the SCU parameters and it worked just fine:

/* Enable the clock for the selected timer */
XMC_CCU8_EnableClock(CCU80, 2);


It writes to 'Global Idle Clear' or 'GIDLC' register and, once again in my understanding and as the name suggests, removes CCU80 from idle mode by connecting a clock to it. Next, the following clock and peripheral configuration procedure is similar to that shown in one of the manuals on CCU8 module from Infineon's product website:

	/* Initialize and configure clock */
XMC_SCU_CLOCK_Init(&clock_config);

/* Connect fCCU and CCU80 */
XMC_CCU8_SetModuleClock(CCU80, XMC_CCU8_CLOCK_SCU);


This configuration procedure, in turn, writes to 'Global Control Register' or 'GCTRL'.

Now, my question is - what is the difference between the two configuration approaches and what is the discrepancy in the results from configuring the clock one way or another?

And, knowing that the fSYS (the indirect source of fCCU) clock comes from either the OFI or the PLL (let's assume it's coming from PLL), and the OSC to the PLL is connected to the OSC_HP, where does that external clock that is routed to the high precision oscillator come from - is it an on-board crystal? Also, if one doesn't go through the whole SCU clock configuration, then what is the clock that is connected to fCCU?

EDIT: I just realized that the two initialization procedures are somewhat different, and we do NOT omit XMC_CCU8_EnableClock(); when going through SCU clock unit configuration, however, I would still like to know what exactly are the clocks in each case, namely what is the clock that is connected to CCU8 whenever we don't follow through with the SCU configuration and what is the external clock that is connected to the OSC_HP?

Thank you all in advance,
Andrey
0 Likes
3 Replies
chismo
Employee
Employee
First like received
Hello Andrey,

As you mentioned, the two are different.
XMC_CCU8_EnableClock() is used for enabling the module clock to CCU8.
XMC_CCU8_SetModuleClock() is used for selecting the prescaler clock source to be from the module clock (default) or one of the 3 possible external clock inputs (an external clock source has to be connected).

XMC_SCU_CLOCK_Init() is to configure the clock tree of the device based on the defined data structure "clock_config".
Below is a screenshot of the data structure. You can refer to the help file that comes together from the XMC peripheral library package.
1742.attach

If this init function is not used, the device simply stays in the default configuration defined from in the system_xmc4200.c file.
This assumes the connection of a 12 MHz external crystal to OSC_HP.
If the internal fast oscillator is to be used, the define statement in the system_xmc4200.c file can be modified accordingly.

/*
// PLL clock source selection
// <0=> External crystal
// <1=> External direct input
// <2=> Internal fast oscillator
// Default: External crystal
*/
#define PLL_CLOCK_SRC 0


In terms of difference to the clock that CCU8 receives, again this depends on what is defined in the data structure "clock_config".
For example, if the fccu is selected to be half of fsys, then this will be different to the default setting of fccu=fsys.

Regards,
Min Wei
0 Likes
Not applicable
Hi Min Wei,

Thank you, the answer is well put and thorough, and is exactly what I am looking for.

I have a follow up question on the topic of the discussion. I have checked the system_XMCxxxx.c file for the default clock configuration and I am still confused about the source of the external clock - is it something present on the board? There are three possible options to choose from for the external crystal, i.e. 8MHz, 12MHz and 16MHz. The default clock is actually set to 12MHz, not 8MHz.

1744.attach

My question is - firstly, can a user choose any available configuration or is it something that is board-specific. Also, is the external crystal something present on the board, and if so, does it oscillate at 12MHz, or is this value something that is produced by OSC_HP and the external clock oscillates at some other frequency?

I have not been able to find the XMC peripheral library anywhere on the website - could you please give me a suggestion as to where to look for it?

Thank you!
Andrey
0 Likes
chismo
Employee
Employee
First like received
Hello Andrey,

Yes, there is an external 12 MHz crystal mounted on the Relax Kit to supply the clock source to the OSC_HP.
I attached the link to the board manual below for your reference:
http://www.infineon.com/dgdl/Infineon-Board_User_Manual_XMC4700_XMC4800_Relax_Kit_Series-UM-v01_00-E...

The actual clock settings in the system file should be then based on 12 MHz as indicated in the #define statement following the comments.
Therefore, the comment line indicating 8 MHz seems wrong.
Yes, the 12 MHz is board-specific.
Eventually if you will have a custom PCB and a different crystal frequency, the system file configuration can be modified accordingly.

The link to the peripheral library package is as follows:
http://dave.infineon.com/Libraries/XMCLib/XMC_Peripheral_Library_v2.1.2.zip
After unzipping the package, you should be able to find the compiled HTML Help file (.cfm) in the root directory.

Regards,
Min Wei
0 Likes