USB学习1-USB电气信号

本文基于对韦东山老师USB专项视频资料的学习以及对USB2.0官方文档的理解撰写

1 USB 2.0 简介

USB 2.0协议支持3种速率:低速(Low Speed,1.5Mbps)、全速(Full Speed, 12Mbps)、高速(High Speed, 480Mbps)。

USB Hub、USB设备,也分为低速、全速、高速三种类型。一个USB设备,可能兼容低速、全速,可能兼容全速、高速,但是不会同时兼容低速、高速。

1.1 USB设备状态切换图

在这里插入图片描述

1.2 USB 电路示例

1.2.1 USB 高速容量收发器电路示意图

在这里插入图片描述

1.2.2 USB Hub Port和USB设备链接电路示意图

在这里插入图片描述

2 USB 信号水平

2.1 USB 低/全速信号水平

Table 7-2 summarizes the USB signaling levels. The source is required to drive the levels specified in the
second column, and the target is required to identify the correct bus state when it sees the levels in the third
column. (Target receivers can be more sensitive as long as they are within limits specified in the fourth
column.)
在这里插入图片描述

2.2 USB 全/高速信号水平

The high-speed signaling voltage specifications in Table 7-3 must be met when measuring at the connector
closest to the transceiver, using precision 45 Ω load resistors to the device ground as reference loads. All
voltage measurements are taken with respect to the local device ground.
在这里插入图片描述
在这里插入图片描述

2.3 设备连接与断开

When no function is attached to the downstream facing port of a host or hub in low-/full-speed, the pull-down
resistors present there will cause both D+ and D- to be pulled below the single-ended low threshold of the host
or hub transceiver when that port is not being driven by the hub. This creates an SE0 state on the downstream
facing port. A disconnect condition is indicated if the host or hub is not driving the data lines and an SE0
persists on a downstream facing port for more than TDDIS (see Figure 7-26).
A connect condition will be detected when the hub detects that one of the data lines is pulled above its VIH
threshold for more than TDCNN (see Figure 7-27 and Figure 7-28).
Hubs must determine the speed of the attached device by sampling the state of the bus immediately before
driving SE0 to indicate a reset condition to the device.
All signaling levels given in Table 7-2 are set for this bus segment (and this segment alone) once the speed of
the attached device is determined.

2.3.1 连接

Hub端口的D+、D-都有15K的下拉电阻,平时为低电平。全速设备内部的D+有1.5K的上拉电阻,低速设备内部的D-有1.5K的上拉电阻,连接到Hub后会导致Hub的D+或D-电平变化,Hub根据变化的引脚分辨接进来的是全速设备还是低速设备。

高速设备一开始也是作为全速设备被识别的。
全速设备、高速设备连接时,D+引脚的电平由低变高:

2.3.1.1 低速/全速断开检测

在这里插入图片描述

2.3.1.2 全速/高速设备连接检测

在这里插入图片描述

2.3.2 断开

对于低速、全速设备,接到Hub时导致D-或D+引脚变为高电平,断开设备后,D-或D+引脚变为低电平:
在这里插入图片描述
对于高速设备,它先作为全速设备被识别出来,然后再被识别为高速设备。工作于高速模式时,D+的上拉电阻是断开的,所以对于工作于高速模式的USB设备,无法通过D+的引脚电平变化监测到它已经断开。
工作于高速模式的设备,D+、D-两边有45欧姆的下拉电阻,用来消除反射信号:
在这里插入图片描述
当断开高速设备后,Hub发出信号,得到的反射信号无法衰减,Hub监测到这些信号后就知道高速设备已经断开,内部电路图如下:
在这里插入图片描述

2.4 复位

A hub signals reset to a downstream port by driving an extended SE0 at the port. After the reset is removed, the device will be in the Default state (refer to Section 9.1).
The reset signaling can be generated on any Hub or Host Controller port by request from the USB System
Software. The reset signaling must be driven for a minimum of 10ms (TDRST). After the reset, the hub port will
transition to the Enabled state (refer to Section 11.5).
As an additional requirement, Host Controllers and the USB System Software must ensure that resets issued to the root ports drive reset long enough to overwhelm any concurrent resume attempts by downstream devices. It is required that resets from root ports have a duration of at least 50 ms (TDRSTR). It is not required that this be 50 ms of continuous Reset signaling. However, if the reset is not continuous, the interval(s) between reset signaling must be less than 3 ms (TRHRSI), and the duration of each SE0 assertion must be at least 10 ms (TDRST).
A device operating in low-/full-speed mode that sees an SE0 on its upstream facing port for more than 2.5 µs
(TDETRST) may treat that signal as a reset. The reset must have taken effect before the reset signaling ends.
从状态切换图上看,一个USB设备连接后,它将会被供电,然后被复位。当软件出错时,我们也可以发出复位信号重新驱动设备。
那么,USB Hub端口或USB控制器端口如何发出复位信号?发出SE0信号,并维持至少10ms。
USB设备看到Reset信号后,需要准备接收"SetAddress()“请求;如果它不能回应这个请求,就是"不能识别的设备”。

