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.

RTOS/MSP-EXP430FR5994: Can't get EUSCI_A1 or UESCI_A3 operational

Part Number: MSP-EXP430FR5994


Tool/software: TI-RTOS

I've trying to get either EUSCI_A1or EUSCI_A3 operational in order to talk to a device that has a UART interface.  I've been starting with attempting to get either UART to work in external loopback mode without success.  I have been using the TI-RTOS project "uartecho_MSP_EXP430FR5994_TI" as a starting point.  I've made the following additions in attempt to get the UARTs operational:


In Board.h I added the following defines:

#define Board_UART1                 MSP_EXP430FR5994_UARTA1

#define Board_UART2                 MSP_EXP430FR5994_UARTA2

#define Board_UART3                 MSP_EXP430FR5994_UARTA3


In MSP_EXP430FR5994.h I added some definitions and changed the definition of the UART init as follows:

/*!
 *  @def    MSP_EXP430FR5994_UARTName
 *  @brief  Enum of UART names on the MSP_EXP430FR5994 dev board
 */
typedef enum MSP_EXP430FR5994_UARTName {
    MSP_EXP430FR5994_UARTA0 = 0,
    MSP_EXP430FR5994_UARTA1 = 1,
    MSP_EXP430FR5994_UARTA2 = 2,
    MSP_EXP430FR5994_UARTA3 = 3,

    MSP_EXP430FR5994_UARTCOUNT
} MSP_EXP430FR5994_UARTName;

/*!
 *  @def    MSP_EXP430FR5994_UARTEnable
 *  @brief  Enum of UARTs to init GPIO for UART mode
 */
typedef enum MSP_EXP430FR5994_UARTEnable {
    MSP_EXP430FR5994_UART0_ENABLE = (1u << 0),
    MSP_EXP430FR5994_UART1_ENABLE = (1u << 1),
    MSP_EXP430FR5994_UART2_ENABLE = (1u << 2),
    MSP_EXP430FR5994_UART3_ENABLE = (1u << 3)
} MSP_EXP430FR5994_UARTEnable;

...

extern void MSP_EXP430FR5994_initUART(unsigned int uartEnable);

And in MSP_EXP430FR5994.c I updated the init as follows:

const UARTEUSCIA_HWAttrs uartEUSCIAHWAttrs[MSP_EXP430FR5994_UARTCOUNT] = {
    {
        .baseAddr = EUSCI_A0_BASE,
        .clockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK,
        .bitOrder = EUSCI_A_UART_LSB_FIRST,
        .numBaudrateEntries = sizeof(uartEUSCIABaudrates)/sizeof(UARTEUSCIA_BaudrateConfig),
        .baudrateLUT = uartEUSCIABaudrates
    },
    {
        .baseAddr = EUSCI_A1_BASE,
        .clockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK,
        .bitOrder = EUSCI_A_UART_LSB_FIRST,
        .numBaudrateEntries = sizeof(uartEUSCIABaudrates)/sizeof(UARTEUSCIA_BaudrateConfig),
        .baudrateLUT = uartEUSCIABaudrates
    },
    {
        .baseAddr = EUSCI_A2_BASE,
        .clockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK,
        .bitOrder = EUSCI_A_UART_LSB_FIRST,
        .numBaudrateEntries = sizeof(uartEUSCIABaudrates)/sizeof(UARTEUSCIA_BaudrateConfig),
        .baudrateLUT = uartEUSCIABaudrates
    },
    {
        .baseAddr = EUSCI_A3_BASE,
        .clockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK,
        .bitOrder = EUSCI_A_UART_LSB_FIRST,
        .numBaudrateEntries = sizeof(uartEUSCIABaudrates)/sizeof(UARTEUSCIA_BaudrateConfig),
        .baudrateLUT = uartEUSCIABaudrates
    }
};

const UART_Config UART_config[] = {
    {
        .fxnTablePtr = &UARTEUSCIA_fxnTable,
        .object = &uartEUSCIAObjects[0],
        .hwAttrs = &uartEUSCIAHWAttrs[0]
    },
    {
        .fxnTablePtr = &UARTEUSCIA_fxnTable,
        .object = &uartEUSCIAObjects[1],
        .hwAttrs = &uartEUSCIAHWAttrs[1]
    },
    {
        .fxnTablePtr = &UARTEUSCIA_fxnTable,
        .object = &uartEUSCIAObjects[2],
        .hwAttrs = &uartEUSCIAHWAttrs[2]
    },
    {
        .fxnTablePtr = &UARTEUSCIA_fxnTable,
        .object = &uartEUSCIAObjects[3],
        .hwAttrs = &uartEUSCIAHWAttrs[3]
    },
    {NULL, NULL, NULL}
};


/*
 *  ======== MSP_EXP430FR5994_initUART ========
 */
void MSP_EXP430FR5994_initUART(unsigned int uartEnable)
{
    if(uartEnable & MSP_EXP430FR5994_UART0_ENABLE)
    {
        /* P2.0,1 = EUSCI_A0 TXD/RXD */
        GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2,
            GPIO_PIN0, GPIO_SECONDARY_MODULE_FUNCTION);
        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P2,
            GPIO_PIN1, GPIO_SECONDARY_MODULE_FUNCTION);
    }

    if(uartEnable & MSP_EXP430FR5994_UART1_ENABLE)
    {
        /* P2.5,6 = EUSCI_A1 TXD/RXD */
        GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2,
            GPIO_PIN5, GPIO_SECONDARY_MODULE_FUNCTION);
        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P2,
            GPIO_PIN6, GPIO_SECONDARY_MODULE_FUNCTION);
    }

    if(uartEnable & MSP_EXP430FR5994_UART2_ENABLE)
    {
        /* P5.4,5 = EUSCI_A2 TXD/RXD */
        GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P5,
            GPIO_PIN4, GPIO_PRIMARY_MODULE_FUNCTION);
        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5,
            GPIO_PIN5, GPIO_PRIMARY_MODULE_FUNCTION);
    }

    if(uartEnable & MSP_EXP430FR5994_UART3_ENABLE)
    {
        /* P6.0,1 = EUSCI_A3 TXD/RXD */
        GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P6,
            GPIO_PIN0, GPIO_PRIMARY_MODULE_FUNCTION);
        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P6,
            GPIO_PIN1, GPIO_PRIMARY_MODULE_FUNCTION);
    }

    /* Initialize the UART driver */
    UART_init();
}

I set it up this way so I can pick and choose which UARTs to enable and disable.  I've tried each individually and I have verified to the best of my knowledge that the GPIOs are properly setup for each UART.  I then added the following to the TI-RTOS XCD config file:

halHwi.create(24, "&UARTEUSCIA_hwiIntFxn", hwiParams); // UARTA3
halHwi.create(43, "&UARTEUSCIA_hwiIntFxn", hwiParams); // UARTA1

to establish the ISRs for each UART.  I then changed the echoFxn task as follows:

Void echoFxn(UArg arg0, UArg arg1)
{
    UART_Handle uartLog;
    UART_Handle uartLoopback;
    UART_Params uartParams;

    /* Create a UART with data processing off. */
    UART_Params_init(&uartParams);
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readReturnMode = UART_RETURN_FULL;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.baudRate = 9600;
    uartLog = UART_open(Board_UART0, &uartParams);

    /* Create a UART with data processing off */
    UART_Params_init(&uartParams);
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readReturnMode = UART_RETURN_FULL;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.baudRate = 9600;
    uartLoopback = UART_open(Board_UART3, &uartParams);

    if((uartLog != NULL) && (uartLoopback != NULL))
    {
        while(1)
        {
            char c;
            char data = 'k';

            UART_write(uartLoopback, &data, 1);
            UART_read(uartLoopback, &c, 1);
            UART_write(uartLog, &c, 1);
        }
    }
    else
    {
        /* Close either UART if they are open */
        if(uartLog != NULL)
        {
            UART_close(uartLog);
        }
        if(uartLoopback != NULL)
        {
            UART_close(uartLoopback);
        }
    }
}

In this case I am testing loopback on UART3.  I have P6.0 and P6.1 jumpered together on the MSP-EXP430FR5994 board.  The above code successfully calls UART_write to the loopback UART but will then block indefinitely on UART_read.  I've also tried this with UART1, in which case I jumpered P2.5 and P2.6 together on the MSP-EXP430FR5994 board.  In either case, I can't transmit out UART1 or UART3 and then read what was sent.  What am I missing in my setup for UART1 and UART3?

  • Are you able to get the examples working outside of RTOS, for example with C or DriverLib code? I'm not suggesting this as a long-term solution, only as a means of isolating the issue. I definitely do not expect a hardware problem given the use of the MSP-EXP430FR5994 with pins on the available header rows. You could try to use the debugger and find any register differences that exist between working and non-working implementations, particularly with the port and eUSCI peripherals. If you still encounter difficulties after further attempts then perhaps send me the project with your changes and I will attempt to find the problem.

    Regards,
    Ryan
  • I have not found an example project yet that is setup to use any UART other than EUSCI_A0.  However, I did find the example "msp430FR599x_euscia0_uart_04" which is a register level example to loopback on EUSCI_A0.  I changed all register references to "A0" to "A1" and I was able to get loopback working on EUSCI_A1.  I haven't gone through the registers yet to determine what is going on, but I'll post back when I find the difference.

  • I found the issue.  The UARTEUSCIA_hwiIntFxn function is a generic ISR for all ESUCIA UARTs, but it takes an index parameter to let it know which UART it is acting upon.  So the RX interrupt for EUSCI_A1 was looking at the registers for EUSCI_A0.  To fix it, I had to put the following in the XDC file.

    var hwiParams = new halHwi.Params();
    
    hwiParams.arg = 0;
    halHwi.create(48, "&UARTEUSCIA_hwiIntFxn", hwiParams); // UARTA0
    hwiParams.arg = 1;
    halHwi.create(43, "&UARTEUSCIA_hwiIntFxn", hwiParams); // UARTA1

    Setting hwParams.arg = 1 for the UART1 interrupts then setup the ISR to look at the registers for the correct UART.  I can now loopback on EUSCI_A1.

**Attention** This is a public forum