Sunday 15 April 2012

FreeRTOS

This week I have been tried to create an application using FreeRTOS as operating sytem.

FreeRTOS is an operating system for embedded systems that provides a pre-emptive real time scheduler. Using FreeRTOS in an embedded software application allows the application to be structured as a set of autonomous tasks. The scheduler selects which task to execute at any point in time in accordance with events and the state and relative priority of each task.

You can visit the FreeRTOS web where you can find the source code and information about how to use it.

In the downloaded files you will find the FreeRTOS source files and the demo files. To do my testing I have use the AVR_ATMega323_WinAVR files from the demo folder. In my system I have a ATMega64 that is similar to the ARMega323 but it has some differences. In my demo I have called one task with a parameter but I have called twice times, with the parameter equal to zero the task turns a led off every one second and with the parameter equal to one turns the led on. There are a delay of half second beetwen both tasks.

To compile the software I have used AVR Studio. You only have to add the files to the source files and compile. To configure the system you have to follow the next steps:
  1. Set the MCU definition
  2. Set the correct clock frequency in the file FreeRTOSConfig.h
  3. Check the configTOTAL_HEAP_SIZE definition that is the available RAM to be used by FreeRTOS.
  4. Check the file Source/portable/GCC/ATMega323/port.c where there are functions that have to be adapted to each microcontroller.
So, the software needs to do at least the nexts steps.
  1. Create the tasks with xTaskCreate. When you define a task, you define the priority, the needed parameters and the amount of memory for the stack
  2. Call the function vTaskStartScheduler that starts the FreeRTOS. This task start the idle task that is a task done in background by the operating system.
The operating system provides APIs to manage the system as delays, start, stop o resume tasks, semaphores, queue or ticks.

No comments:

Post a Comment