Renesas RA2L1, RA2E1 Application Note

Application Note
Kit
Operable Long Timer in LPM
LPM Transition and Clock Changing at Run-Time
EK-RA2E1
Yes
Yes
EK-RA2L1
Yes
Yes
Renesas RA2 Series
Getting Started with Low Power Applications for RA2L1
/RA2E1 Group
Introduction
This application note describes:
LPM module usage in different modes and supported peripherals
Application overview for the different use cases
FSP configuration steps for LPM
Application design highlights
Importing, loading, and running the application project
Project migration steps to other RA Kits.
Required Resources
e2 studio ISDE v2021-01 (21.1.0) or later
Flexible Software Packag e ( FSP) v2.3.0 or later
J-Link RTT viewer V6.94 or later
Primary target devices
EK-RA2L1 kit
EK-RA2E1 kit
Table 1. RA Kits Tested with LPM Application
R11AN0480EU0101 Rev.1.01 Page 1 of 33 Jan.26.21
Renesas RA2 Series Getting Started with Low Power Applications for RA2L1/RA2E1 Group
Contents
1. Application Overview ............................................................................................................... 4
1.1 Low Power Modes .................................................................................................................................. 4
1.1.1 Sleep Mode ........................................................................................................................................... 5
1.1.2 Software Standby Mode ........................................................................................................................ 5
1.1.3 Snooze Mode ........................................................................................................................................ 6
1.2 Activation and Cancel Sources ............................................................................................................... 6
1.3 Peripheral Operation in LPM .................................................................................................................. 6
1.4 Use Case: Changing Clocks at Run-Time .............................................................................................. 6
1.5 Use Case: LPM Transition at Run-Time ................................................................................................ 7
1.6 Use Case: Operable Long Timer in Softwar e Sta ndby Mode ................................................................. 7
2. LPM HAL Module .................................................................................................................... 7
3. FSP Configuration ................................................................................................................... 8
3.1 Components Tab ..................................................................................................................................... 9
3.2 Stacks Tab ............................................................................................................................................. 10
3.3 Module Configuration ............................................................................................................................ 11
3.3.1 LPM Configuration ............................................................................................................................... 11
3.3.1.1 Ac tiv at ion an d Canc elat ion Sour ces ................................................................................................. 11
3.3.1.2 Sleep Mode Configuration ................................................................................................................. 12
3.3.1.3 Software Standby Mode Configuration ............................................................................................. 12
3.3.1.4 Snooze Mode Configuration .............................................................................................................. 13
3.3.2 Timer Configuration ............................................................................................................................. 14
3.3.2.1 RTC Configuration ............................................................................................................................. 14
3.3.2.2 AGT Timer Configuration .................................................................................................................. 15
3.4 Pin Configuration ................................................................................................................................... 17
3.4.1 Pin Configuration in Normal Mode ...................................................................................................... 17
3.4.2 Pin Configuration in LPM ..................................................................................................................... 18
4. Application Architectures ....................................................................................................... 19
4.1 Clock Changing and LPM Transition .................................................................................................... 19
4.2 RTC Timer Operation in LPM ............................................................................................................... 21
4.3 Operable Long Timer in Software Standby Mode ................................................................................. 22
5. Application Code Highlights ................................................................................................... 23
5.1 Clock Source Setup ............................................................................................................................... 23
5.1.1 Handling On-Chip Modules in LPM to Reduce Power Consumption ................................................. 23
5.1.2 Changing System Clock at Run-Time ................................................................................................. 24
6. Importing and Building the Project ......................................................................................... 25
R11AN0480EU0101 Rev.1.01 Page 2 of 33 Jan.26.21
Renesas RA2 Series Getting Started with Low Power Applications for RA2L1/RA2E1 Group
7. Running Applications ............................................................................................................. 25
7.1 Board Setups ......................................................................................................................................... 25
7.2 Downloading the Executables ............................................................................................................... 26
7.2.1 Using a debugging interface with e2 studio ......................................................................................... 26
7.2.2 Using J-Link tools ................................................................................................................................ 26
7.2.3 Using Renesas Flash Programmer ..................................................................................................... 26
7.3 User Interface ........................................................................................................................................ 26
7.3.1 LED Indication ..................................................................................................................................... 26
7.3.1.1 Clock Changing and LPM Transition ................................................................................................. 26
7.3.1.2 Operable Long Timer ........................................................................................................................ 26
7.3.2 User Push Button Input ....................................................................................................................... 26
7.3.2.1 Clock Changing and LPM Transition ................................................................................................. 26
7.3.2.2 Operable Long Timer ........................................................................................................................ 26
7.3.3 RTT Console ....................................................................................................................................... 27
7.4 Debugging Low Power Modes .............................................................................................................. 28
7.5 Steps to Run the Application ................................................................................................................. 29
7.5.1 Clock Changing: .................................................................................................................................. 29
7.5.2 LPM Transition .................................................................................................................................... 29
7.5.3 Operable Long Timer .......................................................................................................................... 30
7.6 Measure MCU Current .......................................................................................................................... 31
8. Migrating LPM Applications to Different MCU/Kit ................................................................... 31
9. References ............................................................................................................................ 31
Revision History ............................................................................................................................ 33
R11AN0480EU0101 Rev.1.01 Page 3 of 33 Jan.26.21
Renesas RA2 Series Getting Started with Low Power Applications for RA2L1/RA2E1 Group

