The MCUXpresso SDK provides a power driver for the MCUXpresso SDK devices.
Function description
Power driver and library provides these functions:
- Functions to enable and disable power to different peripherals
- Functions to enable and disable deep sleep in the ARM Core.
- Functions to enter deep sleep mode and deep power down mode
- Functions to set the voltages for different frequency for both normal regulation and low power regulation modes
Power enable and disable
Power driver provides two API's POWER_EnablePD() and POWER_DisablePD() to enable or disable the PDRUNCFG bits in SYSCON The PDRUNCFG has an inverted logic i.e. the peripheral is powered on when the bit is cleared and powered off when bit is set. So the API POWER_DisablePD() is used to power on a peripheral and POWER_EnablePD() is used to power off a peripheral. The API's take a parameter of type pd_bit_t which organizes the PDRUNCFG bits. The driver also provides two separate API's to power down and power up Flash, POWER_PowerDownFlash() and POWER_PowerUpFlash()
Enable and Disable Deep Sleep in Core
The power driver provides two API's POWER_EnableDeepSleep() and POWER_DisableDeepSleep() to enable or disable the deep sleep bit in the ARM Core. POWER_EnableDeepSleep() is used to enable deep sleep and POWER_DisableDeepSleep() is used to disable deep sleep.
Entering Power Modes
The Power library provides two API's to enter low power modes i.e. Deep Sleep and Deep Power Down. Deep Sleep is a sleep mode in which the ARM Core, Flash and many other peripheral are turned off to save power. The processor can be woken by an IO activity and will resume executing from next instruction after sleep. If a peripheral or RAM needs to On for wakeup or to retain memory then those peripheral need to be kept on during deep sleep. Deep power down is a power down mode where the processor resets upon wake up and during power down the entire part is powered down except for the RTC. For Deep Power Down only the Reset and RTC Alarm or WakeUp can be wakeup sources. The power library provides an API POWER_EnterDeepSleep() to enter deep sleep mode. This function takes a parameter which is a bit mask of the PDRUNCFG register. Any bit that is set will be powered on during deep sleep. So this mask would usually has the RAM memory that needs to retain power and also any wakeup source. The API POWER_EnterDeepPowerDown() is used to enter deep power down mode. This API also has a parameter but since the volatge is cut off for the peripheral this parameter has no effect
Set Voltages for Frequency
The power library provides API's to set the voltage for the desired operating frequency of the processor. The voltage regulation system can be in normal regulation mode or in low power regulation mode. The API POWER_SetVoltageForFreq() is used to set the voltage for normal regulation mode. Based on the frequency parameter the optimum voltage level is set. The API POWER_SetLowPowerVoltageForFreq() is used to set the low power voltage regulation mode and set the voltages for the desired frequency. For POWER_SetLowPowerVoltageForFreq() only two FRO frequencies are supported, 12MHz and 48MHz.
Typical use case
## Power Enable and Set Voltage example {#PowerEnableExample}
kFRO12M_to_MAIN_CLK);
CLOCK_SetFLASHAccessCyclesForFreq(48000000);
Power Mode example
int main(void)
{
BOARD_InitHardware();
BOARD_BootClockVLPR();
LED_GREEN_INIT(1);
POWER_EnterDeepSleep(SYSCON_PDRUNCFG_PDEN_SRAM0_MASK | SYSCON_PDRUNCFG_PDEN_SRAMX_MASK | SYSCON_PDRUNCFG_PDEN_WDT_OSC_MASK);
while (1)
{
LED_GREEN_TOGGLE();
delay();
}
}
static void POWER_EnablePD |
( |
pd_bit_t |
en | ) |
|
|
inlinestatic |
Note that enabling the bit powers down the peripheral
- Parameters
-
en | peripheral for which to enable the PDRUNCFG bit |
- Returns
- none
static void POWER_DisablePD |
( |
pd_bit_t |
en | ) |
|
|
inlinestatic |
Note that disabling the bit powers up the peripheral
- Parameters
-
en | peripheral for which to disable the PDRUNCFG bit |
- Returns
- none
static void POWER_EnableDeepSleep |
( |
void |
| ) |
|
|
inlinestatic |
static void POWER_DisableDeepSleep |
( |
void |
| ) |
|
|
inlinestatic |
void POWER_OtpReload |
( |
void |
| ) |
|
This API must be called if VD6 is power down
and power back again since FROHF TRIM value
is store in OTP. If not, when calling FROHF settng
API in clock driver then the FROHF clock out put
will be inaccurate.
- Returns
- none
void POWER_SetPLL |
( |
void |
| ) |
|
void POWER_SetUsbPhy |
( |
void |
| ) |
|
void POWER_EnterPowerMode |
( |
power_mode_cfg_t |
mode, |
|
|
uint64_t |
exclude_from_pd |
|
) |
| |
- Parameters
-
exclude_from_pd | Bit mask of the PDRUNCFG0(low 32bits) and PDRUNCFG1(high 32bits) that needs to be powered on during power mode selected. |
- Returns
- none
void POWER_EnterSleep |
( |
void |
| ) |
|
void POWER_EnterDeepSleep |
( |
uint64_t |
exclude_from_pd | ) |
|
- Parameters
-
exclude_from_pd | Bit mask of the PDRUNCFG0(low 32bits) and PDRUNCFG1(high 32bits) bits that needs to be powered on during deep sleep |
- Returns
- none
void POWER_EnterDeepPowerDown |
( |
uint64_t |
exclude_from_pd | ) |
|
- Parameters
-
exclude_from_pd | Bit mask of the PDRUNCFG0(low 32bits) and PDRUNCFG1(high 32bits) that needs to be powered on during deep power down mode, but this is has no effect as the voltages are cut off. |
- Returns
- none
void POWER_SetVoltageForFreq |
( |
uint32_t |
freq | ) |
|
- Parameters
-
freq | - The desired frequency at which the part would like to operate, note that the voltage and flash wait states should be set before changing frequency |
- Returns
- none
uint32_t POWER_GetLibVersion |
( |
void |
| ) |
|
- Parameters
-
- Returns
- version number of the power library