Motivation at the moment is just interest / curiosity and the thought that my current home project would be a good system on which to try such a framework. The project uses a small 14 bit PIC (4K words prog mem, 192 bytes RAM) largely because I have a couple in the spares box and thought I should start using up all these old components before they (and me) reach their sell by date.
From your description, you seem to be mostly interested in very small systems. To this end, the QP-nano framework runs on PIC24/dsPIC, MSP430, and AVR (as well as other CPUs, such as Cortex-M0/M0+). QP-nano used to run on PIC18, but the support has been dropped, because the 8-bit PIC family does not really support any standard-compliant C language implementation.
With 4k words program memory and particularly with 192 precious bytes of RAM, you are going to need a very lean event-driven real time framework in order to have sufficient resources left for even a modest application.
RTOS's are configurable so you can limit the memory footprint, but even so you are pretty unlikely to find an RTOS that can even run in 192 bytes of RAM much less leave you enough RAM for an application.
The ubiquitous FreeRTOS shows PIC as one of the available platforms. What you find though is that there is a port for the PIC18F452 which at a minimum has 8192 words of program memory and 768 bytes of RAM.
The situation is similar with Micrium's uC/OS-II or -III. They offer a free maker's license these days and there is a PIC port available, but is is for the PIC24FJ128GA which has more memory resources than the PIC18F452. Here Micrium notes that they require 6k bytes of ROM minimum and 1k+ bytes of RAM.
QL-nano may be your only option, and I believe you'll have to have to do your own port to your 14-bit PIC device. They mention QL-nano running on an 8051 with 256 bytes of RAM. I have no experience with QL-nano, but if I understand correctly you'll be describing your application to the tools as a set of hierarchical state machines as opposed to the more conventional RTOS model where you define tasks and communication in C or C++.
I fully support what you want to do, but if your objective is to test the waters in a real time event driven development environment, you might consider an inexpensive development board based on a 32-bit ARM processor with a readily available port of an RTOS that looks interesting to you.
For this small of a micro, personally I would just do a command loop with interrupt-driven devices.
I don't know the "frameworks" the other posters have suggested.
It really depends on your goal:
- learn RTOS principles
- use up your little PICs
- learn howto shoehorn an OS into a small PIC
If learning an RTOS, I personally would go with am ATXMEGA ($20 from Amazon) and use the FreeRTOS port. That way you have something working that you can play with.
If you want to use up your PICs, I would go the command loop && interrupt devices. You would still learn a lot
The last is the most difficult. You *would* learn a lot, at the cost of much frustration. The other suggestions by the other posters sound like that is the path with the best chance of success.
However, I never stand in the way of someone doing something that looks insane (as long as they leave others alone). If you go with door #3, you have a high probability of failure, but this is not going to melt down a nuclear reactor. (You might end up bald...) This kind of failure is very useful, and if you succeed - wow!
Thanks everyone for the replies. Interesting that the general drift is in the RTOS direction. Perhaps event driven frameworks are just not generally available or known about for small microcontrollers like the PIC16F73 I'm using up from my old 'spares' box. I don't think anything resembling an RTOS could be squashed into this controller as it has a fixed 8 level hardware return stack and no other access to the stack. Sadly leOS looks too locked into the Arduino and controllers larger than my PIC.
Thanks for the reminder Miro (QL) as this is more the approach I'm interested in rather than a straight RTOS. To quote an old team leader I worked for where we used many RTOS threads "We've lost control of the timing". I've read your "Beyond the RTOS" and have Harel's paper on Statecharts, feels the right way to go. I understand your comment about C compilers for small PICs, 'interesting'.
My interest has always been in small low power systems and what can be done with minimal hardware so I'll continue searching for a 'superloop' alternative.
The way forward? I'll have a look at Adam Dunkels Protothreads because it's stackless (although co-operative rather than preemptive). Might have a look at FreeRTOS as I've used the PIC18F542 before. Other than that it might be just a scheduler issuing events from prioritised queues to registered 'receivers'.
Thanks again for the feedback, all helpful even if my project is a little 'insane'.