1. Application Overview

Application Projects accompanying this document serve as references to operate the microcontroller (MCU) in various Low Power Modes demonstrating different levels of power consumption often required to maximize battery life.
For ease of understanding the LPM, these appl icati on pr oj ect s cover:
Different Low Power Modes with different clock settings to showcase each mode
Operation of different peripherals in an LPM
Required pin configurations
Trigger/end source configuration
A user interface to initiate transition to different LPM states and switch back to Normal mode.
The configuration for each mode is maintained as an independ ent ins ta nc e. Users can use these example configurations and ch ang e diff er ent settings to trigger/end operation as desired.
In addition to the LPM, the application also supports changing the source clock of the MCU dynamically and running LPM for these clocks.
Note: In this application note, the project uses the default power supply source from LDO instead of the
optional DC-DC regulator available on the MCU. For more details on using the LPM along with DC­DC regulator, see the MCU Hardware User’s Manual.

1.1 Low Pow er Modes

RA MCUs support four different types of LPM depending on the MCU family. These are:
Sleep mode
Software Standby mode
Snooze mode
Deep Software Standby mode (Available only in selective MCUs).
Low power mode transition and triggering sources for RA MCUs are illustrated in Figure 1. For more deta ils on these transitions, see the User’s Manual for the specific MCU.
Figure 1. LPM Transition Diagram for RA2L1
R11AN0480EU0101 Rev.1.01 Page 4 of 33 Jan.26.21
Renesas RA2 Series Getting Started with Low Power Applications for RA2L1/RA2E1 Group
In LPM, the CPU stops, but on-chip peripherals and oscillator states may be operational depending on the LPM selected. Therefore, their effects on MCU power consumption are very different. The typical current consumption when the MCU is in a Low Power Mode is found in the MCU Hardware User’s Manual section on Operating and Standby Current. Figure 2 shows the typical power consumption when the MCU is in a Low Power Mode vs throughput.
Figure 2. Power Consumption and Throughput of the LPM
In order for the MCU to ent er or exit the LPM, associated special func t ion registers need to be configured. This app note does not focus on the bit-level configuration details, since the bits can be configured using the API provided by the FSP. The API provided by the FSP is documented in the FSP User’s Manual. If you want to explore more details on the LPM and its supported list of peripherals, interrupts, refer to the Low Power Modes section in the RA MCU Datasheet. Low Power Modes commonly available with RA MCUs are described next.
MCU also supports different power control modes to reduce the power consumption as part of the LPM. Power consumption can be reduced in Normal, Sleep, and Snooze mode by selecting an appropriate operating power control mode according to the operating frequency and voltage.
Four operating power control modes are available:
High-speed mode
Middle-speed mode
Low-speed mode
Subosc-speed mode
Note: The Power Control mode is not supported in the bundled application projects. For more details on
power control modes, see the User’s Manual for the specific MCUs.

1.1.1 Sleep Mode

An operational CPU is typically the primary cause of power consumption. In Sleep mode, the CPU stops operating, but the contents of its internal registers are retained. Other peripheral functions in the MCU do not stop. Available resets or interrupts in Sleep mode can cause the MCU to ca nc el Slee p mode. A ll inter r upt sources are available in this mode to cancel the Sleep mode. When using an inter rupt to successfully cancel Sleep mode, you must set the associated IELSRn register before executing a WFI instruction.

1.1.2 Software Standby Mode

