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.

MSP430F5528: ISR problem

Part Number: MSP430F5528


Hi,

I am facing a problem with the interrupt handler. After servicing to the interrupt it not coming back to the main program continuously it is running the same isr.

#include <msp430.h>
***********************************
//lcd initialization 
//
//
//
//functions declaration for lcd
***********************************
char data;
int main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  lcd_init();
  P4SEL = BIT4+BIT5;                        // P3.4,5 = USCI_A0 TXD/RXD
  UCA1CTL1 |= UCSWRST;                      // **Put state machine in reset**
  UCA1CTL1 |= UCSSEL_2;                     // SMCLK
  UCA1BR0 = 6;                              // 1MHz 9600 (see User's Guide)
  UCA1BR1 = 0;                              // 1MHz 9600
  UCA1MCTL = UCBRS_0 + UCBRF_13 + UCOS16;   // Modln UCBRSx=0, UCBRFx=0,
                                            // over sampling
  UCA1CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
  UCA1IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt

  __bis_SR_register(LPM0_bits + GIE);       // Enter LPM0, interrupts enabled
  send_string(data);
  
}

// Echo back RXed character, confirm TX buffer is ready first
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A1_VECTOR))) USCI_A1_ISR (void)
#else
#error Compiler not supported!
#endif
{
  switch(__even_in_range(UCA1IV,4))
  {
  case 0:break;                             // Vector 0 - no interrupt
  case 2: 
    data = UCA1RXBUF;                                  // Vector 2 - RXIFG
    while (!(UCA1IFG&UCTXIFG));             // USCI_A0 TX buffer ready?
    UCA1TXBUF = 52;                  // TX -> RXed character
    break;
  case 4:break;                             // Vector 4 - TXIFG
  default: break;
  }
 __bic_SR_register(LPM0_bits);
}

In the above program I just want to display the received data on an LCD, but it is not executing that instruction,

 

  • Hi Pabel,

    Your code is most likely exiting the main function because you have no main loop. After exiting LPM0 via the USCI_A1_ISR, your code looks like it's setup to send a string via the send_string function. After that, the code exits main which should be avoided by placing a forever loop at the end of main.

    Best regards,
    Caleb Overbay

**Attention** This is a public forum