Renesas HAL Application Note

Application Note Renesas Synergy™ Platform
Low Power Modes V2 HAL Module Guide
Introduction
This module guide will enable you to effec tively use a module in your own des ign. Upon completion of this guide, you will be able to a dd this m odule to your own design, co nfigure it correc tly for the t arget ap plication and write code, using the included application project code as a reference and efficient starting point. References to more detailed API descriptions and suggestions of other application projects that illustrate more advanced uses of the m odule are available in the Re nesas Synergy Knowledge Base ( as described in the References section at the end of this document), and should be valuable resources for creating more complex designs.
The Low Power Modes V2 HAL module is a high-level API for low-power mode applications and is implemented on r_lpm2. The Low Power Modes HAL module uses the low-power mode hardware peripheral on the Synergy MCU.
Contents
1. Low Power Modes V2 HAL Module Features........................................................................... 2
2. Low Power Modes V2 HAL Module APIs Overview ................................................................. 2
3. Low Power Modes V2 HAL Module Operational Overview ....................................................... 3
3.1 Low Power Modes V2 HAL Module Impor tant Operat io nal Notes and Limitations ................................. 5
3.1.1 Low Power Modes V2 HAL Module Operational Notes ........................................................................ 5
3.1.2 Low Power Modes V2 HAL Module Limitations .................................................................................... 6
4. Including the Low Power Modes V2 HAL Module in an Application .......................................... 6
5. Configuring the Low Power Modes V2 HAL Module................................................................. 7
5.1 Low Power Modes V2 HAL Module Clock Configuration ...................................................................... 11
5.2 Low Power Modes V2 HAL Module Pin Configuration .......................................................................... 11
6. Using the Low Power Modes V2 HAL Module in an Application ............................................. 11
7. The Low Power Modes V2 HAL Module Application Project .................................................. 11
8. Customizing the Low Power Modes V2 HAL Module for a Target Application ........................ 15
9. Running the Low Power Modes V2 HAL Module Application Project ..................................... 16
10. Low Power Modes V2 HAL Module Conclusion ..................................................................... 17
11. Low Power Modes V2 HAL Module Next Steps ..................................................................... 17
12. Low Power Modes V2 HAL Module Reference Information .................................................... 17
R11AN0126EU0102 Rev.1.02 Page 1 of 19 Feb.08.19
Renesas Synergy™ Platform Low Power Modes V2 HAL Module Guide

1. Low Power Modes V2 HAL Module Features

The LPM V2 HAL module supports configuration of MCU operating power-control modes and MCU low­power modes using the low-power mode hardware peripheral.
The LPM V2 HAL module supports the following low power modes:
Deep Software Standby mode
Software Standby mode
Sleep mode
Snooze mode
The LPM V2 HAL module supports reducing power consumption when in deep stand-by mode through internal power-supply control and by resetting the states of I/O ports. The LPM V2 HAL module supports disabling and enabling of the MCU’s other hardware peripherals.
Note: Not all low-power V2 modes are available on all MCUs Groups.
Figure 1. Low Power Modes V2 Module Block Diagram

2. Low Power Modes V2 HAL Module APIs Overview

The Low Power Modes V2 HAL module defines APIs for configuring o perations and enabling and disabling low-power operations . A complete list of the availa ble APIs, an example API call a nd a short description of each can be found in the following table. A table of return status values follows the API summary table.
Note: The Low Power Modes V2 HAL module will no longer handle operating power-control modes of the
MCU, these are now handled by the CGC HAL module.
The following API examples illustrate sleep-mode use; “deep_standby” and “standby” can be substituted for “sleep” in the API examples to create examples for those modes.
R11AN0126EU0102 Rev.1.02 Page 2 of 19 Feb.08.19
Renesas Synergy™ Platform Low Power Modes V2 HAL Module Guide
Function Name
Example API Call and Description
.init
g_lpmv2_sleep0.p_api->init(g_lpmv2_sleep0.p_cfg);
in config structure.
.lowerPowerCfg
g_lpmv2_sleep0.p_api->lowerPowerCfg(power_mode,
.lowPowerModeEnter
g_lpmv2_sleep0.p_api->lowPowerModeEnter(void); .versionGet
g_lpmv2_sleep0.p_api->versionGet(&version); Get the driver version and place it at the pointer vers ion.
Name
Description
SSP_SUCCESS
API Call Successful
SSP_ERR_INVALID_POINTER
Pointer is NULL
SSP_ERR_INVALID_MODE
Invalid settings for specified mode
SSP_ERR_INVALID_HW_CONDITION
OPCMTSF and SOPCMTSF flags are not cleared within internally set timeout.
Table 1. Low Power Modes V2 Module API Summary
Open the LPM driver module Initialized the LPM block according to the passed
output_port_enable, power_supply, io_port_state); Configure a low power mode.
Enter low power mode (sleep/standby/deep standby) using WFI macro. Function will return after waking from low power mode.
Note: For details on operation and definitions for the function data structures, typedefs, defines, API data,
API structures, and function variables, review the SSP User’s Manual API References for the associated module.
Table 2. Status Return Values
Note: Lower-level drivers may return common error codes. Refer to the SSP User’s Manual API References
for the associated module for a definition of all relevant status return values.

