1 / 104

ID 221C: USB for Embedded Systems Viewed from the Embedded Target Side

ID 221C: USB for Embedded Systems Viewed from the Embedded Target Side. Christian Légaré. Vice-President. 12 October 2010. Version: 1.0. Mr. Christian Légaré. Vice-President PREVIOUS EXPERIENCE:

airlia
Download Presentation

ID 221C: USB for Embedded Systems Viewed from the Embedded Target Side

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ID 221C: USB for Embedded Systems Viewed from the Embedded Target Side Christian Légaré Vice-President 12 October 2010 Version: 1.0

  2. Mr. Christian Légaré Vice-President PREVIOUS EXPERIENCE: Twenty five years in the Telecom industry as an executive, Engineering Manager, Product Manager, and Engineer at various levels Internation Insstitute of Telecommunication, Schlumberger, Telweb, Mincacom, Alphanet, Teleglobe Canada, Télésystème National, SMIS I hold an MSEE from the University of Sherbrooke, Québec, Canada

  3. USB Products 3

  4. Our Position Micriµm is consistently recognized as a leader in embedded software components. Micriµm products are created for engineers by engineers and are designed to work with the resources available on embedded systems. Micriµm provides you RTOS and Tools. The industry surveys for the last 5 years position Micriµm as the #2 RTOS vendor.

  5. Agenda Hardware architecture Mechanical specifications Electrical specifications Software specifications Compliance Final comments

  6. USB for Embedded Systems Universal Serial Bus : Serial bus standard to interface devices. Peripheral communication protocol of choice for keyboards, printers, and memories Automatic error detection and recovery. Large number of devices. (127) Replaced RS-232 This document covers USB and differentiate USB Host protocol stack from USB Device protocol stack and On-The-Go. It goes over the design implications and some solutions.

  7. Brief history

  8. Architecture topology • • Star network configuration • • Only one host • • Maximum of seven levels of tiers, hub at center • • Host schedules and initiates data transfers. • • Host and hubs provide power to slaves • • Maximum number of devices allowed to connect to the bus is 127 • Devices are referred to as functions • • Three rates: 1.5Mbps (Low), 12Mpbs (Full) & 480Mbps (High)

  9. Mechanical specifications Cable: • Cable is made of 4 28-AWG conductors: Vbus Power Red Gnd Power Black D+ Data Green D-Data White • Data pair is twisted • Maximum cable length is 5 meters • Low speed cables are attached to device Connector: • Connector Type A connects to host • Connector Type B connects to device • Connector power pins are longer for hot-swap • Mini connectors were added in USB 2.0 and OTG supplement 1 2 3 4 Type A USB Connector 2 1 3 4 Type B USB Connector

  10. Mechanical specifications A mini-B plug and receptacle has also been defined as an alternative to the standard B connector on handheld and portable devices. The mini-B connecter has a fifth pin, named ID, but it is not connected. Mini-B Plug and Receptacle Pin Assignments Mini-B USB Connector 1 2 3 4 5

  11. OTG connectors White insulator 5 1 Micro-A USB Connector Black insulator 5 1 Micro Plug Pin Assignments Micro-B USB Connector

  12. Serial Interface Engine (SIE) The complexities and speed of the USB protocol are such that it is not practical to expect a general purpose microcontroller to be able to implement the protocol using an instruction-driven basis. Dedicated hardware is required to deal with the time-critical portions of the specification, and the circuitry grouping which performs this function is referred to as the Serial Interface Engine (SIE).

  13. Electrical specificationsDevice detection Current is limited to 100mA Either the D+ or the D- line will be pulled high D+ is high, the device is a full or high speed D- is high, the device is a low speed High Speed negotiation protocol occurs during the Bus Reset phase After detecting the reset signal, the high speed device will signal the host with a 480 Mbps chirp

  14. The USB bus 5V supply is a very attractive feature. A USB device with a single connection is also attractive to the user Supply voltage can fall to 4.35V at the device When other devices are being plugged, there can be transients lowering the supply voltage by 0.4V Devices can be classified as: Bus powered Self powered Hybrid powered Device Powering

  15. Device Powering Self-powered devices provide power requirements on descriptor (see descriptor in the software section). Initially provides 100mA, this can be increased up to 500mA (high power) Self-powered hubs have a limitation on self-powered devices of 100mA A device may draw up to 500mA after it has been configured as a high-power device. Being configured is dependent on the Hub being able to supply 500mA, which implies a self-powered hub. So there is always a degree of uncertainty whether more than 100mA will be available. It is a good design practice to offer the option of external power via a socket on such a device. Devices requiring more than 500mA are obliged to be self-powered. (It is dangerous to attempt to draw power from two adjacent USB ports using a modified cable. It is not permitted by the specification and can easily damage the ports)

  16. Device Powering There is a suspend mode (no bus activity). In suspend mode, devices consume up to 500µA (where 200 µA already used by the pull up and pull-down resistors) Devices containing a micro-controller need a sleep mode which meets this requirement. but do not forget that a badly placed resistor can very easily draw current which you hadn't expected. Measure your suspend current with a meter High power devices (up to 500 mA) with remote wakeup feature enabled are allowed to draw up to 2.5mA during suspend This suspendcondition will occur at least once before the device is configured

  17. Hot-Pluggable Place a capacitance of at least 1uF across Vbus and GND to prevent from flyback voltage when unplugging a cable at the far end from the device The maximum value of the shunt capacitor across Vbus and GND is limited by the specification to 10uF. This is to avoid other devices to crash because plugging device in, a capacitance between Vbus and GND will cause a dip in voltage across the other ports of the hub For the same reason, the hub port supply must be bypassed with at least 120uF

  18. Self-Powered Devices If you pull, say D+, high in the absence of Vbus then you will risk faulty operation with On-The-Go hosts When designing a self-powered device, you must not pull a D+ or D- line above the Vbus voltage supplied. This means that you must sense when Vbus is connected The D+ or D- resistor should be pulled up to a 3.3V supply derived from Vbus, or controlled by Vbus in such a way that the resistor never sources current to the data line when Vbus is switched off

  19. More Power On-The-Go and Battery Charging Specification both add new powering modes to the USB specification. Powered USB (aka Retail USB, USB Plus Power, and USB + Power) +5 volts DC at up to 6 amps per connector (up to 30 watts) +12 volts DC at up to 6 amps per connector (up to 72 watts) +24 volts DC at up to 6 amps per connector (up to 144 watts) Powered USB uses standard USB signaling with the addition of extra power lines for point-of-sale terminals IBM owns the intellectual rights to Powered USB and charges a licensing fee for its use

  20. Physical layer signaling Asynchronous communications Differential signal with a 4VDC sweep (300mV HS) Data on the bus is encoded using Non-Return-to-Zero-Inverted (NRZI) Use of bit stuffing to avoid loosing synchronization The bits are transmitted least-significant-bit (LSB) first.

  21. Line States Given that there are just 2 data lines to use, it is surprising just how many different conditions are signaled using them:

  22. Detached When no device is plugged in, the host will see both data lines low, as its 15 kohm resistors are pulling each data line low.

  23. Attached When the device is plugged in to the host, the host will see either D+ or D- go to a '1' level, and will know that a device has been plugged in. The '1' level will be on D- for a low speed device, and D+ for a full (or high) speed device.

  24. Idle Idle state D+ and D- The state of the data lines when the pulled up line is high, and the other line is low, is called the idle state. This is the state of the lines before and after a packet is sent.

  25. J and K States To make it easier to talk about the states of the data lines, some special terminology is used. The 'J State' is the same polarity as the idle state (the line with the pull-up resistor is high, and the other line is low), but is being driven to that state by either host or device. The K state is just the opposite polarity to the J state. The J and K terms are used because for Full Speed and Low Speed links they are actually of opposite polarity.

  26. SE0 D+ and D- SE0 The Single Ended Zero (SE0) is when both lines are being pulled low.

  27. EOP signal Last data bits of packet 2 bits 1 bit Idle state D+ and D- EOP The End of Packet (EOP) is an SE0 state for 2 bit times, followed by a J state for 1 bit time.

  28. Single Ended One (SE1) SE1 D+ and D- This is the illegal condition where both lines are high. It should never occur on a properly functioning link.

  29. Reset >= 10ms Idle state Idle state D+ and D- Reset When the host wants to start communicating with a device it will start by applying a 'Reset' condition which sets the device to its default unconfigured state. The Reset condition involves the host pulling down both data lines to low levels (SE0) for at least 10 ms. The device may recognize the reset condition after 2.5 us. This 'Reset' should not be confused with a micro-controller power-on type reset. It is a USB protocol reset to ensure that the device USB signaling starts from a known state.

  30. Suspend Idle state Suspended D+ and D- >= 3ms With today’s emphasis on energy saving, the USB suspend mode is very useful. It allows to power down an unused device. Suspending a device is achieved by not sending anything to the device for 3 ms. A Start-Of-Frame packet (at full speed, see Packets section) or a Keep Alive signal (at low speed) is sent by the host every 1 ms to keep the device awake. A suspended device must recognize the resume signal and the reset signal.

  31. Keep Alive Signal Idle state 2 bits 1 bit Idle state D+ and D- Keep Alive This is represented by a Low speed EOP. It is sent at least once every millisecond on a low speed link, in order to keep the device from suspending.

  32. Resume Suspended Resume D+ and D- Idle J state K state Idle J state >= 20 ms 2 low speed bit time 1 low speed bit time When the host wants to wake the device up after a suspend, it does so by reversing the polarity of the signal on the data lines for at least 20ms. The signal is completed with a low speed end of packet signal. It is also possible for a device with its remote wakeup feature set, to initiate a resume itself. It must have been in the idle state for at least 5ms, and must apply the wakeup K condition for between 1 and 15 ms. The host takes over the driving of the resume signal within 1 ms.

  33. Data Signaling Rate Another area which is often overlooked is the tolerance of the USB clocks. High speed data is clocked at 480.00Mb/s with a data signaling tolerance of ± 500ppm. Full speed data is clocked at 12.000Mb/s with a data signaling tolerance of ±0.25% or 2,500ppm. Low speed data is clocked at 1.50Mb/s with a data signaling tolerance of ±1.5% or 15,000ppm. This allows resonators to be used for low cost low speed devices, but rules them out for full or high speed devices.

  34. Software specificationsUSB Protocols Packets Transfer types Transactions Frames Endpoints Pipes

  35. Packets The fundamental element of communications is the packet A packet is made of three parts: START, INFORMATION, and END-OF-PACKET (EOP) At the START of a packet will be a sequence of transitions which is called SYNC The SYNC pattern is a chirp of either 8 bits (full-/low-speed) or 32 bits (high-speed) where each bit is a J or K state: KJKJKJKJKJKJKJKJKJKJKJKJKJKJKJKJKK The INFORMATION varies from 1 byte up to 1024 bytes Packet Identifier (PID) – 4bits + complement Payload and CRC – Not present in handshake packets The EOP is indicated by having both D+ and D- low for 3 bits (full-/low-speed) or 8 bits (high-speed).

  36. USB Packet FieldsSYNC SYNC All packets must start with a SYNC field. The SYNC field is 8 bits long at low and full speed or 32 bits long for high speed and is used to synchronize the clock of the receiver with that of the transmitter. The last two bits indicate where the PID fields starts.

  37. USB Packet FieldsPID PID PID stands for Packet ID. This field is used to identify the type of packet that is being sent.

  38. USB Packet FieldsPID The first 2 bits of a Token which are transmitted determine which of the 4 groups it falls into. SOF is officially considered to be a Token PID. Bits are transmitted LSB first.

  39. USB Packet FieldsPID PID0 PID1 PID2 PID3 nPID0 nPID1 nPID2 nPID3 PID shown in transmission order, LSB first. The first byte in every packet is the Packet Identifier (PID) byte. This byte needs to be recognized quickly by the USB controller. This is why it is not included in any CRC checks. It has its own validity check. There are 4 bits to the PID. The check method uses the PID 4 bits by repeating and complementing them, making an 8 bit PID field in total.

  40. USB Packet FieldsADDR ADDR The address field specifies which device the packet is designated for. Being 7 bits in length allows for 127 devices to be supported. Address 0 is not valid, as any device which is not yet assigned an address must respond to packets sent to address zero.

  41. USB Packet FieldsENDP ENDP The endpoint field is made up of 4 bits, allowing 16 possible endpoints. Low speed devices, however can only have 2 additional endpoints on top of the default pipe. (4 endpoints max)

  42. Cyclic Redundancy Code (CRC) A CRC is a value calculated from a number of data bytes to form a unique value which is transmitted along with the data bytes, and then used to validate the correct reception of the data USB uses two different CRCs • a 5 bits long (CRC5) and • a 16 bits long (CRC16) The USB specification contains all the details for the algorithms used to compute the CRCs

  43. USB Packet FieldsEOP EOP End of packet. Signalled by a Single Ended Zero (SE0) for approximately 2 bit times followed by a J for 1 bit time.

  44. USB Packet Types USB has four different packet types. Start of Frame Packets Token Packets Data Packets Handshake Packets & Split Transaction Special Token Packets

  45. Start of Frame Packets Start of frame packets indicate the start of a new frame. The SOF packet consisting of an 11-bit frame number is sent by the host every 1ms ± 500ns on a full speed bus or every 125 µs ± 0.0625 µs on a high speed bus. The first transaction in each (micro)frame. An SOF allows endpoints to identify the start of the (micro)frame and synchronize internal endpoint clocks to the host.

  46. Token Packets Token packets indicate the type of transaction to follow. They are always the first packet in a transaction, identifying the targeted endpoint, and the purpose of the transaction. There are three types of token packets: In Informs the USB device that the host wishes to read information. Out Informs the USB device that the host wishes to send information. Setup Used to begin control transfers.

  47. Data Packets Data packets contain the payload. There are two types of data packets each capable of transmitting up to 1024 bytes of data. Data0 Data1 DATA0 and DATA1 PIDs are used in Low and Full speed links as part of an error-checking system. When used, all data packets on a particular endpoint use an alternating DATA0 / DATA1 so that the endpoint knows if a received packet is the one it is expecting. If it is not the expected packet, it will still acknowledge (ACK) the packet as it is correctly received, but will then discard the data, assuming that it has been re-sent because the host missed seeing the ACK the first time it sent the data packet.

  48. Data Packets High Speed mode defines another two data PIDs, DATA2 and MDATA. DATA2 This data packet token has been added as part of a system for controlling multiple isochronous IN packets during one microframe at high speed. For each isochronous IN packet requested, the suffix of the DATAx PID represents the remaining number of packets to be transferred during the current micro-frame. MDATA This data packet token has been added as part of a system for controlling multiple isochronous OUT packets during one microframe at high speed. All but the last packet sent during a microframe use the MDATA PID. The last packet sent uses DATA0, DATA1 or DATA2 depending on whether one, two or three packets were sent.

  49. DATA packets One transaction per microframe DATA0 Two transactions per microframe DATA1 DATA0 Three transactions per microframe DATA2 DATA1 DATA0 Isochronous IN When requesting IN transactions, the device packages them in DATA2, DATA1 or DATA0 packets, depending on how many packets per microframe are specified, and which one it is.

  50. DATA packets One transaction per microframe DATA0 Two transactions per microframe MDATA DATA1 Three transactions per microframe MDATA MDATA DATA2 Isochronous OUT When sending OUT transactions, the host packages them either in MDATA or DATA0 or DATA1 or DATA2 packets.

More Related