- on Microcontrollers
- Published in issue 11/2004 on page 0
PICXEX18 and PICWin8
Operating System and Monitor for PIC Microcontrollers
This article describes the development of a multi-tasking operating system for the PIC18xxx micro controller from Microchip. The code and RAM memory requirements are minimal and the basic idea straightforward, but it can simplify the implementation of an application on this micro controller considerably.Applications are easier to specify, design, code and debug if you start off by separating it into functional elements, or call it tasks. A software structure to handle the tasks could then look like Figure 1.Here our ‘operating system’ is nothing more than a couple of CALL instructions with a GOTO MAIN instruction at the end. The CALL instruction activates the task, and the task must cooperate by executing a RETURN instruction to pass control back to the operating system.The above could do for some small applications, but usually the functions/tasks making up our application require some form of control over their own execution and that of other tasks. For example a key-scanner task could continuously monitor a few push buttons. When one is operated the task associated with that button needs to be activated by the key-scanner task. Or a sequence (task) could be executing one of its (many) steps and then proceed to the next step (code section) once a particular condition is met.