3. Low Power Modes V2 HAL Module Opera tional O ver view

LPM V2 Initialization
The LPM V2 API function lpm_v2_api_t::init should be called before calling any other LPM V2 function. The init function handles initialization of internal variables and locks.
Sleep low-power mode
By default, at power on, sleep mode is enabled as the low-power mode. Sleep mode is the most convenient low-power mode available, as it does not require any special configuration (other than configuring and enabling a suitable interrupt or event to wake the MCU from sleep) to return to normal program-execution mode. Any interrupt wakes the MCU device from sleep low-power mode. The states of the SRAM, the processor registers, and the hardware peripherals are all maintained in sleep mode, and the time needed to enter and wake from sleep is minimal. Any interrupt causes the MCU device to wake from sleep mode, including the Systick interrupt used by the ThreadX lpm_v2_api_t::init should be called before any other function. The LPM API function, lpm_v2_api_t::lowPowerCfg, can be used to configure the MCU to use sleep as its low-power mode. The LPM API function lpm_v2_api_t::lowPowerModeEnter should be used to directly enter sleep mode.
An illustrative code example is available on the LPM_V2 Knowledge Base article, available as described in the Reference Information section at the end of this document.
Software Standby Mode for LPM V2
®
thread scheduler. The LPM API function
In software-standby mode, the CPU, as well as most of the on-chip peripheral functions and all of the internal oscillators, are stopped. Retained are the contents of the CPU internal registers and SRAM data, the states of on-chip peripheral functions and I/O Ports. Software-standby mode allows significant reduction in power consumption, because most of the oscillators are stopped in this mode. Like sleep mode, standby mode requires an interrupt or event be configured and enabled to wake from standby mode.
R11AN0126EU0102 Rev.1.02 Page 3 of 19 Feb.08.19
Renesas Synergy™ Platform Low Power Modes V2 HAL Module Guide
The possible triggers for waking from standby mode are enumerated in the Properties window for convenience; multiple triggers can be enabled.
An illustrative code example is available on the LPM_V2 Knowledge Base article, available as described in the Reference Information section at the end of this document.
Snooze Mode with Software Standby Mode for LPM V2
Snooze mode is available through the standby mode LPM V2 instance. Choose "Standby with Snooze Enabled" for “Choose the low power mode” in the Properties window. Snooze mode can be used with some MCU peripherals to execute basic tasks, while keeping the MCU in a low-power state. The snooze settings are below the standby settings in the Properties window. The ADC, DTC, and other peripherals can be enabled in snooze mode. All the settings for snooze are available through configuration properties for the standby instance, with the exception of the Event Link Controller settings for registers SELSR0 and IELSRn. Snooze is considered an advanced feature.
The “Snooze Mode Settings” are only used if the low-power mode choice is “Standby with Snooze Enabled,” as shown in the following screen capture:
Figure 2. Standby mode with Snooze setting enabled
Snooze is a feature of standby mode that allows some peripherals to run even though the MCU core is not executing instructions. The low-power mode peripheral options related to snooze mode are shown in the following image. Only one snooze-entry source can be enabled, while multiple snooze-exit sources can be enabled; the DTC peripheral can be enabled in snooze mode as well.
R11AN0126EU0102 Rev.1.02 Page 4 of 19 Feb.08.19
Renesas Synergy™ Platform Low Power Modes V2 HAL Module Guide
Figure 3. Snooze Mode Settings
Deep Software Standby Mode for LPM V2
Deep Softwar e Sta ndb y Mode is onl y a vailabl e on s om e MCU de vices. T he MC U de vice a lwa ys wak es f rom Deep Software Standby Mode by going through reset, either by the negation of the reset pin or by one of a set of wake-up events displayed in the configuration Properties window for the LPM deep standby instance.
The possible triggers for waking from deep standby mode are enumerated in the Properties window for convenience. Multipl e triggers can be enabled. Some triggers ha ve an ass oc iat ed edg e type, falling or ri sing. These options are enumerated also as shown above and below.
An illustrative code example is available on the LPM_V2 Knowledge Base article, available as described in the Reference Information section at the end of this document.

3.1 Low Power Modes V2 HAL Module Important Operational Notes and Limitations

3.1.1 Low Power Modes V2 HAL Module Operational Notes