In Software Standby mode, the CPU, most of the on-chip peripheral functions and the oscillators stop operation. However, the contents of the CPU internal registers and the SRAM data, the states of the on-chip peripheral functions, and the I/O port states are retained. Software Standby mode allows a significant reduction in power consumption since most of the oscillators stop in this mode.
R11AN0480EU0101 Rev.1.01 Page 5 of 33 Jan.26.21
Renesas RA2 Series Getting Started with Low Power Applications for RA2L1/RA2E1
Clock Source
HOCO
High Speed On-Chip Oscillator
MOCO
Medium Speed On-Chip Oscillator
LOCO
Low Speed On-Chip Oscillator
Group

1.1.3 Snooze Mode

The Snooze feature provides operational flexibility to dramatically reduce current consumption. Snooze is an extension to the Software Standby mode where limited peripheral modules can operate without waking up the CPU. The Snooze mode can be entered through the Software Standby mode via configured interrupt sources. Similarly the system can be woken up from Snooze mode by interrupts supported in the Snooze mode.

1.2 Activation and Cancel Sources

Low power modes are canceled by various interrupt sources such as RES pin reset, power-on reset, voltage monitor reset, and p erip heral interrupts. Refer to the Low Power Modes section in Renesas RA MCU User’s Manual for list of interrupt sources for different LPMs.
Only Snooze mode is triggered by a Snooze request to enter Snooze mode from Software Standby mode. The transitions to other LPMs are done by executing a WFI instruction with appropriate settings in the Standby Control register (SBYCR).

1.3 Peripheral Operation in LPM

Not all the MCU periphera ls are available in different LPMs. MCU peripherals also have different setting retention capabilities during the different LPMs, such as contents of the internal registers may be retained in some LPMs, but the contents may be undefined in other modes. Depending on the requirements of the application, users are required to choose the peripherals and LPM settings for achieving the maximum power savings. Users are also required to turn off/disable oscillators and on-chip peripherals that are not clock gated or powered off to maximize the power savings. Refer to the Low Power Modes section in each RA MCU User’s Manual: Hardware to understand different oscillator and peripherals available in a specific LPM.
In the next sections we will talk about the use case scenarios for the different LPMs with different clock settings and peripherals.

1.4 Use Case: Changing Clocks at Run-Time

This application use case describes how to change the RA MCU clock dynamically and set it to different clock settings supported by the RA MCU using the FSP CGC HAL driver APIs. While the user can configure the Clock Generation Circuits (CGC) within the MCU using the RA FSP Clock Configurator, in many applications, where the MCU is eventually powered by a battery, there is an inherent requirement to change the clock configuration settings as the MCU is running. Based on the desire d set of clock sources, MCU changes to different clock source and o per ates norm al l y without reboot.
Changing the system clock affects the peripherals, which use derivatives of the system clock as a source and other clocks in the system. Users are advised to select the dividers as applicable for the system. When changing the clock, make sure to allow stabilization with the proper settling time. This stabilization time is designed into the CGC HAL Driver.
This application operates using the user switch input to change the MCU clock mode from the previously running clock to the desired clock. The new clock settings are applied and displayed via the RTT int er fac e for the user notification.
Table 2 shows the available user selectable clock settings in the application
Table 2. User Selectable Clock on EK-RA2L1 Board
The sequence of the clock being configured is HOCOMOCOLOCO HOCO. The objective of this use case is to show the different clock sources which can be changed during run time without halting the MCU. Changing the clock dynamically is accomplished by using the RA CGC HAL driver API R_CGC_ClocksCfg. For more details on CGC HAL driver API, refer to the FSP User’s Manual.
R11AN0480EU0101 Rev.1.01 Page 6 of 33 Jan.26.21
Renesas RA2 Series Getting Started with Low Power Applications for RA2L1/RA2E1
Clock Source Supported
LPM Supported
HOCO
SLEEP, SW_STND B Y, SNOOZE
MOCO
SLEEP, SW_STNDBY, SNOOZ E
LOCO
SLEEP, SW_STND B Y, SNOOZE
Group

1.5 Use Case: LPM Transition at Run-Time

