PIC32MX Port Interrupts question
Posted by reSpawn
on January 17, 2011
I downloaded the FreeRTOS port and I made a simple interrupt driven UART. While looking through the example I noticed that the demo defines an InterruptHandler and an InterruptWrapper. The wrapper is declared as an interrupt like this void __attribute__( (interrupt(ipl2), vector(_UART1_VECTOR))) vU1InterruptWrapper( void ); and is defined in a .S file like this:
The InterruptHandler is a regular function ( void vU1InterruptHandler(void) ). As far as I know, the compiler generates prologue and epilogue for functions with the interrupt attribute (there is an attribute which tells him not to) and I'm worried that what I'm actually getting here, is saving the context twice, and restoring it twice.
RE: PIC32MX Port Interrupts question
Posted by Richard
on January 17, 2011
I'm not quite following your question here.
The wrapper is an assembly function, so not compiled at all and will therefore not have a compiler generated prologue or epilogue sequence. The FreeRTOS provided prologue/epilogue in the portSAVE_CONTEXT() and portRESTORE_CONTEXT() macros switches the stack to an interrupt stack to save RAM (each task does not need to have a stack large enough to handle all the nested interrupts).
The function vU1InterruptHandler is just a standard function. The prologue generated for that will be much smaller than that generated for an interrupt function written in C, and will use the interrupt stack, not the task stack.
Hopefully I will have answered your question but I'm not sure. In any case, if you want to know what is being saved and restored by the compiler just look at the code it generates.
Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd..
See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.