This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler warns about using a function inside an ISR even though the function is inline.

This code --

/**
* Timer A0 interrupt service routine
*/
#pragma vector=TIMERA0_VECTOR
__interrupt void ta0_isr(void)                         // Interrupt after timer reaches TACCR0
{
LED_Control(0);
_BIC_SR_IRQ(LPM3_bits);
}

produces this warning --

"../main.c", line 235: remark #1538-D: (ULP 10.1) ISR ta0_isr calls function LED_Control. Recommend moving function call away from ISR, or inlining the function, or using pragmas

But the function in question is declared and defined as inline --

/*****************************************************************************/
/* Local function prototypes ('static') */
/*****************************************************************************/
static inline void LED_Control (int light);
/*****************************************************************************/
/* Function implementation - global ('extern') and local ('static') */
/*****************************************************************************/
/**
* LED_Control
* param: int light - 0 turn off, 1 turn on
*/
static inline void LED_Control (int light)
{
       if (light) {
         P1OUT |= LED;
       } else {
         P1OUT &= ~LED;
      }
}

Shouldn't using an inline function here eliminate the warning?

  • I recommend reading the Compiler User Guide (SLAU132Y), specifically section 2.11 "Using Inline Function Expansion". It tells you which conditions must be met for the compiler to actually inline your function; using the "inline" keyword is only a suggestion to the compiler.

    The other thing to note, the ULP message isn't really a warning, just an informational guide. If the function is actually inlined in your firmware because it met the conditions in section 2.11 of SLAU123Y, the message will still show because you are calling a function in its point of view. From my experience, the ULP Advisor doesn't look any further than the source code; it doesn't know what the compiler and linker actually do for optimization.

  • Shouldn't using an inline function here eliminate the warning?

    Thank you for asking a reasonable question.  I filed EXT_EP-11101 to have this investigated.  You are welcome to follow it with that link.

    Thanks and regards,

    -George