Other Parts Discussed in Thread: TM4C123GH6PM
Tool/software: Code Composer Studio
I am trying to design and build devices based on the TM4C123GH6PM that do not rely on the ICDI and I have been struggling to implement usb in serial device mode. I have made some progress on this project and I provide a description below (in the WHAT I HAVE DONE section) that I hope will help others who have similar difficulties. Problems are outlined in the paragraph immediately below. Any advice will be gratefully appreciated.
Thanks,
Jack
ISSUES I AM HAVING: As described below, I have successfully run the USB examples provided with TivaWare. My attempt to migrate the usb functionality into an existing program, however, has been unsuccessful. During the build, number of USB related APIs (listed below) were "unresolved symbols". I suspect that these symbols are defined in a program that is linked or imported in the original example. I have copied what seem to be relevant files from the example folder into my new project folder and I've tried linking to different programs but I have been unable to make this work.
undefined first referenced
symbol in file
--------- ----------------
USBBufferEventCallback ./usb_serial_structs.obj
USBBufferFlush ./main.obj
USBBufferInit ./main.obj
USBDCDCInit ./main.obj
USBDCDCPacketRead ./usb_serial_structs.obj
USBDCDCPacketWrite ./usb_serial_structs.obj
USBDCDCRxPacketAvailable ./usb_serial_structs.obj
USBDCDCTxPacketAvailable ./usb_serial_structs.obj
USBDeviceIntHandlerInternal ./usbdhandler.obj
USBStackModeSet ./main.obj
WHAT I HAVE DONE: My approach has been to follow the USB examples (Lab 7) in the LaunchPad Workshop Workbook and I have found points where the workbook could be updated. On page 1-16 of the workbook, the user is instructed to download the Windows side USB example from a TI web page. The link, however, is broken and there is nothing at the url provided. By searching the e2e forums, I determined that the application could be downloaded from http://www.ti.com/tivaware. Next, users need to download and install new drivers that are compatible with Windows 10. What you want are the patch files (SW-TM4C-2.1.4.178.PATCH-1.0.zip) that are also accessed from from the tivaware website.
The usb_dev_bulk example works as described but implementing communications using the bulk device mode would require that I understand the windows application sufficiently to modify it or write my own. Since I am already somewhat familiar with serial communications, I decided to look into the usb_dev_serial example.
The readme file that accompanies the tivaware usb_dev_serial program could be more illustrative, as the purpose of the program, required hardware and connectivity are not described to the user. In March 2016, JustGreg posted the question: "usb_dev_serial example - please explain how it is working" on the e2e TM4C microcontrollers forum. The information in this thread (and my own observations), allowed me to figure out that the program was written to allow two computers to communicate through the device. Computer A connects to the debug usb port and computer B connects to the device port. When computer A sends serial data, the ICDI passes it to the device microcontroller via uart0. The device microcontroller then passes the data on to computer B via the device usb port. In the 2016 thread, JustGreg pointed out that none of the uart related code in this program is necessary to the serial function.
I simplified the example program to give a functioning program that echos back data introduced via the device usb port. I did this by deleting all of the uart related code and inserting the following code in the RXHandler method:
case USB_EVENT_RX_AVAILABLE:
{
uint32_t ui32Read;
uint8_t ui8Char;
bool read = true;
if(g_bSendingBreak) // If currently sending break, don't receive more data.
{ return; }
while(read == true){ // stay in loop until buffer empty
ui32Read = USBBufferRead((tUSBBuffer *)&g_sRxBuffer, &ui8Char, 1);
if(ui32Read) // Did we get a character?
{ // echo character back to com port
USBBufferWrite((tUSBBuffer *)&g_sTxBuffer,
(uint8_t *)&ui8Char, 1);
g_ui32TxCount++; // Update byte count.
}
else { // if no characters left in buffer
read = false; // exit the function.
return;
}
}
break;
}