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 Problem (with MSP430)

Other Parts Discussed in Thread: MSP430FG4618

Hi,

I have a little problem using the UART interface of the MSP430FG4618. I want to send a byte to the controller and the controller should send an echo back to the pc. When I use the hyperterminal it works fine. But when I use my own tool (serialport-class by Visual c# .Net ), the controller doesn't send this echo. In both cases the controller receives the correct byte (it's really the same), an interrupt accures, the byte is written to the TX buffer, but only when I use the hyperterminal the byte arrives.

Has anyone an idea?

Thank you very much!

I use the following code by ti:

#pragma vector=USART1RX_VECTOR
__interrupt void USART1_rx (void)
{
  while (!(IFG2 & UCA0TXIFG));                // TX buffer ready?
  UCA0TXBUF= UCA0RXBUF;                          // RXBUF to TXBUF
}

  • If your entire setup is the same, including the code running on the MSP430, except for the use of HyperTerminal versus your own tool, I would suggest looking there first.

    However, just to make sure that some peculiar thing is not happening, are you able to check the transmit output of the MSP430 on an oscilloscope to see that in both scenarios, the MSP430 is actually transmitting?  If so, again, I would look at your application running on the PC.

  • Hi,

    I checked the communication with an oscilloscope. When I use the hyperterminal to open the port, the voltage level change a little bit. When I use my own c# tool with SerialPort class, the voltage level are still the same... Is this an indicator for any general problem?

    This code defines and opens the port:

    public class UART_init
        {
            public Thread readThread;

            public string port;
            public string baud;
            public string pari;
            public string data;
            public string stop;
            public string flow;
           
            public delegate void AddItemEventHandler(string new_item);
            public event AddItemEventHandler AddItem;

            public delegate void RecTextEventHandler(string rec_text);
            public event RecTextEventHandler RecText;

            public delegate void PortStatusEventHandler(bool status, string rec_text);
            public event PortStatusEventHandler PortStatus;

            static bool _continue = true;

            static SerialPort _serialPort;     

            public void Start()
            {          
                _serialPort = new SerialPort();

                Detect_COM_ports();           
            }


            public void Open()
            {                   

                readThread = new Thread(Read);

                _serialPort.PortName = this.port;
                _serialPort.BaudRate = int.Parse(this.baud);
                _serialPort.Parity = (Parity)Enum.Parse(typeof(Parity), this.pari);           
                _serialPort.DataBits = int.Parse(this.data);
                _serialPort.StopBits = (StopBits)Enum.Parse(typeof(StopBits), this.stop);
                _serialPort.Handshake = (Handshake)Enum.Parse(typeof(Handshake), this.flow);

                _serialPort.ReadTimeout = 500;
                _serialPort.WriteTimeout = 500;

                _serialPort.Open();

                if (_serialPort.IsOpen == true)
                {
                    PortStatus(true,_serialPort.PortName);
                }
                else
                {
                    PortStatus(false,_serialPort.PortName);
                }

                _continue = true;

                readThread.Start();
              
            }

     

  • I would suggest taking a look at both the UART RX and UART TX signals at the MSP430 when you attempt both the HyperTerminal setup and your application.

    What this is intended to determine is if the PC sending data to the MSP430 gets echoed by the MSP430 software in both cases.  You should see activity on the UART TX in both scenarios.

    How are you setting up the COM port in HyperTerminal and in your application?  Do they have the same baud rate, parity, number of stop bits, flow control, etc.?

  • Hi,

    I will try. The COM port settings are the same. 9600, 8N1, no flow control. I have added a functions that flashes a LED if a "x" is received by the MSP430. And it works! With the hyperterminal and with my tool. And also the "x" is copied to the TX-Buffer.

    Greetings

  • Now I have analysed the RX and TX Line: RX is approx. the same.

    Hyperterminal: 8V (= 0) and -6V (=1).
    C#: 8V (= 0) and -4V (=1).

    But the TX levels are not the same:

    Hyperterminal: 6V(=0) and -1V(=1)
    C#: -2V(=0) and -5V(=1)                             <-- I think here we have the problem

    What do you think?

    Thank you!

  • Ah there is another problem: Pin 4 on the experimentation board is approx. 10 V when using the hyperterminal, and -10V when using the C# tool.

  • Problem solved!!! I added follwing code:  

    _serialPort.DtrEnable =

    true;

    Now it work's. Do you know the reason?

  • One thing I neglected to ask you is what hardware platform are you using?  Is this your own target board using the MSP430FG4618, or the Experimenter's Board?

    EDIT : Assuming you are using the MSP430FG4618 Experimenter Board, the MSP430FG4618/F2013 Experimenter’s Board (SLAU213) provides a schematic of the board.  This shows that pin 4 of the DB9 connector is used to enable the opto-isolator devices on the COM port, which is why you would need to enable DTR in your custom application.

**Attention** This is a public forum