rtel wrote on Wednesday, July 14, 2010:
Is there any specification available how the xISRStack is working and what it is used for?
Three things make it advantageous under most circumstances to use a separate interrupt (or ‘system’) stack on the M4K core:
1) The M4K has a large context, that has to be saved on a task by task basis.
2) The M4K does not automatically maintain more than one stack, so each task would have to otherwise maintain a stack that was large enough to hold the entire task and interrupt context. In other words, the interrupt context size would have to be multiplied by the number of tasks you have when working out the RAM usage.
3) The MIPS ABI is not exactly designed to minimise stack usage. That is, when it generates a function call stack frame quite a lot of RAM is required.
Therefore the FreeRTOS port maintains a stack for each task onto which its own context (and no other) is saved, and xISRStack that is switched to each time an interrupt (with nesting count of zero) is accepted. xISRStack is used by the portSAVE_CONTEXT and portRESTORE_CONTEXT macros automatically and dramatically reduces the amount of RAM an application requires to execute were it not used, at the cost of a little extra code required to enter an interrupt.
Is there a way of using a watermark to see the isrStack´s behaivior or if the stack overflowed ?
You could easily extend the code to fill the ISR stack with a known pattern, then check this from anywhere you like to ensure the end of the stack has not been overwritten. For example, from within portSAVE_CONTEXT(), the tick interrupt hook, the traceTASK_SWITCHED_IN() macro, etc, although portSAVE_CONTEXT() would be best as this will be called on each context saving interrupt which is where the overflow would actually occur. Alternatively you could check that there is sufficient space to save the context prior to the context actually being saved, but again this would not catch all overflows, checking for a pattern being overwritten at least demonstrates a historical overflow too.
Is the Compilers usual Prologe/Epiloge left unaffectted by using freeRros ?
Not when using the portSAVE_CONTEXT() and portRESTORE_CONTEXT() macros. Read the “Interrupt Service Routines” section of the port documentation page: http://www.freertos.org/port_PIC32_MIPS_MK4.html