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.

MSP432 UART Receive Problem

I  use PC(use CP2102) send data to MSP432(use UCA3) , and result is weird.

For example , I use PC send 12356 to MSP432 , MSP432 just only receive 6.

My 12M Hz Frequency and UART configure code is from TI example. 

Sorry , my English is poor , forgive me.

If you don't understand my question , please tell me. Thanks.

  • Hi,

    Where are you looking at the received data? If it is in the RX BUFFER then that only holds the last integer that is sent, i.e 6.

    Try just sending a single integer and looking at RX BUFFER or setting up an array that stores each value if you want to continue down the '123456' road.

    Cheers.

  • Jack Swale86 said:
    If it is in the RX BUFFER then that only holds the last integer

    Even less...it is only the last byte, of course.

    Is your RXcounter_3 variable declared as volatile? This is necessary because you alter it's value inside an interrupt.

    Dennis

  • Hi user4621557,

    I made some modifications to msp432p401_euscia0_uart_01 example code and with the MSP432 LP UART backchannel, I was able to receive multiple bytes without any problem.

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2014, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     *
     *                       MSP432 CODE EXAMPLE DISCLAIMER
     *
     * MSP432 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/.../mspdriverlib for an API functional
     * library & https://dev.ti.com/pinmux/ for a GUI approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //   MSP432P401 Demo - eUSCI_A0 UART echo at 9600 baud using BRCLK = 12MHz
    //
    //  Description: This demo echoes back characters received via a PC serial port.
    //  SMCLK/ DCO is used as a clock source and the device is put in LPM3
    //  The auto-clock enable feature is used by the eUSCI and SMCLK is turned off
    //  when the UART is idle and turned on when a receive edge is detected.
    //  Note that level shifter hardware is needed to shift between RS232 and MSP
    //  voltage levels.
    //
    //  The example code shows proper initialization of registers
    //  and interrupts to receive and transmit data.
    //  To test code in LPM3, disconnect the debugger.
    //
    //  
    //
    //                MSP432P401
    //             -----------------
    //         /|\|                 |
    //          | |                 |
    //          --|RST              |
    //            |                 |
    //            |                 |
    //            |     P1.3/UCA0TXD|----> PC (echo)
    //            |     P1.2/UCA0RXD|<---- PC
    //            |                 |
    //
    //   Wei Zhao
    //   Texas Instruments Inc.
    //   June 2014
    //   Built with Code Composer Studio V6.0
    //******************************************************************************
    #include "msp.h"
    #include <stdint.h>
    
    uint8_t rx_buffer[1024];
    uint16_t bufferIndex = 0;
    
    int main(void)
    {
      WDTCTL = WDTPW | WDTHOLD;               // Stop watchdog timer
    
      CSKEY = 0x695A;                        // Unlock CS module for register access
      CSCTL0 = 0;                            // Reset tuning parameters
      CSCTL0 = DCORSEL_3;                   // Set DCO to 12MHz (nominal, center of 8-16MHz range)
                                             // Select ACLK = REFO, SMCLK = MCLK = DCO
      CSCTL1 = SELA_2 | SELS_3 | SELM_3;
      CSKEY = 0;                             // Lock CS module from unintended accesses
    
      // Configure UART pins
      P1SEL0 |= BIT2 | BIT3;                  // set 2-UART pin as second function
    
      __enable_interrupt();
      NVIC_ISER0 = 1 << ((INT_EUSCIA0 - 16) & 31); // Enable eUSCIA0 interrupt in NVIC module
    
      // Configure UART
      UCA0CTLW0 |= UCSWRST;
      UCA0CTLW0 |= UCSSEL__SMCLK;             // Put eUSCI in reset
      // Baud Rate calculation
      // 12000000/(16*9600) = 78.125
      // Fractional portion = 0.125
      // User's Guide Table 21-4: UCBRSx = 0x10
      // UCBRFx = int ( (78.125-78)*16) = 2
      UCA0BR0 = 78;                           // 12000000/16/9600
      UCA0BR1 = 0x00;
      UCA0MCTLW = 0x1000 | UCOS16 | 0x0020;
    
      UCA0CTLW0 &= ~UCSWRST;                  // Initialize eUSCI
      UCA0IE |= UCRXIE;                       // Enable USCI_A0 RX interrupt
    
      while(1)
      {
    	  __no_operation();                       // For debugger
      }
    }
    
    // UART interrupt service routine
    void eUSCIA0IsrHandler(void)
    {
        if (UCA0IFG & UCRXIFG)
        {
        	rx_buffer[bufferIndex] = UCA0RXBUF;
        	bufferIndex++;
          __no_operation();
        }
    }

    I used TeraTerm and the time between the bytes that were transmitted was ~34ms, please take a look at this snapshot.

    My guess is that the PC is sending the bytes faster than the MSP432 can receive them. Could you please take a snapshot of the communication between the PC and the MSP432?? Also please try this example code and let me know if you experience the same problem.

      Thanks,

        David

  • Hi , Jack

    Sorry , I forgot post my declared function.

    I use array to recieved data.

    Actually , I use 430g2553 send sensor data to MSP432 , but MSP432 recieved data was weird , like 666 or 324 etc.

    But I use MSP430 send data to WIFI module(hulk-324) and data is correct , but 432 recieved was incorrect.

    So I test PC to 432 and send string '123456' to 432 and 432 recieved just only '6' , and I sent one number data , like '1', the result is correct , when I sent string(like '123456') the result was incorrect , 432 just recieve '6' .

    Please look again my code , I post UART decline and recieve code and deal with recieve string.

    Want me post all of code of I program ?

    Thank you.

  • Hi , David

    I tested your example and result is perfect , no problem , it's amazing , I don't know why.
    I don't know what happened in my code , this problem is bother me one month , making me do crazy.

    This test result

    I renew my code on my question part , please look again. Or I post all of my program ?

    I try turn of all delay in my code , and result looks a little weird.

    I think you're right , and the new question is 432 recieve first data is ' 6 ' not ' 1 ' ?   how do I improve recieve speed this situation ? increase baud rate ?

    After I must be to use wifi sent data to 432 , so I use PC to test.  

    And I need use delay but delay is too long , I set  12M Hz clock , and I must be to use 8~10 delay 0.03sec to blink LED.

  • Hi , Dennis
    I declared as volatile to RXcounter_3 and close all delay the result is good , but when I use 8 delay 0.03sec in while loop of code in order to blink LED , and the result is weird continuous , just recieve ' 6 ' while I sent ' 123456 ' .

    and when I close all of delay

    So how do I improve this situation ?

**Attention** This is a public forum