Tag Archives: FreeRTOS

3 design hooks of Atmel MCUs for connected cars


The MPU and MCU worlds are constantly converging and colliding, and the difference between them is not a mere on-off switch — it’s more of a sliding bar. 


In February 2015, BMW reported that it patched the security flaw which could allow hackers to remotely unlock the doors of more than 2 million BMW, Mini and Rolls-Royce vehicles. Earlier, researchers at ADAC, a German motorist association, had demonstrated how they could intercept communications with BMW’s ConnectedDrive telematics service and unlock the doors.

security-needs-for-connected-car-by-atmel

BMW uses SIM card installed in the car to connect to a smartphone app over the Internet. Here, the ADAC researchers created a fake mobile network and tricked nearby cars into taking commands by reverse engineering the BMW’s telematics software.

The BMW hacking episode was a rude awakening for the connected car movement. The fact that prominent features like advanced driver assistance systems (ADAS) are all about safety and security is also a testament is that secure connectivity will be a prime consideration for the Internet of Cars.

Built-in Security

Atmel is confident that it can establish secure connections for the vehicles by merging its security expertise with performance and low-power gains of ARM Cortex-M7 microcontrollers. The San Jose, California-based chip supplier claims to have launched the industry’s first auto-qualified M7-based MCUs with Ethernet AVB and media LB peripherals. In addition, this high-end MCU series for in-vehicle infotainment offers the CAN 2.0 and CAN flexible data rate controller for higher bandwidth requirements.

Nicolas Schieli, Automotive MCU Marketing Director at Atmel, acknowledges that security is something new in the automotive environment that needs to be tackled as cars become more connected. “Anything can connect to the controller area network (CAN) data links.”

Schieli notes that the Cotex-M7 has embedded enhanced security features within its architecture and scalability. On top of that, Atmel is using its years of expertise in Trusted Platform Modules and crypto memories to securely connect cars to the Internet, not to mention the on-chip SHA and AES crypto engines in SAM E70/V70/V71 microcontrollers for encryption of data streams. “These built-in security features accelerate authentication of both firmware and applications.”

Crypto

Schieli notes that the Cotex-M7 has embedded enhanced security features within its architecture and scalability. On top of that, Atmel is using its years of expertise in Trusted Platform Modules and crypto memories to securely connect cars to the Internet, not to mention the on-chip SHA and AES crypto engines in SAM E70/V70/V71 microcontrollers for encryption of data streams. “These built-in security features accelerate authentication of both firmware and applications.”

He explained how the access to the Flash, SRAM, core registers and internal peripherals is blocked to enable security. It’s done either through the SW-DP/JTAG-DP interface or the Fast Flash Programming Interface. The automotive-qualified SAM V70 and V71 microcontrollers support Ethernet AVB and Media LB standards, and they are targeted for in-vehicle infotainment connectivity, audio amplifiers, telematics and head control units companion devices.

Software Support

The second major advantage that Atmel boasts in the connected car environment is software expertise and an ecosystem to support infotainment applications. For instance, a complete automotive Ethernet Audio Video Bridging (AVB) stack is being ported to the SAM V71 microcontrollers.

Software support is a key leverage in highly fragmented markets like automotive electronics. Atmel’s software package encompasses peripheral drivers, open-source middleware and real-time operating system (RTOS) features. The middleware features include USB class drivers, Ethernet stacks, storage file systems and JPEG encoder and decoder.

Next, the company offers support for several RTOS platforms like RTX, embOS, Thread-X, FreeRTOS and NuttX. Atmel also facilitates the software porting of any proprietary or commercial RTOS and middleware. Moreover, the MCU supplier from San Jose features support for specific automotive software such as AUTOSAR and Ethernet AVB stacks.

Atmel supports IDEs such as IAR or ARM MDK and Atmel Studio and it provides a full-featured board that covers all MCU series, including E70, V70 and V71 devices. And, a single board can cover all Atmel microcontrollers. Moreover, the MCU supplier provides Board Support Package for Xplained evaluation kit and easy porting to customer boards through board definition file (board.h).

Beyond that, Atmel is packing more functionality and software features into its M7 microcontrollers. Take SAM V71 devices, for example, which have three software-selectable low-power modes: sleep, wait and backup. In sleep mode, the processor is stopped while all other functions can be kept running. While in wait mode, all clocks and functions are stopped but some peripherals can be configured to wake up the system based on predefined conditions. In backup mode, RTT, RTC and wake-up logic are running. Furthermore, the microcontroller can meet the most stringent key-off requirements while retaining 1Kbyte of SRAM and wake-up on CAN.

Transition from MPU to MCU

Cortex-M7 is pushing the microcontroller performance in the realm of microprocessors. MPUs, which boast memory management unit and can run operating systems like Linux, eventually lead to higher memory costs. “Automakers and systems integrators are increasingly challenged in getting performance point breakthrough because they are running out of Flash capacity,” explained Schieli.

On the other hand, automotive OEMs are trying to squeeze costs in order to bring the connected car riches to non-luxury vehicles, and here M7 microcontrollers can help bring down costs and improve the simplification of car connectivity.

