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/EK-TM4C123GXL: UART_read() to receive data continuously.

Part Number: EK-TM4C123GXL
Other Parts Discussed in Thread: ENERGIA

Tool/software: TI-RTOS

Hello,

I am working on interfacing multiple sensors to TM4C123G microcontroller and read the data via UART and store it in a buffer and transmit the same via USB interface. I am facing issues in reading the data via UART, it just returns nothing when I try to read and blocks my next statements. Following is a snippet of the code,

Void echoFxn(UArg arg0, UArg arg1)
{

    uart_multiple_init();
    while(1)
    {
        //UART_read(uart1, a, sizeof(a));
       // UART_read(uart2, c, sizeof(c));
        UART_read(uart3, b, sizeof(b));
        UART_write(uart3, b, sizeof(b));
    }

}

static void uart_multiple_init()
{
     //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 = 115200;

    uart = UART_open(Board_UART0, &uartParams);

    if (uart == NULL) {
        System_printf("NOT opened");
        System_flush();
         //Turn on user LED
        GPIO_write(Board_LED0, Board_LED_ON);
        System_abort("Error opening the UART");
    }

    UART_Params_init(&uartParams1);
    uartParams1.writeDataMode = UART_DATA_BINARY;
    uartParams1.readDataMode = UART_DATA_BINARY;
    uartParams1.readReturnMode = UART_RETURN_FULL;
    uartParams1.readEcho = UART_ECHO_OFF;
    uartParams1.baudRate = 115200;
    uart1 = UART_open(Board_UART1, &uartParams1);

    if (uart1 == NULL) {
        System_printf("UART1 NOT OPEN");
        System_flush();
        // Turn on user LED
        GPIO_write(Board_LED0, Board_LED_ON);
        System_abort("Error opening the UART");
    }

    UART_Params_init(&uartParams2);
    uartParams2.writeDataMode = UART_DATA_BINARY;
    uartParams2.readDataMode = UART_DATA_BINARY;
    uartParams2.readReturnMode = UART_RETURN_FULL;
    uartParams2.readEcho = UART_ECHO_OFF;
    uartParams2.baudRate = 115200;
    uart2 = UART_open(Board_UART2, &uartParams2);

    if (uart2 == NULL) {
        System_printf("UART2 NOT OPEN");
        System_flush();
         //Turn on user LED
        GPIO_write(Board_LED0, Board_LED_ON);
        System_abort("Error opening the UART");
    }

    UART_Params_init(&uartParams3);
    uartParams3.writeDataMode = UART_DATA_BINARY;
    uartParams3.readDataMode = UART_DATA_BINARY;
    uartParams3.readReturnMode = UART_RETURN_FULL;
    //uartParams3.readEcho = UART_ECHO_OFF;
    uartParams3.baudRate = 115200;
   // uartParams.readMode = UART_MODE_CALLBACK;
   // uartParams.readCallback  = readCallback;
    uart3 = UART_open(Board_UART3, &uartParams3);

    if (uart3 == NULL) {
        System_printf("UART3 NOT OPEN");
        System_flush();
         //Turn on user LED
        GPIO_write(Board_LED0, Board_LED_ON);
        System_abort("Error opening the UART");
    }

}

