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.

TMS320F28379D: USB Library Functions

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Dear TI officers,

I am working on the communication between PC and the TMS320F28379D Delfino board. I tried the USB program example ( usb_dev_serial) in C2000 Ware, the program is working beautifully. However, when I tried debugging, I can see that the variable ui32Event is changed when there is data coming to the USB port ( when I send data from PC by typing to terminal), however, the main thing is that the functions RxHandler, or TxHandler are never called inside the main loop, as well as in any other ISR. Still, it is running, in the background I assume. May I ask you how and from where these functions are called, as I don't see any line of code calling these functions, but they are still, by somehow, running in the background and change some flag variables. 

Thanks and best regards,
An.

  • If you look in the usb_serial_structs.c file, you'll see where RxHandler and TxHandler are being plugged into the rx and tx tUSBBuffer objects as call back functions (pfnCallback). If you look through the the actual source for the usblib.lib, you'll see where it gets called.

    Whitney
  • Hello Whitney,

    Why can't I open the usblib.lib file using CCS. Does it require any specific programs to open and read it ?
    Is the usblib.lib file is a Windows application, and what is it role in the USB communication ?

    I have been reading the USB Libary User guide provided in C2000Ware, but it is always referring to some CDC driver, while actually I didn't install any driver, and the usb_dev_serial example is still working fine. Is the usblib.lib file the mentioned CDC driver ?

    Regards,
    An.
  • All the code we used to build the usblib.lib can be found in C2000Ware\libraries\communications\usb\f2837xd

    I'm not familiar with the CDC driver, but the User Guide you referred to seems to indicate that Windows machines should already have one, so you should be fine. The driver isn't specific to our usblib.

    Whitney
  • Hello Whitney,

    I know that directory already, that's where I found the usblib.lib file, also all of the other header files, source code files for USB library. However, what I would like to ask is the role of usblib.lib file ? Is it a Windows application file ? Because you told me earlier that it is from this file, the callback functions, which are RxHandler and TxHandler, are called and they run from here, isn't it ? 

    So how can I open and read this .lib file ? Because as I opened it in CCS, it is all dummy characters which can't be read.

    Regards,
    An.

  • usblib.lib is just a compiled library of the source code in libraries\communications\usb\f2837xd\source. We essentially pre-compiled those source files into a .lib to make it easier to add them to an application project rather than adding the individual .c files. Since the files are already compiled they don't need to be build within the application project either, meaning shorter build times.

    The .lib itself is a binary file that isn't going to be readable in a text editor, similar to how the .out file you load to your F28379D isn't readable either. The .lib is also built using a CCS project if you'd like to look at. You can import it from libraries\communications\usb\f2837xd\ccs and see which files it is built from.

    So when I said, you could see where pfnCallback was being used in the source for usblib.lib, I meant you could open up one of the source files like usbbuffer.c and search for pfnCallback. I hope that clears things up a bit.

    Whitney

  • Hello Whitney,

    I have been reading through all the source codes in the USB communication library folder. However, I have some questions. The descriptions of the functions say the USB serial port on the Delfino board is initialized for CDC device operation by a call to USBDCDCInit() function. As it says: "This function does all the necessary setup for the Delfino board's USB serial port to make use of the CDC communication channel, and the device appears as a virtual serial port on the host system". I am wondering about some things: 

    1. What is the mentioned CDC device class API ? Is this driver already installed on Windows, or was it installed at the moment I installed CCS ? 

    2. How exactly does the Delfino board connect to the PC's CDC driver using the USBCDCInit() function ? As I see in the function, it is comprised of many elements in many structures being assigned to some values, which are product ID, or VID, power attribute, max power mA,... , and then is the USBDCDInit() function, which calls many mapping functions ( I can't open them to see their details, it only opens a header file rom_map.h). Are these mapping functions provided by CDC driver, or Windows driver, or from something else ? 

    3. Is this the setup of the whole system:

    Host application on PC --------- CDC driver on PC ------------ CDC driver on Delfino board ----------- USB Buffer structure ---------- Application code on Delfino board. 

    If it is not, can you help me fix the diagram ? And can you tell me how are the nodes connected to each other, especially the Delfino board's side ? Which function is called in the application program ( usb_dev_serial) to connect those nodes ? 

    4. What is the use of function pointers and callback functions in many USB structures ? Are they for creating multi-threaded application running on the Delfino board's MCU ? 

    5. In an example case, if a host, such as PC, sends a message to its USB port. The USB port is connected with Delfino board's USB serial port via a cable. The Delfino board has done every necessary setup to intialize the USB serial port to work. Now, when the message is sent, what is the next thing to happen with the whole system ? How does the Delfino board's MCU know that it has received a message, is it through an event flag or is it notified by some thing ? What is the thing that calls the function like TxHandler and RxHandler in the background while the main program is running ? 

    I understand that I am asking so many things, but I really want to understand this library and how TI developed it. 

    Regards and thanks in advance, 
    An.

  • Hi,

    1. the CDC device class API is in reference to the C2000 USB library source code.

    2. The mapping functions map to the APIs in usb.h/.c This USBCDCInit() function initializes the C2000 for CDC type enumeration and communication.

    3. Your diagram is pretty accurate.

    4. The use of the function pointers is to allow for the C2000 to handle the received or transmitted data inside the ISR. Those functions are called back from within the ISR so that they are guaranteed to complete. Instead of handling data in the main background loop which can get interrupted and postpone processing. You as the system integrator have the ability to choose what goes where.

    5. When the C2000 receives a character and USB interrupt it generated in the C2000. You can see this by setting breakpoints within the ISR code of the C2000, or you can set a breakpoint in the RxHandler() code and trace the call stack and begin to step into the code line by line.

    The best way to understand the code is to set some breakpoints and follow the execution path of the USB library code.

    Regards,
    sal