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.

MSP430 USB to RS-232 serial adapter issue

Other Parts Discussed in Thread: MSP430FG4618, MSP430WARE

I am very new at programming the MSP430. I have purchased my own MSP430FG4618/F2013 and have purchased a USB to RS-232 adapter to use with my UART programs that I have written at school. When I try them at home with my laptop I do not get the same result as I do at school. Any advice to correct this is greatly appreciated. Do I need to setup the COM port a certain way?

  • "Not the same result" is rather vague. Could you be more specific? What do you expect to happen, and what happens instead?

    The COM port must be configured for the correct baud rate and format, but there should not be any difference between different PCs. What RS-232 are you using at school?

  • We use a 9-pin male to male cable to connect our boards at school the BAUD rate is set for the port at school to be 9600, I set all that to be the same on my computer which is basically the defaults. What I mean by not the same result is when I connect to hyperterminal at school it my program works properly (the output to hyperterminal is what I expect), at home on my computer it gives me gibberish.
  • Stacy Coggin said:
    Any advice to correct this is greatly appreciated. Do I need to setup the COM port a certain way?

    Is the same type of USB to RS-232 adapter used is both cases?

    The reason for asking is looking at the circuit diagram of the MSP430FG4618/F2013 Experimenter’s Board in SLAU213A shows that the transmitter of the RS232 port on the MSP430FG4618/F2013 Experimenter’s Board is powered from pin 4 which is the DTR output from the PC serial port.

    For the transmitter on the RS232 transmitter on the MSP430FG4618/F2013 Experimenter’s to work it looks like pin 4 (DTR) needs to have a positive voltage. Can you check that on the laptop where garbage is received?

  • It is not the same. At school we use a 9pin male to 9 pin male serial cable. The only thing I have been able to get a hold of is a USB to 9pin serial adapter.
  • I'm getting 9vdc on pin 4
  • It's possible that your RS-232/USB adapter is picky about the timing of its input. What clock source are you using for the UART? Something internal, or based on a crystal?
  • I am using the SMCLK... Below is a partial of my program.

    #include <msp430xG46x.h>
    #include <stdio.h>
    #define SW1 BIT0&P1IN // B1-P1.0 switch SW1

    // Current time variables
    unsigned int min=0; // minutes
    unsigned int sec=0; // seconds
    unsigned int hsec=0; // 1/100 second
    char Time[80]; // string to keep current time
    char Display1[80]; // string to keep "Please press switch 1"

    //Function Declarations
    void SetTime(void);
    void SendTime(void);
    //////////////////////////////////////////////////////////////////
    //UART0 Initialization
    //////////////////////////////////////////////////////////////////
    void UART_Initialize(void) // USART in UART Mode
    {
    P2SEL |= BIT4+BIT5; // Set UC0TXD and UC0RXD to transmit and receive data
    UCA0CTL1 |= BIT0; // Software reset
    UCA0CTL0 = 0; // USCI_A0 control register
    UCA0CTL1 |= UCSSEL_2; // Clock source SMCLK
    UCA0BR0=9; // 1048576 Hz / 115200
    UCA0BR1=0; //
    UCA0MCTL=0x0A; // Modulation
    UCA0CTL1 &= ~BIT0; // Undo software reset
    }
  • What is the clock source of SMCLK? The default? Are you using a crystal?

    The example in the User's Guide uses modulation 0x0B for 115200 baud.

    If the clock does not run at an exact multiple of the baud rate, you get timing errors. Higher baud rates have larger errors; if possible, try a lower baud rate like 4800.

  • DCO Oscillator ? Like I said.... I am very new at this and trying really hard to understand (Thank you for patience).

    void main(void)
    { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
    UART_Initialize(); //Initialize UART /* Initialize Timer A to measure 1/100 sec */
    TACTL = TASSEL_2 + MC_1+ ID_3; // Select smclk/8 and up mode
    TACCR0 = 1310; // 100ms interval
    TACCTL0 = CCIE; // Capture/compare interrupt enable

    P2SEL |= BIT4 + BIT5; // P2.4,5 = USCI_A0 RXD/TXD
    UCA0CTL1 |= UCSSEL_2; // SMCLK
    UCA0BR0 = 0x09; // 1MHz/115200 (lower byte)
    UCA0BR1 = 0x00; // 1MHz/115200 (upper byte)
    UCA0MCTL = 0x02; // Modulation (UCBRS0=0x01)(UCOS16=0)
    UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
    IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
    _BIS_SR(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
    P3DIR |= BIT1; // direct MSP430FG4618 to MSP430F2013PW

  • And you are not using the FLL (and a crystal) to adjust the DCO? In that case, the SMCLK frequency is probably not exactly 1 MHz. Again, a lower baud rate might help. Alternatively, try measuring your actual DCO frequency, and adjusting the UART divider appropriately.
  • How do I measure actual DCO frequency? Tried lower BAUD rate and it seems close. The action on hyperterminal seems correct based on how the program is supposed to work but the characters are incorrect.

  • To measure the actual frequency, you would have to compare it against some accurate clock.

    Try adjusting the frequency up and down in your program, and check if the result in Hyperterminal becomes better.

  • I have a buzzer program that does not work also. The LED that is supposed to light works but the buzzer will not sound. Using ACLK on it.
  • Stacy Coggin said:
    How do I measure actual DCO frequency?

    The MSP430FG4618/F2013 Experimenter's Board has a 32.768KHz crystal on XT1 which can be used to set the DCO frequency. See the MSP430Ware "msp430xG46x_fll_02" code example for the MSP430FG461x device which sets the DCO to run at 8MHz.

    With the DCO set to the maximum of 8MHz, and a baud rate divisor set for 9600, should minimize the timing error on the serial output.

  • Would a difference in debuggers matter? I have a newer version than what is used at school.
  • The experimenter board has an isolated RS232 interface. The isolated RS232 side of the interface is powered indirectly from the PC by feeding on the unneeded RTS and DTR signals to get the required +-12V. Perhaps your USB/RS232 adapter doesn't provide them or doesn't provide as much current as the real RS232 port at school does. Or doesn't initialize the signals by default. As a result, the RS232 has no power (or insufficient power) to send the signals.

    Take a look at the schematics of the experimenters board and you'll understand.

**Attention** This is a public forum