I request someone to help me on this, I need atleast one UART to receive the data, so that I can solve other UART receive. 

  • It looks like you are not using TIVAWare but Energia which is a 'duino like platform. You'd be better off asking on an Energia specific forum.

    Robert
  • I am building it in CCS 7.3 and on TI-RTOS for TIVA-2.16. I am sure it is not an Energia code.
  • Then it's unique to TI-RTOS. You'd be better off to try in that forum.

    Or it could be your own invention. In that case you'd be better off using TIVAWare

    Robert
  • uartecho.c
    /*
     * Copyright (c) 2015, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /*
     *  ======== uartecho.c ========
     */
    
    /* XDCtools Header files */
    #include <xdc/std.h>
    #include <xdc/runtime/System.h>
    
    /* BIOS Header files */
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    
    /* TI-RTOS Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/UART.h>
    
    /* Example/Board Header files */
    #include "Board.h"
    
    #include <stdint.h>
    #include <string.h>
    
    #define TASKSTACKSIZE     768
    
    Task_Struct task0Struct;
    Char task0Stack[TASKSTACKSIZE];
    UART_Handle uart, uart1, uart2, uart3;
    UART_Params uartParams, uartParams1, uartParams2, uartParams3;
    
    //char a[] = "\f abcnjdghowrghowgowrgoiwrghigwoogwhwroGGGGGG\n";
    //char b[] = "\f qwiwjifrununrviecunutnvoetuvnieutgnvueNNNNN\n";//,c[1000];
    int a[512], b[512];
    uint32_t RxBytes;
    
    
    static void uart_multiple_init();
    //static void readCallback(UART_Handle handle, void *rxBuf, size_t size);
    
    
    /*
     *  ======== echoFxn ========
     *  Task for this function is created statically. See the project's .cfg file.
     */
    Void echoFxn(UArg arg0, UArg arg1)
    {
    
        uart_multiple_init();
        while(1)
        {
            //UART_write(uart, a, sizeof(a));
            //Task_sleep(1000);
           // UART_write(uart3, b, sizeof(b));
            RxBytes= UART_read(uart2, b, sizeof(b));
            memcpy(a,b,RxBytes);
            UART_write(uart2, a, RxBytes);
        }
    
    
    }
    
    
    static void uart_multiple_init()
    {
         //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 = 115200;
    
        uart = UART_open(Board_UART0, &uartParams);
    
        if (uart == NULL) {
            System_printf("NOT opened");
            System_flush();
             //Turn on user LED
            GPIO_write(Board_LED0, Board_LED_ON);
            System_abort("Error opening the UART");
        }
    
        UART_Params_init(&uartParams1);
        uartParams1.writeDataMode = UART_DATA_BINARY;
        uartParams1.readDataMode = UART_DATA_BINARY;
        uartParams1.readReturnMode = UART_RETURN_FULL;
        uartParams1.readEcho = UART_ECHO_OFF;
        uartParams1.baudRate = 115200;
        uart1 = UART_open(Board_UART1, &uartParams1);
    
        if (uart1 == NULL) {
            System_printf("UART1 NOT OPEN");
            System_flush();
            // Turn on user LED
            GPIO_write(Board_LED0, Board_LED_ON);
            System_abort("Error opening the UART");
        }
    
        UART_Params_init(&uartParams2);
        uartParams2.writeDataMode = UART_DATA_BINARY;
        uartParams2.readDataMode = UART_DATA_BINARY;
        uartParams2.readReturnMode = UART_RETURN_FULL;
        uartParams2.readEcho = UART_ECHO_OFF;
        uartParams2.baudRate = 115200;
        uart2 = UART_open(Board_UART5, &uartParams2);
    
        if (uart2 == NULL) {
            System_printf("UART2 NOT OPEN");
            System_flush();
             //Turn on user LED
            GPIO_write(Board_LED0, Board_LED_ON);
            System_abort("Error opening the UART");
        }
    
        UART_Params_init(&uartParams3);
        uartParams3.writeDataMode = UART_DATA_BINARY;
        uartParams3.readDataMode = UART_DATA_BINARY;
        uartParams3.readReturnMode = UART_RETURN_FULL;
        //uartParams3.readEcho = UART_ECHO_OFF;
        uartParams3.baudRate = 115200;
        //uartParams.readMode = UART_MODE_CALLBACK;
        //uartParams.readCallback  = readCallback;
        uart3 = UART_open(Board_UART3, &uartParams3);
    
        if (uart3 == NULL) {
            System_printf("UART3 NOT OPEN");
            System_flush();
             //Turn on user LED
            GPIO_write(Board_LED0, Board_LED_ON);
            System_abort("Error opening the UART");
        }
    
    }
    /*
     *  ======== main ========
     */
    int main(void)
    {
        /* Call board init functions */
        Board_initGeneral();
        Board_initGPIO();
        Board_initUART();
    
        /* Construct BIOS objects */
        Task_Params taskParams;
    
        Task_Params_init(&taskParams);
        taskParams.stackSize = TASKSTACKSIZE;
        taskParams.stack = &task0Stack;
        //taskParams.instance->name = "echo";
        Task_construct(&task0Struct, (Task_FuncPtr)echoFxn, &taskParams, NULL);
    
    
        /* Start BIOS */
        BIOS_start();
    
        return (0);
    }
    

    Robert,

    If it was my invention I would not be finding a help. I request you to please look into the code before making such nasty comments.

    Thank you,

  • My friend - Robert's comment cannot qualify as, "nasty."     He has presented TWO valid alternatives - for your consideration.

    Now "neither" alternative met  your liking - and while that is "fair" -  such suggestions prove, "far from nasty!"

    For the record - I too looked at your code - saw (none) of the "normal" UART Config & Set-Up Code - which suggests that, "Such necessary data is handled w/in the RTOS."     Neither Robert nor myself use a "vendor restricted" RTOS - thus we can offer "no insights" - in that regard.

    No case has been made for, "Use of the RTOS."       There are powerful code examples w/in the TivaWare API - very well illustrating the (necessary) configuration & set-up of multiple UARTs - which are sure to assist your efforts...         Note that the RTOS adds a "layer of complexity" - which should enter into your "design consideration."

  • Hello Nitihin,

    I already alerted the TI-RTOS to your post.

    Robert, there is no TI-RTOS forum anymore, customers must post into the device specific forums and then we have an internal system to alert the TI-RTOS team about such threads. Nitihin has posted this in the correct forum and provided plenty of detail for the RTOS team as well.
  • Okay, I have configured the multiple UART's in the source file 

    EK_TM4C123GXL.c
    /*
     * Copyright (c) 2015, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /*
     *  ======== EK_TM4C123GXL.c ========
     *  This file is responsible for setting up the board specific items for the
     *  EK_TM4C123GXL board.
     */
    
    #include <stdint.h>
    #include <stdbool.h>
    
    #include <xdc/std.h>
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/System.h>
    #include <ti/sysbios/family/arm/m3/Hwi.h>
    
    #include <inc/hw_ints.h>
    #include <inc/hw_memmap.h>
    #include <inc/hw_types.h>
    #include <inc/hw_gpio.h>
    
    #include <driverlib/gpio.h>
    #include <driverlib/i2c.h>
    #include <driverlib/pin_map.h>
    #include <driverlib/pwm.h>
    #include <driverlib/ssi.h>
    #include <driverlib/sysctl.h>
    #include <driverlib/uart.h>
    #include <driverlib/udma.h>
    
    #include "EK_TM4C123GXL.h"
    
    #ifndef TI_DRIVERS_UART_DMA
    #define TI_DRIVERS_UART_DMA 0
    #endif
    
    /*
     *  =============================== DMA ===============================
     */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_ALIGN(dmaControlTable, 1024)
    #elif defined(__IAR_SYSTEMS_ICC__)
    #pragma data_alignment=1024
    #elif defined(__GNUC__)
    __attribute__ ((aligned (1024)))
    #endif
    static tDMAControlTable dmaControlTable[32];
    static bool dmaInitialized = false;
    
    /* Hwi_Struct used in the initDMA Hwi_construct call */
    static Hwi_Struct dmaHwiStruct;
    
    /*
     *  ======== dmaErrorHwi ========
     */
    static Void dmaErrorHwi(UArg arg)
    {
        System_printf("DMA error code: %d\n", uDMAErrorStatusGet());
        uDMAErrorStatusClear();
        System_abort("DMA error!!");
    }
    
    /*
     *  ======== EK_TM4C123GXL_initDMA ========
     */
    void EK_TM4C123GXL_initDMA(void)
    {
        Error_Block eb;
        Hwi_Params  hwiParams;
    
        if (!dmaInitialized) {
            Error_init(&eb);
            Hwi_Params_init(&hwiParams);
            Hwi_construct(&(dmaHwiStruct), INT_UDMAERR, dmaErrorHwi,
                          &hwiParams, &eb);
            if (Error_check(&eb)) {
                System_abort("Couldn't construct DMA error hwi");
            }
    
            SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
            uDMAEnable();
            uDMAControlBaseSet(dmaControlTable);
    
            dmaInitialized = true;
        }
    }
    
    /*
     *  =============================== General ===============================
     */
    /*
     *  ======== EK_TM4C123GXL_initGeneral ========
     */
    void EK_TM4C123GXL_initGeneral(void)
    {
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    }
    
    /*
     *  =============================== GPIO ===============================
     */
    /* Place into subsections to allow the TI linker to remove items properly */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(GPIOTiva_config, ".const:GPIOTiva_config")
    #endif
    
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/gpio/GPIOTiva.h>
    
    /*
     * Array of Pin configurations
     * NOTE: The order of the pin configurations must coincide with what was
     *       defined in EK_TM4C123GXL.h
     * NOTE: Pins not used for interrupts should be placed at the end of the
     *       array.  Callback entries can be omitted from callbacks array to
     *       reduce memory usage.
     */
    GPIO_PinConfig gpioPinConfigs[] = {
        /* Input pins */
        /* EK_TM4C123GXL_GPIO_SW1 */
        GPIOTiva_PF_4 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,
        /* EK_TM4C123GXL_GPIO_SW2 */
        GPIOTiva_PF_0 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,
    
        /* Output pins */
        /* EK_TM4C123GXL_LED_RED */
        GPIOTiva_PF_1 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
        /* EK_TM4C123GXL_LED_BLUE */
        GPIOTiva_PF_2 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
        /* EK_TM4C123GXL_LED_GREEN */
        GPIOTiva_PF_3 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW
    };
    
    /*
     * Array of callback function pointers
     * NOTE: The order of the pin configurations must coincide with what was
     *       defined in EK_TM4C123GXL.h
     * NOTE: Pins not used for interrupts can be omitted from callbacks array to
     *       reduce memory usage (if placed at end of gpioPinConfigs array).
     */
    GPIO_CallbackFxn gpioCallbackFunctions[] = {
        NULL,  /* EK_TM4C123GXL_GPIO_SW1 */
        NULL   /* EK_TM4C123GXL_GPIO_SW2 */
    };
    
    /* The device-specific GPIO_config structure */
    const GPIOTiva_Config GPIOTiva_config = {
        .pinConfigs = (GPIO_PinConfig *)gpioPinConfigs,
        .callbacks = (GPIO_CallbackFxn *)gpioCallbackFunctions,
        .numberOfPinConfigs = sizeof(gpioPinConfigs)/sizeof(GPIO_PinConfig),
        .numberOfCallbacks = sizeof(gpioCallbackFunctions)/sizeof(GPIO_CallbackFxn),
        .intPriority = (~0)
    };
    
    /*
     *  ======== EK_TM4C123GXL_initGPIO ========
     */
    void EK_TM4C123GXL_initGPIO(void)
    {
        /* EK_TM4C123GXL_GPIO_SW2 - PF0 requires unlocking before configuration */
        HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
        HWREG(GPIO_PORTF_BASE + GPIO_O_CR) |= GPIO_PIN_0;
        GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0);
    
        /* Initialize peripheral and pins */
        GPIO_init();
    }
    
    /*
     *  =============================== I2C ===============================
     */
    /* Place into subsections to allow the TI linker to remove items properly */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(I2C_config, ".const:I2C_config")
    #pragma DATA_SECTION(i2cTivaHWAttrs, ".const:i2cTivaHWAttrs")
    #endif
    
    #include <ti/drivers/I2C.h>
    #include <ti/drivers/i2c/I2CTiva.h>
    
    I2CTiva_Object i2cTivaObjects[EK_TM4C123GXL_I2CCOUNT];
    
    const I2CTiva_HWAttrs i2cTivaHWAttrs[EK_TM4C123GXL_I2CCOUNT] = {
        {
            .baseAddr = I2C1_BASE,
            .intNum = INT_I2C1,
            .intPriority = (~0)
        },
        {
            .baseAddr = I2C3_BASE,
            .intNum = INT_I2C3,
            .intPriority = (~0)
        },
    };
    
    const I2C_Config I2C_config[] = {
        {
            .fxnTablePtr = &I2CTiva_fxnTable,
            .object = &i2cTivaObjects[0],
            .hwAttrs = &i2cTivaHWAttrs[0]
        },
        {
            .fxnTablePtr = &I2CTiva_fxnTable,
            .object = &i2cTivaObjects[1],
            .hwAttrs = &i2cTivaHWAttrs[1]
        },
        {NULL, NULL, NULL}
    };
    
    /*
     *  ======== EK_TM4C123GXL_initI2C ========
     */
    void EK_TM4C123GXL_initI2C(void)
    {
        /* I2C1 Init */
        /* Enable the peripheral */
        SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C1);
    
        /* Configure the appropriate pins to be I2C instead of GPIO. */
        GPIOPinConfigure(GPIO_PA6_I2C1SCL);
        GPIOPinConfigure(GPIO_PA7_I2C1SDA);
        GPIOPinTypeI2CSCL(GPIO_PORTA_BASE, GPIO_PIN_6);
        GPIOPinTypeI2C(GPIO_PORTA_BASE, GPIO_PIN_7);
    
        /* I2C3 Init */
        /*
         * NOTE: TI-RTOS examples configure pins PD0 & PD1 for SSI3 or I2C3.  Thus,
         * a conflict occurs when the I2C & SPI drivers are used simultaneously in
         * an application.  Modify the pin mux settings in this file and resolve the
         * conflict before running your the application.
         */
        /* Enable the peripheral */
        SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C3);
    
        /* Configure the appropriate pins to be I2C instead of GPIO. */
        GPIOPinConfigure(GPIO_PD0_I2C3SCL);
        GPIOPinConfigure(GPIO_PD1_I2C3SDA);
        GPIOPinTypeI2CSCL(GPIO_PORTD_BASE, GPIO_PIN_0);
        GPIOPinTypeI2C(GPIO_PORTD_BASE, GPIO_PIN_1);
    
        /*
         * These GPIOs are connected to PD0 and PD1 and need to be brought into a
         * GPIO input state so they don't interfere with I2C communications.
         */
        GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_6);
        GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_7);
    
        I2C_init();
    }
    
    /*
     *  =============================== PWM ===============================
     */
    /* Place into subsections to allow the TI linker to remove items properly */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(PWM_config, ".const:PWM_config")
    #pragma DATA_SECTION(pwmTivaHWAttrs, ".const:pwmTivaHWAttrs")
    #endif
    
    #include <ti/drivers/PWM.h>
    #include <ti/drivers/pwm/PWMTiva.h>
    
    PWMTiva_Object pwmTivaObjects[EK_TM4C123GXL_PWMCOUNT];
    
    const PWMTiva_HWAttrs pwmTivaHWAttrs[EK_TM4C123GXL_PWMCOUNT] = {
        {
            .baseAddr = PWM1_BASE,
            .pwmOutput = PWM_OUT_6,
            .pwmGenOpts = PWM_GEN_MODE_DOWN | PWM_GEN_MODE_DBG_RUN
        },
        {
            .baseAddr = PWM1_BASE,
            .pwmOutput = PWM_OUT_7,
            .pwmGenOpts = PWM_GEN_MODE_DOWN | PWM_GEN_MODE_DBG_RUN
        }
    };
    
    const PWM_Config PWM_config[] = {
        {
            .fxnTablePtr = &PWMTiva_fxnTable,
            .object = &pwmTivaObjects[0],
            .hwAttrs = &pwmTivaHWAttrs[0]
        },
        {
            .fxnTablePtr = &PWMTiva_fxnTable,
            .object = &pwmTivaObjects[1],
            .hwAttrs = &pwmTivaHWAttrs[1]
        },
        {NULL, NULL, NULL}
    };
    
    /*
     *  ======== EK_TM4C123GXL_initPWM ========
     */
    void EK_TM4C123GXL_initPWM(void)
    {
        /* Enable PWM peripherals */
        SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM1);
    
        /*
         * Enable PWM output on GPIO pins.  Board_LED1 and Board_LED2 are now
         * controlled by PWM peripheral - Do not use GPIO APIs.
         */
        GPIOPinConfigure(GPIO_PF2_M1PWM6);
        GPIOPinConfigure(GPIO_PF3_M1PWM7);
        GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_2 |GPIO_PIN_3);
    
        PWM_init();
    }
    
    /*
     *  =============================== SDSPI ===============================
     */
    /* Place into subsections to allow the TI linker to remove items properly */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(SDSPI_config, ".const:SDSPI_config")
    #pragma DATA_SECTION(sdspiTivaHWattrs, ".const:sdspiTivaHWattrs")
    #endif
    
    #include <ti/drivers/SDSPI.h>
    #include <ti/drivers/sdspi/SDSPITiva.h>
    
    SDSPITiva_Object sdspiTivaObjects[EK_TM4C123GXL_SDSPICOUNT];
    
    const SDSPITiva_HWAttrs sdspiTivaHWattrs[EK_TM4C123GXL_SDSPICOUNT] = {
        {
            .baseAddr = SSI2_BASE,
    
            .portSCK = GPIO_PORTB_BASE,
            .pinSCK = GPIO_PIN_4,
            .portMISO = GPIO_PORTB_BASE,
            .pinMISO = GPIO_PIN_6,
            .portMOSI = GPIO_PORTB_BASE,
            .pinMOSI = GPIO_PIN_7,
            .portCS = GPIO_PORTA_BASE,
            .pinCS = GPIO_PIN_5,
        }
    };
    
    const SDSPI_Config SDSPI_config[] = {
        {
            .fxnTablePtr = &SDSPITiva_fxnTable,
            .object = &sdspiTivaObjects[0],
            .hwAttrs = &sdspiTivaHWattrs[0]
        },
        {NULL, NULL, NULL}
    };
    
    /*
     *  ======== EK_TM4C123GXL_initSDSPI ========
     */
    void EK_TM4C123GXL_initSDSPI(void)
    {
        /* Enable the peripherals used by the SD Card */
        SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
    
        /* Configure pad settings */
        GPIOPadConfigSet(GPIO_PORTB_BASE,
                GPIO_PIN_4 | GPIO_PIN_7,
                GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD);
    
        GPIOPadConfigSet(GPIO_PORTB_BASE,
                GPIO_PIN_6,
                GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU);
    
        GPIOPadConfigSet(GPIO_PORTA_BASE,
                GPIO_PIN_5,
                GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD);
    
        GPIOPinConfigure(GPIO_PB4_SSI2CLK);
        GPIOPinConfigure(GPIO_PB6_SSI2RX);
        GPIOPinConfigure(GPIO_PB7_SSI2TX);
    
        /*
         * These GPIOs are connected to PB6 and PB7 and need to be brought into a
         * GPIO input state so they don't interfere with SPI communications.
         */
        GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_0);
        GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_1);
    
        SDSPI_init();
    }
    
    /*
     *  =============================== SPI ===============================
     */
    /* Place into subsections to allow the TI linker to remove items properly */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(SPI_config, ".const:SPI_config")
    #pragma DATA_SECTION(spiTivaDMAHWAttrs, ".const:spiTivaDMAHWAttrs")
    #endif
    
    #include <ti/drivers/SPI.h>
    #include <ti/drivers/spi/SPITivaDMA.h>
    
    SPITivaDMA_Object spiTivaDMAObjects[EK_TM4C123GXL_SPICOUNT];
    
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_ALIGN(spiTivaDMAscratchBuf, 32)
    #elif defined(__IAR_SYSTEMS_ICC__)
    #pragma data_alignment=32
    #elif defined(__GNUC__)
    __attribute__ ((aligned (32)))
    #endif
    uint32_t spiTivaDMAscratchBuf[EK_TM4C123GXL_SPICOUNT];
    
    const SPITivaDMA_HWAttrs spiTivaDMAHWAttrs[EK_TM4C123GXL_SPICOUNT] = {
        {
            .baseAddr = SSI0_BASE,
            .intNum = INT_SSI0,
            .intPriority = (~0),
            .scratchBufPtr = &spiTivaDMAscratchBuf[0],
            .defaultTxBufValue = 0,
            .rxChannelIndex = UDMA_CHANNEL_SSI0RX,
            .txChannelIndex = UDMA_CHANNEL_SSI0TX,
            .channelMappingFxn = uDMAChannelAssign,
            .rxChannelMappingFxnArg = UDMA_CH10_SSI0RX,
            .txChannelMappingFxnArg = UDMA_CH11_SSI0TX
        },
        {
            .baseAddr = SSI2_BASE,
            .intNum = INT_SSI2,
            .intPriority = (~0),
            .scratchBufPtr = &spiTivaDMAscratchBuf[1],
            .defaultTxBufValue = 0,
            .rxChannelIndex = UDMA_SEC_CHANNEL_UART2RX_12,
            .txChannelIndex = UDMA_SEC_CHANNEL_UART2TX_13,
            .channelMappingFxn = uDMAChannelAssign,
            .rxChannelMappingFxnArg = UDMA_CH12_SSI2RX,
            .txChannelMappingFxnArg = UDMA_CH13_SSI2TX
        },
        {
            .baseAddr = SSI3_BASE,
            .intNum = INT_SSI3,
            .intPriority = (~0),
            .scratchBufPtr = &spiTivaDMAscratchBuf[2],
            .defaultTxBufValue = 0,
            .rxChannelIndex = UDMA_SEC_CHANNEL_TMR2A_14,
            .txChannelIndex = UDMA_SEC_CHANNEL_TMR2B_15,
            .channelMappingFxn = uDMAChannelAssign,
            .rxChannelMappingFxnArg = UDMA_CH14_SSI3RX,
            .txChannelMappingFxnArg = UDMA_CH15_SSI3TX
        }
    };
    
    const SPI_Config SPI_config[] = {
        {
            .fxnTablePtr = &SPITivaDMA_fxnTable,
            .object = &spiTivaDMAObjects[0],
            .hwAttrs = &spiTivaDMAHWAttrs[0]
        },
        {
            .fxnTablePtr = &SPITivaDMA_fxnTable,
            .object = &spiTivaDMAObjects[1],
            .hwAttrs = &spiTivaDMAHWAttrs[1]
        },
        {
            .fxnTablePtr = &SPITivaDMA_fxnTable,
            .object = &spiTivaDMAObjects[2],
            .hwAttrs = &spiTivaDMAHWAttrs[2]
        },
        {NULL, NULL, NULL},
    };
    
    /*
     *  ======== EK_TM4C123GXL_initSPI ========
     */
    void EK_TM4C123GXL_initSPI(void)
    {
        /* SPI0 */
        SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
    
        /* Need to unlock PF0 */
        GPIOPinConfigure(GPIO_PA2_SSI0CLK);
        GPIOPinConfigure(GPIO_PA3_SSI0FSS);
        GPIOPinConfigure(GPIO_PA4_SSI0RX);
        GPIOPinConfigure(GPIO_PA5_SSI0TX);
    
        GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 |
                                        GPIO_PIN_4 | GPIO_PIN_5);
    
        /* SSI2 */
        SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
    
        GPIOPinConfigure(GPIO_PB4_SSI2CLK);
        GPIOPinConfigure(GPIO_PB5_SSI2FSS);
        GPIOPinConfigure(GPIO_PB6_SSI2RX);
        GPIOPinConfigure(GPIO_PB7_SSI2TX);
    
        GPIOPinTypeSSI(GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_5 |
                                        GPIO_PIN_6 | GPIO_PIN_7);
    
        /* SSI3 */
        /*
         * NOTE: TI-RTOS examples configure pins PD0 & PD1 for SSI3 or I2C3.  Thus,
         * a conflict occurs when the I2C & SPI drivers are used simultaneously in
         * an application.  Modify the pin mux settings in this file and resolve the
         * conflict before running your the application.
         */
        SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI3);
    
        GPIOPinConfigure(GPIO_PD0_SSI3CLK);
        GPIOPinConfigure(GPIO_PD1_SSI3FSS);
        GPIOPinConfigure(GPIO_PD2_SSI3RX);
        GPIOPinConfigure(GPIO_PD3_SSI3TX);
    
        GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 |
                                        GPIO_PIN_2 | GPIO_PIN_3);
    
        EK_TM4C123GXL_initDMA();
        SPI_init();
    }
    
    /*
     *  =============================== UART ===============================
     */
    /* Place into subsections to allow the TI linker to remove items properly */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(UART_config, ".const:UART_config")
    #pragma DATA_SECTION(uartTivaHWAttrs, ".const:uartTivaHWAttrs")
    #endif
    
    #include <ti/drivers/UART.h>
    #if TI_DRIVERS_UART_DMA
    #include <ti/drivers/uart/UARTTivaDMA.h>
    
    UARTTivaDMA_Object uartTivaObjects[EK_TM4C123GXL_UARTCOUNT];
    
    const UARTTivaDMA_HWAttrs uartTivaHWAttrs[EK_TM4C123GXL_UARTCOUNT] = {
        {
            .baseAddr = UART0_BASE,
            .intNum = INT_UART0,
            .intPriority = (~0),
            .rxChannelIndex = UDMA_CH8_UART0RX,
            .txChannelIndex = UDMA_CH9_UART0TX,
        }
    };
    
    const UART_Config UART_config[] = {
        {
            .fxnTablePtr = &UARTTivaDMA_fxnTable,
            .object = &uartTivaObjects[0],
            .hwAttrs = &uartTivaHWAttrs[0]
        },
        {NULL, NULL, NULL}
    };
    #else
    #include <ti/drivers/uart/UARTTiva.h>
    
    UARTTiva_Object uartTivaObjects[EK_TM4C123GXL_UARTCOUNT];
    unsigned char uartTivaRingBuffer[EK_TM4C123GXL_UARTCOUNT][32];
    
    /* UART configuration structure */
    const UARTTiva_HWAttrs uartTivaHWAttrs[] = {
        {
            .baseAddr = UART0_BASE,
            .intNum = INT_UART0,
            .intPriority = (~0),
            .flowControl = UART_FLOWCONTROL_NONE,
            .ringBufPtr  = uartTivaRingBuffer[0],
            .ringBufSize = sizeof(uartTivaRingBuffer[0])
        },
        {
            .baseAddr = UART1_BASE,
            .intNum = INT_UART1,
            .intPriority = (~0),
            .flowControl = UART_FLOWCONTROL_NONE,
            .ringBufPtr  = uartTivaRingBuffer[1],
            .ringBufSize = sizeof(uartTivaRingBuffer[1])
        },
        {
            .baseAddr = UART2_BASE,
            .intNum = INT_UART2,
            .intPriority = (~0),
            .flowControl = UART_FLOWCONTROL_NONE,
            .ringBufPtr  = uartTivaRingBuffer[2],
            .ringBufSize = sizeof(uartTivaRingBuffer[2])
        },
        {
            .baseAddr = UART3_BASE,
            .intNum = INT_UART3,
            .intPriority = (~0),
            .flowControl = UART_FLOWCONTROL_NONE,
            .ringBufPtr  = uartTivaRingBuffer[3],
            .ringBufSize = sizeof(uartTivaRingBuffer[3])
        },
        {
            .baseAddr = UART4_BASE,
            .intNum = INT_UART4,
            .intPriority = (~0),
            .flowControl = UART_FLOWCONTROL_NONE,
            .ringBufPtr  = uartTivaRingBuffer[4],
            .ringBufSize = sizeof(uartTivaRingBuffer[4])
        },
        {
            .baseAddr = UART5_BASE,
            .intNum = INT_UART5,
            .intPriority = (~0),
            .flowControl = UART_FLOWCONTROL_NONE,
            .ringBufPtr  = uartTivaRingBuffer[5],
            .ringBufSize = sizeof(uartTivaRingBuffer[5])
        },
        {
            .baseAddr = UART6_BASE,
            .intNum = INT_UART6,
            .intPriority = (~0),
            .flowControl = UART_FLOWCONTROL_NONE,
            .ringBufPtr  = uartTivaRingBuffer[6],
            .ringBufSize = sizeof(uartTivaRingBuffer[6])
        },
        {
            .baseAddr = UART7_BASE,
            .intNum = INT_UART7,
            .intPriority = (~0),
            .flowControl = UART_FLOWCONTROL_NONE,
            .ringBufPtr  = uartTivaRingBuffer[7],
            .ringBufSize = sizeof(uartTivaRingBuffer[7])
        }
    };
    
    const UART_Config UART_config[] = {
        {
            .fxnTablePtr = &UARTTiva_fxnTable,
            .object = &uartTivaObjects[0],
            .hwAttrs = &uartTivaHWAttrs[0]
        },
        {
            .fxnTablePtr = &UARTTiva_fxnTable,
            .object = &uartTivaObjects[1],
            .hwAttrs = &uartTivaHWAttrs[1]
        },
        {
            .fxnTablePtr = &UARTTiva_fxnTable,
            .object = &uartTivaObjects[2],
            .hwAttrs = &uartTivaHWAttrs[2]
        },
        {
            .fxnTablePtr = &UARTTiva_fxnTable,
            .object = &uartTivaObjects[3],
            .hwAttrs = &uartTivaHWAttrs[3]
        },
        {
            .fxnTablePtr = &UARTTiva_fxnTable,
            .object = &uartTivaObjects[4],
            .hwAttrs = &uartTivaHWAttrs[4]
        },
        {
            .fxnTablePtr = &UARTTiva_fxnTable,
            .object = &uartTivaObjects[5],
            .hwAttrs = &uartTivaHWAttrs[5]
        },
        {
            .fxnTablePtr = &UARTTiva_fxnTable,
            .object = &uartTivaObjects[6],
            .hwAttrs = &uartTivaHWAttrs[6]
        },
        {
            .fxnTablePtr = &UARTTiva_fxnTable,
            .object = &uartTivaObjects[7],
            .hwAttrs = &uartTivaHWAttrs[7]
        },
        {NULL, NULL, NULL},
    };
    #endif /* TI_DRIVERS_UART_DMA */
    
    /*
     *  ======== EK_TM4C123GXL_initUART ========
     */
    void EK_TM4C123GXL_initUART(void)
    {
        /* Enable and configure the peripherals used by the uart. */
        SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
        GPIOPinConfigure(GPIO_PA0_U0RX);
        GPIOPinConfigure(GPIO_PA1_U0TX);
        GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
        GPIOPinConfigure(GPIO_PB0_U1RX);
        GPIOPinConfigure(GPIO_PB1_U1TX);
        GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2);
        GPIOPinConfigure(GPIO_PD6_U2RX);
        GPIOPinConfigure(GPIO_PD7_U2TX);
        GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_6 | GPIO_PIN_7);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3);
        GPIOPinConfigure(GPIO_PC6_U3RX);
        GPIOPinConfigure(GPIO_PC7_U3TX);
        GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_6 | GPIO_PIN_7);
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_UART5);
        GPIOPinConfigure(GPIO_PE4_U5RX);
        GPIOPinConfigure(GPIO_PE5_U5TX);
        GPIOPinTypeUART(GPIO_PORTE_BASE, GPIO_PIN_4 | GPIO_PIN_5);
    
        /* Initialize the UART driver */
    #if TI_DRIVERS_UART_DMA
        EK_TM4C123GXL_initDMA();
    #endif
        UART_init();
    }
    
    /*
     *  =============================== USB ===============================
     */
    /*
     *  ======== EK_TM4C123GXL_initUSB ========
     *  This function just turns on the USB
     */
    void EK_TM4C123GXL_initUSB(EK_TM4C123GXL_USBMode usbMode)
    {
        /* Enable the USB peripheral and PLL */
        SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
        SysCtlUSBPLLEnable();
    
        /* Setup pins for USB operation */
        GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5);
    
        if (usbMode == EK_TM4C123GXL_USBHOST) {
            System_abort("USB host not supported\n");
        }
    }
    
    /*
     *  =============================== Watchdog ===============================
     */
    /* Place into subsections to allow the TI linker to remove items properly */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(Watchdog_config, ".const:Watchdog_config")
    #pragma DATA_SECTION(watchdogTivaHWAttrs, ".const:watchdogTivaHWAttrs")
    #endif
    
    #include <ti/drivers/Watchdog.h>
    #include <ti/drivers/watchdog/WatchdogTiva.h>
    
    WatchdogTiva_Object watchdogTivaObjects[EK_TM4C123GXL_WATCHDOGCOUNT];
    
    const WatchdogTiva_HWAttrs watchdogTivaHWAttrs[EK_TM4C123GXL_WATCHDOGCOUNT] = {
        {
            .baseAddr = WATCHDOG0_BASE,
            .intNum = INT_WATCHDOG,
            .intPriority = (~0),
            .reloadValue = 80000000 // 1 second period at default CPU clock freq
        },
    };
    
    const Watchdog_Config Watchdog_config[] = {
        {
            .fxnTablePtr = &WatchdogTiva_fxnTable,
            .object = &watchdogTivaObjects[0],
            .hwAttrs = &watchdogTivaHWAttrs[0]
        },
        {NULL, NULL, NULL},
    };
    
    /*
     *  ======== EK_TM4C123GXL_initWatchdog ========
     *
     * NOTE: To use the other watchdog timer with base address WATCHDOG1_BASE,
     *       an additional function call may need be made to enable PIOSC. Enabling
     *       WDOG1 does not do this. Enabling another peripheral that uses PIOSC
     *       such as ADC0 or SSI0, however, will do so. Example:
     *
     *       SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
     *       SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG1);
     *
     *       See the following forum post for more information:
     *       http://e2e.ti.com/support/microcontrollers/stellaris_arm_cortex-m3_microcontroller/f/471/p/176487/654390.aspx#654390
     */
    void EK_TM4C123GXL_initWatchdog(void)
    {
        /* Enable peripherals used by Watchdog */
        SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0);
    
        Watchdog_init();
    }
    
    /*
     *  =============================== WiFi ===============================
     */
    /* Place into subsections to allow the TI linker to remove items properly */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(WiFi_config, ".const:WiFi_config")
    #pragma DATA_SECTION(wiFiCC3100HWAttrs, ".const:wiFiCC3100HWAttrs")
    #endif
    
    #include <ti/drivers/WiFi.h>
    #include <ti/drivers/wifi/WiFiCC3100.h>
    
    WiFiCC3100_Object wiFiCC3100Objects[EK_TM4C123GXL_WIFICOUNT];
    
    const WiFiCC3100_HWAttrs wiFiCC3100HWAttrs[EK_TM4C123GXL_WIFICOUNT] = {
        {
            .irqPort = GPIO_PORTB_BASE,
            .irqPin = GPIO_PIN_2,
            .irqIntNum = INT_GPIOB,
    
            .csPort = GPIO_PORTE_BASE,
            .csPin = GPIO_PIN_0,
    
            .enPort = GPIO_PORTE_BASE,
            .enPin = GPIO_PIN_4
        }
    };
    
    const WiFi_Config WiFi_config[] = {
        {
            .fxnTablePtr = &WiFiCC3100_fxnTable,
            .object = &wiFiCC3100Objects[0],
            .hwAttrs = &wiFiCC3100HWAttrs[0]
        },
        {NULL,NULL, NULL},
    };
    
    /*
     *  ======== EK_TM4C123GXL_initWiFi ========
     */
    void EK_TM4C123GXL_initWiFi(void)
    {
        /* Configure EN & CS pins to disable CC3100 */
        GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_4);
        GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_0, GPIO_PIN_0);
        GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_4, 0);
    
        /* Configure SSI2 for CC3100 */
        SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);
        GPIOPinConfigure(GPIO_PB4_SSI2CLK);
        GPIOPinConfigure(GPIO_PB6_SSI2RX);
        GPIOPinConfigure(GPIO_PB7_SSI2TX);
        GPIOPinTypeSSI(GPIO_PORTB_BASE, GPIO_PIN_4 | GPIO_PIN_6 | GPIO_PIN_7);
    
        /* Configure IRQ pin */
        GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_2);
        GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_STRENGTH_2MA,
                         GPIO_PIN_TYPE_STD_WPD);
        GPIOIntTypeSet(GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_RISING_EDGE);
    
        SPI_init();
        EK_TM4C123GXL_initDMA();
    
        WiFi_init();
    }
    

    and in header file EK_TM4C123GXL.h

    But my issue is, even after these configurations UART_read function is not reading any data. The configurations and codes TIVAware which you are speaking is bare metal implementation. I am looking something towards an RTOS implementation. I hope this is more clear.

    Thank you.

  • Hello Nitihin,

    Also looking at your code vs the example TI-RTOS project provided a few comments:

    1) If you are having issues with reading data, I advise starting with just one UART channel both in configuration and in read attempts. Once you have it working for one, then move to the others.

    2) You don't seem to have a declaration for the 'b' variable/buffer used by

    UART_read(uart3, b, sizeof(b));

    Can you elaborate that better? Also I'd advise using a more descriptive name...

    3) Are you sure the device you are trying to read from will support 115200kbps baud by default? You may need to use something slower like 9600 to start.

    4) Are you checking the return value from UART_open() to make sure they are opening correctly?

    5) Did you use the Board_initUART(); in your main function? If so, have you checked to see that you have the correct UART ports opened? The default function will only initialize UART0, so you need to modify the EK_TM4C123GXL.c file for your project to add more ports. (More reason to use only one port, specifically UART0, for starters)

  • Hi Nitihin,

    Looks like you answered my question 5) with the post you provided while I was writing my own, though I would still urge to start with just a *single* UART channel until you have read working and then expand from there. Please do look through my questions/comments 1 through 4.
  • Ralph Jacobi said:
    Robert, there is no TI-RTOS forum anymore, customers must post into the device specific forums and then we have an internal system to alert the TI-RTOS team about such threads.

    Considering few here have any expertise in the TI RTOS that is unfortunate. I suspect short-serving the RTOS community and overloading the device community is likely to pay dividends.

    Robert

  • Nitihin N said:
    If it was my invention I would not be finding a help.

    You'd be surprised how many believe otherwise.

    Nitihin N said:
    such nasty comments.

    !??!

    Robert

  • Somehow "KISS" has, "entered my mind?" Multiple Sensors have been mentioned - yet is each/every such 'Sensor" outputting via a CMOS -level UART. (it is my experience that "most such sensors" output via I2C or SPI - UART proves much more rare.)

    No mention is made of the "separation between such sensors and poster's MCU." It is possible that: if the sensors ARE UART-based - they may employ some form of "line driver" (to greatly expand their communication range) and such line drivers - if not expected & properly safeguared via "matching line drivers @ the MCU" - subject the MCU to (almost) certain "death/destruction."

    Some such "Sensor Data" - especially in light of, "No Sensor Data received" - IS very much required...
  • Nitihin,

    Are you using a Launchpad or a custom board? If you are using a custom board, can you hook a scope to see if the UART is transmitting/receiving anything?

    Can you confirm the other UARTs are working? Also, can you try UART3 without the USB. It looks like both USB0 and UART3 use PC6 and PC7, so let's rule out any funny-business with the USB.

    Todd
  • Hello Ralph,

    1) I have checked with single UART also and it is working fine.

    2) Declaration of variable 'b' is done globally and it is an array of type integer. The UART receive data has to be stored in this buffer.

    3) The sensor module (is a BLE module transmitting the data which it has received via UART) is capable of sending the data at 115200kbps. I would check again with the UART transmit is happening.

    4) All the UART modules are opening correctly, I have checked it using breakpoints and I have also put a check status that if it returns NULL then the system would abort.

    Though i would check the individual functionality again, is it not working because does it have to do something  with both UART and USB working together? 

    Thank you.

  • Hello,

    I am uisng Launchpad and I have checked that the UART is transmitting the data. I have checked individually that all the UART's are working. My doubt is that have I done all the configurations/definitions/declarations correct? I have attached the codes in my previous comments.
  • Can you confirm that UART3 is working properly without the USB involved?
  • Hello,

    I checked that whether the data is transferred via UART or not on the sensor side and the sensor is transferring the data. Secondly, I checked with the data receiving side across UART3 Channel and it is not working, Infact none of the channels are receiving the data. I am stuck in this issue.

    Thank you.

  • Nitihin,

    Does the UART Echo example in the product work for you? Can you confirm you are calling Board_initUART in your app where none of the UART instances are working.

    Todd
  • UART ECHO example did work, where it was echoing the characters that i was typing on my serial monitor.I am trying to implement the same concept,but instead of typing, it has to receive the character. I am calling Board_initUART inside my main function. 

  • Can you attach a sample program with the problem and let me know which Launchpad you are using?
  • Hello,

    I am attaching the sample code, where UART receives the data and transmits the data via USB. I am uisng Tiva TM4C123G Launchpad.

    4341.main.c
    /*
     * Copyright (c) 2015, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /*
     *  ======== usbserialdevice.c ========
     */
    
    #include <string.h>
    #include <stdbool.h>
    
    /* XDCtools Header files */
    #include <xdc/std.h>
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/System.h>
    #include <xdc/runtime/IHeap.h>
    #include <xdc/runtime/Memory.h>
    #include <ti/sysbios/heaps/HeapMem.h>
    
    /* BIOS Header files */
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/knl/Semaphore.h>
    
    /* TI-RTOS Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/UART.h>
    
    /* Example/Board Header files */
    #include "Board.h"
    
    /* USB Reference Module Header file */
    #include "USBCDCD.h"
    
    #define TASKSTACKSIZE   1024
    #define DATA_BUFF_SIZE  512
    
    //unsigned char text[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ\n";
    unsigned char data[DATA_BUFF_SIZE];
    //unsigned char a[]="TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\n";
    //unsigned char b[]="RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR\n";
    //unsigned char c[]="PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP\n";
    unsigned char text[100];
    Task_Struct task0Struct, task1Struct;
    Char task0Stack[TASKSTACKSIZE], task1Stack[TASKSTACKSIZE];
    UART_Handle uart, uart1, uart2, uart3;
    UART_Params uartParams, uartParams1, uartParams2, uartParams3;
    static Semaphore_Handle semSerial,sem1Serial;
    int count=0;
    unsigned char a[100],b[100],c[100];
    
    static void uart_multiple_init()
    {
         //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 = 115200;
        uart = UART_open(Board_UART0, &uartParams);
    
        if (uart == NULL) {
            System_printf("NOT opened");
            System_flush();
             //Turn on user LED
            GPIO_write(Board_LED0, Board_LED_ON);
            System_abort("Error opening the UART");
        }
    
        UART_Params_init(&uartParams1);
        uartParams1.writeDataMode = UART_DATA_BINARY;
        uartParams1.readDataMode = UART_DATA_BINARY;
        uartParams1.readReturnMode = UART_RETURN_FULL;
        uartParams1.readEcho = UART_ECHO_OFF;
        uartParams1.baudRate = 115200;
        uart1 = UART_open(Board_UART1, &uartParams1);
    
        if (uart1 == NULL) {
            System_printf("UART1 NOT OPEN");
            System_flush();
            // Turn on user LED
            GPIO_write(Board_LED0, Board_LED_ON);
            System_abort("Error opening the UART");
        }
    
        UART_Params_init(&uartParams2);
        uartParams2.writeDataMode = UART_DATA_BINARY;
        uartParams2.readDataMode = UART_DATA_BINARY;
        uartParams2.readReturnMode = UART_RETURN_FULL;
        uartParams2.readEcho = UART_ECHO_OFF;
        uartParams2.baudRate = 115200;
        uart2 = UART_open(Board_UART2, &uartParams2);
    
        if (uart2 == NULL) {
            System_printf("UART2 NOT OPEN");
            System_flush();
             //Turn on user LED
            GPIO_write(Board_LED0, Board_LED_ON);
            System_abort("Error opening the UART");
        }
    
        UART_Params_init(&uartParams3);
        uartParams3.writeDataMode = UART_DATA_BINARY;
        uartParams3.readDataMode = UART_DATA_BINARY;
        uartParams3.readReturnMode = UART_RETURN_FULL;
        uartParams3.readEcho = UART_ECHO_OFF;
        uartParams3.baudRate = 115200;
        uart3 = UART_open(Board_UART5, &uartParams3);
    
        if (uart3 == NULL) {
            System_printf("UART3 NOT OPEN");
            System_flush();
             //Turn on user LED
            GPIO_write(Board_LED0, Board_LED_ON);
            System_abort("Error opening the UART");
        }
    
    }
    
    
    
    
    Void transmitFxn(UArg arg0, UArg arg1)
    {
    
        while (true) {
    /*        if ((semSerial !=NULL) && (count==0))
            {
                USBCDCD_sendData(data, sizeof(data), BIOS_WAIT_FOREVER);
                Semaphore_post(semSerial);
            }count++;
            if (count >0)
            {*/
                //Semaphore_pend(sem1Serial,BIOS_WAIT_FOREVER);
                // Block while the device is NOT connected to the USB
                 USBCDCD_waitForConnect(BIOS_WAIT_FOREVER);
    
                USBCDCD_sendData(data, 512, BIOS_WAIT_FOREVER);
    
                // Semaphore_post(semSerial);
                Task_sleep(1);
          //  }
    
    
    
       }
    }
    
    
    /*
     *  ======== receiveFxn ========
     *  Task to receive serial data.
     *
     *  This task will receive data when data is available and block while the
     *  device is not connected to the USB host or if no data was received.
     */
    Void receiveFxn(UArg arg0, UArg arg1)
    {
        int res=0,res1=0,res2=0,res3=0;
        uint32_t RxBytes=0;
       // int receive=0;
        uart_multiple_init();
        while (true) {
            //USBCDCD_waitForConnect(BIOS_WAIT_FOREVER);
           // Semaphore_pend(semSerial,BIOS_WAIT_FOREVER);
    /*       if( UART_read(uart1,text, sizeof(text))!= NULL)
           {
               UART_write(uart1, text, sizeof(text));
           }
           if( UART_read(uart2, a, sizeof(a)) != NULL)
           {
               UART_write(uart2, a, sizeof(a));
           }*/
    /*        if ( UART_read(uart3, b, sizeof(b))!= NULL)
            {
                UART_write(uart3, b, sizeof(b));
            }*/
            RxBytes= UART_read(uart3, b, sizeof(b));
            memcpy(a,b,RxBytes);
            UART_write(uart3, a, RxBytes);
    /*        if (UART_read(uart3, c, sizeof(c))!= NULL)
            {
                UART_write(uart3, c, sizeof(c));
            }*/
           // UART_write(uart3, c, sizeof(c));
            //res = sizeof(text);
           // res1= sizeof(a);
            res2= sizeof(a);
           // res3= sizeof(c);
            memcpy(data, a, res);
           // memcpy((data+res),a,res1);
           // memcpy((data+res+res1),b,res2);
            //memcpy((data+res+res1+res2),c,res3);
            USBCDCD_receiveData(data, 512, BIOS_WAIT_FOREVER);
            //GPIO_toggle(Board_LED1);
           // Semaphore_post(sem1Serial);
        }
    }
    /*
     *  ======== main ========
     */
    int main(void)
    {
        /* Construct BIOS objects */
        Task_Params taskParams;
        Error_Block eb;
        Semaphore_Params semParams;
    
        /* Call board init functions */
        Board_initGeneral();
        Board_initGPIO();
        Board_initUSB(Board_USBDEVICE);
        Board_initUART();
    
        USBCDCD_init();
    
        /* Construct tx/rx Task threads */
        Task_Params_init(&taskParams);
        taskParams.stackSize = TASKSTACKSIZE;
        taskParams.stack = &task0Stack;
        taskParams.priority = 2;
        Task_construct(&task0Struct, (Task_FuncPtr)transmitFxn, &taskParams, NULL);
    
        taskParams.stack = &task1Stack;
       //                            taskParams.priority = 3;
        Task_construct(&task1Struct, (Task_FuncPtr)receiveFxn, &taskParams, NULL);
    
        /* RTOS primitives */
        Semaphore_Params_init(&semParams);
        semParams.mode = Semaphore_Mode_BINARY;
        semSerial = Semaphore_create(0, &semParams, &eb);
        if (semSerial == NULL) {
            System_abort("Can't create semaphore");
        }
    
        sem1Serial = Semaphore_create(0, &semParams, &eb);
        if (sem1Serial == NULL) {
            System_abort("Can't create RX semaphore");
        }
        /* Start BIOS */
        BIOS_start();
    
        return (0);
    }
    

  • Hi Nitihin,

    I confirmed your code works when using the uart UART_Handle (instead of uart3) for receiving. Did this work for you?

    Assuming it did, can you give me the wiring you are using for communicate on the uart3 handle (which is really UART5). Also, are you doing this on a LaunchPad or your custom board?

    Todd
  • Hi Todd,

    I managed to make it work for UART5, connected it across the pins E4 and E5. But still it is not transmitting the values via USB com port. It sends out null character, does it have to something with UART and USB working together or should it work without any problem if the pins are configured properly.

    Thank you.