I used the NXP USB HOST stack to implement the playback of Type-C headphones and the acquisition of microphone sound by referring to the sample code in the SDK.
After testing, most Type-C headphones work fine, but there is an exception when testing Apple headphones, where the MCU is able to periodically output data to the OUT endpoint, but is unable to receive data from the IN endpoint. That is, after connecting the Apple headset, calling USB_HostAudioStreamSend can generate the callback normally, but after calling USB_HostAudioStreamRecv, no callback is triggered.
During online debugging, if you set a breakpoint in the callback function specified by USB_HostAudioStreamSend, and the program runs to this breakpoint and then manually continues to run, the callback specified by USB_HostAudioStreamRecv is executed. If all breakpoints are removed and the program is allowed to run at full speed, the callback specified by USB_HostAudioStreamRecv is not executed.
If I only turn on the microphone interface, the callback is generated normally after calling USB_HostAudioStreamRecv.
From what I've seen, the UI bit in the USBSTS register is only set once in 1 millisecond when Apple headphones are connected. Whereas when other normal working headphones are connected, this bit is set twice in 1 ms time.
Please help me see what the cause of this problem is?
Here's what the Apple headset prints when it's connected:
Attached is the Apple headset information obtained using the UsbTreeView software.
Hi @ryanschaw,
Our USB stack is not meant to be put on production out of the box. It is a general application for compatibility with most USB peripherals, but we cannot guarantee it will work flawlessly with every USB device in the market, like it is the case of these specific Type-C headphones.
BR,
Edwin.
hi, @EdwinHz
I don't have an MIMXRT1050-EVK development board; I only have an Easy-RT1052 development board from ZLG company.
This issue can be reproduced both on my own product's hardware and on the Easy-RT1052 development board.
Some individual headphones exhibit this problem, while most headphones work normally. The issue might not be related to hardware connections via the Type-C interface, but possibly lies within the USB peripheral driver code.
The following image is the USB circuit diagram of the Easy-RT1052.
Thanks!
Hi @ryanschaw,
Could you please clarify if you are using the EVK? If so, how are you doing the connections of the USB Type-C headphones?
Hi. @EdwinHz
I tried adding a delay of 10 to 50 microseconds in USB_HostAudioStreamSend, but it made no difference. I also tried submitting the IN endpoint data first, then delaying by approximately 50 microseconds before submitting the OUT data, but that didn't resolve the issue either.
I've confirmed that the headphones don't have any special settings.
Thanks.
Hi @ryanschaw,
The fact that the callback is triggered when a breakpoint is set suggests a timing issue. Try polling instead of relying on callbacks, to track when the data is available. Or, try adding a small delay between USB_HostAudioStreamSend and USB_HostAudioStreamRecv.
Are you using the EVK? How are doing the connections of the USB Type-C? Keep in mind Erratum ERR050101: Chip Errata for the i.MX RT1050
That said, if the issue is only caused with a specific brand's headphones, then it's possible that they have extra requirements or specifications. I recommend contacting this brand's support for more information on what requirements need to be followed for their products to work.
BR,
Edwin.