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.

usb_dev_serial example : how send character from the board to the PC ?



Hi,

Sorry in advance for my lack of MCU knowledge.

I work on EK-LM4F232 board, and i test the usb_dev_serial example.
I'm using HypertTerminal and i can send character to the board (with keyboard), and watch the number of characters sent on the LCD display.

My problem is how send characters from the board to the PC.
This function is not implemented in the example ? Or there is a manipulation appropriated ?

Thanks for your help,
Laurent.

  • Laurent,

    We've all got to start somewhere. And digging through these examples is a perfect place to do so. There are a few examples in which characters are sent from the board to the PC via UART:

    •  I suggest you start with the SD_CARD demo. This demo contains both Rx and Tx. At startup, it prints a simple message to the screen.
    • The UART_ECHO example echos any recieved characters back to the PC.
    • The UDMA_DEMO sends a long array of characters to the PC.

    Take a look at how these examples perform the UART tranmission. After dissecting these, try manipulating the example you're working with.

  • Dear Michael

    I just tried the same code (usb_dev_serial) on the LM3S9D96 Development Board and had the same problems as Laurent. My intention was to send chars over the internal USB device controller to the PC.

    The demo's SD_CARD, UART_ECHO and UDMA_ECHO are communicating over the FTDI device controller, which is working fine. Is there a code sample (like USB_ECHO) for the internal USB device controller?

    Best regards,

    Manfred

  • I misunderstood what you are trying to accomplish. If I follow correctly - You're wanting to echo, or transmit bytes, over the USB? The usb_dev_serial example is what you need.

    A way to verfiy both the Tx and Rx functions of this example is to connect your PC to both the ICDI USB and HOST/DEVICE/OTG USB ports. Then open two terminals in HyperTerminal, TeraTerm, PuTTy, or your ternimal program of choice. Connect one terminal to "Stellaris USB Serial Port" (your Host USB cable) and the other to "Stellaris virtual COM Port". (You can find these in your Windows Device Manager. If they don't appear, update the broken driver & install the drivers in StellarisWare/Windows_Drivers).

    With both terminals connected, this example creates a virtual serial port over the USB host output. You can send characters (as you've already done). To test the Rx - Send characters into the terminal connected to the ICDI USB bus. You'll then recieve the characters from the MCU, on the USB Host terminal you opened.

  • Michael,

    The readme.txt file for the usb_dev_serial example says,

    The application supports the USB Communication Device Class ... to redirect UART0 traffic to and from the USB host system.

    So what you're saying is that anything received on UART0 will be forwarded over USB to the Host, and anything received over USB from the Host will be forwarded to the UART0 output - like this:

    --->  UART0 ---> USB ---> Host

    <---  UART0 <--- USB <--- Host

    Is that right?

    I don't think that's particularly clear from the description in readme.txt file - particularly, the use of the tern, "redirect" ?

  • Laurent Bouchot said:
    Sorry in advance for my lack of MCU knowledge

    Is that just MCUs, or are you also new to programming in general?

    Note that USB is really quite involved - so it might be better to start with something simpler...

  • Dear Michael

    Thank you for your fast response! Now, with two Terminals open and connected to the two COM Ports on the system (ICDI and Host) it works. Out of the readme I suggested that the whole traffic flows over the Host Port. Perhaps it would be a help if you could update the readme.txt.

    Best regards,

    Manfred

  • Andy,

    You're correct. And yes, this will be made more clear.

    Manfred,

    Thanks for the useful feedback. An update to readme will help.

  • I'm still a bit confused.  With the DK-LM3S9D96 development kit, if you connect both the ICDI and OTG USB ports to the computer and a terminal application to both, any character sent to the UART0 will appear on both terminal displays?

    So if I take out the lines that connect UART0 to Port A pin 0 and 1 (which I use for I2C in my design), it will still redirect all UART0 data to the built-in USB port on USB0DP and USB0DM (pins 71 and 70)?

    Edit:

    I'm guessing that would only be these lines that need commented out:

        //
        // Enable and configure the UART RX and TX pins
        //
        ROM_SysCtlPeripheralEnable(TX_GPIO_PERIPH);
        ROM_SysCtlPeripheralEnable(RX_GPIO_PERIPH);
        ROM_GPIOPinTypeUART(TX_GPIO_BASE, TX_GPIO_PIN);
        ROM_GPIOPinTypeUART(RX_GPIO_BASE, RX_GPIO_PIN);