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.

MSP430FR2676: UART Interface Issue

Part Number: MSP430FR2676
Other Parts Discussed in Thread: CAPTIVATE-FR2676, CAPTIVATE-PGMR

Hello All,

I am new to MSP430, However i have worked on TM4C Micro-controller using Tiva C SDK. 

I am using MSP430FR2676 MCU for which I have CAPTIVATE-FR2676 with a CAPTIVATE-PGMR board 

I want to interface a sensor and a MCU using UART communication on MSP430FR2676. For which i created an empty project and  imported MSP430FR2xx_4xx driver library.

I am refering the eusci_a_uart_ex1_loopbackAdvanced example code from the driverlib and included the required part in my code.

Now for two Uart interface i am using eUSCI A0 and eUSCI A1 on pins P5.1(UCA0RXD), P5.2(UCA0TXD) and P2.6(UCA1RXD), P2.5(UCA1TXD) respectively.

As on  CAPTIVATE-FR2676 P5.1 and P5.2 are avliable i tried testing the UARt communicationon the same.

However i am not able to establish UART communication on the  P5.1 and P5.2 port. Can anyone please help with the solution for the same?

Attached is the code snippet for eUSCI A0 

//Communication UART Port
#define EUSCA0_UART_PORT     GPIO_PORT_P5
#define EUSCA0_UART_RX          GPIO_PIN1
#define EUSCA0_UART_TX          GPIO_PIN2

#define EUSCA0_UART_FUNCTION_MODE_TXD       GPIO_PRIMARY_MODULE_FUNCTION
#define EUSCA0_UART_FUNCTION_MODE_RXD       GPIO_PRIMARY_MODULE_FUNCTION



