Hi,
I'm using K70 with MQX system and USB CDC as virtual COM port to send data. From time to time, I can see 12 bytes of data corruption within the sent data package from the receive side. I checked the buffer used to send data by calling USB_Class_CDC_Send_Data() and found that the buffer is allocated by malloc(). I changed the initialization by calling the function in MQX library _mem_alloc_uncached() and the data corruption went away.
I tried to look for the reference on the reference manual about data buffer used in USB transaction but I couldn't find anything. Is there any recommendations on the buffer used in USB has to be allocated in the uncached memory? I want to make sure my change was not just shifting the timing and drive the real problem elsewhere.
The USB is configured in high-speed mode and use a bulk size of 512. USB is running in device mode using EHCI as device controller. Our hardware board is using a USB3300 PHY.
Thanks in advance!
Best Regards,
Lecheng
Solved! Go to Solution.
Hi Lecheng
User application buffers used by USB EHCI Class drivers have to reside in un-cached memory space.
I hope it helps
Regards
Daniel
Hi Lecheng
User application buffers used by USB EHCI Class drivers have to reside in un-cached memory space.
I hope it helps
Regards
Daniel
Hi Daniel,
Would it be acceptable to use a cached buffer and call _DCACHE_FLUSH_MLINES to flush the cache right before sending the data on USB?
Thank you,
Rand Monteleone
Hi Daniel,
Thank you for the confirmation.
Have a nice day,
Lecheng