PIC18 ISR Stack and HW stack

paulholland wrote on Friday, July 27, 2012:

The PIC18 does have a HW stack of 31 but can also be changed into a SW stack and this is what FreeRTOS is doing I can see from the code. But my question is what does FreeRTOS do if an interrupt happens does it save all variables of the interrupt on a special SW stack or simply on the interrupted task SW stack or maybe uses the HW stack ?.

Who knows ??..

paul.

rtel wrote on Friday, July 27, 2012:

There are several reasons why the PIC18 architecture, as per that used to generate the PIC18 port, is less than ideal to run a preemptive RTOS.  The hardware stack is one, the banking another, and the compiler using RAM for temporaries yet another, still….

When an interrupt occurs the low interrupt runs, which calls a peripheral specific interrupt handler.  So far, that is all done by the compiler generated code.  If the peripheral interrupt then decides a context switch is required, the stacks are saved onto the task stack (including the memory area used by the compiler).

Regards.

paulholland wrote on Friday, July 27, 2012:

I know PIC18 is not ideal but the HW stack is not used but a SW stack is implemented by FreeRTOS solving this problem. My question was if the compiler memory area uded by the compiler is stored on a special stack like with PIC32 or on the task stack and why this is different !. It would be better to use the HW stack memory for this since its waisted now.

rtel wrote on Friday, July 27, 2012:

The PIC32 benefits greatly by implementing (in software) a separate system stack.  This is for a few reasons:  It has a lot of registers, the compilers ABI is very RAM hungry, and the PIC32 port has a full interrupt nesting model meaning the interrupt stack can get very deep.  The PIC18 on the other hand is a massively more simple device, and does not support interrupt nesting - the stack never holds more than one interrupt stack frame and that is insignificant in size compared to the stack required to hold the context during a context switch.

Regards.