I'm trying to use the SMC_HAL_Setmode command in KDS 1.3.0 for my KL03 project to change power mode but it has a warning associated with it on compile
I first defined the parameters for smc_power_configuration as follows:
// Setup the parameters for smc power configuration
smc_power_mode_config_t smc_power_cfg_VLPS =
{
.powerModeName = kPowerModeVlps, // Set the desired power mode
.stopSubMode = kSmcStopSub3, // Set the sub-mode but I think this is not relevant for VLPS
};
The other config parameters were either non-applicable to my KL03 or I didn’t need them for the VLPS mode.
I then issued the command to change the processor to VLPS mode similar to the instructions on page 19 of AN4503
SMC_HAL_SetMode(SMC_BASE, &smc_power_cfg_VLPS);
but there's a warning in the left margin that expands to... "passing argument 1 of 'SMC_HAL_SetMode' makes pointer from integer without a cast [enabled by default]"
The code runs but I don't think it's working properly (because the power usage doesn't drop significantly) and the warning message is worrying because I don't understand what it's trying to tell me.
Have I missed something or done something wrong?
Thanks
Hi Ted,
The warning is a type-cast issue. If you look at the API declaration, the first parameter is of type (SMC_Type *)
smc_hal_error_code_t SMC_HAL_SetMode(SMC_Type * base,
const smc_power_mode_config_t *powerModeConfig);
Your code passes SMC_BASE
SMC_HAL_SetMode(SMC_BASE, &smc_power_cfg_VLPS);
Looking at the device header file below, you can use SMC_BASE_PTR or SMC instead to include the type-casting
/* SMC - Peripheral instance base addresses */
/** Peripheral SMC base address */
#define SMC_BASE (0x4007E000u)
/** Peripheral SMC base pointer */
#define SMC ((SMC_Type *)SMC_BASE)
#define SMC_BASE_PTR (SMC)
/** Array initializer of SMC peripheral base addresses */
#define SMC_BASE_ADDRS { SMC_BASE }
/** Array initializer of SMC peripheral base pointers */
#define SMC_BASE_PTRS { SMC }
That should remove the warning. I’m not sure if that will fix the application and lower the power consumption for you. But you can refer to the low-power example in KSDK for entering any of the low-power modes, including VLPS. It’s located at C:\Freescale\KSDK_1.3.0\examples\frdmkl03z\demo_apps\power_manager_hal_demo. The example uses the KSDK power manager, but the power manager calls the SMC HAL APIs if you want to reference that.
Thanks
To add to Derek's reply....make sure the debugger cable/hardware has been disconnected and application runs without debugger to see power changes.
Regards,
David