KDSK CLOCK_SYS_SetConfiguration() no uptade  ticks in _time_delay() MQX

cancel
Showing results for 
Search instead for 
Did you mean: 

KDSK CLOCK_SYS_SetConfiguration() no uptade  ticks in _time_delay() MQX

Jump to solution
911 Views
voider
Contributor II

I create e new project for a custom board using KSDK + PEx and then I add MQX like this Training: Training Class: MQX RTOS for Kinetis SDK, Kinetis Design Studio (6 labs, including TCP/IP)

Looking the way HAL and FSL work I think is not any more necessary create a BSP. PEx take care of the hardware configuration. So I went in this way.

 

Then I create tasks OK, RS232 for debug is Ok, interrupts for GPIO when MCU is wake and for LLWU when is in STOP and everithing is working.

But I need to change my clock from run (48Mhz in startup) to low power to (4Mhz and stop in LLS)  mode and I note when I change my clock using:

 

CLOCK_SYS_SetConfiguration(&clockMan1_InitConfig1);  // Will run in 4Mhz for Low power mode

 

the _time_delay()  function from MQX not work as expectec taking much more time to execute, I think because the clock #1 I´m running in lower clock.

 

then I call:

 

POWER_SYS_SetMode(1U, kPowerManagerPolicyAgreement);   // put in STOP mode LLS

 

And is in LLS just fine.

 

My question is: 

 

How can I tell to MQX that the clock changed to calculate the _time_delay()  correctly? I know that is in _bsp_pre_init() that MQX receive the clock config and make the adjustments, but when I change clock I need to update, I try recall _bsp_pre_init() or some internal function that bsp_pre/_init calls  and the _time_delay() get work, but I not some other strange behaviors. Some one have a good way to do this?

 

KSDK 1.2

MQX for KSDK

 

Thank you

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

Hello voider:

In your case you need to use the Clock Manager notification framework to notify the low level drivers when the clock changes. To do that you have the API CLOCK_SYS_UpdateConfiguration() and use clock callbacks as discussed in this thread.

I created an example [MQX_KSDK + PE] project with KDS v3.0.0 for the FRDM-K64F so you can take it as reference. In the project there are callbacks to adjust the UART (debug console) and SysTick timer (MQX RTOS tick) frequencies. If you connect the terminal at a 115200 baud then you will see how a message is printed BEFORE and AFTER changing frequency. Also the green LED blinks at the same frequency before and after the clock change.

If you have a different evaluation board then I can replicate it, just let me know.


Regards!,
Jorge Gonzalez

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

View solution in original post

0 Kudos
1 Reply
162 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello voider:

In your case you need to use the Clock Manager notification framework to notify the low level drivers when the clock changes. To do that you have the API CLOCK_SYS_UpdateConfiguration() and use clock callbacks as discussed in this thread.

I created an example [MQX_KSDK + PE] project with KDS v3.0.0 for the FRDM-K64F so you can take it as reference. In the project there are callbacks to adjust the UART (debug console) and SysTick timer (MQX RTOS tick) frequencies. If you connect the terminal at a 115200 baud then you will see how a message is printed BEFORE and AFTER changing frequency. Also the green LED blinks at the same frequency before and after the clock change.

If you have a different evaluation board then I can replicate it, just let me know.


Regards!,
Jorge Gonzalez

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

View solution in original post

0 Kudos