Separate interrupt stack Coldfire MCF52259

perklint wrote on Wednesday, July 17, 2013:


We are using FreeRTOS Version 7.01 with a port very similar to the reference Coldfire 52259 demo.

Due to the problem that interrupts will use the interrupted task’s stack to run, every task in the system needs to have extra stack allocated for this. We have up to 17 task running in ours system, so this extra stack eats a lot of valuable ram.

Is there a port handling interrupts in a separate stack for the Coldfire/68K family architecture?

I read on the forum that the PIC32 port has this and the stack is configured with configISR_STACK_SIZE parameter.

Best regards,

/// Per

rtel wrote on Wednesday, July 17, 2013:

While all the newer ports maintain a separate interrupt stack, unfortunately being one of the older ports, the ColdFire port does not.  Also, with Freescale spending many more dollars on Kinetis marketing over ColdFire marketing, it is unlikely the Coldfire port will get updated to do the same.

That said, I think it would be simple enough to implement the change (?).  You would need to keep an interrupt nesting count.  On interrupt entry (before interrupts are enabled), if the nest count is 0 then switch to a statically allocated system stack after the task context is saved.  On exit, after decremented the count, if it is zero again, switch back to the task stack - which would probably happen anyway.  Of course, it is always easier to say than do - I would have to refamiliarise myself with the Coldfire port to know for sure.  You can re-use the stack that is already allocated by your linker for use by the main() function as the system stack.

The PIC32 does do this, but most is done in assembly so maybe not so easy to follow.  The new A9 port goes a step further and only saves the task context if a context switch is actually needed.


perklint wrote on Friday, July 19, 2013:

Thanks for your answer!

I think I understand how it should be done, hopefully it will not be that difficult to implement.

Best regards,

/// Per