USB CDC buffer initialization

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

USB CDC buffer initialization

跳至解决方案
15,899 次查看
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

标记 (3)
0 项奖励
回复
1 解答
2,081 次查看
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 项奖励
回复
3 回复数
2,082 次查看
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 项奖励
回复
2,081 次查看
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 项奖励
回复
2,081 次查看
SantiZ
Contributor I

Hi Daniel,

Thank you for the confirmation.

Have a nice day,

Lecheng

0 项奖励
回复