Tag Archives: Real-time operating system

Designing a gateway with Atmel’s SAMA5D35 eMPU

A gateway can best be described as a device that enables communication between various classes of networks using multiple communication protocols and technologies. A concentrator performs an identical function as a gateway, although it is also capable of acting as an aggregation point for data in smart energy networks.

Key design considerations when building a gateway or concentrator include connectivity (both wired and wireless) to communicate between the different protocols and networks concurrently, as well as integration, high performance and security.


Both concentrator and gateway can be designed using a number of Atmel components, including the SAMA5D35 Cortex-A5 (ARM) eMPU, AT86RF212 900MHz RF transceiver, AT86RF231/233 2.4GHz RF transceivers, ATPL220A Prime PLC controller, ATPL100A FSK PLC controller, ATSHA204 authentication IC and AT30TS temperature sensor.

“Atmel’s SAMA5D35-powered platform offers a highly integrated device with optimized performance and extensive connectivity peripherals to simplify product design and BOM. Connectivity is ensured via a number of integrated comm peripherals including SDIO, CAN, 10/100 Ethernet MAC Controller and a 10/100/1000 Gigabyte Ethernet MAC Controller with IEEE1588 support,” an Atmel engineer told Bits and Pieces.

“There is also an integrated External Bus Interface (EBI) for DDR2 support, a MLC/SLC NAND Controller (including ECC) for NAND Flash, a low-power Real Time Clock (RTC) that can be battery operated during outages and a Floating Point Unit (FPU) for energy calculations and data statistics. Last, but certainly not least, the above-mentioned Atmel platform – which is equipped with 160-Bits of OTP Fuses for secret storage and secure boot – supports a number hardware security functions, including TRNG, AES-256, TDES and SHA256.”

As expected, Atmel also provides Linux support for the ATSAMA5D35 eMPU, along with a full range of development tools, such as RTOS, middleware and support services, as well as free software packages like TCP/IP stacks and Wi-Fi drivers. Meanwhile, an Evaluation Kit facilitates code development of applications running on a ATSAMA5D35-based device.

Additional information about Atmel’s ATSAMA5D35 Cortex-A5 eMPU can be found here.

Atmel’s SAM4L ARM Cortex-M4 MCU saves power with FreeRTOS tick suppression

FreeRTOS can best be described as a popular real-time operating system for embedded devices, including Atmel’s SAM4L ARM Cortex-M4 MCU (microcontroller). The real-time operating system is succinct, as it consists of three or four C files, and is written primarily in the same language.

So why use an RTOS? Well, a real-time operating system for embedded devices offers a wide variety of benefits, including an optimized design with cleaner interfaces, the ability to reuse code and the opportunity to benefit from low-power operation.

Applications coded to take advantage of an RTOS are designated as a set of of autonomous, communicating threads of execution. Specifically, in FreeRTOS each thread of execution is known as a task, with each typically spending varying degrees of time waiting for an event.

As Richard Barry of FreeRTOS explains, a task may have to wait for an interrupt, a time period to expire, or a message from another task.

“In FreeRTOS a task that is waiting for something to happen is said to be in the blocked state. An RTOS scheduler will not run a task that is in the blocked state. When all the tasks that were created by the application are in the blocked state the RTOS scheduler will run a task called the idle task, which is created by the RTOS itself,” Barry wrote in a recent blog post published on EE Times Embedded.

“An RTOS therefore provides a very convenient and automatic way of knowing when the application is idle, and therefore when the microcontroller on which the application is running can be placed into a low-power state.”

Indeed, FreeRTOS allows an app writer to add their own into the idle task via the definition of an idle task callback or hook function. It is therefore quite common to reduce the power consumed by the microcontroller on which FreeRTOS is running by exploiting the idle task callback to switch the microcontroller into a low power state.

However, the resulting power saving achieved by the above-mentioned method is limited if the RTOS requires a periodic exit of the low power state to process tick interrupts (periodic interrupts used by an RTOS to track time). Meaning, any energy savings will be outweighed if the frequency of the tick interrupt is excessive – for all but the lightest power saving modes.

Enter the FreeRTOS tickless idle mode, which halts (or suppresses) the periodic tick interrupt when the idle task is executing, subsequently making a correcting adjustment to the time maintained by the RTOS when the tick interrupt is restarted. This allows the microcontroller to remain in a deep power saving state until an interrupt occurs or the RTOS kernel transitions a task out of the blocked state.

“There is a run-time overhead associated with suppressing the tick interrupt: the peripheral used to generate the periodic tick must be reprogrammed before entering the low-power state, and again when exiting the low power state,” said Barry.

“For this reason, and to ensure correct processor time sharing between tasks of equal priority, the tick interrupt is not suppressed unless all the application tasks are in the blocked state.”

The tick suppression feature supported by FreeRTOS can perhaps be best illustrated by Atmel’s SAM4L ARM Cortex-M4 microcontroller, which is specifically designed for low power applications.

As you can see in the image below, the SAM4L evaluation kit (SAM4L-EK) includes a board monitor that displays the amount of current consumed by the microcontroller as it executes applications.

This particular image is a photograph of the board monitor display captured when the microcontroller was executing a simple FreeRTOS demo with the optional tick suppression feature enabled – clearly spending the majority of its time in the special retention low power mode of the SAM4L.

“The current readings taken when in retention mode resulted in the flat horizontal line visible along the bottom of the graph in the photograph. Every 500 and 500 + 20 milliseconds an application task briefly left the blocked state to perform a trivial piece of processing,” Barry noted.

“The current readings taken when an application task was executing resulted in the two small dots that appear four times on the graph above (the measurement resolution and screen resolution make the dots appear almost as one elongated dot). As four execution instances are visible on the graph it can be seen that the graph in the photograph covers a two second period.”

Additional information about Atmel’s SAM4L can be found here, while key data pertaining to FreeRTOS and its tick suppression feature is available here.