Change between clock configurations

cancel
Showing results for 
Search instead for 
Did you mean: 

Change between clock configurations

Jump to solution
1,919 Views
matthias
Contributor III

Hello,

 

I have an application running KSDK1.2.0 with MQX and I would like to change between different clock settings. In a previous post (Re: Clock configuration with KDS3.0/KSDK1.2.0 ), Jorge gave me some hints on how to use several clock settings. However, I did not manage to make use of these hints yet, so I am opening a new thread for my questions:

 

When I use CLOCK_SYS_SetConfiguration(), I can apply a new clock setting, but then all timers, uart, etc., do not work properly any more because they get not informed that the clocks have changed. In the reference manual I see that the function CLOCK_SYS_UpdateConfiguration() should be the right one to use, because it can notify all drivers that the clock has changed. However, it seems that I manually have to implement callback functions for all component drivers that should be notified. Is there a way that Processor Expert takes care of notifying all affected drivers automatically when the clock configuration changes?

 

Best regards

Matthias

Labels (1)
0 Kudos
1 Solution
355 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello matthias:

The fsl_clock_manager component lets you add callbacks, but the callback's body itself needs to be implemented manually. Each callback will require different actions depending on the peripheral (uart, pit, i2c, etc) and also the callback code might be application dependent.

Attached is a simple example for FRDM-K64F with Processor Expert to show the use of the clock manager system. The example blinks the on-board blue LED using the PIT timer interrupt and each time you press SW2 the clock switches between configurations 0 and 5. In main.c there is a macro which works as next:

- CLOCK_CALLBACKS = 0: Clock configurations are changed using CLOCK_SYS_SetConfiguration(). PIT driver is not informed and the blink frequency changes.

- CLOCK_CALLBAKS = 1: Clock configurations are changed using CLOCK_SYS_UpdateConfiguration(). The PIT driver is notified of the clock change using the callback and the frequency is adjusted by De-initializing/Initializing the driver.

I hope this helps.


Regards!,
Jorge Gonzalez

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

View solution in original post

4 Replies
356 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello matthias:

The fsl_clock_manager component lets you add callbacks, but the callback's body itself needs to be implemented manually. Each callback will require different actions depending on the peripheral (uart, pit, i2c, etc) and also the callback code might be application dependent.

Attached is a simple example for FRDM-K64F with Processor Expert to show the use of the clock manager system. The example blinks the on-board blue LED using the PIT timer interrupt and each time you press SW2 the clock switches between configurations 0 and 5. In main.c there is a macro which works as next:

- CLOCK_CALLBACKS = 0: Clock configurations are changed using CLOCK_SYS_SetConfiguration(). PIT driver is not informed and the blink frequency changes.

- CLOCK_CALLBAKS = 1: Clock configurations are changed using CLOCK_SYS_UpdateConfiguration(). The PIT driver is notified of the clock change using the callback and the frequency is adjusted by De-initializing/Initializing the driver.

I hope this helps.


Regards!,
Jorge Gonzalez

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

View solution in original post

355 Views
matthias
Contributor III

Hello Jorge,

thanks for the info and the example. I'll have a look at it.

Regards

Matthias

0 Kudos
355 Views
oaf
Contributor IV

Hi,

This was disappointing news :smileysad:. I've used PEx on HC12 for several years, and when change of clock PEx there was able to create callbacks to all devices and maintain settings. E.g. when change PLL frequency the UART will still communicate with the selected baud-rate. If the setting could not be achieved PEx inhibited the code-generation. And also, PEx is capable to make the initial setting so this, in my opinion, is a major flaw/bug in PEx working for the ARM uC....

0 Kudos
355 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Ole Asbjorn Fadum:

First thanks a lot for your comments.

Processor Expert with KSDK is very different from classic Processor Expert. The legacy PEx like the one you used for HC12 had full control over the generated driver's source code.

With the introduction of KSDK platform libraries, now all drivers are static and Processor Expert developers are making an effort to accelerate and ease the use of KSDK. So this thing about clock configurations is not a PEx bug, but rather a KSDK limitation, which is a new product still growing up. If you give a check to KSDK driver folders, there are files ready with the callback functions (e.g. for PIT in C:\Freescale\KSDK_1.2.0\platform\drivers\src\pit\fsl_pit_lpm_callback.c). But the driver reconfiguration code is not included.

I could not say right now when those gaps will be filled by the KSDK team, but if I get some information about it I will let you know.

And again thanks for letting us know your expectations, this kind of feedback is very valuable.

Regards!

Jorge Gonzalez

0 Kudos