Published:2011/8/12 1:20:00 Author:Phyllis From:SeekIC
By Lourens le Grange
This article describes the development of a multi-tasking operating system for the PIC1 8xxx microcontroller from Microchip. The code and RAM memory requirements are minimal and the basic idea straight forward, but it can simplify the implementation of an application on this microcontroller 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.
It is clear that we will require more than RETURN instructions for the scanner and sequence tasks above to cooperate in a system. The key-scanner task needs to activate one of a few dormant (switched OFF) tasks, while the sequence task must have the ability to modify its own entry point so that only a particular section of its code (i.e. the active step and its criteria) is executed at a time. A task’s entry point is the memory location at which the task’s code will start executing when the operating system passes control to that task.
PICXEX18 functionality
In PICXEXl 8 the following functions are provided in the form of macros that the programmer uses in his task code.
XexTaskON TaskNr
With this macro the user can activate any task in the application. It can also be used in code outside a task, for instance an interrupt service routine can start a task.
XexTaskOFF TaskNr
With this macro the user can deactivate any task in the application. It can also be used in any code.
XexTaskExit
A macro used in a task to pass control back to the operating system.
XexSetEPoint TaskNr, EPoint
Modify a task’s entry point. It can also be used in any code.
XexEPNexr TaskNr
Set a task’s entry point to the next instruction. Only to be used in the code of the task of which the entry point is to be modified.
Reprinted Url Of This Article: http://www.seekic.com/blog/project_solutions/2011/08/12/PICXEX18_AND_PlCWIN8__Operating_System_and_Monitor_for_PIC_Microcontrollers__(1).html
Print this Page | Comments | Reading(527)
Author:Ecco Reading(30202)
Author:Ecco Reading(3462)
Author:Ecco Reading(3182)
Author:Ecco Reading(3662)
Author:Ecco Reading(5233)
Author:Ecco Reading(3249)
Author:Ecco Reading(3390)
Author:Ecco Reading(3531)
Author:Ecco Reading(3936)
Author:Ecco Reading(3708)
Author:Ecco Reading(3678)
Author:Ecco Reading(3715)
Author:Ecco Reading(6029)
Author:Ecco Reading(3693)
Author:Ecco Reading(4479)