FreeRTOS Jump Start

 Date: April 17, 2014

In this semester I am taking Real-Time Systems course. In one of the programming assignments, we had to develop program for embedded device Tiva C Series LaunchPad TM4C123G. It is a low-cost evaluation platform for ARM Cortex-based microcontrollers from Texas Instruments. It is very nice board if you want to start with embedded devices. It cost only $25 on eBay. You can connect it to your computer using USB. Finally, the board has key feature of embedded device for beginners: the LED.

Tiva LaunchPad

A typical process-control system can be divided into four types of components: the process, sensors, actuators, and controller (see Figure below). LED allows you to mock your target actuator. Majority of operations performed by embedded devices is control of the actuators. What is nice about LED: it is cheap and easy to control whether and how it is working.

safety critical loop

Code Composer Studio

As a development environment for Tiva C Series I recommend you Code Composer Studio. It is Eclipse based IDE, which makes development easy. Especially for beginners. Tutorial for installation and running first program on Tiva TM4C123G board using Code Composer Studio can be found here. I recommend to follow the "Single Download" option (download 1GB+ file). More precisely, download and install: "EK-TM4C123GXL-CCS: TivaWare for C Series and Code Composer Studio for the Tiva C Series TM4C123G LaunchPad" available on this website. I wasted a lot of time trying to install it following "Individual Downloads" instructions (download <1MB file). Installer was hanging, when it was downloading files form the Internet and never recovers. In "Single Download" most of files are already downloaded along with the installer.

FreeRTOS

FreeRTOS is one of the most popular Real Time Operating Systems (RTOS). Additionally, it is free. This is where its name comes from (free + Real Time Operating System = FreeRTOS). The System is written in C language. Thus, we write programs for it in C as well. More details can be found on freertos.org and wikipedia.

The cool thing about FreeRTOS is that it enables easy modifications of Operating System. You can modify e.g. scheduler.

Once you have Code Composer installed. You need to install TivaWare software (which includes FreeRTOS). It can be found in previously downloaded package (if you were following "Single download" option) in TivaWare/SW-EK-TM4C123GXL-1.1.exe.

Running example programs

The TivaWare software contains examples, which are ready to run. You can find them in the directory, where you installed TivaWare C Series software. In my case (default path) it is: C:\ti\TivaWare_C_Series-1.1\examples.

There is an example project freertos_demo. It makes the LED blinking and allows you to manipulate the colors using buttons (located at the bottom of the board). The project can be found in examples\boards\ek-tm4c123gxl\freertos_demo. It is ready to run. You just need to connect the board to the PC, open the project (import it) in Code Composer Studio and run it in debug mode. Code Composer Studio will automatically port the program into the board.

You can modify the code, and make the LED blinking faster or slower. Colors manipulation is also easy.

Queues and semaphores

FreeRTOS supports multitasking. In the Real-Time systems, communication between different tasks are usually implemented using queues and semaphores. It is also the case in freertos_demo program. Buttons send messages to the LED using queues. Semaphores are use to guard concurrent access to UART.

This tutorial is very good point to start with FreeRTOS. It describes basics, queues, semaphores and more.

Summary

Developing code for embedded devices is usually, more complex than for Web or Desktop. Running, even very simple application is more complex, because it requires more steps. You need to configure connection between your computer/OS and specific device. Then you need to setup many settings, which varies almost among every device. The communication with ports is also different and every device has different set of them.

There are no universal installers etc. Every single device require slightly different setup. Sometimes, you need to spend hours to run simple "Hello, World!" application. On the other hand, it is fun to create some system, which do stuff outside of your PC.

If you are interested in embedded devices, check out my other post: BeagleBoard - your personal computer smaller than your wallet.

To get started with FreeRTOS and Tiva C Series: check this tutorial to run first program and FreeRTOS Tutorial to get more details. You can buy Tiva C Series LaunchPad on eBay.

 Tags:  hadrware programming

Previous
⏪ SPARK Ada programming language

Next
Moving WordPress blog to Azure from Webio hosting ⏩