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.

MSP430f5529LP UART Producing garbage values

Other Parts Discussed in Thread: MSP430F5529

Hi all,

I am working on a project in which i am using the MSP430f5529 Launchpad. I am trying to send some data through the UART of the MSP to a XBEE. The data is then transmitted to another XBEE which is connected to a pc. When i try to view the data in the pc by using hyperterminal, some garbage values(different kinds of symbols) keeps coming. The following is the code in the microcontroller.

#include <msp430f5529.h>

/*
 * main.c
 */
int main(void) {
	WDTCTL = WDTPW + WDTHOLD;	// Stop watchdog timer

	// DC0CTL = 0;
	// BCSCTL1 = CALBC_1MHZ;
	// DC0CTL = CALDCO_1MHZ;
	// UCSCTL1 |=

    P3SEL |= BIT3 + BIT4; // P3.3,4 = USCI_A0 TXD/RXD
    UCA0CTL1 |= UCSWRST; // Reset the state machine
    UCA0CTL1 |= UCSSEL_2; // SMCLK
    UCA0CTL0 &= ~UCPEN + ~UCMSB + ~UC7BIT + ~UCSPB; //  Disable parity, SET LSB first, Set8 data bits, Set 1 Stop bit
    UCA0BR0 = 109; // 1.048MHz/9600
    UCA0BR1 = 0; //
    UCA0MCTL &= ~UCOS16;
    UCA0MCTL |= UCBRS_2 + UCBRF_0; // Modulation UCBRSx=2, UCBRFx=0
    //UCA0STAT |= UCLISTEN;
    UCA0CTL1 &= ~UCSWRST; // Initialize the state machine
    UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt


    	while (!(UCA0IFG&UCTXIFG)); // Is the USCI_A0 TX buffer ready?
    	UCA0TXBUF = 0x41; // TX -> A
   
    //while (!(UCA0IFG&UCTXIFG));
    //UCA0TXBUF = 0x42; // TX -> B
    //while (!(UCA0IFG&UCTXIFG));
    //UCA0TXBUF = 0x43; // TX -> C

    __bis_SR_register(GIE); //interrupts enabled
    //__no_operation();
	
	return 0;
}
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
//Insert Code for the RX interrupt
	// int received = UCA0RXBUF;
}


Both the Xbee's have been configured and are working properly. The completion of my project depends on this so any kind
of help will be greatly appreciated.

~Ram

 

  • Hi,

    Your UCA0 initialization looks perfectly fine, please confirm the baud rate settings of your terminal. You might try adjusting the baud rates and see if that makes any difference, or calibrate the SMCLK frequency. Do you have a logic analyzer or oscilloscope so that you can capture a transmission and compare what is being sent versus what is expected? Do you get different garbage symbols or the same one each time you attempt to transmit the same character?

    Regards,
    Ryan
  • Ryan Brown1 said:


    please confirm the baud rate settings of your terminal. 

    I have checked the baud rate settings and they are fine.

    Ryan Brown1 said:


    You might try adjusting the baud rates and see if that makes any difference

    I have tried with two baud rates(9600 & 115200), not working in both.

    Ryan Brown1 said:

    calibrate the SMCLK frequency.

     

    I am new to msp430(new to microcontrollers, to be honest) so I am not sure how to do that. Can i find some example code which shows me how to do that.

    Ryan Brown1 said:


    Do you have a logic analyzer or oscilloscope so that you can capture a transmission and compare what is being sent versus what is expected?

     

    I don't have a logic analyzer or oscilloscope.

    Ryan Brown1 said:


    Do you get different garbage symbols or the same one each time you attempt to transmit the same character?

    I am getting different garbage symbols each time for the same character.

  • Did you try to receive your own characters by connecting Tx and Rx? If it works, the clock might be the problem. Remember that UART is asynchronous, so the communication has to rely on an accurate clock on both sides. But without having an oscilloscope to check the clock and the data, finding the issue might be difficult.

    Dennis
  • Different garbage symbols seems to indicate a clocking mismatch. There are code examples provided by TI , particularly MSP430F55xx_UCS_02.c and MSP430F55xx_UCS_03.c, that show how the DCO can be increased to 8 and 12 MHz, respectively. Try using these examples and adjust your UCA0 registers accordingly to see if it makes any difference. I also recommend trying Dennis' loopback test.

    Regards,
    Ryan
  • Hi Dennis,

    I tried as you suggested by enabling loopback mode(enabling UCLISTEN) and it seems to be working fine. I compared the received character and toggled an led. the received data is correct.

    I am even more confused right now, am I initializing the USCI module properly or should I change the clock settings.

    Is there any work around to check if the generated baud rate is proper ?
  • A successful loopback test shows that the USCI module is initialized properly, please try to change the clock settings. As Dennis mentioned it is hard to validate the baud rate or clock speeds without any bench equipment for testing.

    Regards,
    Ryan
  • Hi Ryan,

    After some searching I found an example program for the USCI module (MSP430F55xx_uscia0_UART_01.c). It configures the UART module in 115200 baud rate. Now I am able to communicate properly!!!

    still just want to make sure if I calculated the values for configuring the modules properly. this is how I did it

    Clock frequency by default is
    fSMCLK = 1.048576 MHz so
    1048576/9600 = 109.22666666
    taking the integer value N=109, UCA0BR0=109 & UCA0BR1=0
    As for the values after the decimal point ( .22666666 * 8 = 1.8133 or 2) Which is the value for modulation control, UCA0MCTL |= UCBRS_2 + UCBRF_0; // Modulation UCBRSx=2, UCBRFx=0
    UCBRFx=0 because UCOS16 is disabled

    Am I doing it right?

    and, thanks for the help!!!

    ~Ram
  • Hi Ram,

    Always start with a TI-provided example. And yes, that initialization properly follows the UART procedure and typical baud rate settings as defined in the User's Guide. I'm glad to hear that you can now communicate.

    Regards,
    Ryan

**Attention** This is a public forum