Using Low-Energy Timers

Description

The Low Energy Timer is a 2 channel 16-bit down count timer, which is available in energy mode EM2 DeepSleep, EM1 Sleep, and EM0 Active. As a result, it can be used for timing and output generation when most of the device is powered down, allowing simple tasks to be performed while the power consumption of the system is kept at an absolute minimum. The timer runs from the LFACLK, which can be clocked by the LFXO, LFRCO, or HFCORECLKLE/2. In this example, the LFXO is used as a clock source with a frequency of 32768 Hz. The LETIMER can be used to output a variety of waveforms with minimal software intervention. It can also be connected to the Real-Time Counter (RTC) using the Peripheral Reflex System (PRS) and can be configured to start counting on compare matches from the RTC. These are the supported waveforms:

LETIMER also support interrupts from the following events:

In this example, the use of the Low Energy Timer is demonstrated by setting up a PWM signal, which drives the LEDs directly without waking up the device from EM2.

Conversely, a soft timer would wake up the device into EM0 active mode each time the timer expires and the output is toggled.

For more information about the Low Energy Timer, see the Application Note AN0026 and in EFR32xG1x Wireless Gecko Reference Manuals.

Setting up

  1. Create a new SoC – Empty project for your preferred device.

  2. Copy em_letimer.c and em_letimer.h file into the project from the SDK folder

    C:\SiliconLabs\SimplicityStudio\vX\developer\sdks\gecko_sdk_suite\vY\platform\emlib\src (and inc)).

  3. Copy the attached app.c file into the project (overwriting the existing one).

    Note that, if you are not using EFR32BG13 and LED output pins are not PF4 and PF5, you may need to configure your timer routing location. For example, for BGM111, the respective pins are PF6 and PF7 and routing location 30.

  4. Build and flash the project to your device.

Usage

Observe the LEDs blinking at roughly 1 Hz, duty-cycle 50 %. Verify that the device goes to sleep with Energy Profiler. The figure below shows the energy consumption on a linear scale. Peaks are sections where LEDs are turned on and lows are sections where LEDs are off. Changing the PWM frequency and duty-cycle is done by adjusting the compare value registers according to commented formulas.

Energy Profiler

Source