SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on how to get your MSP JTAG programmer up and running.
By Agriggers
#82774
I am trying to use the usart using a poll instead of the ISR and Im having trouble. I am using hyper term and it gets the char, but instead of repeating it once it continues to repeat it until I press the next ch and it repeats that.

Code: Select all
P3SEL = 0x30;                             // P3.4,5 = USCI_A0 TXD/RXD
  UCA0CTL1 |= UCSWRST;                      // **Put state machine in reset**
  UCA0CTL1 |= UCSSEL_2;                     // SMCLK
  UCA0BR0 = 9;                              // 1MHz 115200 (see User's Guide)
  UCA0BR1 = 0;                              // 1MHz 115200
  UCA0MCTL |= UCBRS_1 + UCBRF_0;            // Modulation UCBRSx=1, UCBRFx=0
  UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
  UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt


while(1)
{
    if(UCRXIFG == 1)
    {        
      
      UCA0TXBUF = UCA0RXBUF;

        
    }   
}
}

By gm
#82850
Your flag checking is incorrect. You are checking the bit definition, not the actual flag. To correctly check the register flag your IF statement should be:
Code: Select all
if ( (IFG2 & UCA0RXIFG) == UCA0RXIFG )
{
   UCA0TXBUF = UCA0RXBUF; 
}