Skip to main content

The Asynchronous General Purpose Timer, Providing RA Microcontrollers with Low Power Timing Solutions

Image
Graeme Clark
Graeme Clark
Principal Product Marketing Specialist
Published: February 9, 2023

Over the last few months, previous blogs in this series have looked at some of the more unusual peripherals available on many of the RA microcontrollers and how they can be used to help simplify and automate some basic housekeeping and I/O tasks that are common in microcontroller applications. 

In this blog, we’re going to look at one of my favorite peripherals, especially for low power designs, the Asynchronous General Purpose Timer. This timer has a long history on Renesas MCUs, and multiple channels of the latest versions of this timer can be found on many members of the RA family.

The Asynchronous General Purpose Timer (AGT) is a down counter available in 16- and 32-bit flavors that can be used for pulse output, external pulse width or period measurement, and counting external events. The asynchronous nature of the timer is that it is capable of some basic timing operations without any system clock and can operate in the lowest power operating modes of the device.

Image
Simplified implementation of Asynchronous General Purpose Timer

The AGT can use a variety of different clock sources, the peripheral clock, PCLKB, or PCLKB divided by 2 or 8. We can also select two low power options, the AGTSCLK which is derived from the 32 kHz sub clock oscillator, and the AGTLCLK which is derived from the on-chip 32 kHz LOCO. The choice of AGTSCLK or AGTLCLK also means that you can select from a much wider range of divide ratios, with dividers available from /1 to /128.

The result of this choice of the divider from the low speed clocks means that you can have a very wide timer range and can generate extremely long timeouts, all while consuming the minimum amount of power.

Let’s look in a little more detail at some ways we can use the AGT, concentrating on the low power functions we can create by using the low-speed oscillator options.

In many low power sensor applications, we often have to communicate by radio at regular intervals, while minimizing power consumption. The best way to achieve this is to put the sensor, and hence the microcontroller, to sleep, and to program it to wake up and power up the radio circuit when the next transmission is due. The AGT, especially with the 32-bit count register is an ideal solution to this requirement. You can reload the down counter automatically from a reload register with any 32-bit value. So using this feature we can create timeouts of up to 36.4 hrs with a resolution of 30 µseconds using the direct connection of the sub-clock, all the way to a time out around 194 days with a resolution of 3.9 ms when using the sub-clock input divided by 128.

Image
AGT Long timeout

The AGT supports many other interesting applications. One I’ve found useful in the past is the ability to count external events in low power mode, with the count gated by an external signal.

In this case, we can configure the AGT to count external pulses, and use the AGTEE enable pin to select when the pulses are counted; either the pulses can be counted when the gate signal is high, or when the gate signal is low.

This can be especially useful if you want to monitor a position sensor and count the number of rotations of a shaft. If you have two channels of AGT operating in this mode, one channel can count forward rotation, and the second can count reverse rotation, both counting depending on the polarity of a “direction” signal. To get the total rotation count you just add the value of the two counters. The big advantage of this method is that the AGT timer can operate asynchronously in this case, so without a clock, and therefore consumes very little current, and operates even in the lowest power modes of the RA microcontroller.

I hope this has given you some idea of what the AGT is capable of, it has a variety of operating modes and the ability of the timer to operate from the lowest speed clocks on the microcontroller, along with the larger range of divide ratios available, mean that you can operate with extremely low current operation while counting. 

The AGT is a really interesting peripheral, and hopefully, you can find some interesting ways to use it in your application.

Share this news on