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.

CCS/TM4C123GE6PM: Using UART printf beyond just through USB (using UART1 instead for bluetooth)

Part Number: TM4C123GE6PM

Tool/software: Code Composer Studio

Hello,

I was using the UART console example from TI's resource explorer to try to figure out to implement printf functions to display data to PuTTy. After combing through the code, I noticed that the example was specifically coded to run through a USB and UART0.

I was wondering if there was a way I could manipulate this existing program to use UART1 instead where my bluetooth module is connected.

I have attached the example code below in a .txt file. /cfs-file/__key/communityserver-discussions-components-files/908/uartconsole.txt

  • Henry,

    First you need to add UART1 into the "board" files. We populate them enough so all of the out of box examples work. We don't put all the peripherals in since some are mutually exclusive. So you need to do the following (assuming you still want to use UART0)

    EK_TM4C1294XL.h: add in UART1. For examples
    typedef enum EK_TM4C1294XL_UARTName {
    EK_TM4C1294XL_UART0 = 0,
    EK_TM4C1294XL_UART1 = 1,

    EK_TM4C1294XL_UARTCOUNT
    } EK_TM4C1294XL_UARTName;

    note: the EK_TM4C1294XL_UARTCOUNT value automatically increases

    EK_TM4C1294XL.c: fill in the index 1 location for uartTivaHWAttrs and UART_config

    Board.h: if desired add Board_UART1. We have this file to allow us to have examples work on multiple boards and devices.
    #define Board_UART0 EK_TM4C1294XL_UART0
    #define Board_UART1 EK_TM4C1294XL_UART1

    Next you need to change uartconsole.c to use UART1
    freopen("UART:1", "w", stdout);
    freopen("UART:1", "r", stdin);

    Finally change UARTUtils.c to add in the second index

    #define NUM_PORTS 2
    static UARTPorts ports[NUM_PORTS] = {
    {NULL, Board_UART0, 0, false}
    {NULL, Board_UART1, 0, false}
    };

    I just noticed the comments/field names are not the best on the UARTPorts structure...

    Todd
  • Thank you for your help.

    **A note for other users**
    Make sure to verify that you are using your specific board name in your #define(s) statements.