XMC4700: slow system clock at runtime instead of sleep modes stalls FreeRTOS timers

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

cross mob
Not applicable
Hello everyone.

I'm trying to slow system clock of my XMC4700 device at runtime instead of using sleep modes for some reason.

First of all, let me know if there is any kind of Application Note which provides such approach, namely, changing system clock source and system clock frequency at runtime for any purpose.

I have extracted content of SystemCoreClockSetup() generated by the DAVE in two
interesting clock sets. Then I named slower of them SystemCoreClockSetupSleep() and faster one keeps default name SystemCoreClockSetup() and starts by default.

So, when I'm going to slow my device to keep energy, I call SystemCoreClockSetupSleep() and it works in general.
At least my device starts to consume less then a half of the current in the "waked up" mode.

But then I was faced with the next issue. It is about strange behaviour of my FreeRTOS application in such environment.

Firstly, it's systick timer, obviously, must to be updated to work properly at the new frequency.
So I've added vPortSetupTimerInterrupt() calling after manipulations with the system frequency.
On the first sight, it reinits and works as expected... But even trivial pin toggle task runs slower by 1.3 times.
OK, let's suppose, that Internal Fast Clock's frequency floats and depends on voltage, even when I use XMC_SCU_CLOCK_FOFI_CALIBRATION_MODE_FACTORY.

But next issue is for FreeRTOS guru, perhaps:
I'm using FreeRTOS timers to manipulate some pins and do other periodic things.
So, after my manipulations with System Clock and even reinitialization of SysTick,
my FreeRTOS timers seems to be frozen. A little suffering, I waited until my pin have been changed.
And count that FreeRTOS Timers stalled by 4300 times.

Let me know if you have any idea about such behavior of FreeRTOS timers and possibly ways to collect additional data to clarify this situation.
0 Replies