TI E2E Community
Tiva™ ARM® Microcontrollers
Tiva™ ARM® C Series Microcontrollers Forum
USB Demo Program on EKS-LM3S3748
I have an application that requires handling bi-directional data on RS-232 and USB ports. Am already familiar with Stellaris parts but have not worked with USB interface.
I have an EKS-LM3S3748 Eval Kit and tried to run the "usb_dev_serial" demo to get familiar with the USB interface and library, but don't understand what the demo program is supposed to do.
I thought at first the program worked like an FTDI adapter cables, RS-232 on one end and USB on the other. The demo program is written to work with U0Tx/Rx. Looking at the eval board schematic the UART0 pins tie in to the FT2232 and CPLD, so there is no way to access these pins directly.
I changed the demo program to run with UART1 (added "#define REDIRECT_UART1" and modified vector table) and tried inputting TTL RS-232 to U1Rx, but so far that doesn't work. In the meantime I'm hoping someone can briefly explain how the demo program works and if there is a better way to exercise the USB interface. Thanks.
Sounds like you are performing the right steps. When running the code, are you able to see a COM port added in Device Manager (it should show strings for Texas Instruments Virtual Com Port)?
1) right click "My Computer"
2) Select "Manage"
3) Open Device Manager and expand the "Ports and LPT" selection.
Using the #ifdef REDIRECT_UART1 will move the data transfers to UART1 which can be found on the header on the left side of the board. You should be able to provide a UART interface to that port and transfer data to the host.
The laptop recognized the new hardware when I connected the "USB Device" port. I used the "Browse" button to point to the driver and that all loaded properly.
The UART part of the program is still not working. I use an FTDI USB/TTL RS-232 cable and HyperTerminal to send strings to UART1 but the UART doesn't see any characters. I also tried HyperTerminal with the virtual com port but that didn't make anything happen either.
So far the code never hits any of the breakpoints I have set. At this point I'm not sure if it's better to try slogging through the demo or use the USB code from the demo with UART code I have written for other projects and understand better.
Can we verify your set-up? You have a USB cable connected to to both USB device ports (one for the debug interface and one for the UART1 connection). Once the device enumerates successfully you will have two serial ports associated with this board. The first is the Stellaris USB Serial port (which is enumerated as part of the debug interface) and the Stellaris Virtual COM Port (which is from the example code).
Next, can we try putitng UART1 into loopback? You can do this either by placing a physical jumper between the pads for U1Rx and U1Tx or you can use the internal loopback by adding this call to the example code where the UART gets initialized (I put it on line 1455 in the code example I am using).
HWREG(USB_UART_BASE + UART_O_CTL) |= UART_CTL_LBE;
Make sure the terminal application you are using is looking at the correct COM port and type some keys. Do you see it returned on the screen?
Let me know how this goes.
From your email I'm not sure my setup is correct. Please look at the attached block diagram and let me know if this will work for the demo program. Thanks.
That setup should work assuming COM1 is UART1, the TX and RX are wired correctly and the voltage levels (and polarity) are correct. There is no transceiver on the eval board for UART1. If we can disconnect the FTDI part and put UART1 in loopback that would get rid of the FTDI bridge for now and verify that you can type in the HyperTerminal app on Laptop #1 and see the data returned in HyperTerminal on the same laptop. That way we can isolate the test app and get it working first. Then the complete system can be verified.
What I had labeled "COM1" on the block diagram is UART1 on the eval board. The FTDI cable is USB/TTL RS-232 so the levels are correct and the Tx and Rx lines are connected correctly. I verified this with a scope.
I got back into Device Manager and found that I had the laptop comm port assignments backwards. The Debug USB port is labeled Stellaris Virtual COM Port and the Device USB port is labeled Stellaris USB serial port. I verified this by first unplugging the device cable and then the debug cable.
I added the HWREG line to put the UART into loopback mode and also corrected the comm port on HyperTerminal. There is nothing echoed in HyperTerminal.
The laptop does recognize when the USB device cable is plugged in. I put a breakpoint at the "switch(ulEvent)" instruction in the "ControlHandler()" routine and the program hits that breakpoint when I plug in the USB device cable, so that much seems to be working.
The problem could be with HyperTerminal but I have used that program with FTDI USB/RS-232 cables on the same laptop with no problems.
Do you have any suggestion for what I could try next? Thanks.
Can you open a second HyperTerminal window connected to the other COM port and see data looped back? I have used HyperTerminal in the past as well, but have found that TeraTerm seems a little more reliable. Many times the RS232 connection has to be re-established in the terminal app if lossed for some reason. Are you able to take screen shots? Would like to see the Device Manager Ports and the terminal set up. Is the UART definitely in loopback? You can check if bit 7 of the UART control register is set. After this it might be easier if you attach your file and I can try it here.
I have a Windows 7 laptop that already has TeraTerm loaded. I copied the Stellaris Windows Driver files and plugged in the USB Device port to that laptop. I did a manual load of the driver and the board showed up as a COM3. I started TeraTerm and set up for COM3, but it hung at that point and would not run. The laptop recognized the device but for some reason TeraTerm would not work; I tried a couple times restarting both TeraTerm and the program running on the eval board.
I have zipped and attached the project to this post. Please give it a look when you get a chance and let me know what you find. Thanks.
I noticed the code has been modified. Can you go back to the original code and see if we can verify your set-up? Then you can make the changes you want and see if it breaks at a certain point? I added your file to my project and running it the host is disconnecting the COM port. It won't re-enumerate it after that either. That appears to by why you cannot transfer any data. Here is the file I am using (rename the .zip to .c)
The only modifications I made were to comment out the calls to formike128x128x16. Before commenting out, I got several compile warnings; ROM_SysCtlPeripheralEnable, ROM_GPIOPinTypeGPIOOutput, etc were declared implicitly. Those warnings are back with the version attached to your post.
I also got several error messages related to g_pFontFixed6x8 is undefined. I couldn't figure out how to fix that either.
I think the problem with both the warnings and errors is in Project -> Properties, either an include or library entry, but couldn't make it work. If you can help me sort this out I would like to run your file and see if it works. Thanks.
That does sound like the project properties may be off. A couple of questions.
1) Did you start with the actual project that is provided in Stellarisware?
2) Is the StellarisWare directory different than the standard install?
The project uses relative paths for the include directories and one of those should take you to the c:\Stellarisware directory. This is typically the SW_ROOT variable. The libraries for StellarisWare are included in the linker options File Search Path. The directories listed there should point to the install location for the tools.
Hope this helps.
All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.