AnsweredAssumed Answered

USB CDC Lockup

Question asked by Robert Hodson on Jul 19, 2012
Latest reply on May 1, 2013 by Robert Hodson

I was wondering if anyone has experienced occasional lock ups with MQX CDC Driver. I have seen the same problem occur with both 3.7 and 3.8 using drivers for the K60twrk60n512 - though I think the problem is more wide spread than just one processor. I was using a coldfire 51JE256 and I recall the problem occured there too.


Basically what happens is calls to USB_Class_CDC_Send_Data() return with a status code of USBERR_DEVICE_BUSY

and all additional calls, regardless of wait time return with the same error code.


It happens most frequently when transmitting data rapidly, but I don't know if there is a correlation other than more data = occur sooner.


I wrote a quick workaround which involves modifying usb_cdc.h and usb_cdc.c by adding the following function. It seemed to mask the issue, and allows me to continue without lockups, but is obviously not optimial( is suspect data loss is going to occur). This problem seems to be similar to some earlier posts, has someone else found a better way?


uint_8 USB_Class_CDC_Wipe_Data CDC_HANDLE handle,uint_8 ep_num)





uint_8 index;


    devicePtr = USB_Cdc_Get_Device_Ptr(handle);


if (NULL == devicePtr)




/* map the endpoint num to the index of the endpoint structure */

    index = USB_Map_Ep_To_Struct_Index(devicePtr, ep_num);


ep[index].bin_consumer = 0x00;        


ep[index].bin_producer = 0x00;  


return USB_OK;;