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.

DK-TM4C123g OTG USB_Dev_Serial



I'm try to use the USB_Dev_Serial example to create a Virtual COM port using the OTG connector on the DK-TM4C123G. I have changed the UART to UART 3 and added code to initialize the pins appropriately(GPIO_PC7_U3TX). When I load the example, I get an unknown device on the Windows 7 computer that I have connected. I have loaded both the USB_DEV_Serial and USB_Dev_CSerial drivers. The Stellaris Virtual Serial port shows up and I can use it to send information to the PC from the stock usb_dev_serial example.

Is there anything that I'm missing?

  • Hello Thomas,

    If the device is showing up as a unknown device then most probably the device descriptor is faulty. Is the project a hand written project or is it derived from one of the existing DK-TM4C123 project? Please do the share the code.

    Regards
    Amit
  • Hi Thomas,
    The USB example uses an interrupt vector routine to determine the OTG attached peripheral modes (device/host). That interrupt vector must be added to statup_ccs.c. or the Windows CDM device driver will not receive the descriptor as Amit pointed out.
  • Thanks for the replies.

    I've have made some progress. I added the following lines of code to the example per the "usb_dev_serial example, change UART module not work" forum thread.

    ROM_GPIOPinConfigure(GPIO_UARTRX);
    ROM_GPIOPinConfigure(GPIO_UARTTX);

    I also found that there was some conflict on my computer with the drivers that I had installed.

    I can now see the USB serial port on my PC. I can also send characters to the serial port on the PC if I use USBBufferWrite in the application. The last issue that I have is that I've been trying to resolve is why I cannot use the UARTCharPut call as opposed the USBBufferWrite. When I call UARTCharPut , nothing is transmitted and the interrupt eventually get disabled

    Is there anything else that I would need to change on UART3 to make it behave like UART0 in the example?

    Here is the code that I've changed from the DK-TM4C123G example.


    // usb_dev_serial.c - Main routines for the USB CDC serial example.
    ....
    //*****************************************************************************
    //
    // The base address, peripheral ID and interrupt ID of the UART that is to
    // be redirected.
    //
    //*****************************************************************************

    //*****************************************************************************
    //
    // Defines required to redirect UART3 via USB.
    //
    //*****************************************************************************
    #define USB_UART_BASE UART3_BASE // UART0_BASE
    #define USB_UART_PERIPH SYSCTL_PERIPH_UART3 // SYSCTL_PERIPH_UART0
    #define USB_UART_INT INT_UART3 // INT_UART0

    ....
    //*****************************************************************************
    //
    // GPIO peripherals and pins muxed with the redirected UART. These will depend
    // upon the IC in use and the UART selected in USB_UART_BASE. Be careful that
    // these settings all agree with the hardware you are using.
    //
    //*****************************************************************************

    //*****************************************************************************
    //
    // Defines required to redirect UART0 via USB.
    //
    //*****************************************************************************
    #define TX_GPIO_BASE GPIO_PORTC_BASE
    #define TX_GPIO_PERIPH SYSCTL_PERIPH_GPIOC
    #define TX_GPIO_PIN GPIO_PIN_7
    #define GPIO_UARTTX GPIO_PC7_U3TX

    #define RX_GPIO_BASE GPIO_PORTC_BASE
    #define RX_GPIO_PERIPH SYSCTL_PERIPH_GPIOC
    #define RX_GPIO_PIN GPIO_PIN_7
    #define GPIO_UARTRX GPIO_PC6_U3RX

    ....
    //*****************************************************************************
    //
    // This is the main application entry function.
    //
    //*****************************************************************************
    int
    main(void)
    {
    uint32_t ui32TxCount;
    uint32_t ui32RxCount;
    tRectangle sRect;
    char pcBuffer[16];
    uint32_t ui32Fullness;
    const char message[] = "Hello World!";
    size_t messageLength;
    uint8_t messageIndex = 0;

    messageLength = strlen(message);
    //
    // Enable lazy stacking for interrupt handlers. This allows floating-point
    // instructions to be used within interrupt handlers, but at the expense of
    // extra stack usage.
    //
    ROM_FPULazyStackingEnable();

    //
    // Set the clocking to run from the PLL at 50MHz
    //
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
    SYSCTL_XTAL_16MHZ);

    //
    // Configure the required pins for USB operation.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

    /*
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
    ROM_GPIOPinConfigure(GPIO_PG4_USB0EPEN);
    ROM_GPIOPinTypeUSBDigital(GPIO_PORTG_BASE, GPIO_PIN_4);
    */

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
    ROM_GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7);
    ROM_GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    ...

    //
    // Enable the UART that we will be redirecting.
    //
    ROM_SysCtlPeripheralEnable(USB_UART_PERIPH);

    //
    // Enable and configure the UART RX and TX pins
    //
    ROM_SysCtlPeripheralEnable(TX_GPIO_PERIPH);
    ROM_SysCtlPeripheralEnable(RX_GPIO_PERIPH);

    ROM_GPIOPinConfigure(GPIO_UARTRX);
    ROM_GPIOPinConfigure(GPIO_UARTTX);

    ROM_GPIOPinTypeUART(TX_GPIO_BASE, TX_GPIO_PIN);
    ROM_GPIOPinTypeUART(RX_GPIO_BASE, RX_GPIO_PIN);

    ...
    //
    // Main application loop.
    //
    while(1)
    {

    if (g_bUSBConfigured== true)
    {
    // USBBufferWrite((tUSBBuffer *)&g_sTxBuffer, (uint8_t *)message, messageLength);
    if (messageIndex == (messageLength-1))
    {
    messageIndex = 0;
    }
    UARTCharPut(USB_UART_BASE, message[messageIndex++]);
    }
    ....
    }
    }
  • Hello Thomas,

    How is UART3 connected to the PC Serial Console. Is there a USB2UART Converter? UART0 is connected to the PC via the ICDI chip.

    Regards
    Amit