void IntClock(void) { //Set ACLK = REFOCLK with clock divider of 1 MAP_CS_initClockSignal(CS_ACLK,CS_REFOCLK_SELECT,CS_CLOCK_DIVIDER_1); //Set SMCLK = DCO with frequency divider of 1 MAP_CS_initClockSignal(CS_SMCLK,CS_DCOCLKDIV_SELECT,CS_CLOCK_DIVIDER_1); //Set MCLK = DCO with frequency divider of 1 MAP_CS_initClockSignal(CS_MCLK,CS_DCOCLKDIV_SELECT,CS_CLOCK_DIVIDER_1); } int UARTInit(void) { MAP_GPIO_setAsPeripheralModuleFunctionInputPin(EUSCA0_UART_PORT, EUSCA0_UART_TX, EUSCA0_UART_FUNCTION_MODE_TXD); MAP_GPIO_setAsPeripheralModuleFunctionInputPin(EUSCA0_UART_PORT, EUSCA0_UART_RX, EUSCA0_UART_FUNCTION_MODE_RXD); //Configure UART //SMCLK = 1MHz, Baudrate = 115200 //UCBRx = 8, UCBRFx = 0, UCBRSx = 0xD6, UCOS16 = 0 CommUartParam.selectClockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK; CommUartParam.clockPrescalar = 8; CommUartParam.firstModReg = 0; CommUartParam.secondModReg = 0xD6; CommUartParam.parity = EUSCI_A_UART_NO_PARITY; CommUartParam.msborLsbFirst = EUSCI_A_UART_LSB_FIRST; CommUartParam.numberofStopBits = EUSCI_A_UART_ONE_STOP_BIT; CommUartParam.uartMode = EUSCI_A_UART_MODE; CommUartParam.overSampling = EUSCI_A_UART_LOW_FREQUENCY_BAUDRATE_GENERATION; if (STATUS_FAIL == EUSCI_A_UART_init(EUSCI_A0_BASE, &CommUartParam)) { return ERROR; } // Enable UART MAP_EUSCI_A_UART_enable(EUSCI_A0_BASE); // Clear USCI_A0 interrupt MAP_EUSCI_A_UART_clearInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT); // Enable USCI_A0 RX interrupt MAP_EUSCI_A_UART_enableInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT); return SUCCESS; } void UARTSend(const uint8_t *pTransmitBuffer, uint8_t ui8Len) { while(ui8Len--) { // Load data onto buffer MAP_EUSCI_A_UART_transmitData(EUSCI_A0_BASE, *pTransmitBuffer++); } } #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=USCI_A0_VECTOR __interrupt #elif defined(__GNUC__) __attribute__((interrupt(USCI_A0_VECTOR))) #endif void EUSCI_A0_ISR(void) { switch(__even_in_range(UCA0IV,USCI_UART_UCTXCPTIFG)) { case USCI_NONE: break; case USCI_UART_UCRXIFG: ui8RxData = MAP_EUSCI_A_UART_receiveData(EUSCI_A0_BASE); if((ui8CommRxData == NULL) || (ui8CommIndex >= BUFFER_SIZE)) { //Call Response or status Handling function memset(ui8Buffer,'\0',COMMUNICATION_BUFFER_SIZE-1); ui8Index = 0; } else { ui8Buffer[ui8Index++] = ui8RxData; } break; case USCI_UART_UCTXIFG: break; case USCI_UART_UCSTTIFG: break; case USCI_UART_UCTXCPTIFG: break; } }

As the UART was not working on above pins i changed the pins to P1.4 and P1.5 with same code snippet but here only UART send is working,

But not UART receive is not working so Please check and let me know if i am missing out any config steps ?

Please help me at the earliest

Thanks and regards

Utkarash

  • In order to get UART function on P5.1/2 you need to set SYSCFG3:USCIA0RMP [Ref data sheet (SLASEO5C) Table  6-11 and User Guide (SLAU445I) Table 1-32]. 

    Last I looked there wasn't a driverlib function to do this, so just add:

    > SYSCFG3 |= USCIA0RMP;  // Use alternate (P5) eUSCI pins per data sheet Table 6-11

    [It's possible the header file defines this as "USCIARMP" rather than "USCIA0RMP" so if one fails try the other.]

    -------

    For the receive problem: Don't forget to "__enable_interrupt();" somewhere in main(). Unlike the Cortex-M, the MSP430 starts up with interrupts (GIE) disabled.

  • Hello Bruce,

    Thank you for your suggestion and help,

    I tried adding the pin remapping part for my UARt config as mentioned below, However it did not work.

    MAP_GPIO_setAsPeripheralModuleFunctionInputPin(EUSCA0_UART_PORT, EUSCA0_UART_TX, EUSCA0_UART_FUNCTION_MODE_TXD);
        MAP_GPIO_setAsPeripheralModuleFunctionInputPin(EUSCA0_UART_PORT, EUSCA0_UART_RX, EUSCA0_UART_FUNCTION_MODE_RXD);
    
        SYSCFG3 |= USCIA0RMP;
    
    MAP_GPIO_setAsPeripheralModuleFunctionInputPin(EUSCA0_UART_PORT, EUSCA0_UART_TX, EUSCA0_UART_FUNCTION_MODE_TXD);
        MAP_GPIO_setAsPeripheralModuleFunctionInputPin(EUSCA0_UART_PORT, EUSCA0_UART_RX, EUSCA0_UART_FUNCTION_MODE_RXD);
    
        //Configure UART
       //SMCLK = 1MHz, Baudrate = 115200
       //UCBRx = 8, UCBRFx = 0, UCBRSx = 0xD6, UCOS16 = 0
    
       CommUartParam.selectClockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK;
       CommUartParam.clockPrescalar = 8;
       CommUartParam.firstModReg = 0;
       CommUartParam.secondModReg = 0xD6;
       CommUartParam.parity = EUSCI_A_UART_NO_PARITY;
       CommUartParam.msborLsbFirst = EUSCI_A_UART_LSB_FIRST;
       CommUartParam.numberofStopBits = EUSCI_A_UART_ONE_STOP_BIT;
       CommUartParam.uartMode = EUSCI_A_UART_MODE;
       CommUartParam.overSampling = EUSCI_A_UART_LOW_FREQUENCY_BAUDRATE_GENERATION;
    
       if (STATUS_FAIL == EUSCI_A_UART_init(EUSCI_A0_BASE, &CommUartParam))
       {
           return ERROR;
       }
    
       // Enable UART
       MAP_EUSCI_A_UART_enable(EUSCI_A0_BASE);
    
       // Clear USCI_A0 interrupt
       MAP_EUSCI_A_UART_clearInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT);
    
       // Enable USCI_A0 RX interrupt
       MAP_EUSCI_A_UART_enableInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT);
    

    For UART receive problem in main i am using "__enable_interrupt();" but still receive issue remains, 

    However when i shorted the UART TX pin to RX as shown in driver lib example i was able to get interrupt but when i connect external TTL board and try to send message on UART i am not getting any interrupt.

    Is there any pull up registers required while connecting UART to external Boards.

    I have already shorted GND of both the Borads.

    Please help if i am missing out on something.

    Thanks and regards

    Utkarash

  • Could you describe (1) how you're doing the connection, and (2) what the other board is?

    1) As I read the CAPTIVATE-FR2676 schematics [slar157.zip], the J2->J6 path connects to UCA0 on P1.4/P1.5, not P5.1/P5.2. Is that where you're connecting?

    2) The thing to check on the other board is the bit-rate (clock), since that's the main thing loopback doesn't test.

  • 1) As I read the CAPTIVATE-FR2676 schematics [slar157.zip], the J2->J6 path connects to UCA0 on P1.4/P1.5, not P5.1/P5.2. Is that where you're connecting?

    -- I have Connected P5.1 and P5.2 to a USB to TLL Board and that board i have connected to my PC where i am checking messages on Serial terminal.

    2) The thing to check on the other board is the bit-rate (clock), since that's the main thing loopback doesn't test.

    Do you mean to say the clock frequency of the other board should match with Clock frequency of MSP430 configured for UART?

    Also I have tried the loop back with same USB to TTL board so if clock is the issue will it not work with USB to TTL board

  • Hello Bruce,

    My UART Transmit and receive issue is resolved there was GPIO periph function  initi and remapping issue which is now solved

    Thank You For all your suggestion the remapping code helped me.

    Thanks and Regards

    Utkarash

**Attention** This is a public forum