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.

UART-USB

Other Parts Discussed in Thread: MSP430WARE

Hi, I hope you can help me. I am trying to make some code work, but it just does not, I don't get why. I want to configure USCI 1 for UART in the MSP430F5529LP and read what I send and receive with the serial monitor H-Term. But nothing I do seems making it work. Here is the code, which is actually also distribute via MSP430ware. 

#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P4SEL |= BIT4+BIT5; // P4.4,5 = USCI_A1 TXD/RXD
UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
UCA1CTL1 |= UCSSEL_2; // SMCLK
UCA1BR0 = 6; // 1MHz 9600 (see User's Guide)
UCA1BR1 = 0; // 1MHz 9600
UCA1MCTL = UCBRS_0 + 0x80 + UCOS16; // Modln UCBRSx=0, UCBRFx=0,
// over sampling
UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA1IE |= UCRXIE; // Enable USCI_A1 RX interrupt

__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
__no_operation(); // For debugger
}
// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
{
switch(__even_in_range(UCA1IV,4))
{
case 0:break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
while (!(UCA1IFG&UCTXIFG)); // USCI_A1 TX buffer ready?
UCA1TXBUF = UCA1RXBUF; // TX -> RXed character
break;
case 4:break; // Vector 4 - TXIFG
default: break;
}
}

I mean, the configuration is very easy, and I do it in port 1 so it can communicate with the computer, should I still configure something else? It should mirror what it receives from the serial monitor, when I sent something, it answered with nonsense (like 5 decimal numbers of 3 digits each) but now it does not do anything.

  • You’re likely talking to the FET part of the LaunchPad rather than the target MSP.
    Or the MSP on the LaunchPad has a pre-programmed firmware, and you didn't ever properly upload your code to it at all, so you're talking to the wrong firmware.

  • Hi

    Look TI's document for msp430f5529lp(http://www.ti.com/lit/ug/slau533b/slau533b.pdf) - Table 9. Clock Settings

    SMCLK speed is 8MHz. so I think you should re-calculate and resetting your Baud-Rate related register setting. (UCA1BR0 , UCA1BR1, UCA1MCTL)

    I might wrong because of I am a newbie just like you heh

**Attention** This is a public forum