usbd_lib_cdc example support large data packet?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

usbd_lib_cdc example support large data packet?

1,238 Views
pulverizadorasf
Contributor II

Hi everyone,

                    Im using Embedded Artist Base Board with LPC1769.. I want to transfer data from LPC (end device) to PC (Host) using Bulk transfer.. I need a data rate upto 1 megabyte/sec. I started with usbd_lib_cdc (LPCOPENv2.1) all works fine.. but when I want to send more than 64bytes I dont receive anything on Host..

while (1) {

        /* Check if host has connected and opened the VCOM port */

        if ((vcom_connected() != 0) && (prompt == 0)) {

            vcom_write("Hello World!!\r\n", 15);

            prompt = 1;

        }

        /* If VCOM port is opened echo whatever we receive back to host. */

if (prompt) {

            rdCnt = vcom_bread(&g_rxBuff[0], 256);

            if (rdCnt) {

                if(g_rxBuff[0]=='S')

               {

                    vcom_write("Hello Host I'm LPC1769!! I want to send more than 64 bytes, but", 63); // works!

                    //vcom_write("Hello Host I'm LPC1769!! I want to send more than 64 bytes, but i cant do it!", 77); // dont work.

               }

            }

        }

        /* Sleep until next IRQ happens */

        __WFI();

    }

 

any suggestions?

Thanks a lot!

(sorry my bad english)

Labels (3)
4 Replies

716 Views
rolfmeeser
NXP Employee
NXP Employee

This is the expected behavior of the USBD stack in its current form. The ...->hw->WriteEP call (used in vcom_write()) cannot handle packets larger than the endpoint packet size. It will not even fail gracefully if you try, but rather corrupt the transmission in an unpredictable way.

You're on your own to implement large packet handling in your application. Split up larger TX packets into 64-byte chunks, then call vcom_write() until everything is out. Make sure that the VCOM_TX_BUSY flag is cleared before making the next vcom_write() call.

0 Kudos

716 Views
pulverizadorasf
Contributor II

Hi Rolf, Thanks for reply! I did what you told me and works! But, to send 100 packets of 64 bytes  takes 24.4 msec , (i guess 25 transfer of 4 transaction each, 1 packet for transaction, could be?) How i could improve performance? I've read is possible reach up 19 transactions per transfer.. o may be change to synchronous rather bulk transfer..(there are any examples to guide my?)

any suggestions?

Thanks a lot!

(sorry my bad english again)

Mauro

0 Kudos

716 Views
rolfmeeser
NXP Employee
NXP Employee

You are right, there seem to be four packets per 1-ms frame, quite a bit below the maximum of 13 packets (not 19, as we are using 64-byte payload!).

I have used the USBD CDC implementation in a couple of projects, but never required data rates anywhere near the rate that you can already achieve now. I cannot comment at this time whether it is a limitation of the USBD stack to not allow higher troughput.

And bulk transfer is your only option. It's mandated by the CDC class, and even if you used a vendor class you would still want guaranteed sequential transfer.

716 Views
pulverizadorasf
Contributor II

Hi Rolf,

             Im still trying to solve the issue.. I share you a snapshot of USBLyzer, may be you can give me a clue..between 5 data packets of 60 bytes (with 64bytes dont work)..  it's sending 5 empty packets of 4096 byte??

---- code---

while (1) {

                   /* Check if host has connected and opened the VCOM port */

              if ((vcom_connected() != 0) && (prompt == 0)) {

                  vcom_write("Hello World!!\r\n", 15);

                  prompt = 1;

                  }

              /* If VCOM port is opened echo whatever we receive back to host. */

              if (prompt) {

                  rdCnt = vcom_bread(&g_rxBuff[0], 256);

                  if (rdCnt) {

                     if(g_rxBuff[0]=='S'){

                      for(i=0;i<100;i++) {

                           vcom_write("I can tell a lot about character  by the way he eats jely be", 60);

                      }

                    }

             }

         }

        /* Sleep until next IRQ happens */

        __WFI();

  }

Thanks advanced!

0 Kudos