This use case shows the different LPMs supported by the MCU for the dif feren t cloc k settings. The application requires user input from the push button switch to change the LPM available for the MCU
and perform transitions as programmed. The supported LPM and its transitions to the different LPMs are displayed using the RTT interface for notifying the user. The application also showcases the use of few peripherals, like the AGT timer, and RTC op er ati ng in different LPMs. It also displays the RTC time information regularly when MCU transitions to the normal mode from the LPM. AGT1 Timer is used in the Snooze mode to alter nate between Software Standby mode and Snooze mode. RTC Alarm interrupt is used to cancel the Software Standby mode and ent er normal mode. IRQn (User Switch Interrupt) is used to cancel the Sleep mode.
The visual indication of the LPM transitio n can also be s een with the User LED on the Board. When the LED is blinking approximately every 1 seconds, it is running in the Normal mode. If the LED is turned OFF, it is in an LPM.
Note: More details on the application are explained in the architecture section 4.1 .The peripherals used in
the application are just few of those available for the MCU. For the complete list of peripherals supported in the LPM, refer to the LPM section of the MCU User’s Hardware Manual.
Different clock sources and LPMs supported for the RA MCUs are shown in Table 3.
Table 3. Clock Sources and Supported LPM for EK-RA2L1 Board
Transitioning to the different LPMs is accomplished by using the RA LPM HAL driver API R_LPM_LowPowerModeEnter. More details of this API can be found in the FSP User’s Manual.

1.6 Use Case: Operable Long Timer in Software Standby Mode

The Operable Long Timer in Software Standby mode requires a timer that can operate in a Low Power Mode. The count source of the timer is another element that should be considered carefully as well. In Renesas RA MCUs, the 16-bit Asynchronous General-Purpose Timer channel 0 (AGT0) and 16-bit channel 1 (AGT1) can be used in cascade mode to create an 32-bit timer. In the cascade mode, AGT0 underflow interrupt will trigger the counter of AGT1, AGT0 count source can be the sub-clock oscillator or LOCO clock, which are available in Software Standby mode. The AGT1 Underflow interrupt is used to wake the MCU up from LPM.
The maximum period of the 16-bit AGT timer channel 0 with the Sub-Clock count source running at 32.768 kHz is approximately 2.0 seconds. The Operable Lo ng Timer with two AGT timer channels in cascade mode will have a maximum period of approximately 2184.5 hours with a timer resolution of 30.517 µs.
Note: If a longer wakeup time is required, the RTC can be used via the RTC alarm, but here the resolution
of the timer is limited to 1 second.
Note: With RTC Periodic timer interrupt, the resolution of 1/256 sec can be achieved. However, the RTC
periodic timer events cannot be linked to other peripherals with LPM operations.

2. LPM HAL Module

The LPM HAL module in FSP provides a method t o in c lude the LPM driver into the application and to configure it for different modes. It also allows configuring different trigger/cancel signals as required for LPM activation/cancellation. FSP also provides essential APIs to configure and place the MCU in Low Power Modes. It supports the following Low Power Modes:
Deep Software Standby mode (on supported MCUs)
Software Standby mode
Sleep mode
Snooze mode
R11AN0480EU0101 Rev.1.01 Page 7 of 33 Jan.26.21
Renesas RA2 Series Getting Started with Low Power Applications for RA2L1/RA2E1 Group

3. FSP Configuration

When developing an FSP application in e2 studio, first configur e the FSP using the RA Configurator. To properly configure the FSP, you must have detailed knowledge of both the software design that you will be implementing, along with the specific hardware it will be running on. For the hardware, this includes the types of peripherals to be used on the hardware, and the pins they are map ped to, internal or external to the MCU. From the software perspective, you need to add the HAL modules for the peripherals you use and decide how many threads will be used, and what additional software objects like semaphores, queues, and so on that each thread will require. Once you have this information, you will be ready to successfully configure the FSP for your specific application needs.
In an application using FSP, the FSP configuration is stored in a file named configuration.xml. Double­clicking on this file brings up the RA Configuration tab for the project.
Figure 3. configuration.xml on the Project Plane
When you build a project from scratch, this configuration tab is where you will perform the initial configuration of the FSP. As you can see in Figure 4, the RA Configuration pane contains a Summary screen highlighting the items you may configure, along with a scrolling window that lists all the software components currently selected for this project. Below this scrolling window are tabs that allow you to tailor the FSP to the needs of your specific app lic ation . More details on the use of the FSP configurator can be found in the FSP user’s manual.
For the purposes of this application note, we will highlight a few of the details of the FSP properties such as the r_lpm driver, r_rtc driver, and r_agt driver modules as they are key components operated in the use cases provided in the application.
When you have configured the project appropriately, click the Generate Project Content, the green arrow button above the summary screen, to build all the auto-generated files necessary to implement the components you defined.
R11AN0480EU0101 Rev.1.01 Page 8 of 33 Jan.26.21
Renesas RA2 Series Getting Started with Low Power Applications for RA2L1/RA2E1 Group
Figure 4. Summary of the Operable Long Timer Configuration

3.1 Components Tab

