Using freertos kernel in avr projects

FreeRTOS is known as Real Time Operating System. Probably it would be too dare call it real-time-os, rather a real time scheduler where applications can be split in to independent tasks that share full processor resources by switching them rapidly it looks like all tasks are executed in parallel. This feature is called multitasking.

There are lots of debates on using RTOS on AVR microcontrollers as they are arguable too small for running scheduler. The main limitation is small amount of ram and increased power usage. If you are gonna use lots tasks in application, probably you will run out of ram that is used for saving context when switching between tasks. Consider FreeRTOS only if you use larger scale AVRs like Atmega128 or Atmega256. Surely you can find smaller schedulers that are specially designed for smaller microcontrollers even tiny series. In other hand if you master FreeRTOS it can be used with multiple types of microcontrollers like ARM, Cortex, PIC and multiple compilers including IAR, GCC, Keil, Rowley, Attolic. And main reason to keep eye on it – its free.

Probably it would take lots of time and space to go through RTOS theory. Some great information can be found on FreeRTOS website itself. In this series of posts we are going to focus on practical side of using RTOS on AVR microcontroller. We will go through several steps from single task application to more complex solutions.
Things needed to start with FreeRTOS

To start using FreeRTOS we need to download it from http://www. freertos. org/. While writing this post latest version was FreeRTOSV7.0.1. In downloaded package you’ll find freertos source code files, ports to specific microcontrollers and lots of example programs for various microcontrollers and compilers. We are going to use old good Piconomic Atmega128L development board with external memory expansion board that adds additional 8K of SRAM. You can chose any Atmega128 development board as far as it can

blink LEDs, read buttons and use USART. Programs will work fine on any of them. As programming environment we are going to use AVRStudio5 which is still quite new and capricious. If you want to learn how to start working with AVRStudio5, check out this short tutorial.
Preparing AVRStudio5 project

First of all we create new project in AVRStudio5. For this we simply File->New Project and select AVR GCC C Executable Project. Enter proper location where your project will be stored.

Click OK. Then select Device “Atmega128” from device list:

Click OK and yo are set up with basic project with main program file that contains some initial code. As FreeRTOS package contains lots of files that we don’t need for our project we are going to copy necessary files to our folder. To make it easier to update FreeRTOS files with upcoming releases we are going to maintain folder structure close to original. To do so in out project tree we are going to create Source folder. To do so just click right mouse button on project folder and select Add->New Folder and type in Source. Now import following files to Source folder from downloaded FreeRTOS package Source folder:

Add all files that are in Source directory (including readme. txt). Adding files is simple – just click right mouse button of Source folder and select Add->Existing Item and in file browser select necessary files (multiple select is possible!).

We have added only kernel C files. Now we have to take care of headers. For this we need to create include folder inside Source folder.


1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)



Using freertos kernel in avr projects