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.

USCI UART in msp430f5438

Other Parts Discussed in Thread: MSP430F5438, MAX3232

hi,

i'm trying to use UART to print on the linux terminal and i'm using this code segment.

#include "msp430f5438.h"

void main()
{
    P5SEL = 0xC0;
    UCA1CTL1 = UCSSEL_2 + UCSWRST;
    UCA1BR0 = 0x09;
    UCA1MCTL = UCBRS_1;
    UCA1CTL1 &= ~UCSWRST;
    while(!(UCA1IFG & UCTXIFG));
    UCA1TXBUF = '5';

    UCA1CTL1 |= UCSWRST;
}


here it prints '5' on the terminal after that it keeps printing junk infinitely. even after stopping the UART. why does that happen ? am i missing something ? 

  • After clearing SWRST, UCTXIFG is always set (since there is nothing in the transmit buffer). So the while is superfluous.

    However, the real problem is that immediately after writing to TXBUF, you immediately reset the USCI, so it has no chance to send anything. Also, your code fall out of main after the last instruction. There is no OS to return to. So what happens is undefined and depends on the compiler. Likely, the device will enter LPM4, which might even switch the USCI clock off.

    But in any case, it shouldn't continue sending something. So I guess you have a hardware problem. How is the MSP connected to the PC? Do you use a proper level shifter (PC COM ports require RS232 levels while the MSP uses TLL levels). A MAX3232 is a good choice.
    Or do you use a USB/SER converter? If so, does it produce TTL I/O or does it give RS232 signals?

**Attention** This is a public forum