Even though the Components tab is the last tab showing, it is important to visit and verify the configured components are checked against the desired FSP version. Components are automatically selected when the modules are added selected, it is a good process to verify these selections are checked in the Components tab. One of the advantages of the FSP is that it will only compile the components you choose, thereby reducing the size of your overall application. As shown in Figure 5, components are broken down into seven categories.
in the Stack tab specific to the application. As the final step to verify the components
Figure 5. Components Tab Categories
R11AN0480EU0101 Rev.1.01 Page 9 of 33 Jan.26.21
Renesas RA2 Series Getting Started with Low Power Applications for RA2L1/RA2E1
Category
Component
Version
Description
BSP
ra2l1_ek
2.3.0
RA2L1-EK Board Suppor t Pack age Files
ra2e1_ek
2.3.0
RA2E1-EK Board Support Package Files
CMSIS
CoreM
5.7.0
Arm CMSIS Version5 - Core (M)
Common
fsp_common
2.2.0
Board Support Package Common Files
HAL Drivers
r_cgc
2.3.0
Clock Generation Circuit
r_ioport
2.3.0
I/O Port
r_lpm
2.3.0
Low Power Modes
r_icu
2.3.0
External Interrupt
r_gpt
2.3.0
General PWM Timer
r_agt
2.3.0
Asynchronous General-Purpose Timer
r_rtc
2.3.0
Real Time Clock
Group
You may expand any of the categories by clicking the arrow to the left of the category name. The following table highlights the selections used for the LPM applications.
Table 4. Components Used in the LPM Applications
Note: This section is for user reference and for read-only purposes. Don’t select or deselect the generated
options by the FSP configurator.

3.2 Stacks Tab

The Stacks tab is where you can add and configure the threads that the FSP automatically creates for your application. You define a new thread by clicking the button and then entering a unique name for your
new thread. Once you add a new thread, you must define the modules that the thread will use along with any thread objects that will be used by your application thread.
As an example, if you click the Stacks tab and then single click on the HAL/Common thread, you should see something like the screen capture shown in Figure 6. This shows that the application requires multiple drivers, like the r_lpm driver which is the driver for Low Power Modes of Renesas RA MCU. The LPM applications do not use RTOS, so there is only one HAL/Common thread is available in this type of application.
R11AN0480EU0101 Rev.1.01 Page 10 of 33 Jan.26.21
Figure 6. Drivers Usage in LPM Application
Renesas RA2 Series Getting Started with Low Power Applications for RA2L1/RA2E1
Category
Interrupt Source
Application
Description
Request Source
AGT1_AGTI
Clock Changing and
AGT Channel 1 Underflow Interrupt
End Source
AGT1_AGTI
Clock Changing and LPM Transition
AGT Channel 1 Underflow Interrupt
Wake/Cancel
AGT1_AGTI
Operable Long Timer
AGT Channel 1 Underflow Interrupt
PORT_IRQ3
Clock Changing and LPM Transition
External Interrupt 3
RTC_ALM
Clock Changing and
RTC Alarm Interrupt
Group
You can add additional modules to a thread by clicking the button. As an example, Figure 7 shows you how to add an AGT timer. The timer is added by choosing (+) New Stack > Driver > Timers > Timer Driver on r_agt.
If you pick a module that you have not preselected, the appropriate component for the module will be automatically selected by FSP for you. If the configurator tool detects errors due to incorrect settings with the module addition, it presents the module with an error. You may examine the errors by hovering over the module name.
Figure 7. Adding r_agt Driver to HAL/Common Thread

3.3 Module Configuration

Once you have added a module to your project, you need to configure its properties. The properties are dependent on the module(s) that you have added. Use the Properties tab to configure them.

3.3.1 LPM Configuration

The LPM applications add the r_lpm driver module as the main component to configure the Renesas RA MCUs in Low Power Modes, for Sleep, Software Standby, and Snooze. The main settings of Low Power Modes configures the trigger/cancel sources, different modes.
3.3.1.1 Activation and Cancelation Sources
The cancelation source of an LPM will wake up the MCU from the specific LPM. The request of the Snooze mode puts the MCU into Snooze mode from Software Standby mode. These sources are interrupt sources. Refer to the Low Power Modes section in Renesas RA MCU Hardware Manual for more details on what interrupts are available in the LPM.
Table 5 shows the activation and cancelation sources using in the LPM applications.
Table 5. Activation and Cancelation Source Configuration
LPM Transition
Source
R11AN0480EU0101 Rev.1.01 Page 11 of 33 Jan.26.21
LPM Transition
Loading...
+ 23 hidden pages