Use of #pragma INTERRUPT with nc100 compiler

I'm develloping a multi-task application with µC/OS and try to use the #pragma directive to set up interrupt handler but I get an issue:

A way of coding that I tested and that works is to use assembly to enter in the interrupt:

void my_c_subroutine(void)

{

     ...

}

void asm_isr(void);

#pragma ASM

_asm_isr:

PUSHC       FB

PUSHM       SB,A3,A2,A1,A0,R7R5,R6R4,R3R1,R2R0                      // Save context

JSR         _my_c_subroutine 

POPM        R2R0,R3R1,R6R4,R7R5,A0,A1,A2,A3,SB                      // Restore all processor registers

POPC        FB

REIT

#pragma ENDASM

But if I do (to gain in performance):

#pragma INTERRUPT my_c_subroutine

void my_c_subroutine(void)

{

     ...

}

My program crash when returning from the scheduler

I have a look at the assembly code generated using the #pragma INTERRUPT directive and it look like that:

_my_c_subroutine:

PUSHM       SB,A3,A2,A1,A0,R7R5,R6R4,R3R1,R2R0
...
POPM        R2R0,R3R1,R6R4,R7R5,A0,A1,A2,A3,SB
REIT

I can see that the FB is not pushed, that explain why my scheduler can't restore the context of the task properly but I don't understand why the #pragma INTERRUPT directive don't save FB.

  • NC100 does not have to save FB because it does not use it. As long as the interrupt routine does not change FB it does not matter if it is saved or not.

    If the interrupt function calls a function that uses FB, this call will also save the actual FB value to the stack (see enter and exit instructions in the R32C software manual).

    And usually interrupt routines run outside of RTOS control. So uC/OS should not care if the interrupt saves FB or not.