jasonfromca wrote on Sunday, February 23, 2014:
Thanks for your input on this …
FreeRTOS discusses this GCC naked attribute here:
http://www.freertos.org/implementation/a00013.html
Issue #1:
However, under the XC32 V1.31 and when using the naked attribute with an ISR, you get the following compiler error message:
** error: interrupt handler functions cannot also be naked functions **
Of course, that’s where I’d want the naked attribute to be used: in the ISR since we are utilizing a different FreeRTOS ISR stack.
However, it can possibly be done this way:
__attribute__(( naked )) void MyISR()
{
//NOTE: No way to call portSAVE_CONTEXT() or portRESTORE_CONTEXT()
//under the Pic32MX port from XC32. If I could, then it would look
//like the following:
portSAVE_CONTEXT();
//do some work here
//clear interrupt flag here
portRESTORE_CONTEXT();
}
void __attribute__((interrupt(ipl1), vector(_EXTERNAL_1_VECTOR))) TrueISRHandler(void)
{
MyISR();
}
However, I’m not sure how portRESTORE_CONTEXT() will behave since ‘TrueISRHandler’ is NOT naked.
But, I’m also faced with the other issue (assuming the above may possibly work):
Issue #2:
portSAVE_CONTEXT() and portRESTORE_CONTEXT() are both written as assembly macro’s under the Pic32MX port. Assuming the naked attribute did work, I don’t know of a way to call from C an assembly macro. From C, I can call an assembly function. However, I don’t know how to call an assembly macro under the XC32 compiler.
Any input on this second related issue?
Once I have a solution to Issue #2, I can then try and see what we’ve discussed in Issue #1 above.