The M7 microcontrollers enable automotive embedded systems without the requirement of a Linux head and can target applications with high performance while running RTOS or bare metal implementation. In other words, M7 opens up avenues for automotive OEMs if they want to make a transition from MPU to MCU for cost benefits.

However, the MPU and MCU worlds are constantly converging and colliding, and the difference between them is not a mere on-off switch. It’s more of a sliding bar. Atmel, having worked on both sides of the fence, can help hardware developers to manage that sliding bar well. “Atmel is using M7 architecture to help bridge the gap between microprocessors and high-end MCUs,” Schieli concludes.


Majeed Ahmad is the author of books Smartphone: Mobile Revolution at the Crossroads of Communications, Computing and Consumer Electronics and The Next Web of 50 Billion Devices: Mobile Internet’s Past, Present and Future.

Video: Building a GPS tracker with Atmel’s SAM D20 MCU



A GPS tracking unit uses the Global Positioning System to determine and record the precise location of a vehicle, device or individual. Key design requirements for a GPS tracker include a small form factor, low power consumption and flexible connectivity options.

Atmel’s versatile SAM D20 ARM Cortex-M0+ based microcontroller (MCU) can be used to power such a device, taking all of the above-mentioned design requirements into account.

Indeed, the SAM D20 MCU – embedded with serial communication modules (SERCOM) and low power consumption – provides the flexibility, connectivity and low power required for GPS tracker applications.

In terms of low power consumption, the SAM D20 boasts <150µA/MHz in active (CoreMark) and <2µA with RTC and full RAM retention. Meanwhile, the peripheral event system and intelligent peripherals with Atmel SleepWalking technology further reduces CPU activity and power sipping.

It should also be noted that the SAM D20 MCU offers design engineers 6 highly flexible serial communication modules (SERCOM), each configurable to operate as USART, I2C and SPI – thereby facilitating easy and flexible connection to external sensors, memories, PCs and wireless modules.

Atmel supports a wide range of dev tools and software, including FreeRTOS, Atmel Studio 6 (free IDE with GCC compiler), Atmel Software Framework (free SW libraries of production ready source code), Atmel Gallery (open to extensions) and the SAM D20 Xplained Pro Kit which is packaged with programmer and debugger, as well as connectors for expansion wings.

Interested in learning more? You can check out Atmel’s SAM D20 GPS tracker reference design here.

FreeRTOS with Atmel’s SAM D20 Xplained Pro

Atmel’s SAM D20 lineup is based on the ARM Cortex- M0+ core, setting a new benchmark for flexibility and ease-of-use. The microcontroller (MCU) series is ideal for a number of low-power, cost-sensitive industrial and consumer devices, such as GPS trackers, appliance controllers, intelligent remotes and optical transceivers.

As William Wong of Electronic Design notes, the SAM D20 specifically targets the entire low-end space currently handled by 8- and 16-bit microcontrollers, while also hitting the low-end 32-bit space.

“The SAM D20 incorporates high-end support like the high-speed bus matrix linked to three AHB/APB bridges. System and power controllers can be found off one bridge. Memory controllers are found off another,” Wong wrote in an article posted on Electronic Design earlier this year. “The third bridge handles the convention interfaces that include up to six programmable serial ports, eight timers, a 20-channel, 350-ksample/s analog-to-digital converter (ADC), a pair of comparators, and a 10-bit, 350-ksample/s digital-to-analog converter (DAC). There is also Atmel’s touch interface controller.”

Recently, a detailed SAM D20 demo project went live on FreeRTOS.org (FreeRTOS, FreeRTOS+CLI).  The demo – which targets Atmel’s SAM D20 Xplained Pro evaluation board – leverages the FreeRTOS ARM Cortex-M0 GCC port and builds with the free Atmel Studio IDE (using the Visual Studio framework and kernel aware FreeRTOS plug-in).

Meanwhile, the command line interface character input and output employs drivers provided Atmel’s Software Framework (ASF), with a #define tasked with switching the build between a simple blinky style application and a comprehensive test/demo application that incorporates the FreeRTOS+CLI component.

Want to build and run the ARM Cortex-M0+ RTOS Application? It should probably be noted that the FreeRTOS download contains the source code for all FreeRTOS ports, so obviously there is a surplus of unneeded files for this specific SAMD20 demo. As such, it might be a good idea to check out the the Source Code Organization section for a description of the directory structure. The Atmel Studio solution file is called RTOSDemo.atsln, which is located in the FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained directory.

Building and running the ARM Cortex-M0+ RTOS application

  1. Open FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo.atsln in the Atmel Studio IDE.
  2. Locate the mainCREATE_SIMPLE_BLINKY_DEMO_ONLY definition at the top of main.c.
  3. Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to 1 to create the simple blinky demo, or 0 to create the comprehensive demo that also includes the command line interpreter.
  4. Select “Rebuild RTOSDemo” from the Atmel Studio “Build” menu (or press F7) to build the demo project.
  5. Connect a USB cable between the USB port on the SAMD20 Xplained Pro board and the host computer.
  6. Select “Start Debugging and Break” from the Atmel Studio “Debug” menu to program the microcontroller flash memory and kick off a debug session.

Interested in learning more about running FreeRTOS on Atmel’s SAM D20 Xplained Pro? Be sure to check out the official FreeRTOS demo 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.