Using this driver to configure the LPM peripheral to wake the MCU from standby mode through interrupts requires the interrupt to be configured and enabled by the peripheral driver or framework that uses that interrupt. For example, to wake from standby through AGT1 underflow, that interrupt must be enabled through the configuration of the AGT timer module.
If the main oscillator or PLL with main-oscillator source is used for the system clock, the wake time from standby mode can be affected by the Main Oscillator Wait Time Setting in the MOSCWTCR register. This register setting is available to be changed through the Main Oscillator Wait Time setting in the CGC HAL module properties. See the Wakeup Timing and Duration table in Electrical Characteristics for more information.
Note: When a project uses ThreadX and the low-power mode standby, deep standby or standby with
snooze enabled, the call to the lpm_v2_api_t::lowPowerCfg API function should occur immediately before the call to the lpm_v2_api_t::lowPowerModeEnter API function. This is necessary since ThreadX also uses low-power modes in its idle loop and tx_thread_sleep function; ThreadX expects the MCU device to be configured for the low-power mode sleep.
When a project uses ThreadX and the low-power mode standby or standby with snooze enabled, the low-power mode should be reverted to sleep after the MCU device wakes from standby after returning from the lpm_v2_api_t::lowPowerModeEnter function. This is necessary since ThreadX also uses low-power modes in its idle loop and tx_thread_sleep function; ThreadX expects the MCU device to be configured for the low-power mode sleep. The API function lpm_v2_api_t::lowPowerCfg needs to be called again before lpm_v2_api_t::lowPowerModeEnter to re-configure the low-power mode to sleep, if the tx_thread_sleep function is used in the project, or if there may not always be a thread ready to run.
Detailed information about the expected power consumption of the MCU device in operating states and in Low Power Modes V2 can be found in the Operating and Standby Current section within the Elec tric al Characteristics section of the MCU Synergy Hardware User’s Manual.
R11AN0126EU0102 Rev.1.02 Page 5 of 19 Feb.08.19
Renesas Synergy™ Platform Low Power Modes V2 HAL Module Guide
Resource
ISDE Tab
Stacks Selection Sequence
g_lpmv2_deep_standby0 S7G2 Low
Threads
New Stack> Driver> Power> Low Power
g_lpmv2_sleep0 S7G2 Low Pow er
Threads
New Stack> Driver> Power> Low Power
g_lpmv2_standby0 S7G2 Low Power
Threads
New Stack> Driver> Power> Low Power

3.1.2 Low Power Modes V2 HAL Module Limitations

Flash stop (code flash disable) is not supported. See the section “Flash Operation Control Register
(FLSTOP)” of the S1/S3 Synergy Hardware User’s Manual.
Reduced SRAM retention area in software standby mode is not supported. See the section “Power Save
Memory Control Register (PSMCR)” of the S3 Synergy Hardware User’s Manual.
The MCU may not enter or stay in Software Standby and Deep Software Standby modes with the
debugger attached. Instead , the MCU ma y be woken fr om Software Standby and Deep Software Stand b y modes by the debugger. To properly test and verify Software Standby and Deep Software Standby modes, the debugger must not be attached.
2
(NOTE: Due to some issues, the Application project works only when connected to debugger for e
2
studio. So. while using e
studio, use the application project along with debugger connected to test the
low power modes.).
If the main oscillator or PLL with the main oscillator source is used for the system clock, the wake time
from standby mode can be affected by the Main Oscillator Wait Time Setting in the MOSCWTCR register. This register setting can be changed through the Main Oscillator Wait Time setting in the CGC HAL module properties. See the “Wakeup Timing and Duration” table in Electrical Characteristics for more information.
Refer to the latest SSP Release Notes for any additional operational limitations for this module.

4. Including the Low Power Modes V2 HAL Module in an Application

This section describes how to include the Low Power Modes V2 HAL module in an application using the SSP configurator.
Note: It is assumed you are familiar with creating a project, adding threads, adding a stack to a thread and
configuring a block within the stack. If you are unfamiliar with any of these items, refer to the first few sections of the SSP User’s Manual to learn how to manage each of these important steps in creating SSP-based applications.
To add a Low Power Modes V2 Driver to an application, simply add it to a thread using the stacks selection sequence given in the following table. (The default name for the Low Power Modes Driver is g_lpmv2_<mode>0. This name can be changed in the associated Properties window.)
Table 3. Low Power Modes V2 Module Selection Sequence
Power Mode Sleep on r_lpmv2
Mode Sleep on r_lpmv2
Mode Sleep on r_lpmv2
Mode Deep Standby on r_lpmv2
Mode Sleep on r_lpmv2
Mode Standby on r_lpmv2
Note: The selection sequences list modes available for the S7G2 Group. Other MCUs will have a different
selection sequence available in the ISDE.
If you add the LPM V2 HAL module to more than one thread, or to a thread and to HAL/Common, give each instance of the LPM V2 Driver a unique name by highlighting the instance of the driver in the Modules window and changing the entry for name in the Properties view. The default settings for the LPM V2 HAL module configuration structure can also be changed using this view.
(The following figure shows the three available low power modes for the S7G2 MCU. These modules can be added individually or in groups. This figure shows all three for completeness; the c onf igurat or automatically adds any needed lower-level modules. Modul es with a Gray band are individual modules that stand alone. Modules with a Blue band are shared or common and need only be added once and can be used by multiple stacks.
R11AN0126EU0102 Rev.1.02 Page 6 of 19 Feb.08.19
Loading...
+ 14 hidden pages