USB CDC buffer initialization

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

USB CDC buffer initialization

Jump to solution
14,966 Views
SantiZ
Contributor I

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

Tags (3)
0 Kudos
1 Solution
1,148 Views
danielchen
NXP TechSupport
NXP TechSupport

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

View solution in original post

0 Kudos
3 Replies
1,149 Views
danielchen
NXP TechSupport
NXP TechSupport

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

0 Kudos
1,148 Views
rand_monteleone
Contributor I

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

0 Kudos
1,148 Views
SantiZ
Contributor I

Hi Daniel,

Thank you for the confirmation.

Have a nice day,

Lecheng

0 Kudos