Maintaining FreeRTOS tick interrupt frequency / Systick while switching clock configurations

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Maintaining FreeRTOS tick interrupt frequency / Systick while switching clock configurations

899 Views
linkeleo
Contributor I

Hi all,

 

I am working on a project built on a KL17 with FreeRTOS and I'm running into an issue with clock configurations - so I was hoping someone here could help point me in the right direction. I am using Kinetis Design Studio 3.0 with PEx and the KSDK 2.0.

 

I need to switch between two clock speeds during runtime (to allow the processor to go into VLP mode between periodic tasks) - from 48MHz to 2MHz core clock. To do this, I am using the fsl_clock_manager's CLOCK_SYS_SetConfiguration function along with two clock_manager_user_config_t structures. (On a side note, I am using configurations defined in my own code, as I also need to make use of the asynchronous 32KHz RTC_CLKIN - the configuration structures generated by PEx do not include the .simConfig.er32kSrc = 2U properties needed to keep the RTC_CLKIN active between configuration changes - not sure if I'm just missing a setting for this somewhere or if it isn't possible at this time).

 

Switching between clock configurations and power modes is working fine, but I'm running into an issue where the FreeRTOS Tick, as well as the PIT, "runs slow" while the 2MHz clock configuration is active. While I can't be sure, it seems intuitive to me that the issue is simply that the CLOCK_SYS_SetConfiguration function does not update whatever prescaler or interval is used to generate the sysTick, thus everything relying on it runs 24 times slower. At this point I have to admit I don't know enough about FreeRTOS or the sysTick yet to to know how to adjust this while the code is running.

 

Any help would be appreciated, thank you!

Labels (1)
0 Kudos
1 Reply

388 Views
soledad
NXP Employee
NXP Employee

Hello Andrew,

Please check the below thread and let me know if this helps!!!

K64F12+KDS3.0+KSDK1.2.0+USB CDC Virtual COM Demo(FreeRTOS) without PE


Have a great day,

Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos