MSP430 Coding, Can I Place an Interrupt Vector Inside a Function

ccode-designmsp430

As the title said, I am trying to see if an Interrupt Vector can be embedded inside a function? I am using IAR, but gcc or ccs would work too. I don't see it done in any code online. Example:

void function_funtime (int test){
    int lm4970_state = 0;
    int abc = test + 3;

    // Port 1 interrupt service routine
    #pragma vector = PORT1_VECTOR
    __interrupt void Port_1_ISR (void)
    {
         _BIC_SR_IRQ(LPM3_bits + GIE);     // Clear LPM/Disable Interrupts
         lm4970_state++;     // Increase LM4970 state by 1
         P1IFG &= ~PB;       // P1.3 IFG cleared
    }
}

Function "function_funtime" is called from the main code before the interrupt is ever seen. Can this be done?

Best Answer

No.

You can't define a function inside of another function in C. I'm not sure what you're trying to do, but maybe you can set flags for the ISR in the function or simply enable the interrupt in the function. Either of those may have the same effect.