2.5 设备速率识别

2.5.1 低速/全速

Hub端口的D+、D-都有15K的下拉电阻,平时为低电平。全速设备内部的D+有1.5K的上拉电阻,低速设备内部的D-有1.5K的上拉电阻,连接到Hub后会导致Hub的D+或D-电平变化,Hub根据变化的引脚分辨接进来的是全速设备还是低速设备。
在这里插入图片描述

2.5.2 高速

高速设备必定兼容全速模式,所以高速设备内部D+也有1.5K的上拉电阻,只不过这个电阻是可以断开的:工作于高速模式时要断开它。
高速设备首先作为全速设备被识别出来,然后Hub如何确定它是否支持高速模式?
Hub端口如何监测一个新插入的USB设备能否工作于高速模式?流程如下:

  • 对于低速设备,Hub端口不会监测它能否工作于高速模式。低速设备不能兼容高速模式。
  • Hub端口发出SE0信号,这就是复位信号
  • USB设备监测到SE0信号后,会发出"a high-speed detection handshake"信号表示自己能支持高速模式,这可以细分为一下3种情景
    • 如果USB设备原来处于"suspend"状态,它检测到SE0信号后,就发出"a high-speed detection handshake"信号
    • 如果USB设备原来处于"non-suspend"状态,并且处于全速模式,它检测到SE0信号后,就发出"a high-speed detection handshake"信号。这个情景,就是一个设备刚插到Hub端口时的情况,它一开始工作于全速模式。
    • 如果USB设备原来处于"non-suspend"状态,并且处于高速模式,它会切换回到全速模式(重新连接D+的上拉电阻),然后发出"a high-speed detection handshake"信号

“a high-speed detection handshake"信号,就是"高速设备监测握手信号”,既然是握手信号,自然是有来有回:

  • USB设备维持D+的上拉电阻,发出"Chirp K "信号,表示自己能支持高速模式
  • 如果Hub没监测到"Chirp K "信号,它就知道这个设备不支持高速模式
  • 如果Hub监测到"Chirp K “信号后,如果Hub能支持高速模式,就发出一系列的"Chirp K”、“Chirp J"信号,这是用来通知USB设备:Hub也能支持高速模式。发出一系列的"Chirp K”、"Chirp J"信号后,Hub继续维持SE0信号直到10ms。
  • USB设备发出"Chirp K “信号后,就等待Hub回应一系列的"Chirp K”、"Chirp J"信号
    • 收到一系列的"Chirp K"、"Chirp J"信号:USB设备端口D+的上拉电阻,使能高速模式
    • 没有收到一系列的"Chirp K"、"Chirp J"信号:USB设备转入全速模式
      在这里插入图片描述

2.6 数据信号

在这里插入图片描述

2.6.1 低速/全速的SOP和EOP

SOP:Start Of Packet,Hub驱动D+、D-这两条线路从Idle状态变为K状态。SOP中的K状态就是SYNC信号的第1位数据,SYNC格式为3对KJ外加2个K。
EOP:End Of Packet,由数据的发送方发出EOP,数据发送方驱动D+、D-这两条线路,先设为SE0状态并维持2位时间,再设置为J状态并维持1位时间,最后D+、D-变为高阻状态,这时由线路的上下拉电阻使得总线进入Idle状态。
在这里插入图片描述

2.6.2 高速的SOP

高速的EOP比较复杂,作为软件开发人员无需掌握。
高速模式中,Ide状态为:D+、D-接地。SOP格式为:从Idle状态切换为K状态。SOP中的K状态就是SYNC信号的第1位数据。
高速模式中的SYNC格式为:KJKJKJKJ KJKJKJKJ KJKJKJKJ KJKJKJKK,即15对KJ,外加2个K。

2.6.3 NRZI与位填充

NRZI:Non Return Zero Inverted Code,反向不归零编码。NRZI的编码方位为:对于数据0,波形翻转;对于数据1,波形不变。
在这里插入图片描述

使用NRZI,发送端可以很巧妙地把"时钟频率"告诉接收端:只要传输连续的数据0即可。在下图中,低速/全速协议中"Sync Pattern"的原始数据是"00000001",接收端从前面的7个0波形就可以算出"时钟频率"。
在这里插入图片描述
使用NRZI时,如果传输的数据总是"1",会导致波形维持不变。如果电平长时间维持不变,比如传输100位1时,如果接收方稍有偏差,就可能认为接收到了99位1、101位1。而USB中采用了Bit-Stuffing位填充处理,即在连续发送6个1后面会插入1个0,强制翻转发送信号,从而让接收方调整频率,同步接收。而接收方在接收时只要接收到连续的6个1后,直接将后面的0删除即可恢复数据的原貌。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值