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.

MSP-EXP432P401R: Display_Handle access second UART Display

Part Number: MSP-EXP432P401R

Hello everybody,

this might be a stupid question, but how do I change the display I acctually want to access?
I have two UART Displays and due to the standard defintion


Display_Handle hSerial = Display_open(Display_Type_UART, NULL);

calls the first display only. How can I set the ID correct to access the second display? I tried "1" and "0" however it's always the first display chosen as output.

Thanks for your help,

all the best
Aaron

  • Hi Aaron,

    Actually, the same Display_open() function can be used to open both displays, but it's not done using the second function parameter. I found the "display_MSP_EXP432P401R_tirtos_ccs" code example in TI Resource Explorer. In the 'display.c', you can see where two displays are opened: LCD and UART. They use the same function and parameters but are set equal to different structures, hLcd and hSerial.

    /* Open both an available LCD display and an UART display.
     * Whether the open call is successful depends on what is present in the
     * Display_config[] array of the driver configuration file.
     */
    Display_Handle hLcd = Display_open(Display_Type_LCD, &params);
    Display_Handle hSerial = Display_open(Display_Type_UART, &params);

    You could change this code to something like this.

    Display_Handle hLcd1 = Display_open(Display_Type_LCD, &params);
    Display_Handle hLcd2 = Display_open(Display_Type_LCD, &params);

    For your code, you will also need to configure the displays (e.g. type, baud rate, etc.) by modifying the .syscfg file in SysConfig.

  • Hi James,
    thank you very much for your answer. Maybe I should specify. I tried the proposed solution of yours beforehand:

    Display_Params paramsDP;
    Display_Params_init(&paramsDP);
    paramsDP.lineClearMode = DISPLAY_CLEAR_BOTH;
    
    Display_Handle hUARTXDS = Display_open(Display_Type_UART, &paramsDP);
    Display_Handle hUARTXP = Display_open(Display_Type_UART, &paramsDP);

    Both Displays are defined in the syscfg

    However "&params" doesn't work. When adding the second Display_Open function, even the first display doesn't work anymore.

    So I imagine the problem is with the second parameter in the "Display_open" function.

    All the best and thanks for trying to help me.

  • I think this might be also a problem:

     /*
     * @note        Only one display is opened. If the type matches more than one,
     *              only the first one found in the Display_config array is opened.
     */

    As stated in display.h

  • Due to debugging I found out that the problem seems to be with the Display_print - function. The program is running proberly until this function is reached.

    This are the Variables BEFORE the Display_print - function is called:

    The program stays in an endless loop, after calling the funtion. Even a line after that isn't reached.

  • This would be the code in ti_drivers_config.c

    /*
     *  ============================= Display =============================
     */
    
    #include <ti/display/Display.h>
    #include <ti/display/DisplayUart.h>
    
    #define Display_UARTBUFFERSIZE 1024
    static char displayUARTBuffer[Display_UARTBUFFERSIZE];
    
    DisplayUart_Object displayUartObject;
    
    const DisplayUart_HWAttrs displayUartHWAttrs = {
        .uartIdx      = XDS110_UART,
        .baudRate     = 115200,
        .mutexTimeout = (unsigned int)(-1),
        .strBuf       = displayUARTBuffer,
        .strBufLen    = Display_UARTBUFFERSIZE
    };
    
    const Display_Config Display_config[] = {
        /* XPort_Display */
        {
            .fxnTablePtr = &DisplayUartMin_fxnTable,
            .object      = &displayUartObject,
            .hwAttrs     = &displayUartHWAttrs
        },
        /* XDS110_Display */
        {
            .fxnTablePtr = &DisplayUartMin_fxnTable,
            .object      = &displayUartObject,
            .hwAttrs     = &displayUartHWAttrs
        },
    };
    
    const uint_least8_t Display_count = 2;

    I'm kind of wondering why there is no statement for the displays in the header file, is there an explanation for that?

  • Thanks for sharing the detailed updates. I'm starting to suspect that the latest issue may be caused by the XDS110_UART hardware selection. For both Display instances in SysConfig, can you try changing "Use Hardware" to "none"? Otherwise, both displays may be trying to use the same backchannel UART. You'll still need to call Display_open() for each display.

  • Thanks for helping, again. I created a new syscfg - file, since I want to port it later on to a board with a little different pin layout. Because of that I don't have the possibility to choose between "Use Hardware" and "none", I haven't implemented "Hardware" in the Sys Config.

  • This is my current config:

    Thank you so much for helping! :)

  • For now, you may want to use the default config file, just in case there's an issue with the custom version. I think what's important is making sure the UART port/pin isn't the same between the two display instances.

  • Hello everybody,
    I finally managed to resolve my issue with the output of the two displays:

    The issue is in the generated version of the “ti_drivers_config.c” file. In the generated version the SystConfig generates only ONE instance of DisplayUart_HWAttrs and DisplayUart_Object:

    DisplayUart_Object displayUartObject;
    
    const DisplayUart_HWAttrs displayUartHWAttrs = {
        .uartIdx      = XPORT_UART,
        .baudRate     = 115200,
        .mutexTimeout = (unsigned int)(-1),
        .strBuf       = displayUARTBuffer,
        .strBufLen    = Display_UARTBUFFERSIZE
    };
    
    const Display_Config Display_config[] = {
        /* XDS110_Display */
        /* XDS110 UART */
        {
            .fxnTablePtr = &DisplayUartMin_fxnTable,
            .object      = &displayUartObject,
            .hwAttrs     = &displayUartHWAttrs
        },
        /* XPort_Display */
        {
            .fxnTablePtr = &DisplayUartMin_fxnTable,
            .object      = &displayUartObject,
            .hwAttrs     = &displayUartHWAttrs
        },
    };

    As you can see the addresses in the Display_Config Table are the same for both instances. Therefore, when opening both displays the code crashes. When just opening one of the displays, always the same will be accessed since the other isn’t initialised at all.

    You’ll resolve the issue when creating manually the second instance:

    DisplayUart_Object displayUartObject_XDS;
    DisplayUart_Object displayUartObject_XP;
    
    const DisplayUart_HWAttrs displayUartHWAttrs_XDS = {
        .uartIdx      = XDS110_UART,
        .baudRate     = 115200,
        .mutexTimeout = (unsigned int)(-1),
        .strBuf       = displayUARTBuffer,
        .strBufLen    = Display_UARTBUFFERSIZE
    };
    
    const DisplayUart_HWAttrs displayUartHWAttrs_XP = {
        .uartIdx      = XPORT_UART,
        .baudRate     = 115200,
        .mutexTimeout = (unsigned int)(-1),
        .strBuf       = displayUARTBuffer,
        .strBufLen    = Display_UARTBUFFERSIZE
    };
    
    const Display_Config Display_config[] = {
        /* XDS110_Display */
        /* XDS110 UART */
        {
            .fxnTablePtr = &DisplayUartMin_fxnTable,
            .object      = &displayUartObject_XDS,
            .hwAttrs     = &displayUartHWAttrs_XDS
        },
        /* XPort_Display */
        {
            .fxnTablePtr = &DisplayUartMin_fxnTable,
            .object      = &displayUartObject_XP,
            .hwAttrs     = &displayUartHWAttrs_XP
        },
    };
    
    const uint_least8_t Display_count = 2;
    

    Now you’re able to access both displays but take care that not both of them are “opened” at the same time, because this will result in a crash of the program.

    I wrote two functions that resolve this issue for me and close the Display every time after using it. This should work with any type of display:

    //Display printf Functions
    void XDS_printf(char *string, ...)        //XDS110 - Display - Error Function
    {
        Display_Params paramsDP;
        Display_Params_init(&paramsDP);
        hUARTXDS = Display_open(0, &paramsDP);      //first param is the ID
    
        //Debug
        va_list va;
        va_start(va, string);
        hUARTXDS->fxnTablePtr->vprintfFxn(hUARTXDS, 1, 0, string, va);
        va_end(va);
    
        Display_close(hUARTXDS);
    }
    
    void XP_printf(char *string, ...)         //XPort - Display - Error Function
    {
        Display_Params paramsDP;
        Display_Params_init(&paramsDP);
        hUARTXP = Display_open(1, &paramsDP);       //first param is the ID
    
        //Debug
        va_list va;
        va_start(va, string);
        hUARTXP->fxnTablePtr->vprintfFxn(hUARTXP, 1, 0, string, va);
        va_end(va);
    
        Display_close(hUARTXP);
    }
    

    Take care that the Display_open - function takes the ID (number in the "Display_Config") as first parameter.
    If you have any questions concerning the code, please reach out to me.
    All the best
    Aaron

    P.s.: @TI-Developers: Could you please resolve the issue of the SystConfig – manager?