INTRODUCTION
This application note describes the RTC and the Backup RTC(BURTC). The software examples includes how to use the RTC and the BURTC to wake up from energy mode 2 (EM2).
1 Real Time Counters
1.1 General
Many microcontroller applications have long time intervals in which almost no activity is required. In order to save energy, these intervals should be spent in an appropriate sleep mode. The EFM32 features several such modes, including energy mode 2 (EM2). In this mode the core and high-speed peripherals are shut down, whereas low-energy peripherals such as LCD, LEUART and RTC may be enabled. These peripherals run on a low-frequency oscillator, hence their current consumption is very low. To keep track of time and to wake up while in sleep mode can be achieved by using the RTC.
1.2 Comparison
The EFM32 has two different real time counters, the RTC and the Backup RTC(BURTC). The BURTC uses less power than the RTC and also works in the backup power domain. The backup power domain allows the EMF32 to be powered by a reserve power supply if a main power brownout should occur, in this mode it still have access to the BURTC and 512 bytes of retention memory. For more information see application note AN0041 Backup Power Domain. The BURTC and the backup power domain is only available in the Giant, Leopard and Wonder Gecko families.
Both the RTC and the BURTC can be clocked from a 32.768kHz crystal oscillator, a 32.768kHz RC oscillator or the 2kHz Ultra Low Frequency RC Oscillator which is the most energy effective clock in the EFM32. The real time counters both have a maximum wrap time of 194 days, where the RTC has a resolution of 1s, the BURTC has a resolution of 3.9ms. See Table 1.1 (p. 2) for a comparison between the two real time counters.
Table 1.1. Real Time Counter Comparison
Counter Width | Maximum Wrap Time | Compare Channels | Available down to Energy Mode | Clock Sources | |
RTC | 24-bit | 194 days @ 1s ticks | 2 | EM2 | LFRCO, LFXO, ULFRCO |
BURTC | 32-bit | 194 days @ 3.9ms ticks | 1 | EM4 | LFRCO, LFXO, ULFRCO |
2 RTC
2.1 General
The RTC increments a counter on each positive edge of its clock. When the value of the counter is equal to either of its compare registers, an interrupt is triggered (if enabled). This interrupt can wake up the EFM32 from EM2, and code execution is resumed. The RTC can also issue an interrupt on overflow.
It is possible to set up a compare register (RTC_COMP0) to be the top value. In this mode, the RTC will restart the counter when reaching the value of the compare register.
2.2 Software Example
In the following two examples the 32.768 kHz Low Frequency RC Oscillator (LFRCO) is used as source for the RTC.
In the RTC software example the EFM32 repeatedly enter energy mode 2 and sleeps for 500ms using the RTC. The RTC is configured to interrupt and to automatically reset the counter on compare match on channel 0.
In the RTC driver software example the RTC Driver found in the Board Support Package is used to replicate the behaviour from the first example. The RTC API gives access to three functions. One to configure the RTC, one to set a variable delay in ms and a trigger function that will invoke a callback function after a given time has expired.
3 Backup RTC
3.1 General
The Backup Real Time Counter(BURTC) is available in the Giant, Leopard and Wonder Gecko families. It allows for timekeeping in all energy modes and can run in EM4 with a total current consumption of less than 0.5 µA. The BURTC contains a 32-bit counter and is clocked either by a 32.768 kHz crystal oscillator, a 32.768 kHz RC oscillator or a 2kHz Ultra Low Frequency RC Oscillator.
3.2 Software Example
The software example shows how to set up the BURTC to wake up the MCU from EM2 every 500ms using interrupt on match on channel 0.
3.3 More info
For a software example on how to use the BURTC in EM4, see application note AN0007 Energy Modes. It shows how to repeatedly enter EM4 and sleep for 5 seconds and how to use the BURTC retention register to keep track of the number of times the MCU has woken up from a BURTC interrupt.
For more details on using the BURTC in the backup power domain, see application note AN0041 Backup Power Domain. It demonstrates how to use the BURTC while running on backup power. Also see the BURTC example found in the EFM32GG_STK3700 kit example for more software demonstrations.
No comments:
Post a Comment