Microchip logo
  • All
  • Products
  • Documents
  • Applications Notes


A Real-Time Operating System for PIC16/17
Jerry Farmer
Ever dream of having a Real-Time Kernel for the PIC16CXXX family of microcontrollers? Or ever wonder what Multitasking or Threads are all about? Then this article is for you. We will explore how to implement all of the features of a large Real-Time Multitasking Kernel in much less space, with more control, and with-out the large overhead of existing kernels. By planning ahead, and using the techniques outlined here, you can build your own fast, light, powerful, flexible real-time kernel with just the features needed to get the job done. Included in this article are two large examples: one on the PIC16C54, and the other on the more powerful PIC16C64. A ?Remote Alarm? is implemented on the PIC16C54 as an example of a Non-Preemptive Kernel, with two asynchronous serial input sources capable of running up to 19,200 Baud along with seven sensors needing to be debounced as inputs. One more input line is monitored and causes an internal software recount. For output, this example has an LED that shows eight different internal states of the ?Remote Alarm?, blinking at different rates and different sequences. Last but not least, is an asynchronous serial output capable of running at 38,400 Baud, passing the inputs to the next remote alarm station. Several short and long timers are included to round out the nine cooperating tasks in this example. Please refer to Figure 2 and Appendix B. The second example is implemented on an PIC16C64 featuring an interrupt driven Semi-Preemptive Kernel. This example has the serial input and output routines of the first example moved into Interrupt Service Routines (ISR) for more speed and accuracy. The interrupt capabilities of the PIC16C64 will be explored, and a Real-Time Multitasking Kernel framework will be developed.
Application Notes & Source Code
 Last Updated
  AN585 Source Code - A Real-Time Operating System for PIC16/17
Silicon Products