EMU - Energy management unit#
Energy management unit control peripheral.
Example#
EMU Basic temperature measurement example:
{
// Wait for temperature sensor to be ready
while (!sl_hal_emu_is_temperature_ready()) {
// Wait for temperature readiness
}
// Read temperature in degrees Celsius
float temperature = sl_hal_emu_get_temperature();
// Power management example with DCDC
#if defined(SL_HAL_EMU_DCDC_BUCK_PRESENT)
// Initialize DCDC regulator
sl_hal_emu_dcdc_init_t init = SL_HAL_EMU_DCDC_INIT_DEFAULT;
sl_hal_emu_init_dcdc(&init);
// Set DCDC mode to regulation
sl_hal_emu_set_dcdc_mode(SL_HAL_EMU_DCDC_MODE_REGULATION);
#endif
// RAM power management
// Power down all RAM blocks except the first one
sl_hal_emu_ram_power_down(SRAM_BASE, SRAM_BASE + SRAM_SIZE);
// Power up all RAM blocks when needed again
sl_hal_emu_ram_power_up();
// Clear reset cause when done handling it
uint32_t reset_cause = sl_hal_emu_get_reset_cause();
sl_hal_emu_clear_reset_cause();
}
Enumerations#
Number of samples to use for temperature averaging.
Peripheral reset control.
Peripheral reset control and reset source control.
Functions#
Power down RAM memory blocks.
Power up all available RAM memory blocks.
Lock EMU registers in order to protect them against unintended modification.
Unlock the EMU so that writing to locked registers again is possible.
Enable one or more EMU interrupts.
Disable one or more EMU interrupts.
Clear one or more pending EMU interrupts.
Get pending EMU interrupt flags.
Get enabled and pending EMU interrupt flags.
Set one or more pending EMU interrupts.
Get EMU STATUS register.
Temperature measurement ready status.
Get averaged temperature in degrees Celsius.
Request averaged temperature.
Get temperature in degrees Celsius.
Clear the reset cause register.
Get the cause of the last reset.
Disable/enable reset for various peripherals and signal sources.
Disable one or more EFP interrupts.
Enable one or more EFP interrupts.
Get pending EMU EFP interrupt flags.
Set one or more pending EMU EFP interrupts.
Clear one or more pending EMU EFP interrupts.
Get enabled and pending EMU EFP interrupt flags.
Enable EFP to drive DVDD voltage.
Disable EFP to drive DVDD voltage.
Enable EFP Direct Mode.
Disable EFP Direct Mode.
Set to enable EFP to drive Decouple voltage.
Set to disable EFP to drive Decouple voltage.
Lock DCDC registers in order to protect them against unintended modification.
Unlock the DCDC so that writing to locked registers again is possible.
Wait for the DCDC to complete all synchronization of register changes.
Enable EMU DCDC interrupts.
Disable EMU DCDC interrupts.
Enumeration Documentation#
sl_hal_emu_temperature_average_num_t#
sl_hal_emu_temperature_average_num_t
Number of samples to use for temperature averaging.
Enumerator | |
---|---|
SL_HAL_EMU_TEMP_AVERAGE_16 | 16 samples used for temperature averaging. |
SL_HAL_EMU_TEMP_AVERAGE_64 | 64 samples used for temperature averaging. |
sl_hal_emu_reset_mode_t#
sl_hal_emu_reset_mode_t
Peripheral reset control.
Enumerator | |
---|---|
SL_HAL_EMU_RESET_MODE_DISABLED | Reset mode disabled. |
SL_HAL_EMU_RESET_MODE_ENABLED | Reset mode enabled. |
sl_hal_emu_reset_source_t#
sl_hal_emu_reset_source_t
Peripheral reset control and reset source control.
Enumerator | |
---|---|
SL_HAL_EMU_RESET_WDOG0 | WDOG0 reset select. |
SL_HAL_EMU_RESET_SYS | SYSRESET select. |
SL_HAL_EMU_RESET_CORE_LOCKUP | Cortex lockup reset select. |
SL_HAL_EMU_RESET_AVDD | AVDD monitoring select. |
SL_HAL_EMU_RESET_IOVDD0 | IOVDD0 monitoring select. |
SL_HAL_EMU_RESET_DECOUPLE | Decouple monitoring select. |
Function Documentation#
sl_hal_emu_ram_power_down#
void sl_hal_emu_ram_power_down (uint32_t start, uint32_t end)
Power down RAM memory blocks.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | start | The start address of the RAM region to power down This address is inclusive. |
uint32_t | [in] | end | The end address of the RAM region to power down. Except for xg27 It can only have two values: 0 or more than RAM0_END. Any other valid RAM address will just do nothing without any error or indication that nothing happened. This address is exclusive. If this parameter is 0, all RAM blocks contained in the region from start to the end of RAM will be powered down. |
This function will power down all the RAM blocks that are within a given range. The RAM block layout is different between device families, so this function can be used in a generic way to power down a RAM memory region which is known to be unused.
This function will power down blocks from start to the end of RAM. For xg27, it will shut off blocks which are completely enclosed by the memory range given by [start, end].
This is an example to power down all RAM blocks except the first one. The first RAM block is special in that it cannot be powered down by the hardware. The size of the first RAM block is device-specific. See the reference manual to find the RAM block sizes.
sl_hal_emu_ram_power_down(SRAM_BASE, SRAM_BASE + SRAM_SIZE);
Note
The specified memory block(s) will stay off until a call to sl_hal_emu_ram_power_up() is done.
sl_hal_emu_ram_power_up#
void sl_hal_emu_ram_power_up (void )
Power up all available RAM memory blocks.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function will power up all the RAM blocks on a device this means that the RAM blocks are retained in EM2/EM3.
sl_hal_emu_lock#
void sl_hal_emu_lock (void )
Lock EMU registers in order to protect them against unintended modification.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Note
If locking EMU registers, they must be unlocked prior to using any EMU API functions modifying EMU registers, excluding interrupt control and regulator control if the architecture has a EMU_PWRCTRL register.
sl_hal_emu_unlock#
void sl_hal_emu_unlock (void )
Unlock the EMU so that writing to locked registers again is possible.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
sl_hal_emu_enable_interrupts#
void sl_hal_emu_enable_interrupts (uint32_t flags)
Enable one or more EMU interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | flags | EMU interrupt sources to enable. Use one or more valid interrupt flags for the EMU module (EMU_IEN_nnn). |
Note
Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. To ignore a pending interrupt, consider using sl_hal_emu_clear_interrupts() prior to enabling the interrupt.
sl_hal_emu_disable_interrupts#
void sl_hal_emu_disable_interrupts (uint32_t flags)
Disable one or more EMU interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | flags | EMU interrupt sources to disable. Use one or more valid interrupt flags for the EMU module (EMU_IEN_nnn). |
sl_hal_emu_clear_interrupts#
void sl_hal_emu_clear_interrupts (uint32_t flags)
Clear one or more pending EMU interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | flags | Pending EMU interrupt sources to clear. Use one or more valid interrupt flags for the EMU module EMU_IF_nnn. |
sl_hal_emu_get_pending_interrupts#
uint32_t sl_hal_emu_get_pending_interrupts (void )
Get pending EMU interrupt flags.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Returns
EMU interrupt sources pending. Returns one or more valid interrupt flags for the EMU module (EMU_IF_nnn).
Note
Event bits are not cleared by the use of this function.
sl_hal_emu_get_enabled_pending_interrupts#
uint32_t sl_hal_emu_get_enabled_pending_interrupts (void )
Get enabled and pending EMU interrupt flags.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Useful for handling more interrupt sources in the same interrupt handler.
Returns
Pending and enabled EMU interrupt sources Return value is the bitwise AND of
the enabled interrupt sources in EMU_IEN and
the pending interrupt flags EMU_IF.
Note
Interrupt flags are not cleared by the use of this function.
sl_hal_emu_set_interrupts#
void sl_hal_emu_set_interrupts (uint32_t flags)
Set one or more pending EMU interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | flags | EMU interrupt sources to set to pending. Use one or more valid interrupt flags for the EMU module (EMU_IFS_nnn). |
sl_hal_emu_get_status#
uint32_t sl_hal_emu_get_status (void )
Get EMU STATUS register.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Returns
STATUS register value.
sl_hal_emu_is_temperature_ready#
bool sl_hal_emu_is_temperature_ready (void )
Temperature measurement ready status.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Returns
True if temperature measurement is ready.
sl_hal_emu_get_averaged_temperature#
float sl_hal_emu_get_averaged_temperature (void )
Get averaged temperature in degrees Celsius.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Returns
Averaged temperature.
Note
An averaged temperature measurement must first be requested by calling sl_hal_emu_get_averaged_temperature() and waiting for the TEMPAVG interrupt flag to go high.
sl_hal_emu_request_averaged_temperature#
void sl_hal_emu_request_averaged_temperature (sl_hal_emu_temperature_average_num_t num_samples)
Request averaged temperature.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_hal_emu_temperature_average_num_t | [in] | num_samples | Number of temperature samples to average. |
sl_hal_emu_get_temperature#
float sl_hal_emu_get_temperature (void )
Get temperature in degrees Celsius.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Returns
Temperature in degrees Celsius.
sl_hal_emu_clear_reset_cause#
void sl_hal_emu_clear_reset_cause (void )
Clear the reset cause register.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function clears all the reset cause bits of the RSTCAUSE register. The reset cause bits must be cleared by software before a new reset occurs. Otherwise, reset causes may accumulate. See sl_hal_emu_get_reset_cause().
sl_hal_emu_get_reset_cause#
uint32_t sl_hal_emu_get_reset_cause (void )
Get the cause of the last reset.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
To be useful, the reset cause must be cleared by software before a new reset occurs. Otherwise, reset causes may accumulate, See sl_hal_emu_clear_reset_cause(). This function call will return the main cause for reset, which can be a bit mask (several causes) and clear away "noise".
Returns
A reset cause mask. See the reference manual for a description of the reset cause mask.
sl_hal_emu_set_reset_control#
void sl_hal_emu_set_reset_control (sl_hal_emu_reset_source_t reset, sl_hal_emu_reset_mode_t mode)
Disable/enable reset for various peripherals and signal sources.
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_hal_emu_reset_source_t | [in] | reset | Reset types to enable/disable. |
sl_hal_emu_reset_mode_t | [in] | mode | Reset mode. |
sl_hal_emu_efp_disable_interrupts#
void sl_hal_emu_efp_disable_interrupts (uint32_t flags)
Disable one or more EFP interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | flags | EFP interrupt sources to disable. Use one or more valid interrupt flags for the EFP module (EFPIENnnn). |
sl_hal_emu_efp_enable_interrupts#
void sl_hal_emu_efp_enable_interrupts (uint32_t flags)
Enable one or more EFP interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | flags | EFP interrupt sources to enable. Use one or more valid interrupt flags for the EFP module (EFPIENnnn). |
sl_hal_emu_efp_get_pending_interrupts#
uint32_t sl_hal_emu_efp_get_pending_interrupts (void )
Get pending EMU EFP interrupt flags.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Note
Event bits are not cleared by the use of this function.
Returns
EMU EFP interrupt sources pending.
sl_hal_emu_efp_set_interrupts#
void sl_hal_emu_efp_set_interrupts (uint32_t flags)
Set one or more pending EMU EFP interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | flags | EMU EFP interrupt sources to set to pending. Use one or more valid interrupt flags for the EMU EFP module. |
sl_hal_emu_efp_clear_interrupts#
void sl_hal_emu_efp_clear_interrupts (uint32_t flags)
Clear one or more pending EMU EFP interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | flags | Pending EMU EFP interrupt sources to clear. Use one or more valid interrupt flags for the EMU EFP module. |
sl_hal_emu_efp_get_enabled_pending_interrupts#
uint32_t sl_hal_emu_efp_get_enabled_pending_interrupts (void )
Get enabled and pending EMU EFP interrupt flags.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Useful for handling more interrupt sources in the same interrupt handler.
Note
Interrupt flags are not cleared by the use of this function.
Returns
Pending and enabled EMU EFP interrupt sources Return value is the bitwise AND of
the enabled interrupt sources in EMU_EFPIEN and
the pending interrupt flags EMU_EFPIF.
sl_hal_emu_enable_efp_drive_dvdd#
void sl_hal_emu_enable_efp_drive_dvdd (void )
Enable EFP to drive DVDD voltage.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Set this if EFP's DCDC output is powering DVDD supply. This mode assumes that internal DCDC is not being used.
sl_hal_emu_disable_efp_drive_dvdd#
void sl_hal_emu_disable_efp_drive_dvdd (void )
Disable EFP to drive DVDD voltage.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
sl_hal_emu_enable_efp_direct_mode#
void sl_hal_emu_enable_efp_direct_mode (void )
Enable EFP Direct Mode.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
sl_hal_emu_disable_efp_direct_mode#
void sl_hal_emu_disable_efp_direct_mode (void )
Disable EFP Direct Mode.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
sl_hal_emu_enable_efp_drive_decouple#
void sl_hal_emu_enable_efp_drive_decouple (void )
Set to enable EFP to drive Decouple voltage.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Once set, internal LDO will be disabled, and the EMU will control EFP for voltage-scaling. Note that because this bit disables the internal LDO powering the core, it should not be set until after EFP's DECOUPLE output has been configured and enabled.
sl_hal_emu_disable_efp_drive_decouple#
void sl_hal_emu_disable_efp_drive_decouple (void )
Set to disable EFP to drive Decouple voltage.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
sl_hal_emu_dcdc_lock#
void sl_hal_emu_dcdc_lock (void )
Lock DCDC registers in order to protect them against unintended modification.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
sl_hal_emu_dcdc_unlock#
void sl_hal_emu_dcdc_unlock (void )
Unlock the DCDC so that writing to locked registers again is possible.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
sl_hal_emu_dcdc_sync#
void sl_hal_emu_dcdc_sync (uint32_t mask)
Wait for the DCDC to complete all synchronization of register changes.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | mask | A bitmask corresponding to SYNCBUSY register defined bits indicating registers that must complete any ongoing synchronization. |
sl_hal_emu_dcdc_enable_interrupts#
void sl_hal_emu_dcdc_enable_interrupts (uint32_t flags)
Enable EMU DCDC interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | flags | DCDC interrupt sources to enable. |
sl_hal_emu_dcdc_disable_interrupts#
void sl_hal_emu_dcdc_disable_interrupts (uint32_t flags)
Disable EMU DCDC interrupts.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | [in] | flags | DCDC interrupt sources to disable. |