The MCUXpresso SDK provides a peripheral driver for the System Mode Controller (SMC) module of MCUXpresso SDK devices. The SMC module sequences the system in and out of all low-power stop and run modes.
API functions are provided to configure the system for working in a dedicated power mode. For different power modes, SMC_SetPowerModexxx() function accepts different parameters. System power mode state transitions are not available between power modes. For details about available transitions, see the power mode transitions section in the SoC reference manual.
Typical use case
Enter wait or stop modes
SMC driver provides APIs to set MCU to different wait modes and stop modes. Pre and post functions are used for setting the modes. The pre functions and post functions are used as follows.
- Disable/enable the interrupt through PRIMASK. This is an example use case. The application sets the wakeup interrupt and calls SMC function SMC_SetPowerModeStop to set the MCU to STOP mode, but the wakeup interrupt happens so quickly that the ISR completes before the function SMC_SetPowerModeStop. As a result, the MCU enters the STOP mode and never is woken up by the interrupt. In this use case, the application first disables the interrupt through PRIMASK, sets the wakeup interrupt, and enters the STOP mode. After wakeup, enable the interrupt through PRIMASK. The MCU can still be woken up by disabling the interrupt through PRIMASK. The pre and post functions handle the PRIMASK.
- Disable/enable the flash speculation. When entering stop modes, the flash speculation might be interrupted. As a result, pre functions disable the flash speculation and post functions enable it.
|
enum | smc_power_mode_protection_t {
kSMC_AllowPowerModeVlls = SMC_PMPROT_AVLLS_MASK,
kSMC_AllowPowerModeLls = SMC_PMPROT_ALLS_MASK,
kSMC_AllowPowerModeVlp = SMC_PMPROT_AVLP_MASK,
kSMC_AllowPowerModeAll
} |
| Power Modes Protection. More...
|
|
enum | smc_power_state_t {
kSMC_PowerStateRun = 0x01U << 0U,
kSMC_PowerStateStop = 0x01U << 1U,
kSMC_PowerStateVlpr = 0x01U << 2U,
kSMC_PowerStateVlpw = 0x01U << 3U,
kSMC_PowerStateVlps = 0x01U << 4U,
kSMC_PowerStateLls = 0x01U << 5U,
kSMC_PowerStateVlls = 0x01U << 6U
} |
| Power Modes in PMSTAT. More...
|
|
enum | smc_run_mode_t {
kSMC_RunNormal = 0U,
kSMC_RunVlpr = 2U
} |
| Run mode definition. More...
|
|
enum | smc_stop_mode_t {
kSMC_StopNormal = 0U,
kSMC_StopVlps = 2U,
kSMC_StopLls = 3U,
kSMC_StopVlls = 4U
} |
| Stop mode definition. More...
|
|
enum | smc_stop_submode_t {
kSMC_StopSub0 = 0U,
kSMC_StopSub1 = 1U,
kSMC_StopSub2 = 2U,
kSMC_StopSub3 = 3U
} |
| VLLS/LLS stop sub mode definition. More...
|
|
enum | smc_partial_stop_option_t {
kSMC_PartialStop = 0U,
kSMC_PartialStop1 = 1U,
kSMC_PartialStop2 = 2U
} |
| Partial STOP option. More...
|
|
enum | _smc_status { kStatus_SMC_StopAbort = MAKE_STATUS(kStatusGroup_POWER, 0)
} |
| SMC configuration status. More...
|
|
struct smc_power_mode_lls_config_t |
struct smc_power_mode_vlls_config_t |
Enumerator |
---|
kSMC_AllowPowerModeVlls |
Allow Very-low-leakage Stop Mode.
|
kSMC_AllowPowerModeLls |
Allow Low-leakage Stop Mode.
|
kSMC_AllowPowerModeVlp |
Allow Very-Low-power Mode.
|
kSMC_AllowPowerModeAll |
Allow all power mode.
|
Enumerator |
---|
kSMC_PowerStateRun |
0000_0001 - Current power mode is RUN
|
kSMC_PowerStateStop |
0000_0010 - Current power mode is STOP
|
kSMC_PowerStateVlpr |
0000_0100 - Current power mode is VLPR
|
kSMC_PowerStateVlpw |
0000_1000 - Current power mode is VLPW
|
kSMC_PowerStateVlps |
0001_0000 - Current power mode is VLPS
|
kSMC_PowerStateLls |
0010_0000 - Current power mode is LLS
|
kSMC_PowerStateVlls |
0100_0000 - Current power mode is VLLS
|
Enumerator |
---|
kSMC_RunNormal |
Normal RUN mode.
|
kSMC_RunVlpr |
Very-low-power RUN mode.
|
Enumerator |
---|
kSMC_StopNormal |
Normal STOP mode.
|
kSMC_StopVlps |
Very-low-power STOP mode.
|
kSMC_StopLls |
Low-leakage Stop mode.
|
kSMC_StopVlls |
Very-low-leakage Stop mode.
|
Enumerator |
---|
kSMC_StopSub0 |
Stop submode 0, for VLLS0/LLS0.
|
kSMC_StopSub1 |
Stop submode 1, for VLLS1/LLS1.
|
kSMC_StopSub2 |
Stop submode 2, for VLLS2/LLS2.
|
kSMC_StopSub3 |
Stop submode 3, for VLLS3/LLS3.
|
Enumerator |
---|
kSMC_PartialStop |
STOP - Normal Stop mode.
|
kSMC_PartialStop1 |
Partial Stop with both system and bus clocks disabled.
|
kSMC_PartialStop2 |
Partial Stop with system clock disabled and bus clock enabled.
|
Enumerator |
---|
kStatus_SMC_StopAbort |
Entering Stop mode is abort.
|
static void SMC_SetPowerModeProtection |
( |
SMC_Type * |
base, |
|
|
uint8_t |
allowedModes |
|
) |
| |
|
inlinestatic |
This function configures the power mode protection settings for supported power modes in the specified chip family. The available power modes are defined in the smc_power_mode_protection_t. This should be done at an early system level initialization stage. See the reference manual for details. This register can only write once after the power reset.
The allowed modes are passed as bit map. For example, to allow LLS and VLLS, use SMC_SetPowerModeProtection(kSMC_AllowPowerModeVlls | kSMC_AllowPowerModeVlps). To allow all modes, use SMC_SetPowerModeProtection(kSMC_AllowPowerModeAll).
- Parameters
-
base | SMC peripheral base address. |
allowedModes | Bitmap of the allowed power modes. |
This function returns the current power mode status. After the application switches the power mode, it should always check the status to check whether it runs into the specified mode or not. The application should check this mode before switching to a different mode. The system requires that only certain modes can switch to other specific modes. See the reference manual for details and the smc_power_state_t for information about the power status.
- Parameters
-
base | SMC peripheral base address. |
- Returns
- Current power mode status.
void SMC_PreEnterStopModes |
( |
void |
| ) |
|
This function should be called before entering STOP/VLPS/LLS/VLLS modes.
void SMC_PostExitStopModes |
( |
void |
| ) |
|
This function should be called after wake up from STOP/VLPS/LLS/VLLS modes. It is used with SMC_PreEnterStopModes.
static void SMC_PreEnterWaitModes |
( |
void |
| ) |
|
|
inlinestatic |
This function should be called before entering WAIT/VLPW modes.
static void SMC_PostExitWaitModes |
( |
void |
| ) |
|
|
inlinestatic |
This function should be called after wake up from WAIT/VLPW modes. It is used with SMC_PreEnterWaitModes.
status_t SMC_SetPowerModeRun |
( |
SMC_Type * |
base | ) |
|
- Parameters
-
base | SMC peripheral base address. |
- Returns
- SMC configuration error code.
status_t SMC_SetPowerModeWait |
( |
SMC_Type * |
base | ) |
|
- Parameters
-
base | SMC peripheral base address. |
- Returns
- SMC configuration error code.
- Parameters
-
base | SMC peripheral base address. |
option | Partial Stop mode option. |
- Returns
- SMC configuration error code.
status_t SMC_SetPowerModeVlpr |
( |
SMC_Type * |
base | ) |
|
- Parameters
-
base | SMC peripheral base address. |
- Returns
- SMC configuration error code.
status_t SMC_SetPowerModeVlpw |
( |
SMC_Type * |
base | ) |
|
- Parameters
-
base | SMC peripheral base address. |
- Returns
- SMC configuration error code.
status_t SMC_SetPowerModeVlps |
( |
SMC_Type * |
base | ) |
|
- Parameters
-
base | SMC peripheral base address. |
- Returns
- SMC configuration error code.
- Parameters
-
base | SMC peripheral base address. |
config | The LLS power mode configuration structure |
- Returns
- SMC configuration error code.
- Parameters
-
base | SMC peripheral base address. |
config | The VLLS power mode configuration structure. |
- Returns
- SMC configuration error code.