How to use clockMan and pwrMan PE components with debug console

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

How to use clockMan and pwrMan PE components with debug console

873 Views
marks
Contributor IV


Hello, I'm trying to do some simple clock and power mode changes. I would like to be able to go between Run, HSRun, VLPRun and VLPWait.

 

Using the FRDM-K22 board, KSDK 1.3, and KDS 3.2. When creating the KDS project I selected the pre-configured "board" file which provided a pre-configured clockMan1 component with 6 clock configurations. Just to get to something that works, I tried to get the current clock configuration using:

ret =  CLOCK_SYS_GetCurrentConfiguration()

and then transitioning to a new clock config using

CLOCK_SYS_SetConfiguration()

 

I do think I am transitioning to the new clock configurations but CLOCK_SYS_GetCurrentConfiguration() always returns zero. Also, the debug console baud rate does not track with the clock configurations. It is supposed to do that. right?

 

Also trying to change power modes using the pwrMan component to go between Run mode, High speed run mode, Very low power run mode, and Very low power wait mode.

 

Just to get something working, I tried to get the current power mode configuration using

current_mode = POWER_SYS_GetCurrentMode();

But this never returns anything. Also tried changing the power mode using

ret = POWER_SYS_SetMode()

but I'm not sure if its working because POWER_SYS_GetCurrentMode(); doesn't return anything for me.

 

I've attached my project. The code in main was just an attempt to get anything to work.

So my questions are:

Q1. How do i get the debug console to have the same baud rate when jumping between Run, HSRun and VLPRun?

Q2. Why does CLOCK_SYS_GetCurrentConfiguration() always return zero.

Q3. Why does POWER_SYS_GetCurrentMode() seem not to return anything?

Q4. Is it possible to take what I have there, delete my code in main, and write a few line of code that shows how to transition between clock and power modes and have the debug console baud rate also track with the changes?

 

Thank you in advance!

 

Best Regards,

Mark

Original Attachment has been moved to: Clock_and_Power_K22.zip

0 Kudos
1 Reply

434 Views
isaacavila
NXP Employee
NXP Employee

Hello Mark,

There are some conditions that need to be considered when transitioning between Clock configurations and Power Management modes.

There is an example in KSDK folder that could be helpful for you: <KSDK_1_3_PATH>\examples\frdmk22f\demo_apps\power_manager_hal_demo\kds

For Clock manager, you can install a callback that will be called after and/or before switching between clock modes, in this callback, Debug Console should be de-initialized (when callback is called Before switching) and should be initialized again (when callback is called after new mode is set), next code snippet shows this:

clock_manager_error_code_t debugCallback(clock_notify_struct_t *notify,

                                    void* callbackData)

{

    clock_manager_error_code_t result = kClockManagerSuccess;

    switch (notify->notifyType)

    {

        case kClockManagerNotifyBefore:     // Received "pre" message

            DbgConsole_DeInit();

            break;

        case kClockManagerNotifyRecover: // Received "recover" message

        case kClockManagerNotifyAfter:    // Received "post" message

            dbg_uart_reinit();

            break;

        default:

            result = kClockManagerError;

            break;

    }

    return result;

}

In the dbg_uart_reinit function, console is initialized and obtains the new clock value for uart module (that was modified according the clock configuration used).

For clock and low power modes, it is neccessary to define a clock manager user configuration structure and power manager user configuration structure as well:

const clock_manager_user_config_t * g_defaultClockConfigurations[] = {

    NULL,

    &g_defaultClockConfigVlpr,

    &g_defaultClockConfigRun,

    &g_defaultClockConfigHsrun,

};

power_manager_user_config_t const *powerConfigs[] =

    {

      &runConfig,

      &waitConfig,

      &stopConfig,

      &vlprConfig,

      &vlpwConfig,

      &vlpsConfig,

      &llsConfig,

      &vlls0Config,

      &vlls1Config,

      &vlls2Config,

      &vlls3Config,

      &hsrunConfig

    };

In order to be able to return the current clock/low power configuration that is set.

I would also like to refer to this useful document that talks more about Clock configurations and Low Power Modes on KSDK 1.3: KSDK Clock configurations and Low Power modes with Processor Expert

I hope you can find it useful.

Best Regards,

Isaac

0 Kudos