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.

Not receiving the UART RX interrupt

Other Parts Discussed in Thread: MSP430G2955

I am using MSP430G2955 and I am unable to receive RX interrupt but I am able to see that RXBUF has been filled with the data sent from a host PC.

I have enabled the GIE and also the RXIE, so is there anything else which needs to be set. 

#define TXLED BIT0
#define RXLED BIT1
#define TXD BIT5
#define RXD BIT4

const char SendString[] = { "Received 56 bytes of data\r\n" };
char RecString[56];
unsigned int nRecStringCount; // counter for bytes recevied
unsigned int nCount; //Counter



#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0TX_ISR(void)
{
 //some stuffs here
}

#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
   //Some stuffs here

}


int main(void) {
	WDTCTL = WDTPW | WDTHOLD;		// Stop watchdog timer

   DCOCTL = 0; // Select lowest DCOx and MODx settings
   BCSCTL1 = CALBC1_1MHZ; // Set DCO
   DCOCTL = CALDCO_1MHZ;

   P2DIR |= 0xFF; // All P2.x outputs
   P2OUT &= 0x00; // All P2.x reset


   P3SEL |= RXD + TXD ; // P1.1 = RXD, P1.2=TXD
   P3SEL2 |= RXD + TXD ; // P1.1 = RXD, P1.2=TXD
   P2DIR |= RXLED + TXLED;
   P2OUT &= 0x00;

   UCA0CTL0 |= UCPEN + UCPAR ; // for Even parity
   UCA0CTL1 |= UCSSEL_2 ; // 2 for SMCLKm, 1 for ACLK

   UCA0BR0 = 0x34; // 1MHz 19200
   UCA0BR1 = 0x00; // 1MHz 19200
   UCA0MCTL = UCBRS0 ;//+ UCBRS2; // Modulation UCBRSx = 5


   nRecStringCount = 0;

   UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**

   IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt

   LPM0 + GIE; // Enter LPM0 w/ int until Byte RXed

   while (1)
   { }

}

Also to note that I have recieved that the data sent 0xAB from a remote PC to UART port of the controller. 

  • LPM0 + GIE; // Enter LPM0 w/ int until Byte RXed

    what is that? unless CCS has some new macro thing I don't know, you need to use a type of __intrinsics like this

     _BIS_SR(LPM0_bits + GIE);   // Enter LPM0 w/ interrupt

  • Hi Kewal!

    By the way: You have two RX ISRs defined

    #pragma vector = USCIAB0RX_VECTOR
    __interrupt void USCI0TX_ISR( void )
    {
      // Some stuff here
    }
    
    #pragma vector = USCIAB0RX_VECTOR
    __interrupt void USCI0RX_ISR( void )
    {
      // Some stuff here
    }

    It is not your own name

    __interrupt void USCI0TX_ISR( void )

    that specifies the ISR, it is the #pragma

    #pragma vector = USCIAB0RX_VECTOR

    And if you successfully changed your code according to Tony's suggestion, you should do something in your ISR to set a breakpoint or add a NOP to see that your program is inside the ISR. Furthermore keep in mind that if you do not read the RX buffer or clear the bit manually after a received byte, the IFG stays set and the ISR is executed over and over again.

    Dennis

  • Hi Tony,

    LPM0 is defined in the intrinsics as _BIS_SR(LPM0_bits );

    Also,

    I had another question releated to setting it to LPM0 ....I did search through few tutorials and questions but have been able to form a concrete idea on this.

    So I have a while loop in main and also i need to set __BIS_SR(LPM0_bits + GIE);

    Do i need to just put it to LPM0 mode and then call the while loop.

    What I am trying to achieve is,... When some push button is pressed it sets a enable flag,. based on that enable flag the while loop would update some stuff and return back to LPM0 mode. so code would something like below, is it correct?




    Main { //Initialize and configure While(1) { if(updateflag updated) //Do something and toggle something //Go to low power mode __BIT_SR(LPM0 +GIE) } //Never comes here end of app } __ISR Port pin ISR { //Update flag }

  • The interrupt handler has to wake up the main loop with something like __bic_SR_register_on_exit(LPM0_bits); otherwise, the CPU goes back to sleep as soon as the interrupt handler is finished.

    This is explained in SLAA294.

**Attention** This is a public forum