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.

Trouble with UART sending

Other Parts Discussed in Thread: MSP430F1611

Hello

 I have trouble using the UART IF on MSP430F1611. I cant send any data (nor receive). The output just doesn’t do anything. Here is my used code for configuration and sending:

 int main(void)

{                       WDTCTL = WDTPW + WDTHOLD;   // Stop watchdog timer

                        reseterror();

                        IOselect();                        // Setup of IO config incl. P3OUT = 0x10; P3DIR = 0x1F; P3SEL = 0x03;

                        CLK_init();                       // Sets SMCLK to XT2CLK (7.3728MHz)

                        .

                        .

                        .

                        

                        // Configuration of UART:

                       

                        U0CTL |= SWRST;

 

                        ME1 |= UTXE0 + URXE0;                                         //Enable USART0 TXD / RXD

                        U0CTL |= CHAR;                                                       // 8 Bit operation

 

                       

                        U0TCTL |= SSEL0;                                                        // Set SSELx high to switch BRCLK to SMCLK

                        U0TCTL |= SSEL1;                                                        // Set SSELx high to switch BRCLK to SMCLK

                       

                        //Baudrate = 7.3728MHz / 768 = 9600; 768 = 0x0300

                        U0BR0 = 0x00;

                        U0BR1 = 0x03;

                        U0MCTL =0x00;

                       

                        U0CTL &= ~SWRST;

                       

                        IE1 |= URXIE0 + UTXIE0;                 // vs Rx&Tx interrupt

 

 

 

                        // Send Loop:

 

                        while(1)

                        {                      

                                                while(!(IFG1 & UTXIFG0));                                     //wait until USART0 TX buffer ready

                                                U0TXBUF = 0x61;

                                                while(!(IFG1 & UTXIFG0));                                     //wait until USART0 TX buffer ready

                                                U0TXBUF = 0x99;

                        }

}

 

I would be glad for any help.

 

Best regards

 

Chrishen

  • I had a similar issue. What I discovered that some USB ports don't work with my UART communication. Have you tried the USB ports in the back of your computer? Also, try using the wireless sensor demo to test communication.

    -Hope this helps

  • No, I checked with a scope that the Tx Pin of the MSP is doing nothing at all.

  • check my modyfication:

    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
    
      P3SEL |= 0x30;                            // P3.4,5 = USART0 TXD/RXD
    
    
      BCSCTL1 &= ~XT2OFF;                       // XT2on
    
      do
      {
      IFG1 &= ~OFIFG;                           // Clear OSCFault flag
      for (i = 0xFF; i > 0; i--);               // Time for flag to set
      }
      while ((IFG1 & OFIFG));                   // OSCFault flag still set?
    
      BCSCTL2 |= SELM_2 + SELS;                 // MCLK = SMCLK = XT2 (safe)
    
    
      ME1 |= UTXE0 + URXE0;                     // Enable USART0 TXD/RXD
      UCTL0 |= CHAR;                            // 8-bit character
      UTCTL0 |= SSEL1;                          // UCLK = SMCLK
      UBR00 = 0x00;                             // 
      UBR10 = 0x03;                             //
      UMCTL0 = 0x00;                            // no modulation
      UCTL0 &= ~SWRST;                          // Initialize USART state machine
    
      while(1)
      {                      
           while(!(IFG1 & UTXIFG0));    // wait until USART0 TX buffer ready
           U0TXBUF = 0x61;
    
           while(!(IFG1 & UTXIFG0));     //wait until USART0 TX buffer ready
           U0TXBUF = 0x99;
       }
    
    
    }

  • S..t! Found the error, I mixed up

    P3SEL |= 0x03;

    instead of

    P3SEL |= 0x30;

    Thanks for the fast answers.
  • exactlly, this is it,,,

**Attention** This is a public forum