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.

Launchpad stops when uart is operating

Other Parts Discussed in Thread: MSP430G2553

Hi!


I have a little problem what i can not solve by my self.

I running code on a Launchpad ver. 1.5 with msp430g2553 installed, i use msp430-gcc/mspdebug.

I want to keep the mcu in active mode at 16Mhz and the uart running at 9600 baud.

So a LED can blink while an interrupt service the communication.

It seems separately everything is just fine, but not the same time.

When i comment out " UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine* " then the blinking appear, but of course there is no communication.

When i uncomment the above line, the communication works, but not the blinking.

However if is send many character via the terminal, the LED sometime change state.

I guessed the mcu goes lpm* when not servicing the interrupt, so the main program stops running, but i also tried it the 32k crystal installed on and changed the clock source. 

I got the same result...

Any help would be great!


This is my code:

#include <msp430.h>
#include <stdint.h>

uint8_t task_master = 0;
uint8_t serial_input=0;


int main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  P1DIR |= 0x01;
  BCSCTL1 = CALBC1_16MHZ;                    // Set DCO
  DCOCTL = CALDCO_16MHZ;
  P1SEL = BIT1 + BIT2 ;                     // P1.1 = RXD, P1.2=TXD
  P1SEL2 = BIT1 + BIT2 ;                    // P1.1 = RXD, P1.2=TXD
  UCA0CTL1 |= UCSSEL_2;                     // SMCLK
  UCA0BR0 = 0b10000010;                            // 16MHz 9600
  UCA0BR1 = 0b00000110;                              // 16MHz 9600
  UCA0MCTL = 0b00001100;                        //7-4:UCBRFx 3-1:UCBRSx 0:UCOS16

  UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
  IE2 |= 0x03;                                                   //UCA0RXIE;                          // Enable USCI_A0 RX interrupt


  __bis_SR_register(GIE);       //  interrupts enableda


uint8_t in_buffer[64];
uint8_t in_buffer_pos = 0;


for(;;){
 UCA0TXBUF=0x75;
    volatile unsigned int i;

    P1OUT ^= 0x01;                          // Toggle P1.0 using exclusive-OR

    i = 500;                              // Delay
    do (i--);
    while (i != 0);

}
}


//  Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void){

  serial_input=UCA0RXBUF;
  task_master=1;
 UCA0TXBUF=0x77;
  }



__interrupt void USCI0TX_ISR(void){


}

  • > IE2 |= 0x03;                                                   //UCA0RXIE;                          // Enable USCI_A0 RX interrupt

    You're enabling the TX interrupt, but there's no Tx ISR, (without a "#pragma vector" it effectively doesn't exist) so your program is resetting constantly. Since the Rx interrupt is higher priority than the Tx, every so often you can fit an Rx byte in, which in your code delays the Tx interrupt briefly.

    Since USCI0TX_ISR doesn't do anything to clear (or disable) the Tx interrupt, if you just add a "#pragma vector" for it you'll just end up in a different kind of spin.

    I suggest you Not enable the Tx interrupt at all.

  • Hi!

    Thank you, that solved the problem!

    Somehow it was not obvious to me, the mcu will stuck in that case.

    I will study this topic more deeply.

    That really made my day!

**Attention** This is a public forum