USB On-The-Go (OTG) Basics

USB On-The-Go (OTG) Basics
USB On-The-Go (OTG) Basics
To accomplish OTG functionality, a USB device must be able
to function as a host, a role previously served exclusively by
desktop or laptop personal computers. Adding host capability
to a USB device is only part of the requirements to operate as
an OTG device, however. The OTG Specification introduces
new cables, connectors and two new protocols—Session Request Protocol (SRP) and Host Negotiation Protocol (HNP).
Additionally, the OTG specification defines a new type of USB
device with both host and peripheral capabilities called a “dualrole device”.
The release of the On-The-Go (OTG) supplement to the USB
2.0 Specification changed the USB world. For the first time,
spec-compliant USB devices can talk to each other without
requiring the services of a host computer. Cell phones and
PDAs can exchange contact lists, phones can attach to printers and print faxes, and MP3 players can swap tunes.
mini-B receptacle and plug were defined, so a mini-B plug
mates with the new mini-AB receptacle. As Figure 3 illustrates,
a camera with the new OTG mini-AB receptacle is a direct
substitute for the camera with the mini-B connector in Figure 2.
Figure 3. New OTG Mini-AB Receptacle
As its name implies, the mini-AB receptacle accepts either the
standard mini-B plug, or a new OTG plug, the mini-A. Two new
OTG cables are defined, the mini-A to B, and the mini-A to
mini-B (Figure 4).
This note covers the electrical and protocol aspects of OTG,
providing “big picture” information that should make it easier to
read and understand the formal OTG Specification.
Printer B
Figure 4. Two New OTG Cables
Figure 1. Standard USB A-B Cable
Two new cables and two adapters are defined in the OTG
Specification. For background, Figure 1 shows the traditional
A and B connectors, and the standard A-to-B cable that connects USB peripherals to PC hosts. Following the Figure 1
model, the OTG specification refers to hosts as “A” devices
and peripherals as “B” devices.
In October 2000, the mini-B receptacle and plug were incorporated as standard USB components to allow portable equipment such as digital cameras and MP3 players to use a smaller connector than the relatively large “B” receptacle (Figure 2).
Figure 2. Standard USB Mini-B Receptacle and Plug
OTG introduces a new receptacle, the mini-AB, which accepts
either the standard USB mini-B plug, or a new OTG plug, the
mini-A (Figure 3). Fortunately, OTG was anticipated when the
Cypress Semiconductor Corporation
The top cable allows a new OTG device to talk as a host to a
traditional USB peripheral. The bottom cable allows two OTG
devices to talk to each other.
In the Figure 4 camera-to-camera connection, both dual-role
cameras provide mini-AB receptacles, so each must function
either as host or peripheral. This raises an obvious question:
at connection, which is the host, and which is the peripheral?
The OTG spec resolves this question in a very simple manner—the cable decides.
OTG receptacles and plugs contain a fifth pin, added to the
standard four USB pins (VBUS, GND, D+ and D–). This is a fifth
pin in the connector, not a fifth wire in the cable. The mini-A
plug has the fifth pin tied to its ground pin, and the mini-B plug
leaves the fifth pin unconnected. A dual-role device requires
circuitry to read the state of this fifth pin (with, for example, the
aid of a pull-up resistor) to determine which end of the cable is
The dual-role device receiving the mini-A plug is the default
To understand why the word “default” is important, take a look
at Figure 5.
3901 North First Street
San Jose
CA 95134
May 17, 2002
[+] Feedback
invented the Host Negotiation Protocol (HNP) to allow two connected dual-role devices to exchange roles. Using HNP, the
camera in Figure 5 can assume the host role, even though the
initial cable connection established the printer as the default
host (A-Device). This saves (a) informing the user of an nonworkable connection, and (b) making the user remove the cable and plug it in “the other way”.
To summarize: For an orderly start-up, one of the devices must
be the “initial” (default) host, a role established by the cable.
Once connected, the devices can use HNP to exchange roles.
Figure 5. “Backwards” Cable Connection
In Figure 5, two dual-role devices are connected with a mini-A
to mini-B cable. The camera contains a printer driver. However,
the mini-A end of the cable was connected to the printer, making it the default host. This would be backwards—the camera
needs to be the host in order to print.
Note: Dual-role devices must operate at full speed (high
speed optional) as a peripheral. Dual-role devices must operate at full speed (low and high speed optional) as a host.
The OTG architects put a lot of thought into the user experience. Realizing that the Figure 5 connection is possible, they
[+] Feedback
a_bus_req =
a_bus_suspend &
Figure 6. HNP Simplified and Combined State Diagram
Host Negotiation Protocol (HNP)
Device a window of opportunity to become host, the A-Device
suspends the bus (a_suspend state). The A-Device suspends
the bus according to standard USB protocol, i.e. by stopping
all bus traffic for at least 3 ms. The A-Device is still operating
as the host, so its pull-down resistors remain on.
The OTG specification provides individual A-Device and B-Device state diagrams to illustrate how dual-role devices function.
The state diagram shown in Figure 6 is derived from these
state diagrams. Figure 6 combines A and B-Device behavior
into one simplified diagram, which contains the states relevant
to HNP. The A-Device is on the left, and the B-Device is on the
right. As in the OTG spec, state names with the “a_” prefix
pertain to the A-Device, and state names with the “b_” prefix
pertain to the B-Device.The Figure 6 state names and the italicized signal names are taken directly from the OTG specification. The added “PU” ovals indicate connection of the D+/D–
pullup resistor, and the “PD” ovals represent connection of the
15-kΩ pull-down resistors on D+ and D–.
The B-Device, sensing that the bus is inactive, now has a shot
at becoming the host. If (a) the B-Device is HNP-capable and
(b) the B-Device has HNP-enabled, and (c) the B-Device detects that the A-Device has suspended the bus, and (d) the
application running on the B-Device wants to request the bus
(b_bus_req signal), then the B-device transitions to the
b_wait_acon state, meaning “the B-Device waits for the ADevice to connect”. In this state the B-Device “disconnects” by
turning its pullup resistor off and turning its pull-down resistors
on. Because neither side is driving the bus, the put-downs
cause D+ and D– to go LOW, a condition known as a singleended-zero (SE0).
Initial conditions are the A-Device operating as host (a_host
state) and the B-Device operating as a peripheral
(b_peripheral state). As a host, the A-Device has its pull-down
resistors turned on, and as a peripheral the B-Device has its
pull-up turned on. In this state, the A-Device performs all the
normal host duties, including bus reset, generating SOF packets, enumerating the B-Device, and suspend-resume.
After “disconnecting,” the B-Device waits in the b_wait_acon
state for the A-Device to “connect” as a peripheral. The ADevice, which is in the a_suspend state, detects the SE0, and
transitions to the a_peripheral state, where it “connects” as a
peripheral in the normal USB way, by powering its D+ pullup
resistor. This connection creates a J-state on the bus, which
the B-Device detects as an A-Device peripheral connect event.
This causes the B-Device to transition to the b_host state, and
the role reversal is complete.
At some point, the application running on the A-Device no
longer needs to use the B-Device. At this point, the A-Device
must give the B-Device an opportunity to be the host.There are
prerequisites to this benevolence:
• When the A-Device enumerated the B-Device, the B-Device
must have returned an OTG Descriptor indicating that it is
capable of supporting HNP. The B-Device includes this descriptor in its response to the Get_Descriptor(Configuration)
Going the opposite way, from A-peripheral/ B-host back to Ahost/B-peripheral is very similar. The B-Device suspends, and
the A-Device disconnects.
The OTG Specification imposes timing constraints on the state
transitions. For example, the A-Device must make its transition
from a_suspend to a_peripheral within 3 ms of detecting an
SE0 on the bus. Once in the a_peripheral state, it must maintain its connected state for at least 3 ms to give the B-Device
time to respond and generate a bus reset. The B-Device has
1 ms to detect and respond to the A-Device connect, so the
3-ms holding time insures 2 ms of margin.
• The A-Device must have enabled the B-Device for HNP by
sending an OTG-specific Set_Feature request (with feature
selector, “b_hnp_enable”).
The application running on the A-Device starts the HNP ball
rolling by negating an internal signal called “a_bus_req”, indicating that it does not need to use the bus. To give the B-
[+] Feedback
The simplified Figure 6 state diagram omits many details for
clarity. It shows the normal progression of events for a successful HNP role switch. The OTG Specification also covers
the “else” conditions, such as a mid-HNP cable detach.
An OTG dual-role device must have a power decoupling capacitor that is in the range of 1.0–6.5 µF (Figure 7). This is a
departure from a classic host, which has a minimum VBUS capacitance of about 95 µF (this value takes capacitor tolerance
into effect). As we’ll see, this large capacitance difference allows the SRP VBUS pulsing method to be recognized by dualrole device while causing no damage if the B-Device plugs into
a standard host.
The OTG state diagrams use “timer variables” to resolve some
signaling issues. For example, in the b_wait_acon state, the
B-Device waits for a J-state on the bus, signifying that the ADevice has connected as a peripheral. When the B-Device is
in its b_wait_acon state, the A-Device is in its a_suspend
state, so neither side is driving the bus, resulting in an SE0 bus
state. However, an SE0 can also represent a USB bus reset,
if it is held for 10 ms. Therefore the B-Device must revert to the
b_peripheral state if, while in the b_wait_acon state, it does
not detect a J-state within 3.125 ms.
An A-device must be able supply at least 8 mA of VBUS current
at 4.4V, the minimum voltage necessary to guarantee proper
B-Device operation. A voltage comparator with a 4.4V (min.)
threshold in the A-Device provides a signal called
a_vbus_valid. The spec requires a_vbus_valid to be true
within 100 ms after the A-Device turns on VBUS.
Note: If a_vbus_valid does not go TRUE within 100 ms, this
implies that the B-Device is drawing more current that the ADevice can supply, so the A-Device turns off VBUS and terminates the session.
Session Request Protocol (SRP)
The OTG specification contributes a new mechanism that allows an A-Device to turn off VBUS as a power saving measure.
From this state, a B-Device can wake up the A-Device by asking it to turn on VBUS and start a new session. This mechanism
is called Session Request Protocol (SRP).
An unpowered A-Device must present an input impedance
less than 100 kΩ. If the device is designed to respond to the
VBUS pulsing method, the input impedance must be at least
40 kΩ (Figure 8).
The relationship between SRP and HNP can be summarized
as follows:
• Dual-role devices are required to be able to initiate and respond to SRP.
• The A-Device always provides VBUS. Even if two dual-role
devices use HNP to make the B-Device a host and the ADevice a peripheral, the A-Device still supplies VBUS.
• Non dual-role devices, which are inherently incapable of
HNP, may still initiate SRP. For example a mouse with an
internal battery could request a session from a dual-role
1-6.5 uF
Figure 8. Load Presented by an Unpowered A-Device
A “session” is defined as the period of time that VBUS is on, or
more particularly, VBUS is above a device’s “session valid”
threshold voltage.
Before starting SRP, the B-device must first insure that VBUS
is low enough that an SRP-capable A-device is below its session valid threshold (0.8V min.). One way to do this is simply
to wait for the pull-down resistors to discharge the bypass capacitors. If two dual-role devices are connected, then the
weakest pull-down is the parallel combination of two 100K resistors, and the maximum capacitance is 2*6.5 µF. Using these
worst-case values leads to the longest discharge time being
approximately 1.1 second.
B-Devices use two methods to request a session, data line
pulsing followed by VBUS pulsing. A-Devices are required to
respond to one of the two signaling methods, but a B-Device
must use both methods to insure that any A-Device recognizes
B-Devices perform data line pulsing by powering their D+/D–
pull-up resistor for 5–10 ms. Dual-role devices must use the
D+ pull-up.
The B-Device may speed this discharge by connecting a resistor from VBUS to ground. The maximum current the B-Device
may draw is 8 mA, so the minimum resistance to ground is
5.25V / 8 mA = 656Ω. The R-C time constant for the discharge
is then (656Ω)(13 µF) = 8.5 ms. The VBUS capacitance can
discharge from 5.25V to 0.8V in 1.88 time constants, or 16 ms.
B-Devices perform VBUS pulsing by driving VBUS. Driving
power onto a wire connected to an “off” power source (in the
A-Device) obviously requires some care. The following discussion illustrates the important factors by working through a simplified example, pointing out the important OTG spec issues.
Note: The 5.25 Volt starting voltage is conservative, since the
B-Device may not initiate SRP until VBUS has dropped below
its session threshold of 4.4 Volts (max).
As an alternative to timing the discharge, the B-Device may
use a 0.8-Volt “session end” comparator to directly measure
VBUS (Figure 9).
1-6.5 uF
Figure 7. An OTG A-Device Powering VBUS
[+] Feedback
0.8-2.0 V
1. Not connected to a dual-role device (whose VBUS would
have discharged below 0.8V due to its much smaller capacitance), or
the signal b_session_end. The B-Device may either wait 1.1
second, or pull down VBUS through a resistor (for example a
656Ω resistor for 16 ms) to try to pull VBUS below 0.8V. If the
attempt fails (b_session_end is not TRUE), the B-Device can
deduce that it is either:
2. It is plugged into an A-Device that is driving VBUS.
OTG A-Device
The first case would happen if the standard host had very recently powered down, leaving a residual voltage on its VBUS
capacitor(s). In either case, the B-Device should go to the
b_peripheral state, where it cannot initiate SRP until its
session_valid variable goes FALSE.
Pulsing a VBUS capacitance of 96 uF through a 281Ω resistor
for the computed 10 ms raises the capacitor voltage by:
OTG B-Device
Figure 9. B-Device Pulses VBUS to Wake Up A-Device
Vc = (3.6V – 0.8V) (1-e-t/RC) = 0.87V
Having determined that VBUS is under 0.8V, the B-Device may
attempt to wake up the A-Device by pulsing VBUS.The example
circuit in Figure 9 shows a 281Ω current-limiting resistor,
whose value is calculated to guarantee that the unconfigured
B-Device never draws more than the OTG-specified 8 mA, as
follows. The worst-case current draw occurs when a the ADevice turns on VBUS while the B-Device is still signaling SRP,
and the B-Device VCC is the minimum 3.0V, causing the largest
voltage difference between the devices. The minimum series
resistance required to limit the current flowing into the B-Device is derived as follows:
Since we assumed a worst-case initial VBUS voltage of 0.8V,
the resulting voltage across the VBUS capacitance is
0.8V + 0.87V = 1.67V, safely below the 2.0V limit.
Note that if the B-Device tested for end-of-session by connecting a 656Ω resistor to ground for 16 ms (as in this example),
the voltage on the capacitor initially decreased by 1.82V before
the B-Device applied the VBUS pulse. Therefore the pulse did
not raise VBUS above its starting value.
Conclusion: As long as the design insures that more charge
is removed than added to the VBUS decoupling capacitance by
a VBUS pulse, a standard USB host will be unaffected and
undamaged by the pulse.
(5.25V – 3.0V) / 8 mA = 281Ω
How long should the B-Device pulse VBUS? Two factors determine this. The pulse width must be:
This discharge-before-charge sequence allows a cost sensitive B-Device to replace the session-end comparator with a
simple gate, as shown in Figure 10. In this case the B-Device
must time the discharge of the VBUS capacitor as previously
described, since it cannot precisely measure 0.8V. Before
pulsing VBUS, the B-Device must insure that the
b_session_valid variable is FALSE, whatever the threshold
voltage of the gate happens to be. Since the detection method
involves a discharge mechanism for the VBUS capacitance prior to pulsing VBUS, the designer can insure that no net voltage
increase occurs on VBUS, and therefore that the VBUS pulse
does not inadvertently trip the B-Device’s session-valid threshold.
1. Long enough to guarantee that the maximum capacitance
of two dual-role devices (13 µF) is charged to at least 2.1V,
2. Short enough to guarantee that the capacitance of a legacy
host (95 µF) is not driven above 2.0V.
The designer of the B-Device knows the current limit of its
VBUS charging circuit. Using the example circuit of Figure 9
with the maximum capacitance values, and ignoring the pulldown resistors, one R-C time constant is approximately:
RC = 281 * 13 µF = 3.6 ms
A discharged R-C network reaches 0.950 of its driving voltage
after three time constants. Using the minimum VCC of 3.0V,
driving VBUS for three time constants (10 ms) raises the voltage by 3V*.95 or 2.85V. 2.85V is above the required 2.1V spec
value, so the first condition is met.
Classic Host
Note: Ten milliseconds is a conservative charging time. It
takes 1.2 time constants to charge from 0.0V to 2.1V with a 3V
supply. Ignoring component tolerances, and using the 3.6-ms
time constant, charging from 0V to 2.1V takes 3.6*1.2 = 4.4
ms. Nevertheless, we’ll use the more conservative 10 ms value
for the example calculation.
At least
96 uF
Now we need to check the effect of this pulse when the BDevice is plugged into a standard USB host.
Assume that the B-Device has a session-end comparator, as
in Figure 9. In the OTG spec, the output of this comparator is
Figure 10. A Cost-Sensitive B-Device
[+] Feedback
Turn on VBUS
a_sess_vld /
& b_conn /
Turn off VBUS
b_sess_vld /
Figure 11. SRP Simplified and Combined State Diagram
To help understand the A and B-Device interactions while performing SRP, the state diagram in Figure 11 simplifies and
combines the OTG Specification A-Device and B-Device state
state, where it waits for the B-Device to “connect” by turning
on its pull-up resistor. The B-Device, sensing that VBUS has
exceeded its session valid threshold voltage (0.8V–4.0V), transitions to the b_peripheral state where it turns on its data pullup resistor. The A-Device sense this as the b_conn signal,
which, after adequate debounce time of the data line, causes
a transition to a_host, and we’re in business—the A-Device
operates in its a_host meta-state, exhibiting all host behavior,
and the B-Device operates in its b_peripheral meta-state, exhibiting all peripheral behavior.
Before starting a new session, the B-Device must insure that
two initial conditions are valid:
• No session is in progress (VBUS < 0.8V).
• While in the b_idle state (which disconnects the B-Device’s
pullup resistor, creating an SE0 on the bus), the bus must
have been in the SE0 state for at least 2 ms.
At some point, the A-Device is done with the session. One of
many possible definitions of “DONE” is that the A-Device batteries are dangerously low. In this particular case, since the Adevice can't continue to power VBUS and allow the B-device to
become host, the A-Device turns off VBUS and transitions to
a_wait_fall. The B-Device, also sensing the drop in VBUS as it
drops below the B-Device’s session-valid threshold (0.8-4.0V),
transitions back to its b_idle state.
Once these conditions are met, the application running on the
B-Device can indicate that it wants to use the bus (to signal a
wakeup) by asserting the b_bus_req signal, causing the BDevice to transition to the b_srp_init meta-state. (A “metastate” is a state containing other states or behaviors; in this
example the b_srp_init state contains the data-pulsing and
VBUS pulsing methods described above.)
The A-Device waits in its a_wait_vfall state until two requirements are met:
The A-Device must be in its a_idle state to detect the B-Device
attempting to initiate SRP, and when it sees the a_srp_det variable go true, it turns on VBUS and transitions to the
a_wait_vrise state, where it waits for VBUS to reach a valid
level (4.4 V minimum). The B-Device, having finished its SRP
signaling, transitions back to its b_idle state, where it waits for
the A-Device to indicate a valid session.
1. VBUS has dropped below the A-Device’s session-valid voltage, and
2. The B-Device has indicated its session is over by disconnecting its data pullup resistor (the variable b_conn is
Meanwhile, back at the A-Device, when VBUS reaches its session threshold voltage (4.4V), it transitions to its a_wait_bcon
[+] Feedback
The second requirement avoids a subtle race condition. If the
A-Device made its transition to a_idle before the B-Device
turned off its pull-up resistor (indicating that the B-Device
knows its session is over), the A-Device would find a data line
high and think the B-Device was (again) signaling SRP, and
immediately transition to the a_wait_vrise state. This provision is indicative of the care taken by the OTG Specification
authors to cover all possibilities.
ately suspend and start HNP. This is especially useful if the BDevice did SRP, since it gains control quickly. If the B-Device
did SRP but STALLS the SetFeature (b_hnp_enable) request,
it’s a peripheral-only device and the A-Device goes ahead and
enumerates it.
Although the example design presented in this note uses simplified diagrams and values, the example calculations and
state diagrams should aid the understanding of what constitutes a spec-compliant OTG device. The background information presented in this note should help the reader navigate the
parameters and state diagrams in the OTG Specification.
SRP-HNP “Shortcut”
An interaction between SRP and HNP is worth noting. To save
time, the A-Device can just come on and send a SetFeature
(b_hnp_enable) request. If the B-Device doesn’t STALL, then
the B-Device is HNP-capable and the A-Device can immedi-
All product and company names mentioned in this document may be the trademarks of their respective holders.
approved dsg 6/4/02
[+] Feedback
© Cypress Semiconductor Corporation, 2002. The information contained herein is subject to change without notice. Cypress Semiconductor Corporation assumes no responsibility for the use
of any circuitry other than circuitry embodied in a Cypress Semiconductor product. Nor does it convey or imply any license under patent or other rights. Cypress Semiconductor does not authorize
its products for use as critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress
Semiconductor products in life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress Semiconductor against all charges.
[+] Feedback
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF