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.

CCS/TMS320F28379D: USB serial communication

Part Number: TMS320F28379D


Tool/software: Code Composer Studio

Hello to everyone,

I am currently working with the TMS320F28379D in topics related to communication, especially with the example provided by Texas Instruments called usb_dev_serial. This example established the communication between two serial terminals, in a way that what is written in one of them can be on the other and vice versa

I am opening this thread in order to ask if anyone know if it is possible to modificate this example or another one (I am thinking of the usb_dev_bulk project) in order to have only one terminal. That is to say, what I want to do is sending data from the DSP to the serial terminal on my computer only, not the other way round (from the computer to the DSP).

Thank you very much in advance

Regards

  • Hi user4866272,

    You can modify either the usb_dev_bulk or the usb_dev_serial to accomplish this.

    The usb_dev_serial has to connections to the Host PC. One uses SCI and the other uses USB. You can modify this example to only use the USB serial connection if you wish. Also, the usb_dev_bulk only has one connection to the Host PC via USB Bulk transfers. You can use this example as well. It depends on the Host PC application you will be using/developing and your comfort with the USB library or examples we provide.

    Hope this helps!

    sal
  • Hi Sal,

    First of all, thank you for the information.

    I have been doing some research and I have found some example you posted on the following link: e2e.ti.com/.../2378063

    I have tried those, using in the Host PC the Visual Studio 2015 and it haven't worked properly. First of all, when I build the CCS project, it appears the following warnings:

    «#169-D argument of type "unsigned char *" is incompatible with parameter of type "uint8_t *"», referred to the parameters in the function USBDBulkPacketWrite. This warning appears two times due to the fact that this function is called twice during the code. It also warns because the function EchoNewDataToHost is declared but never used.

    In the PC project, I have discovered that it doesn't run properly because it is stacked in the following line:

    dwError = ReadUSBPacket(hUSB, szBuffer, ECHO_PACKET_SIZE, &ulRead, INFINITE, NULL);

    Having all this information into account, when I launched both the CCS and the PC project, in the new window it appears the following, after a description indicating we are in echo mode:

    Running in echo mode: Press Ctrl+C to exit.

    Throughput:     0kbps.   Packets: 0

    This message appears all the time without changing the rate in kbps or the number of packets sent.

    I was wondering if you could tell the reason why this examples aren't working on my project and if I have to make some changes to make them work

    Thank you very much

    Regards

  • It looks like the device is not connecting properly. Make sure the device is running and connected (enumerated) properly to your Windows PC and that the driver is installed properly.

    After this, execute the host VS project. This should begin to read from the device. Once this happens, the the host will update the packet count and the throughput.

    sal
  • Hi,
    First of all, I have a question about the CCS project you have just sent me because there are two .c archives (usb_dev_bulk.c and usb_dev_bulk_stress.c). Which one of these should I used? Are there any particular difference between the two?
    Anyhow, in order to check if the device is connected properly, I have tried the original bulk projects, in which you enter a string and it is returned with all the characters swapped, and it have worked just fine. Do I have to check anything else in order to be fully positive the device is connected?
    Thank you,
    Regards
  • One of those files should already be excluded from the project properties. I believe you should be using usb_dev_bulk.c. It is a modified version of the original.

    You can see in your device manager if it is connected or not. If it is connected, it will show up in the Windows Device Manager.

    sal
  • Hi,

    Now it all works perfect; the problem was that I was using usb_dev_bulk_stress.c instead of usb_dev_bulk.c.

    Nonetheless, I would like to ask you some questions about this project. First of all, the data sent in variable 'buffer' (which is initialize with [0, 1, 2, ..., 255]), can I get them in some variable in the VS project? I ask this because in the original project, this information (the data sent to the DSP and the data received by the PC is avalaible in 'szBuffer', but in this case, this variable doesn't have the same information which is sent in 'buffer'.

    Another issue is that I would like to know if I can call the USBDBulkPacketWrite function whenever I want and not being dependent of the TxHandler interrupt; practically not having to use it ever.

    Thank you very much

    Regards.

  • Hi,
    I have finally solved the problem with the szBuffer buffer. I hadn't noticed that there was a crucial line commented after updating the byte and packet counters.
    However, I haven't been able to solve the other issue. The thing is that I don't know when the TxHandler interrupt is executed, because I thought it was executed when some data was about to be sent to the host but, inside the function, the USBDBulkPacketWrite function is called to send the buffer. The same happens with RxHandler, and I don't know if this interrupt is ever executed during the running of the program, because, supposedly, data is only sent from the device to the PC host; the device doesn't receive any data. Could I, for example, use the USBDBulkPacketWrite in a while(1) loop in main, being preceded by USBDBulkTxPacketAvailable, without having to use the TxHandler?
    Thank you very much for your time
    Regards.
  • Hi,

    I am glad you got it working properly and have understood the example well.

    You can call the USBDBulkPacketWrite() function from your application, e.g. While(1) loop.

    Just make sure you have enough space available, like I have in the example.

    uint32_t ui32Space = USBDBulkTxPacketAvailable(&g_sBulkDevice);
    if(ui32Space)
    {
    USBDBulkPacketWrite(&g_sBulkDevice, buffer, ui32Space, true);
    }

    Hope this helps.

    sal
  • Hi,

    I adapted the main function of the code you posted to perform what you have just told me. I have the following code:

    while(firstPacket)
    {
           if(g_bConnected)
           {
                  if(firstPacket)
                  {
                         ui32Space = USBDBulkTxPacketAvailable(&g_sBulkDevice);

                         if(ui32Space)
                                USBDBulkPacketWrite(&g_sBulkDevice, buffer, ui32Space, true);

                         firstPacket = 1;

                  }

           }
    }

    while(1)
    {
           ui32Space = USBDBulkTxPacketAvailable(&g_sBulkDevice);

           if(ui32Space)
                  USBDBulkPacketWrite(&g_sBulkDevice, buffer, ui32Space, true);
    }

    In order to see if everything was working fine, I set a breakpoint in the line just after while(1) and it never reaches to that point. However, I set two additional breakpoints: one in the first line of TxHandler interrupt and another one in the line that it uses the function USBDBulkPacketWrite. In this case, after sending the first packet when firstPacket=1, it always stops in the first line of the TxHandler interrupt and it jumps from one breakpoint to the other, never reaching the first one I set in the main function. I would like to know if this operation, which TxHandler is doing, I can do it only in main, that is to say, never have to use the TxHandler interrupt and get rid of it.

    Thank you very much,

  • The TXHandler function will get called because it is configured as a callback function from the USBlib after a successful transmission. However, you do not have to do anything in that function. You can handle it in your main control loop.

    Please see the USB Library User's Guide for more information.

    Hope this helps.

    sal