MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
ASMC: Auxiliary System Mode Controller Driver

Overview

The MCUXpresso SDK provides a peripheral driver for the Auxiliary System Mode Controller (ASMC) module of MCUXpresso SDK devices. The ASMC module is responsible for sequencing Core 1 into and out of all low-power Stop and Run modes. The ASMC (Auxiliary System Mode Control) provides status and control registers for Core 1.

API functions are provided for configuring the system working in a dedicated power mode. For different power modes, the function ASMC_SetPowerModexxx accepts different parameters. System power mode state transitions are not available for 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

The ASMC driver provides APIs to set the MCU to different wait modes and stop modes. At the same time, there are pre function and post function for the modes setting. The pre function and post function are used to:

  1. Disable/Enable the interrupt through PRIMASK. In practise, there is such a scenario: the application sets the wakeup interrupt and calls SMC function ASMC_SetPowerModeStop to set MCU to STOP mode, but the wakeup interrupt happens so quickly that the ISR completes before the function ASMC_SetPowerModeStop. As a result, the MCU enters STOP mode and is never waken up by the interrupt. In this case, the application could first disable the interrupt through PRIMASK, then set the wakeup interrupt and enter STOP mode. After wakeup, the first thing you need to do is enable the interrupt through PRIMASK. The MCU can still wakeup when you disable interrupt through PRIMASK. The pre and post functions handle the PRIMASK inside.
/* Enable the wakeup interrupt here. */

Enumerations

enum  _asmc_system_reset_status_flags {
  kASMC_LowLeakageWakeupResetFlag = ASMC_SRS_WAKEUP_MASK,
  kASMC_WatchdogResetFlag = ASMC_SRS_WDOG1_MASK,
  kASMC_ChipResetNotPORFlag = ASMC_SRS_RES_MASK,
  kASMC_PowerOnResetFlag = ASMC_SRS_POR_MASK,
  kASMC_Core1LockupResetFlag = ASMC_SRS_LOCKUP_MASK,
  kASMC_SoftwareResetFlag = ASMC_SRS_SW_MASK,
  kASMC_StopModeAcknowledgeErrorResetFlag
}
 System Reset Status. More...
 
enum  asmc_power_mode_protection_t {
  kASMC_AllowPowerModeVlls = ASMC_PMPROT_AVLLS_MASK,
  kASMC_AllowPowerModeLls = ASMC_PMPROT_ALLS_MASK,
  kASMC_AllowPowerModeVlp = ASMC_PMPROT_AVLP_MASK,
  kASMC_AllowPowerModeAll
}
 Power Modes Protection. More...
 
enum  asmc_power_state_t {
  kASMC_PowerStateRun = 0x01U << 0U,
  kASMC_PowerStateStop = 0x01U << 1U,
  kASMC_PowerStateVlpr = 0x01U << 2U,
  kASMC_PowerStateVlpw = 0x01U << 3U,
  kASMC_PowerStateVlps = 0x01U << 4U,
  kASMC_PowerStateLls = 0x01U << 5U,
  kASMC_PowerStateVlls = 0x01U << 6U
}
 Power Modes in PMSTAT. More...
 
enum  asmc_run_mode_t {
  kASMC_RunNormal = 0U,
  kASMC_RunVlpr = 2U
}
 Run mode definition. More...
 
enum  asmc_stop_mode_t {
  kASMC_StopNormal = 0U,
  kASMC_StopVlps = 2U,
  kASMC_StopLls = 3U,
  kASMC_StopVlls = 4U
}
 Stop mode definition. More...
 
enum  asmc_partial_stop_option_t {
  kASMC_PartialStop = 0U,
  kASMC_PartialStop1 = 1U,
  kASMC_PartialStop2 = 2U
}
 Partial STOP option. More...
 

Driver version

#define FSL_ASMC_DRIVER_VERSION   (MAKE_VERSION(2, 0, 1))
 ASMC driver version 2.0.1. More...
 

