| 
 
| 本帖最后由 香水城 于 2017-8-14 14:23 编辑 
 
 HID 与音频冲突问题
 前言
 Demo 程序中,HID 和 Audio 单独运行都不会有问题,把 HID 和 Audio 整合在一起,同进传送数据时,会出现Audio 不能传送数据的情况。
 
 根本原因
 
 基本情况:
 1. 当增加HID 的传输频率时,这种情况更容易出现。
 2. 当HID 包在帧开始时,不会出现这个问题。
 根本原因是相关的参考手册中描述的一个已知的问题。
 35.13.8 Worst case response time
 When the OTG_HS controller acts as a device, there is a worst case response time for any
 tokens that follow an isochronous OUT. This worst case response time depends on the AHB
 clock frequency.
 The core registers are in the AHB domain, and the core does not accept another token
 before updating these register values. The worst case is for any token following an
 isochronous OUT, because for an isochronous transaction, there is no handshake and the
 next token could come sooner. This worst case value is 7 PHY clocks when the AHB clock
 is the same as the PHY clock. When the AHB clock is faster, this value is smaller.
 If this worst case condition occurs, the core responds to bulk/interrupt tokens with a NAK
 and drops isochronous and SETUP tokens. The host interprets this as a timeout condition
 for SETUP and retries the SETUP packet. For isochronous transfers, the Incomplete
 isochronous IN transfer interrupt (IISOIXFR) and Incomplete isochronous OUT transfer
 interrupt (IISOOXFR) inform the application that isochronous IN/OUT packets were
 dropped.
 因此,建议在帧开始的时候或帧结束前开始发送HID 数据包。
 
 
 解决方案:
 1. 在帧开始的时候发送数据。
 2. 在帧80%,85%,90%,95%时发送数据。通过设置
 #define DCFG_FRAME_INTERVAL_80                        0
 #define DCFG_FRAME_INTERVAL_85                        1
 #define DCFG_FRAME_INTERVAL_90                        2
 #define DCFG_FRAME_INTERVAL_95                        3
 
 USBx_DEVICE->DCFG |= DCFG_FRAME_INTERVAL_80;
 
 
 RM0090
 34.16.4 Device-mode registers
 OTG_FS device configuration register (OTG_FS_DCFG)
 
 Bits 12:11 PFIVL: Periodic frame interval
 Indicates the time within a frame at which the application must be notified using
 the end of
 periodic frame interrupt. This can be used to determine if all the isochronous
 traffic for that
 frame is complete.
 00: 80% of the frame interval
 01: 85% of the frame interval
 10: 90% of the frame interval
 11: 95% of the frame interval
 
 对应PDF:HID与音频冲突问题
 更多实战经验请看:【ST MCU实战经验汇总贴】
 
 
 | 
 |