1 / 24

Universal Serial Bus System Architecture (2)

Universal Serial Bus System Architecture (2). Physical layer. Data Encoding/Decoding The USB employs NRZI data encoding when transmitting packets. In NRZI encoding, a “1” is represented by no change in level and a “0” is represented by a change in level. Bit Stuffing

micol
Download Presentation

Universal Serial Bus System Architecture (2)

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. Universal Serial Bus System Architecture (2)

  2. Physical layer • Data Encoding/Decoding • The USB employs NRZI data encoding when transmitting packets. • In NRZI encoding, a “1” is represented by no change in level and a “0” is represented by a change in level. • Bit Stuffing • In order to ensure adequate signal transitions, bit stuffing is employed by the transmitting device when sending a packet on USB • A zero is inserted after every six consecutiveones in the data stream before the data is NRZI encoded, to force a transition in the NRZI data stream. • gives the receiver logic a data transition at least once every seven bit times to guarantee the data and clock lock.

  3. The Example of NRZI and Bit Stuffing

  4. Protocol Layer- Token Packet format 8-bit 8-bit 7-bit 4-bit 5-bit • Bit Ordering • Bits are sent out onto the bus least-significant bit (LSB) first • SYNC Field • All packets begin with a synchronization (SYNC) field, which is a coded sequence that generates a maximum edge transition density. • The SYNC field pattern is 00000001 • Packet Identifier Field (PID) • identify the packet is the token, data, and handshake packets • PID[7:4]=PID[3:0]#

  5. Address(7-bit) • 用來定址最多127個週邊裝置, 但位址0為default address. • endpoint(4-bit) • 可看成微管線, 為每個device內的register (或窗口), 最多一個device有32個endpoint (16* (IN/OUT)), endpoint 00為default communication point. • crc (cycle redundancy checks, 5-bit) • covers the ADDR and ENDP fields of IN, SETUP, and • OUT tokens or the time stamp field of an SOF token. The generator polynomial is: • G(X) = X5 + X2 + 1

  6. Data Packet format • PID為data0或data1 • 最初的資料封包都以DATA0為開始, 其後才是DATA1, 然後依此方式交替切換, 此動作稱為DATA TOGGLE 可確保整個傳輸過程中, 主機能與DEVICE維持同步 • 根據不同的傳輸型態, 其data field的長度限制將不同 • 控制型傳輸的DATA FIELD固定為8-BYTE • 中斷型傳輸在全速度傳輸時data為64 bytes,慢速傳輸僅為8 bytes,當資料小於設定值時,就表示最後一次的傳輸了 • 巨量型傳輸之data最大限制為8、16、32 or 64 bytes • 即時傳輸之data可為0~1023 bytes • CRC is a 16-bit polynomial applied over the data field of a data packet. • The generating polynomial is: G(X) = X16 + X15 + X2 + 1 8-bit 8-bit 0 ~1023 bytes 16-bit

  7. Handshake Packet 與SOF Packet Handshake packet • 接收端對傳送端送過來的資料回應 • Handshake packet有下列三種 • Ack packet :device己成功接收資料 • Nak packet:device尚未就緒 • Stall packet:發生接收錯誤 • SOF packet是用於即時型傳輸 • 讓device可利用SOF packet來辨識frame的起點 • 即在1ms的frame開始時, 即時型傳輸會利用SOF啟動傳輸並達到同步傳輸的作用. 8-bit 8-bit Start of Frame packet 8-bit 8-bit 11-bit 5-bit

  8. Transaction Format • Packet transaction format varies depending on the endpoint type. • There are four endpoint types: • bulk,control, interrupt, and isochronous. • Bulk Transactions • guarantee error-free delivery of data between thehost and a function • By means of error detection and retry. • use a three-phase transaction • token, data, and handshake packets

  9. Bulk Transfer

  10. Control Transfers • have two or three transaction stages: • Setup and Status. • May optionally contain a Data stage between the Setup and Status stages. • SETUP stage • SETUP transaction is used to transmit information to the control endpoint of a function.

  11. Control Transfers • Data stage • consists of one or more IN or OUT transactions • follows the same protocol rules as bulk transfers (consisting three packet, token, data, handshake). • All the transactions in the Data stage must be in the same direction • all INs or all OUTs • The amount of data to be sent during the data phase and its direction are specified during the Setup stage. • If the amount of data exceeds the prenegotiated data packet size, the data is sent in multiple transactions (INs or OUTs) that carry the maximum packet size. • Any remaining data is sent as a residual in the last transaction.

  12. Status stage • is the last operation of control transfer in the sequence. • A status stage is delineated by a change in direction of data flow from the previous stage and always uses a DATA1 PID.

  13. The Status stage reports to the host the outcome of the previous Setup and Data stages of the transfer. • Three possible results may be returned: • The command sequence completed successfully. • The command sequence failed to complete. • The function is still busy completing command.

  14. Control Transfer – three stages

  15. Example of Control Transfer (1) • device剛連上USB界面時, 其default位址為0, 主機利用default位址向其取得device descriptor(get_descriptor), 才知此device是做何用途, 將以何種傳輸方式來傳送資料, 其device driver為何, 等等. 因此, pc端必需先執行一setup token packet, 做為get_descriptor的transaction的開始.

  16. Example of Control Transfer (2) • 在setup token packet (為控制型傳輸)後面所接的data packet為 控制型傳輸的DATA FIELD固定為8-BYTE

  17. Example of Control Transfer (3) • handshake packet

  18. Interrupt Transactions • may consist of IN or OUT transfers. • the data toggle protocol must be followed.

  19. Interrupt Transfer

  20. Isochronous Transactions • have a token and data phase, but no handshake phase, • The host issues either an IN or an OUT token followed by the data phase in which the endpoint (for INs) or the host (for OUTs) transmits data.

More Related