SputnickOnline.com Home | Files | Titans
Main / Projects / Programs / micro / uC/OS-II for PIC18

Work Wanted


Microchip LogoA real-time, preemptive kernel is software that manages the time of a microprocessor or microcontroller to ensure that all time critical events are processed as efficiently as possible. This software allows a real-time kernel, µC/OS-II to work with the Microchip PIC18 series of microcontrollers.  These processors are much like the previous PIC processors, but have enhanced C code compatibility.

To get started you must obtain µC/OS-II in source code form.  The author, Jean J. Labrosse includes the complete kernel with the book MicroC OS II: The Real Time Kernel available from Amazon for about $55. µC/OS-II is also known by the following names, UCOS, uC/OS, UCOS-II, and MicroC/OS-II.

The other real-time kernel that works with PICs is called Salvo.  They have a free version that is limited to 3 tasks and 5 events.  The full version and the full version with source code cost $750 and $1,250 respectively.  The major difference is that Salvo supports non-preemptive scheduling, also called cooperative multitasking.  µC/OS-II on the other hand is preemptive and should be used when system responsiveness is important as task switches can occur in a deterministic amount of time.

The MPLAB-C18 Port

I am providing this free of charge and hope that you will be able to keep me updated with any bug fixes that you apply.  For more details see my page on how it works.  µC/OS-II its-self however is not free; you must purchase the book directly from the products website or along with the book.  You also need to purchase or use the demo of MPLAB-C18 from Microchip; another compiler may work with modifications.

I have tested this software both in the MPLAB simulator and on the PICDEM 2 Plus board with an 18F452 microcontroller. As an added bonus, my port includes an enhanced version of the XLCD library so you can use the LCD on the PICDEM 2 Plus board through that library. See the test project for an example.

It is important to note that it only works with the following compiler options:

  • Integer promotion disabled
  • Default storage class of Auto
  • Large code model
  • Large data model
  • Multi-bank stack model
  • All Optimizations disabled

The libraries that come with MPLAB-C18 must be re-compiled with the multi-bank stack model enabled.  Included in the port are modified *.bat files with that compiler flag set.

Get the most recent version of the µC/OS-II port for Microchip MPLAB-C18!

I am currently working on a new version that will work with more standard options including single-bank stack, the normal library and with the ability to use optimizations. I also hope to take care of the MATH_DATA and .tmpdata section problems (results from floating point operations or even integer division). Encouragement would always help.


This port of µC/OS-II works with the following Microchip processors:

  • PIC18Cxxx
  • PIC18Fxx20
  • PIC18Fxx2
  • PIC18Fxx8
  • PIC18Fxx39
Copyright © 2005 Nathan Brown