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.

Serial Port

Other Parts Discussed in Thread: MSP430F5438A, MAX3232

Hi, 

I am trying to communicate to the Tera Terminal program running on Windows 7. I am using MSP430F5438A and its Experienter Board. I am connected to the PC in the following way

MSP430 ----> MAX3232 board ---->Serial  to USB adapter ----> PC(USB PORT)

MAZ3232 Board : http://www.mouser.com/ds/2/272/max3232_manual_v100-37494.pdf

Serial to USB Adapter: http://sgcdn.startech.com/005329/media/sets/ICUSB232V2_Manual/ICUSB232V2.pdf

http://www.startech.com/Cards-Adapters/Serial-Cards-Adapters/USB-to-RS232-Serial-Adapter-Cable~ICUSB232V2#dnlds

The driver for the Serial to USB adapter is installed and working fine. I configured the Tera Terminal program for 

9600, 8 bit and 1 bit stop. Mycode is as follows 

#include "msp430x54xA.h"

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P3IN = 0x20; // P3.5 RXD input
P3OUT = 0x10; // P3.4 TXD output
P3SEL = 0x30; // P3.4,5 = USCI_A0 TXD/RXD
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL1 |= UCSSEL_1; // CLK = ACLK
UCA0BR0 = 0x03; // 32kHz/9600=3.41 (see User's Guide)
UCA0BR1 = 0x00; //
UCA0MCTL = UCBRS_3+UCBRF_0; // Modulation UCBRSx=3, UCBRFx=0
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt

__bis_SR_register(LPM3_bits + GIE); // Enter LPM3, interrupts enabled
__no_operation(); // For debugger
}

// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
switch(__even_in_range(UCA0IV,4))
{
case 0:break; // Vector 0 - no interrupt
case 2: // Vector 2 - RXIFG
while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = UCA0RXBUF; // TX -> RXed character
break;
case 4:break; // Vector 4 - TXIFG
default: break;
}
}

Questions:

1. Is this a right hardware setup to go with? 

2. I am not seeing the characters echo back. Does someone has any experience with it. 

Melissa

  • 1) The hardware setup seems a bit roundabout, since it raises the UART logic (3V) levels to RS232 (12V) then back down for the USB, but if you have a reason for doing that it should work.

    2) I don't see anything obviously wrong. You may want to re-check your wire connections to the MSP430. RX-MCU should be connected to P3.5 (UCA0RXD); this is opposite to the more common convention that Rx goes to Tx. Similarly for TX-MCU and P3.4 (UCA0TXD). Also, make sure flow control is disabled in TeraTerm.

  • Hi, 

    I changed the code and tried again. I can see TXD and RXD signals on the oscilloscope. I tested the code with Tera Terminal. I typed a letter in the "Tera Terminal" Window but MSP430 did not return the same character back to the Tera Terminal though I can see the TXD toggling on the scope. Am I using the Tera Terminal correctly?

    Melissa

    #include <msp430.h>

    int main(void)
    {
    WDTCTL = WDTPW + WDTHOLD; // Stop WDT
    P3SEL = 0x30; // P3.4,5 = USCI_A0 TXD/RXD
    UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
    UCA0CTL1 |= UCSSEL_3; // SMCLK
    UCA0BR0 = 6; // 1MHz 9600 (see User's Guide)
    UCA0BR1 = 0; // 1MHz 9600
    UCA0MCTL = UCBRS_0 + UCBRF_13 + UCOS16; // Modln UCBRSx=0, UCBRFx=0,
    // over sampling
    UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
    UCA0IE |= UCRXIE; // Enable USCI_A0 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
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=USCI_A0_VECTOR
    __interrupt void USCI_A0_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
    switch(__even_in_range(UCA0IV,4))
    {
    case 0:break; // Vector 0 - no interrupt
    case 2: // Vector 2 - RXIFG
    while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
    UCA0TXBUF = UCA0RXBUF; // TX -> RXed character
    break;
    case 4:break; // Vector 4 - TXIFG
    default: break;
    }
    }

  • melissa walraven said:

    I am trying to communicate to the Tera Terminal program running on Windows 7. I am using MSP430F5438A and its Experienter Board. I am connected to the PC in the following way

    MSP430 ----> MAX3232 board ---->Serial  to USB adapter ----> PC(USB PORT)

    #1. Could you describe your MSP430 ----> MAX3232 board connection in more detail? That is, which MSP430 pins are connected to the MAX3232 board pins RX_MCU, TX_MCU, CTS_MCU, RTS_MCU, VCCO, and GND?

    #2. In order to check out your said setup, could you do the following: (a) Disconnect your MSP430 ----> MAX3232 board connection. (b) Put a jumper between  the MAX3232 board pins RX_MCU and TX_MCU. (c) Operate Tera Terminal on the PC the same way you did before. Do you see the correct character echoed back correctly? (Looped back by the jumper instead of your MSP430 code.)

  • When you say that you are getting an echo back from the MSP430, but it's not the correct character, that tells me that the baud rate (i.e. UART clock) is off by a little bit. (Since this appears to be example uart_04 I would expect it to work, but what you probably want to do now is make it work, then step backwards to figure out what went wrong.)

    Since you have a scope hooked up, try measuring the bits that you're seeing, and figure out what your actual bit rate is. This will allow you to set UCA0BR0 accordingly. Byte 0x5A ('Z') is handy for this.

    Alternatively, try adjusting UCA0BR0 in steps. You will get better resolution by not setting UCOS16 nor the modulator (just set UCA0MCTL=0). Then start with UCA0BR0=6*16 (what you're using now) and step it up and/or down until you get the result you want. Yes, this is a bit tedious, but I've used it at times when I ran out of First Principles.

  • melissa walraven said:
    I changed the code and tried again. I can see TXD and RXD signals on the oscilloscope.

    Since you can see those signals on the oscilloscope, you should be able to verify if they are correct. For example, when you transit or receive the capital U at 9600 b/s, both signals should be five pulses of ~104 usec each.

    Also, your code assumes that SMCLK is at 1.0 MHz, you should be able to verify if that assumption is correct. You could modify your code to output SMCLK on one of the I/O pins and verify the frequency with an oscilloscope.

  • Port  3.4 (TxD;pin39) is connected to TXD of the MAX3232

    Port 3.5 (RxD;pin40)  is connected to RXD of the MAX3232

     

    I can see the activity on both lines when I try to send a character from Tera Terminal but do not see the same character echoed back from the MSP430F5438A. 

    Melissa

  • melissa walraven said:
    I can see the activity on both lines when I try to send a character from Tera Terminal but do not see the same character echoed back from the MSP430F5438A. 

    Are the activity on both lines the same character?

  • melissa walraven said:

    Port  3.4 (TxD;pin39) is connected to TXD of the MAX3232

    Port 3.5 (RxD;pin40)  is connected to RXD of the MAX3232

    I can see the activity on both lines when I try to send a character from Tera Terminal

    When you type capital U on the Tera Terminal, do both TXD and RXD look like this on the oscilloscope?

**Attention** This is a public forum