EZ-USB® 技术参考手册



8.6.1.2 EP0BCH 和 EP0BCL

These are the byte count registers for bytes sent as the optional data stage of a Control transfer. Although the EP0 buffer is only 64 bytes wide, the byte count registers are 16 bits wide to allow using the Setup Data Pointer to send USB IN data records that consist of multiple packets.

To use the Setup Data Pointer in its most-general mode, firmware clears the SUDPTR AUTO bit and writes the wordaligned address of a data block into the Setup Data Pointer, then loads the EP0BCH:L registers with the total number of bytes to transfer. The EZ-USB automatically transfers the entire block, partitioning the data into MaxPacketSize packets as necessary.

Note The Setup Data Pointer is the subject of section 8.7 The Setup Data Pointer on page 95.

For IN transfers without using the Setup Data Pointer, firmware loads data into EP0BUF, then writes the number of bytes to transfer into EP0BCH and EP0BCL. The packet is armed for IN transfer when the firmware writes to EP0BCL, so EP0BCH should always be loaded first. These transfers are always 64 bytes or less, so EP0BCH must be loaded with ‘0’ (and EP0BCL must be in the range [0-64]). EP0BCH holds that zero value until firmware overwrites it.

For EP0 OUT transfers, the byte count registers indicate the number of bytes received in EP0BUF. Byte counts for EP0 OUT transfers are always 64 or fewer, so EP0BCH is always zero after an OUT transfer. To re-arm the EP0 buffer for a future OUT transfer, the firmware simply writes any value to EP0BCL.

Note The EP0BCH register must be initialized on reset, since its power-on-reset state is undefined. 


EP0BCHEP0BCL作为控制传输在可选的数据阶段发送的字节的字节计数寄存器。虽然EP0缓冲区是64字节宽度,字节计数寄存器是16位宽度,允许使用Setup Data Pointer(SUDPTR)发送由多个数据包组成的USB IN数据记录。

要在常规模式下使用Setup Data Pointer,固件将清除SUDPTR AUTO位,并将数据块的对齐地址写入Setup Data Pointer,然后将EP0BCH:L寄存器装入要传输的总字节数。EZ-USB自动传输整个块,根据需要将数据分割为MaxPacketSize数据包。

注意 Setup Data Pointer作为第958.7节的主题。

输入传输没有使用Setup Data Pointer,固件将数据加载到EP0BUF中,然后将要传输的字节数写入到EP0BCHEP0BCL。当固件写入EP0BCL时,包就会进行传输,因此应始终首先加载EP0BCH。这些传输总是64字节或更少,因此EP0BCH必须装载“0(并且EP0BCL必须在[0 - 64]范围内)EP0BCH保持零值,直到固件覆盖它。

对于EP0输出传输,字节计数寄存器表示在EP0BUF中接收的字节数。 EP0输出传输的字节计数总是为64或更少,因此在输出传输结束之后,EP0BCH始终为零。为了在将来的输出传输中重新使用EP0缓冲区,固件只需将任何值写入EP0BCL

注意 EP0BCH寄存器必须在复位时初始化,因为其上电复位状态未定义。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值