Go Down

Topic: Arduino + FreeRTOS + C++ = Platform for Teaching Real-Time Software Design (Read 5 times) previous topic - next topic

Chip Overclock

I've run FreeRTOS on a 328P, so it's certainly possible. But having multiple threads, each with its own stack, is a real challenge given the tiny RAM on that target.


Sorry for my very late reply. Life intrudes.

For an platform of modest capabilities like the Arduino Uno that uses the 328P, I think an RTOS is probably overkill, and difficult to boot because of the memory constraints. You spend all your time agonizing over how big the stack for each task needs to be.

On the Arduino Mega that uses the 2560, it's completely doable and reasonably painless. But is it necessary?

There are a lot of applications that, for reasons of functionality or performance, really gain from [1] interrupt driven device drivers, and [2] multithreading as a fundamental mechanism to talk to the device drivers. Not only is it a more useful architecture, but the ability to separate functionality behind a more opaque interface, saves money in the long run (in terms of commercial development). Plus, it's a very useful teaching platform, since this approach is used a lot in the commercial world on 2560-class processors and above.

On the flip side, I'm in the midst of a paying gig in which I'm writing firmware for several products based on a PIC16F1823 microcontroller, which has a scant 2K of program memory (flash) and 96 bytes (that's bytes, not KB) of RAM. I'm writing in C, and I've developed as many as six interrupt driven device drivers on one of the products. But there's no RTOS, nor is there really space to have such a thing. It's just a task loop. So i think it totally depends on the problem you're trying to solve and the resources at your disposal. A colleague is developing for a larger PIC on a related project, and he is in fact using FreeRTOS and multitasking so that he can do slower, non-real-time tasks in the background.

At the higher end of the embedded realm, which in my work typically involves PowerPC and ARM SoCs, it's all over the map, using OSes (not necessarily RT) like CMX, C-Executive, Simple Executive, VxWorks, the late pSOS, and even a stripped down Linux. These range from very simple to extremely complex in terms of API, use model, capability, etc.

I need to do a project that requieres RTOS on Arduino UNO with ATmega328, for what I read and what you say is not possible right? In any case, do you think theirs a way to implement it like DUINOS or something else?


Hi Chip,

Are you still tracking this thread? I'd like to incorporate your ideas into an IDE I'm working on.

The IDE allows arduino users to use predefined declarations for tasks, either in code or as flowchart symbols

I've been looking at FEMTOS too, users can select either Free RTOS or FEMTOS

It needs work but it sounds like you have allready done the parts I was planning on doing next, can you PM me?

Mark G.


Good stuff!  I was brought up in the embedded world back in the 80's and think interrupts vs. polling loops.  I've always been surprised how small an RTOS can be to fit into a microprocessor.  You really don't need much.

I'm working on a project now that involves a few serial devices (XBee being one) and would love to try it out after I get the initial design in place.  Keep up the good work!


This is very interesting.  When I took a grad course in real-time programming we started by coding a simplified version of the project on bare hardware (a 486 if I recall), just to show how hard it is, then we wrote our own real time OS and developed a feature-rich version of the program.  I think it was having a GUI and maintaining the real time hardware control that made the OS a blessing.

I remember struggling over coding the memory manager (which paid off when I interviewed with Microsoft's NT Kernel group and had to design a virtual memory manager on a white board in front of a panel of interviewers).  Without the RTOS you simply wouldn't have a memory manager; it wouldn't be a matter of being more complex to not have the OS.  I can't imagine why you'd even want to try to deal with paging within application code.

For the scope of what you can do with an arduino, I think simply using timer interrupts will let you do anything you could possibly want with real time, but I do understand that's not the point of your post.

Go Up