Auxiliary system mode controller APIs

static uint32_t ASMC_GetSystemResetStatusFlags (ASMC_Type *base)
 Gets ASMC system reset status flags. More...
 
static void ASMC_SetPowerModeProtection (ASMC_Type *base, uint8_t allowedModes)
 Configures all power mode protection settings. More...
 
static asmc_power_state_t ASMC_GetPowerModeState (ASMC_Type *base)
 Gets the current power mode status. More...
 
static void ASMC_PreEnterStopModes (void)
 Prepare to enter stop modes. More...
 
static void ASMC_PostExitStopModes (void)
 Recovering after wake up from stop modes. More...
 
static void ASMC_PreEnterWaitModes (void)
 Prepare to enter wait modes. More...
 
static void ASMC_PostExitWaitModes (void)
 Recovering after wake up from stop modes. More...
 
status_t ASMC_SetPowerModeRun (ASMC_Type *base)
 Configure the system to RUN power mode. More...
 
status_t ASMC_SetPowerModeWait (ASMC_Type *base)
 Configure the system to WAIT power mode. More...
 
status_t ASMC_SetPowerModeStop (ASMC_Type *base, asmc_partial_stop_option_t option)
 Configure the system to Stop power mode. More...
 
status_t ASMC_SetPowerModeVlpr (ASMC_Type *base)
 Configure the system to VLPR power mode. More...
 
status_t ASMC_SetPowerModeVlpw (ASMC_Type *base)
 Configure the system to VLPW power mode. More...
 
status_t ASMC_SetPowerModeVlps (ASMC_Type *base)
 Configure the system to VLPS power mode. More...
 
status_t ASMC_SetPowerModeLls (ASMC_Type *base)
 Configure the system to LLS power mode. More...
 
status_t ASMC_SetPowerModeVlls (ASMC_Type *base)
 Configure the system to VLLS power mode. More...
 

Macro Definition Documentation

#define FSL_ASMC_DRIVER_VERSION   (MAKE_VERSION(2, 0, 1))

Enumeration Type Documentation

Enumerator
kASMC_LowLeakageWakeupResetFlag 

Reset caused by LLWU module wakeup source.

kASMC_WatchdogResetFlag 

Reset caused by watchdog timeout.

kASMC_ChipResetNotPORFlag 

Chip Reset caused by a source other than POR occurred.

kASMC_PowerOnResetFlag 

Reset caused by POR.

kASMC_Core1LockupResetFlag 

Reset caused by core LOCKUP event.

kASMC_SoftwareResetFlag 

Reset caused by software setting of SYSRESETREQ bit.

kASMC_StopModeAcknowledgeErrorResetFlag 

Reset caused by peripheral failure to acknowledge attempt to enter stop mode.

Enumerator
kASMC_AllowPowerModeVlls 

Allow Very-Low-Leakage Stop Mode.

kASMC_AllowPowerModeLls 

Allow Low-Leakage Stop Mode.

kASMC_AllowPowerModeVlp 

Allow Very-Low-Power Mode.

kASMC_AllowPowerModeAll 

Allow all power mode.

Enumerator
kASMC_PowerStateRun 

0000_0001 - Current power mode is RUN

kASMC_PowerStateStop 

0000_0010 - Current power mode is STOP

kASMC_PowerStateVlpr 

0000_0100 - Current power mode is VLPR

kASMC_PowerStateVlpw 

0000_1000 - Current power mode is VLPW

kASMC_PowerStateVlps 

0001_0000 - Current power mode is VLPS

kASMC_PowerStateLls 

0010_0000 - Current power mode is LLS

kASMC_PowerStateVlls 

0100_0000 - Current power mode is VLLS

Enumerator
kASMC_RunNormal 

normal RUN mode.

kASMC_RunVlpr 

Very-Low-Power RUN mode.

Enumerator
kASMC_StopNormal 

Normal STOP mode.

