USB-CDC

Hi im currently working on USB drivers for LP2468 MCU.I want to send data to the host PC as fast as I can.Since i dont have much knowledge on USB HID development on the PC end Ive decided to implement USBCDC class which will appear as a virtual comport on PC.
In my code i have initialised USB using the following statements

CDC_Init (); /*VCOM Initialization*/
USB_Init( EA_BOARD_LPC24XX );
USB_Connect(TRUE);

After i get USB_Configuration flag when an USB cable is
connected i send data to PC using

USB_WriteEP (CDC_DEP_IN,str,len );

Where str is the string i want to write and len is the length

This works as far as I insert a delay between 2 succesive USB writes.
If i reduce the delay the MCU hangs.Ive tried increasing the buffer size by sending more data collectively by changing usbpacket size
#define USBPKTLEN 1000

i have also commented out the following code as im not using CDC to send data packets to the serial port

void USB_EndPoint2 (DWORD event) {

switch (event) { case USB_EVT_OUT: /// CDC_BulkOut (); /* data received from Host */ break; case USB_EVT_IN: // CDC_BulkIn (); /* data expected from Host */ break; }
}

Can someone please suggest what measures can i take to increase the throughput of USBCDC or is there anyway to monitor the status of USB clear to send flag if any
Thank you

Parents
  • My advise to you is simple: stop the spaghettization of the sample code. Revert back to the original sample and dp not comment anything without fully understanding what the implication would be. Remember that when you act as a device, USB is still a host driven bus - so you should never 'USB_WriteEP' unless the host addressed your device using the 'BulkOut' callback (you can reply from other pieces of the program, of couse). Once you 'USB_WriteEP', you can expect 'BulkIn' callbacks until you transmitted all the data.

Reply
  • My advise to you is simple: stop the spaghettization of the sample code. Revert back to the original sample and dp not comment anything without fully understanding what the implication would be. Remember that when you act as a device, USB is still a host driven bus - so you should never 'USB_WriteEP' unless the host addressed your device using the 'BulkOut' callback (you can reply from other pieces of the program, of couse). Once you 'USB_WriteEP', you can expect 'BulkIn' callbacks until you transmitted all the data.

Children
More questions in this forum