Featured post

Arduino FreeRTOS Mutex Examples

In this section, we will explain using an example to demonstrate mutexes in Arduino using freeRTOSThere are two freeRTOS Mutex examples in this tutorial, the first example demands some hardware (LCD) While the second does not need any hardware, you can try out both if you have the resources.

In the last tutorial, we considered in detail: semaphores and mutexes and we also established the difference between binary semaphores and mutexes.
Just for a review:Recall that a mutex is a locking mechanism that implements the take and gives functionality in itself, unlike a binary semaphore. See this tutorial if you have not before continuing.
Example 1: Protecting the LCD Resource Using Mutex in freeRTOS
Program Description

In this program, we Demonstrated the use a 16x2 LCD display to implement a mutex.

The LiquidCrystal library works with all LCD displays that are compatible with the Hitachi HD44780 driver. you can usually tell them by their 16-pin interface.


* LCD RS pin to digital…

Arduino FreeRTOS Tutorial: Getting Started

For the next week, we will be starting a FreeRTOS series, we have already completed a basic introduction to RTOS. In this tutorial series, we will be implementing an RTOS (Real-Time Operating Systems) using FreeRTOS.

To better appreciate this tutorial, we will be taking a project that will encompass all we need to understand in FreeRTOS, I will propose a simple project to help us digest the concept of RTOS using FreeRTOS.

This tutorial series will cover the following contents:

  • Basic Introduction to FreeRTOS

  • FreeRTOS Installation

  • Task Creation, States, Scheduling and Deleting

  • Semaphores and Mutexes


FreeRTOS is to RTOS what windows OS is to OS. FreeRTOS provides the implementation of an RTOS for embedded application, however, freeRTOS is not a full OS, it is more accurately called freeRTOS Kernel because its functions is limited to kernel services of core real time scheduling functionality, inter-task communication, timing and synchronization only.

Why should you use FreeRTOS?

FreeRTOS has the following benefits accrued to it.

  • FreeRTOS is a professionally developed real-time kernel,

  • It is free to use and you do not need to obtain intellectual property permit to use the software, moreover, you retain ownership of your application.

  • It can be used in a commercial project without any requirements

  • It is released under the MIT licence

  • It is open soure

  • If you need written guarantees, or service level agreements, backup or indemnification, you can always upgrade to do that anytime.

  • It can be ported to over 32 different architectures

See http://www.FreeRTOS.org/license for the latest open source license information.

I can just develop my Applications, why do I need a real-time kernel?

First, what is a real-time kernel?

A real-time kernel is the central part of a real-time operating system for embedded systems that manages the operations of the computer and the hardware especially the memory and CPU time, In an embedded system, it handles the task management, scheduling, and memory allocation.

For simple projects, you could always write your programs and get it to work just as you want without the use of a real-time kernel, however, the concept of a real-time kernel is most obvious in complex embedded applications where there is a need to monitor system performance, ensure that deadlines are met and processes optimized.

Take for instance, you are writing a program for an Arduino based control system, and in the implementation of a task, there is need to go beyond the normal procedural programming and check an interrupt or periodically check if the user has made any input, using the normal programming, this can be done easily if your program is small, however, in the presence of multiple tasks that take time to complete you may experience delays which may not be tolerable to the project, which brings about the concept of task scheduling and prioritization, and these can only be implemented using a Real-Time kernel.

Thus, using a Real-time kernel will provide you with the following benefits:

  • Hiding away the timing ambiguities. This ensures that your codes are reusable and not tied to a particular architecture, modifying the code does not need altering the underlying hardware.

  • Encouraging teamwork and collaboration since tasks are independent entities.

  • Application modularization since tasks are independent of each other

  • Loose coupling through a structured programming style thus encouraging reusability

  • Easy to Debug and unit testing procedures can be implemented

  • Flexible interrupt handling that can be modified by the user.

  • Power management etc

Getting Started: Installation

FreeRTOS does not need any special installation, for the tutorial series, we chose an Arduino because it is readily available and affordable, we would use it to properly understand how to make a Real Time Embedded System using FreeRTOS.

  • Download the FreeRTOS Library

  • Unzip the file

  • Copy the folder into the examples folder of Arduino

  • Run your Arduino IDE, locate examples, you will find the freeRTOS


Popular posts from this blog

Arduino FreeRTOS Tutorial 05: Binary Semaphores and Mutexes

Arduino FreeRTOS Beginner Tutorial: Task Creation, Scheduling, Deleting

Digital Systems and Stability Analysis using Jury's Stability Test