I am trying to understand how real time operating systems work. I have looked at the source codes of some RTOSes. I want to learn by creating my simple RTOS, something like FLIRT.
I am using PIC16 series and XC8 C compiler with MPLABX. I also want to implement this very simple RTOS to PIC12 series.
So, I decided that I should start by learning how to manipulate stack (like supercat did in this answer) and I started searching and came across AN818 which is titled "Manipulating the Stack of the PIC18 Microcontroller". Cited from the application note:
Traditionally, the microcontroller stack has only been used as a storage space for return addresses of subroutines or interrupt routines, where all ‘push’ and ‘pop’ operations were hidden.
For the most part, users had no direct access to the information on the stack. The PIC18 microcontroller diverges from this tradition slightly. With the new PIC18 core, users now have access to the stack and can modify the stack pointer and stack data directly.
I am confused. How come there are RTOSes made for PIC microcontrollers that work with PIC16 cores? For example, OSA RTOS is available for PIC12/16 with mikroC compiler.
Can you direct me to some resources, or if possible give examples, so that I can learn about stack switching?
JumpC4 & 255to W does? – abdullah kahraman Jun 09 '12 at 20:38movlw/gotoversusretlw, the latter saves a word of code space per task-switch, but ends up being a cycle slower because of the need tocalla "springboard". More significantly, when usingmovlw/goto, it's possible for one task to perform task switches from within nested routines; if one were to limit the use ofretlwto tasks which didn't need to switch from within nested routines, that would be fine, but mixing task-switching paradigms could add confusion. – supercat Jun 10 '12 at 16:15