The MCUXpresso SDK provides a peripheral driver for the Smart Power Switch (VBAT) block of MCUXpresso SDK devices. The VBAT includes the following features:
- Oscillator for 32.768 kHz crystal (OSC32K);
- The OSC32K is disabled by default on VBAT PORT.
- When enabled, it takes the oscillator start-up time before the OSC_RDY flag is set and the clock is output to other modules.
- Internal 16 kHz free running oscillator (FRO16k);
- The FRO16K is enabled by default on VBAT POR.
- It can be disabled by software.
- Backup retention SRAM regulator(SRAM LDO).
- The SRAM LDO is a retention regulator used to retain VBAT retention SRAM in low power modes, including when VBAT is the only available supply.
- Before entering a low power mode where the retention SRAM is powered by VBAT supply, software must enable the bandgap and LDO.
- The refresh mode must also be enabled for lowest power consumption.
Based on VBAT's features the VBAT driver are divided into 6 function groups.
FRO16K Control Interfaces
Functions in this group can be used to configure internal 16kHz free running oscillator.
To enable and lock the FRO16K:
- Invoke VBAT_EnableFRO16k(VBAT0, true) to enable FRO16K;
- Invoke VBAT_LockFRO16kSettings(VBAT0) to lock FRO16K settings;
- Invoke VBAT_UngateFRO16k(VBAT0, kVBAT_EnableClockToVddBat | kVBAT_EnableClockToVddSys) to ungate clock to VDD_BAT power domain and VDD_SYS power domain.
OSC32K Control Interfaces
Functions in this group can be used to configure internal 32k crystal oscillator.
To configure and lock OSC32kHz for lowest power operation(Switched mode):
- Invoke VBAT_SetCrystalOsc32kModeAndLoadCapacitance(VBAT0, kVBAT_Osc32kEnabledToLowPowerSwitchedMode, kVBAT_Osc32kCrystalLoadCap0pF, kVBAT_Osc32kCrystalLoadCap0pF) to set OSC32k as low power switched mode.
- Invoke VBAT_EnableCrystalOsc32k(VBAT0, true) to enable OSC32kHz.
- Invoke VBAT_LookOsc32kSettings(VBAT0) to lock OSC32k settings.
- Invoke VBAT_UngateOsc32k(VBAT0, kVBAT_EnableClockToVddBat | kVBAT_EnableClockToVddSys) to ungate clock to VDD_BAT power domain and VDD_SYS power domain.
RAM_LDO Control Interfaces
Functions in this group can be used to control internal bandgap and RAM_LDO.
To enable and lock the LDO and bandgap:
- Check if FRO16k is enabled by invoking VBAT_CheckFRO16kEnabled(VBAT0).
- Invoke VBAT_EnableBandgap(VBAT0, true) to enable bandgap.
- Invoke VBAT_EnableBandgapRefreshMode(VBAT0, true) to enable bandgap low power refresh mode.
- Invoke VBAT_EnableBackupSRAMRegulator(VBAT0, true) to enable backup SRAM regulator.
- Invoke VBAT_LockRamLdoSettings(VBAT0) to lock LDO settings.
Bandgap Timer Control Interfaces
Functions in this group can be used to control internal software bandgap timers. Please note that bandgap timers are available when the bandgap is enabled and are clocked by the FRO16k.
Status, Interrupt, Wakeup Control Interfaces
VBAT_GetStatusFlags() and VBAT_ClearStatusFlags() function in this group can be used to get and clear status flags. VBAT_EnableInterrupts() and VBAT_DisableInterrupts() function in this group can be used to enable/disable interrupt. VBAT_EnableWakeup() and VBAT_DisableWakeup() function in this group can be used to enable/disable wakeup features.
Switch Control Interfaces
Functions in this group can be used to switch power supply of VBAT modules.
|
enum | {
kStatus_VBAT_Fro16kNotEnabled = MAKE_STATUS(kStatusGroup_VBAT, 0),
kStatus_VBAT_BandgapNotEnabled = MAKE_STATUS(kStatusGroup_VBAT, 1),
kStatus_VBAT_WrongCapacitanceValue = MAKE_STATUS(kStatusGroup_VBAT, 2),
kStatus_VBAT_ClockMonitorLocked = MAKE_STATUS(kStatusGroup_VBAT, 3),
kStatus_VBAT_OSC32KNotReady = MAKE_STATUS(kStatusGroup_VBAT, 4),
kStatus_VBAT_LDONotReady = MAKE_STATUS(kStatusGroup_VBAT, 5),
kStatus_VBAT_TamperLocked = MAKE_STATUS(kStatusGroup_VBAT, 6)
} |
| The enumeration of VBAT module status. More...
|
|
enum | _vbat_clock_enable {
kVBAT_EnableClockToDomain0 = 1U << 0U,
kVBAT_EnableClockToDomain1 = 1U << 1U,
kVBAT_EnableClockToDomain2 = 1U << 2U,
kVBAT_EnableClockToDomain3 = 1U << 3U
} |
| The enumeration of connections for OSC32K/FRO32K output clock to other modules. More...
|
|
enum | vbat_bandgap_refresh_period_t {
kVBAT_BandgapRefresh7P8125ms = 0U,
kVBAT_BandgapRefresh15P625ms = 1U,
kVBAT_BandgapRefresh31P25ms = 2U,
kVBAT_BandgapRefresh62P5ms = 3U
} |
| The enumeration of bandgap refresh period. More...
|
|
struct vbat_fro16k_config_t |
bool vbat_fro16k_config_t::enableFRO16k |
uint8_t vbat_fro16k_config_t::enabledConnectionsMask |
Enumerator |
---|
kStatus_VBAT_Fro16kNotEnabled |
Internal 16kHz free running oscillator not enabled.
|
kStatus_VBAT_BandgapNotEnabled |
Bandgap not enabled.
|
kStatus_VBAT_WrongCapacitanceValue |
Wrong capacitance for selected oscillator mode.
|
kStatus_VBAT_ClockMonitorLocked |
Clock monitor locked.
|
kStatus_VBAT_OSC32KNotReady |
OSC32K not ready.
|
kStatus_VBAT_LDONotReady |
LDO not ready.
|
kStatus_VBAT_TamperLocked |
Tamper locked.
|
Enumerator |
---|
kVBAT_EnableClockToDomain0 |
Enable clock to power domain0.
|
kVBAT_EnableClockToDomain1 |
Enable clock to power domain1.
|
kVBAT_EnableClockToDomain2 |
Enable clock to power domain2.
|
kVBAT_EnableClockToDomain3 |
Enable clock to power domain3.
|
Enumerator |
---|
kVBAT_BandgapRefresh7P8125ms |
Bandgap refresh every 7.8125ms.
|
kVBAT_BandgapRefresh15P625ms |
Bandgap refresh every 15.625ms.
|
kVBAT_BandgapRefresh31P25ms |
Bandgap refresh every 31.25ms.
|
kVBAT_BandgapRefresh62P5ms |
Bandgap refresh every 62.5ms.
|
static void VBAT_EnableFRO16k |
( |
VBAT_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | VBAT peripheral base address. |
enable | Used to enable/disable 16kHz FRO.
- true Enable internal 16kHz free running oscillator.
- false Disable internal 16kHz free running oscillator.
|
static bool VBAT_CheckFRO16kEnabled |
( |
VBAT_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | VBAT peripheral base address. |
- Return values
-
true | The internal 16kHz Free running oscillator is enabled. |
false | The internal 16kHz Free running oscillator is enabled. |
static void VBAT_UngateFRO16k |
( |
VBAT_Type * |
base, |
|
|
uint8_t |
connectionsMask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | VBAT peripheral base address. |
connectionsMask | The mask of modules that FRO16k is connected, should be the OR'ed value of vbat_clock_enable_t. |
static void VBAT_GateFRO16k |
( |
VBAT_Type * |
base, |
|
|
uint8_t |
connectionsMask |
|
) |
| |
|
inlinestatic |
static void VBAT_LockFRO16kSettings |
( |
VBAT_Type * |
base | ) |
|
|
inlinestatic |
- Note
- Please note that the operation to ungate/gate FRO 16kHz output clock can not be locked by this function.
- Parameters
-
base | VBAT peripheral base address. |
static bool VBAT_CheckFRO16kSettingsLocked |
( |
VBAT_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | VBAT peripheral base address. |
- Returns
true
in case of FRO16k settings are locked, false
in case of FRO16k settings are not locked.