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.

MSP430 Low Power Mode Exit With Function Call in Interrupt

Hi,


I would like to exit low power mode inside a function call in interrupt.

Here is what I tried so far,

int main(void) // <--- Same for all code
{
  // Stop watchdog timer (prevent timeout reset)
  WDTCTL = WDTPW | WDTHOLD;
 
  // Some initialization code for DMA, ADC and UART that works so far
 
  while (1)
  {
    __bis_SR_register(LPM0_bits + GIE);
 
    // I want the program counter to come here after low power mode exit
    __no_operation();
  }
}

// DMA Interrupt Handler
#pragma vector=DMA_VECTOR
__interrupt void dmaInterruptHandler(void) // <--- This way, interrupt handler works and low power mode exists
{
  // Toggle Led
  P4OUT ^= BIT0;
    
  __bic_SR_register_on_exit(LPM0_bits); // <--- This works here
}



Above interrupt code works just fine. But when I tried to call a function inside the DMA interrupt handler

// DMA Interrupt Handler
#pragma vector=DMA_VECTOR
__interrupt void dmaInterruptHandler(void) // Does NOT work
{
  _adcDmaInterruptHandler(); // Function Call
    
  __bic_SR_register_on_exit(LPM0_bits); // <--- This does NOT work and program counter stuck
}

#pragma FUNC_ALWAYS_INLINE(_adcDmaInterruptHandler) // <--- Always inline pragma did not help
__interrupt void _adcDmaInterruptHandler() // __interrupt keyword did not help
{
  // Toggle Led
  P4OUT ^= BIT0;
}


What I actually want is

// DMA Interrupt Handler
#pragma vector=DMA_VECTOR
__interrupt void dmaInterruptHandler(void)
{
  _adcDmaInterruptHandler(); // Function Call
}

#pragma FUNC_ALWAYS_INLINE(_adcDmaInterruptHandler) // <--- Always inline pragma did not help
__interrupt void _adcDmaInterruptHandler() // __interrupt keyword did not help
{
  // Toggle Led
  P4OUT ^= BIT0;
 
  __bic_SR_register_on_exit(LPM0_bits); // <--- This does NOT work either and program counter stuck as well
}


So Is there any workaround for calling low power mode exit inside a function call in an interrupt call ?

Thank you,


  • in my opinion  in this code 

    // DMA Interrupt Handler
    #pragma vector=DMA_VECTOR
    __interrupt void dmaInterruptHandler(void) // Does NOT work
    {
      _adcDmaInterruptHandler(); // Function Call
        
      __bic_SR_register_on_exit(LPM0_bits); // <--- This does NOT work and program counter stuck
    }

    _adcDmaInterruptHandler(); function should be normal function

    without __bic_SR ... ( you should call normal function )

     

    P.S.

    in interrupt routine MSP430 working  in ActiveMode,

  • When an interrupt occurs the PC and SR are stored on the stack. When returning from an interrupt the SR bits are popped back and can be altered now followed by a PC pop and the RETI instruction is executed.

    When you just (normally) call the ISR only the PC will be pushed on the stack but the ISR will return with an RETI instead of a normal RET and POP’s the stack twice and also you get the wrong return address.

  • Thank you, RET and RETI difference makes me understand the viewpoint.

**Attention** This is a public forum