Run FreeRTOS on Arduino UNO (ATMega328P)

http://yalneb.blogspot.com/2017/05/run-freertos-on-arduino.html

On one hand we have FreeRTOS, an awesome tiny operating system you can run on almost any microcontroller in order to run concurrent processes. It is also great to learn how more complex operating systems, say Linux, work under the hood. And on the other hand we have Arduino, a small, low-cost and user-friendly microcontroller development board.

So, why not combine both? Let's have a look at it.


Getting Arduino ready



Assuming you have your Arduino at hand, let's get started. First and foremost Configure your PC to program Arduino with Atmel Studio. 

Once you have done that, you could proceed to download FreeRTOS from its website. However, the FreeRTOS project is huge, as it includes examples for many microcontrollers and ARMs, despite that the FreeRTOS source code istelf is relatively compact. Furthermore, you'll find that none of the examples works directly on the ATmega328P, and that you will have to modify some files.

Specifically, you will have to modify how FreeRTOS accesses one of the ATmega328P's timers, as it is needed by the operating system to control how much time to allocate to each task.

But don't worry, you have to do nothing of that. Below is a link from which to download a ported Atmel Studio project for the ATmega328P.


Get FreeRTOS for Arduino UNO (ATmega328P)



The below project was created by [Cipriano], a collegue of mine at work. But truth be said, he told be that he took a great portion of the port from another blog or forum, but he can't remember from where exactly. As soon as we find out, I'll modify this post to add the credits.

Without further babbling, download the FreeRTOS project from this link:

>>> DOWNLOAD <<<


Test FreeRTOS



After downloading and unzipping the above project, you should be able to open it with Atmel Studio. Either from within Atmel Studio (File>>Open>>Project) or directly by double clicking on ArduinoFreeRTOS.atsln (the top-nmost project file contained in the zip).

Try to compile the solution and send it to Arduino as seen here. The result should be a blinking LED. If you want to go the next step, see this post on how to run several task concurrently on FreeRTOS.

If you have any questions or comments, please leave a comment below. I'll try to answer in the briefest possible time.

No comments :

Post a Comment