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