kASMC_StopVlps 

Very-Low-Power STOP mode.

kASMC_StopLls 

Low-Leakage Stop mode.

kASMC_StopVlls 

Very-Low-Leakage Stop mode.

Enumerator
kASMC_PartialStop 

STOP - Normal Stop mode.

kASMC_PartialStop1 

Partial Stop with both system and bus clocks disabled.

kASMC_PartialStop2 

Partial Stop with system clock disabled and bus clock enabled.

Function Documentation

static uint32_t ASMC_GetSystemResetStatusFlags ( ASMC_Type *  base)
inlinestatic

This function gets all ASMC system reset status flags. The flag indicates the source of the most recent MCU reset. The reset state of these bits depends on what caused the MCU to reset. The flags are returned as the logical OR value of the enumerators _asmc_system_reset_status_flags. To check for a specific status, compare the return value with enumerators in the _asmc_system_reset_status_flags. For example, to check whether the reset is caused by POR:

Parameters
baseASMC peripheral base address.
Returns
ASMC system reset status flags. See "_asmc_system_reset_status_flags".
static void ASMC_SetPowerModeProtection ( ASMC_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 ASMC_SetPowerModeProtection(kASMC_AllowPowerModeVlls | kASMC_AllowPowerModeVlps). To allow all modes, use ASMC_SetPowerModeProtection(kASMC_AllowPowerModeAll).

Parameters
baseASMC peripheral base address.
allowedModesBitmap of the allowed power modes. See "asmc_power_mode_protection_t".
static asmc_power_state_t ASMC_GetPowerModeState ( ASMC_Type *  base)
inlinestatic

This function returns the current power mode stat. Once application switches the power mode, it should always check the stat to check whether it runs into the specified mode or not. An 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 asmc_power_state_t for information about the power stat.

Parameters
baseASMC peripheral base address.
Returns
Current power mode status.
static void ASMC_PreEnterStopModes ( void  )
inlinestatic

This function should be called before entering STOP/VLPS/LLS/VLLS modes.

static void ASMC_PostExitStopModes ( void  )
inlinestatic

This function should be called after wake up from STOP/VLPS/LLS/VLLS modes. It is used together with ASMC_PreEnterStopModes.

static void ASMC_PreEnterWaitModes ( void  )
inlinestatic

This function should be called before entering WAIT/VLPW modes..

static void ASMC_PostExitWaitModes ( void  )
inlinestatic

This function should be called after wake up from WAIT/VLPW modes. It is used together with ASMC_PreEnterWaitModes.

status_t ASMC_SetPowerModeRun ( ASMC_Type *  base)
Parameters
baseASMC peripheral base address.
Returns
ASMC configuration error code.
status_t ASMC_SetPowerModeWait ( ASMC_Type *  base)
Parameters
baseASMC peripheral base address.
Returns
ASMC configuration error code.
status_t ASMC_SetPowerModeStop ( ASMC_Type *  base,
asmc_partial_stop_option_t  option 
)
Parameters
baseASMC peripheral base address.
optionPartial Stop mode option.
Returns
ASMC configuration error code.
status_t ASMC_SetPowerModeVlpr ( ASMC_Type *  base)
Parameters
baseASMC peripheral base address.
Returns
ASMC configuration error code.
status_t ASMC_SetPowerModeVlpw ( ASMC_Type *  base)
Parameters
baseASMC peripheral base address.
Returns
ASMC configuration error code.
status_t ASMC_SetPowerModeVlps ( ASMC_Type *  base)
Parameters
baseASMC peripheral base address.
Returns
ASMC configuration error code.
status_t ASMC_SetPowerModeLls ( ASMC_Type *  base)
Parameters
baseASMC peripheral base address.
Returns
ASMC configuration error code.
status_t ASMC_SetPowerModeVlls ( ASMC_Type *  base)
Parameters
baseASMC peripheral base address.
Returns
ASMC configuration error code.