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.

LAUNCHXL-CC1312R1: Adding second UART

Part Number: LAUNCHXL-CC1312R1
Other Parts Discussed in Thread: CC1352R, CC1312R

I would like to use the back channel UART and another one. I poked around in the .h files and found that only one UART (UART0) is defined. Is there an easy way to add one, or do I need to add all the bits and pieces by hand?

  • I did a quick look and for some reason the second UART is not defined in the LAUNCHXL CC1312R files. If you look at the board files for CC1352R you will find the following code that you should be able to copy into your project. In the first file listed you can map the UART pins to the DIOs you want to use.:

    CC1352R1_LAUNCHXL.h

    /* UART Board */
    #define CC1352R1_LAUNCHXL_UART0_RX              IOID_12         /* RXD */
    #define CC1352R1_LAUNCHXL_UART0_TX              IOID_13         /* TXD */
    #define CC1352R1_LAUNCHXL_UART0_CTS             IOID_19         /* CTS */
    #define CC1352R1_LAUNCHXL_UART0_RTS             IOID_18         /* RTS */
    #define CC1352R1_LAUNCHXL_UART1_RX              PIN_UNASSIGNED
    #define CC1352R1_LAUNCHXL_UART1_TX              PIN_UNASSIGNED
    #define CC1352R1_LAUNCHXL_UART1_CTS             PIN_UNASSIGNED
    #define CC1352R1_LAUNCHXL_UART1_RTS             PIN_UNASSIGNED



    CC1352R1_LAUNCHXL.c

    const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[CC1352R1_LAUNCHXL_UARTCOUNT] = {
        {
            .baseAddr       = UART0_BASE,
            .powerMngrId    = PowerCC26XX_PERIPH_UART0,
            .intNum         = INT_UART0_COMB,
            .intPriority    = ~0,
            .swiPriority    = 0,
            .txPin          = CC1352R1_LAUNCHXL_UART0_TX,
            .rxPin          = CC1352R1_LAUNCHXL_UART0_RX,
            .ctsPin         = PIN_UNASSIGNED,
            .rtsPin         = PIN_UNASSIGNED,
            .ringBufPtr     = uartCC26XXRingBuffer[CC1352R1_LAUNCHXL_UART0],
            .ringBufSize    = sizeof(uartCC26XXRingBuffer[CC1352R1_LAUNCHXL_UART0]),
            .txIntFifoThr   = UARTCC26XX_FIFO_THRESHOLD_1_8,
            .rxIntFifoThr   = UARTCC26XX_FIFO_THRESHOLD_4_8,
            .errorFxn       = NULL
        },
        {
            .baseAddr       = UART1_BASE,
            .powerMngrId    = PowerCC26X2_PERIPH_UART1,
            .intNum         = INT_UART1_COMB,
            .intPriority    = ~0,
            .swiPriority    = 0,
            .txPin          = CC1352R1_LAUNCHXL_UART1_TX,
            .rxPin          = CC1352R1_LAUNCHXL_UART1_RX,
            .ctsPin         = PIN_UNASSIGNED,
            .rtsPin         = PIN_UNASSIGNED,
            .ringBufPtr     = uartCC26XXRingBuffer[CC1352R1_LAUNCHXL_UART1],
            .ringBufSize    = sizeof(uartCC26XXRingBuffer[CC1352R1_LAUNCHXL_UART1]),
            .txIntFifoThr   = UARTCC26XX_FIFO_THRESHOLD_1_8,
            .rxIntFifoThr   = UARTCC26XX_FIFO_THRESHOLD_4_8,
            .errorFxn       = NULL
        }
    };

  • TER,

    That looks like the correct implementation, but this will not work since the powerMngerId for UART1 has not been added to the power Drivers.

    This will not work unless we add the macro for PowerCC26X2_PERIPH_UART1, and also add the a new power resource record to the power resourceDB in the power driver.

    In addition to the configuration you posted above, you and the customer will need to add this to PowerCC26XX.h:

    .
    .
    .
    .
     
    #define PowerCC26XX_PERIPH_UART1   7  /*!< Resource ID: UART 1 */
    
    .
    .
    .
    
    

    Also you will need to add a new element to the power manager DB inside PowerCC26XX.c

    /* resource database */
    const PowerCC26XX_ResourceRecord resourceDB[PowerCC26XX_NUMRESOURCES] = {
        { PowerCC26XX_PERIPH  | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_TIMER0 },    /* PERIPH_GPT0 */
        { PowerCC26XX_PERIPH  | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_TIMER1 },    /* PERIPH_GPT1 */
        { PowerCC26XX_PERIPH  | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_TIMER2 },    /* PERIPH_GPT2 */
        { PowerCC26XX_PERIPH  | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_TIMER3 },    /* PERIPH_GPT3 */
        { PowerCC26XX_PERIPH  | PowerCC26XX_DOMAIN_SERIAL, PRCM_PERIPH_SSI0 },      /* PERIPH_SSI0 */
        { PowerCC26XX_PERIPH  | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_SSI1 },      /* PERIPH_SSI1 */
        { PowerCC26XX_PERIPH  | PowerCC26XX_DOMAIN_SERIAL, PRCM_PERIPH_UART0 },     /* PERIPH_UART0 */
        { PowerCC26XX_PERIPH  | PowerCC26XX_DOMAIN_SERIAL, PRCM_PERIPH_UART1 },     /* PERIPH_UART1 */
        { PowerCC26XX_PERIPH  | PowerCC26XX_DOMAIN_SERIAL, PRCM_PERIPH_I2C0 },      /* PERIPH_I2C0 */
        { PowerCC26XX_PERIPH  | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_TRNG },      /* PERIPH_TRNG */
        { PowerCC26XX_PERIPH  | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_GPIO },      /* PERIPH_GPIO */
        { PowerCC26XX_PERIPH  | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_UDMA },      /* PERIPH_UDMA */
        { PowerCC26XX_PERIPH  | PowerCC26XX_DOMAIN_PERIPH, PRCM_PERIPH_CRYPTO },    /* PERIPH_CRYPTO */
        { PowerCC26XX_PERIPH  | PowerCC26XX_PERIPH_UDMA, PRCM_PERIPH_I2S },         /* PERIPH_I2S */
        { PowerCC26XX_SPECIAL | PowerCC26XX_DOMAIN_RFCORE, 0 },                     /* PERIPH_RFCORE */
        { PowerCC26XX_SPECIAL | PowerCC26XX_NOPARENT, 1 },                          /* XOSC_HF */
        { PowerCC26XX_DOMAIN  | PowerCC26XX_NOPARENT, PRCM_DOMAIN_PERIPH },         /* DOMAIN_PERIPH */
        { PowerCC26XX_DOMAIN  | PowerCC26XX_NOPARENT, PRCM_DOMAIN_SERIAL },         /* DOMAIN_SERIAL */
        { PowerCC26XX_DOMAIN  | PowerCC26XX_NOPARENT, PRCM_DOMAIN_RFCORE },         /* DOMAIN_RFCORE */
        { PowerCC26XX_SPECIAL | PowerCC26XX_NOPARENT, 2 }                           /* DOMAIN_SYSBUS */
    };

  • Thanks guys, this is *exactly* why I asked the question here rather than bulling through on my own!
  • Another question:
    Where is uartCC26XXRingBuffer[] defined? Does it have room for two ring buffers?
  • I am going to answer my own question. I need to add an entry to this:

    typedef enum CC1312R1_LAUNCHXL_UARTName {
    CC1312R1_LAUNCHXL_UART0 = 0,

    CC1312R1_LAUNCHXL_UARTCOUNT
    } CC1312R1_LAUNCHXL_UARTName;

    So I can get UARTCOUNT to 2!
  • AB: For me it looks like these are already defined in the PowerCC26X2.h/c files 

  • TER,

    It is, but the drivers and Definitions used by default in the board and LAunchXl files are from UARTCC26XX.h.

    /*
     *  =============================== UART ===============================
     */
    #include <ti/drivers/UART.h>
    #include <ti/drivers/uart/UARTCC26XX.h>
    
    UARTCC26XX_Object uartCC26XXObjects[CC1312R1_LAUNCHXL_UARTCOUNT];
    
    uint8_t uartCC26XXRingBuffer[CC1312R1_LAUNCHXL_UARTCOUNT][32];
    
    const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[CC1312R1_LAUNCHXL_UARTCOUNT] = {
        {
            .baseAddr       = UART0_BASE,
            .powerMngrId    = PowerCC26XX_PERIPH_UART0,
            .intNum         = INT_UART0_COMB,
            .intPriority    = ~0,
            .swiPriority    = 0,
            .txPin          = CC1312R1_LAUNCHXL_UART_TX,
            .rxPin          = CC1312R1_LAUNCHXL_UART_RX,
            .ctsPin         = PIN_UNASSIGNED,
            .rtsPin         = PIN_UNASSIGNED,
            .ringBufPtr     = uartCC26XXRingBuffer[CC1312R1_LAUNCHXL_UART0],
            .ringBufSize    = sizeof(uartCC26XXRingBuffer[CC1312R1_LAUNCHXL_UART0]),
            .txIntFifoThr   = UARTCC26XX_FIFO_THRESHOLD_1_8,
            .rxIntFifoThr   = UARTCC26XX_FIFO_THRESHOLD_4_8,
            .errorFxn       = NULL
        },
        {
            .baseAddr       = UART1_BASE,
            .powerMngrId    = PowerCC26XX_PERIPH_UART0,
            .intNum         = INT_UART1_COMB,
            .intPriority    = ~0,
            .swiPriority    = 0,
            .txPin          = CC1312R1_LAUNCHXL_UART1_TX,
            .rxPin          = CC1312R1_LAUNCHXL_UART1_RX,
            .ctsPin         = PIN_UNASSIGNED,
            .rtsPin         = PIN_UNASSIGNED,
            .ringBufPtr     = uartCC26XXRingBuffer[CC1312R1_LAUNCHXL_UART1],
            .ringBufSize    = sizeof(uartCC26XXRingBuffer[CC1312R1_LAUNCHXL_UART1]),
            .txIntFifoThr   = UARTCC26XX_FIFO_THRESHOLD_1_8,
            .rxIntFifoThr   = UARTCC26XX_FIFO_THRESHOLD_4_8,
            .errorFxn       = NULL
        }
    };
    
    const UART_Config UART_config[CC1312R1_LAUNCHXL_UARTCOUNT] = {
          {
           .fxnTablePtr = &UARTCC26XX_fxnTable,
           .object      = &uartCC26XXObjects[CC1312R1_LAUNCHXL_UART0],
           .hwAttrs     = &uartCC26XXHWAttrs[CC1312R1_LAUNCHXL_UART0]
          },
          {
           .fxnTablePtr = &UARTCC26XX_fxnTable,
           .object      = &uartCC26XXObjects[CC1312R1_LAUNCHXL_UART1],
           .hwAttrs     = &uartCC26XXHWAttrs[CC1312R1_LAUNCHXL_UART1]
          },
    };
    
    const uint_least8_t UART_count = CC1312R1_LAUNCHXL_UARTCOUNT;
    

    Unless you also change those dependencies you won't be able to see those definitions. 

    Regards,

    AB