Helpful ReplyUSB Serial Interface Engine (SIE) - Error detection in USB protocol

Author
natraj20
Junior Member
  • Total Posts : 103
  • Reward points : 0
  • Joined: 2010/10/20 09:43:47
  • Location: 0
  • Status: offline
2012/04/13 07:55:37 (permalink)
0

USB Serial Interface Engine (SIE) - Error detection in USB protocol

In the USB FAQ regarding error detection in USB protocol, it was given as follows.
          http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2651&param=en534460#P189_15342 
12. How does USB protocol detect an error in communication?
USB protocol detects error using CRC (Cyclic Redundancy Check). This is done by the SIE (Serial Interface Engine), thus eliminating the need of CRC check in software and reduces the software overhead. For token packet CRC is 5 bit & data packet CRC is 16 bits.


13. What happens if the SIE receives data that is corrupted?
The SIE discards the corrupt packet if the packet fails the CRC checks. No software intervention is required. An error flag is set indicating that a corrupted packet was received. The SIE will not ACK packets that have incorrect CRC values. For interrupt, bulk, and control transfers the host will try to retransmit the packet if it fails to receive the ACK. In this way these transmissions will not have data loss due to a corrupted packet but may suffer from lower application bandwidth.

Can anyone help me with info on SIE, its flags and how CRC is implemented in the PIC18 USB framework? 
#define USB_ENDPOINT_ERROR_CRC16                0x24    // USB Module - CRC16 failure.
 This error code value was listed in usb_common.h



Thanks!



#1
DarioG
Scheisse Menschen
  • Total Posts : 52256
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: hi there
  • Status: offline
Re:USB Serial Interface Engine (SIE) - Error detection in USB protocol 2012/04/13 08:38:00 (permalink) ☄ Helpful
0
Hmm, from you quote above (and what I used to know too), the CRC errors are handled in hardware (SIE) and hence not visible (and maybe not even available) to the user software...

Dario Greggio
--
Wouldn't it be wonderful, if you lost one son for every promise you don't keep?
#2
chinzei
Super Member
  • Total Posts : 2250
  • Reward points : 0
  • Joined: 2003/11/07 12:39:02
  • Location: Tokyo, Japan
  • Status: offline
Re:USB Serial Interface Engine (SIE) - Error detection in USB protocol 2012/04/13 10:14:54 (permalink) ☄ Helpful
0

Can anyone help me with info on SIE, its flags and how CRC is implemented in the PIC18 USB framework?


SIE reports CRC error to U1EIR (PIC32, PIC24) or UEIR (PIC18), USB ERROR INTERRUPT STATUS
REGISTER.

PIC SIE's CRC implementation should follow this document from USB.org

USB-IF Technical White Papers - "Cyclic Redundancy Checks in USB"
http://www.usb.org/develo../whitepapers/crcdes.pdf

Tsuneo
#3
DarioG
Scheisse Menschen
  • Total Posts : 52256
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: hi there
  • Status: offline
Re:USB Serial Interface Engine (SIE) - Error detection in USB protocol 2012/04/13 14:11:55 (permalink)
0
ah good Smile

Dario Greggio
--
Wouldn't it be wonderful, if you lost one son for every promise you don't keep?
#4
natraj20
Junior Member
  • Total Posts : 103
  • Reward points : 0
  • Joined: 2010/10/20 09:43:47
  • Location: 0
  • Status: offline
Re:USB Serial Interface Engine (SIE) - Error detection in USB protocol 2012/04/17 10:47:27 (permalink)
0
Thanks guys! That was very helpful!
Any references to serial interface engine basics ?
#5
chinzei
Super Member
  • Total Posts : 2250
  • Reward points : 0
  • Joined: 2003/11/07 12:39:02
  • Location: Tokyo, Japan
  • Status: offline
Re:USB Serial Interface Engine (SIE) - Error detection in USB protocol 2012/04/18 08:54:25 (permalink)
0
This webpage explains bus signaling well
USB Made Simple, Part 3 - Data Flow
http://www.usbmadesimple.co.uk/ums_3.htm
 
USB spec defines the SIE process in details. Therefore, the implementation of SIE for the bus side is (almost) same among USB MCUs. But the SIE interface to the firmware (ie. registers) is implementation-specific.
Here is a brief explanation, supplement of PIC datasheet.
 
Roughly speaking, SIE has two major roles,
1) Packet decoding, and automatic response to transaction
2) Bus event detection
 
1) Packet decoding - transaction response
USB PHY shapes incoming bus signaling using 4x over-sampling DPLL (for full-/low-speed). NRZI decode and bit-unstuff is applied to the incoming signaling. SIE detects SYNC pattern at the start of every packet from this signaling. After a SYNC pattern, a PID (Packet ID) field follows. The next fields after PID depend on its PID value. An EOP concludes the packet.
In this way, a packet is decoded by SIE. Many protocol errors, including CRC, are checked in this process (UEIR).
When SIE puts a packet, it is encoded using bit-stuffing and NRZI, before the packet is sent to the bus.
 
A transaction starts with a SETUP, OUT or IN packet (Token packets) coming from host. One or two packets follow a token packet in a transaction. The timing of these packets in a transaction is tightly tied together by the USB spec. Therefore, SIE automatically responds to token packets according to the endpoint status, set by the firmware beforehand. In other word, a transaction is fully processed by SIE.
 
a) SETUP transaction
After Seeing a SETUP and a DATA0 packet from host,
- If the SETUP or DATA0 packet is corrupted, SIE gives no response to host.
- If the device address of the SETUP packet doesn't match to this one (UADDR), SIE ignores this packet.
- If the default endpoint is not enabled (UEP0.EPCONDIS, .EPOUTEN .EPINEN), SIE gives no response to host (protocol error).
- If the default endpoint is not armed (BD0STAT.UOWN for EP0 OUT), SIE returns no response to host. This is spec violation. The firmware should manage this endpoint, so that this accident doesn't occur.
- If the endpoint is armed, an ACK packet is sent by SIE. The 8 bytes SETUP data is stored to the buffer, specified by BD0ADRH:BD0ADRL, BD0CNT for EP0 OUT. And SIE notifies firmware of the transaction completion(UOWN, UIR.TRNIF, UCON.PKTDIS). Until firmware drops PKTDIS bit, all endpoints return NAK to IN/OUT transactions.
 
b) OUT transaction
After Seeing an OUT and a DATA packet from host,
- If the OUT or DATA packet is corrupted, SIE gives no response to host.
- If the device address of the OUT packet doesn't match to this one (UADDR), SIE ignores this packet.
- If the target endpoint is not enabled (UEPn.EPOUTEN), SIE gives no response to host (protocol error).
- If the endpoint is not armed (BDnSTAT.UOWN for EPn OUT), SIE returns a NAK packet to host. Firmware is notified of nothing.
- If the endpoint is armed, an ACK packet is sent by SIE, for a control/interrupt/bulk endpoint (UEPn.EPHSHK). The data is stored to the buffer, specified by BDnADRH:BDnADRL, BDnCNT for EPn OUT. And it notifies firmware of the transaction completion(UOWN and UIR.TRNIF). For an isoc endpoint, no ACK is put by SIE. SIE notifies firmware at the end of DATA packet.
- If STALL bit is enabled (BDnSTAT.BSTALL), a STALL packet is sent to host. Firmware is notified(UEPn.EPSTALL, UIR.STALLIF)
 
c) IN transaction
After Seeing an IN packet from host,
- If the IN packet is corrupted, SIE gives no response to host.
- If the device address of the IN packet doesn't match to this one (UADDR), SIE ignores this packet.
- If the target endpoint is not enabled (UEPn.EPINEN), SIE gives no response to host (protocol error).
- If the endpoint is not armed (BDnSTAT.UOWN), SIE returns a NAK packet to host. Firmware is notified of nothing.
- If the endpoint is armed, a DATA packet is sent by SIE. The data is sent from the buffer, specified by BDnADRH:BDnADRL, BDnCNT for EPn IN. For a control/interrupt/bulk endpoint, SIE expects ACK packet from host. When SIE gets a ACK packet successfully, it notifies firmware of the transaction completion(UOWN and UIR.TRNIF). For an isoc endpoint, no ACK comes from host. SIE notifies at the end of DATA packet output.
- If STALL bit is enabled (BDnSTAT.BSTALL), a STALL packet is sent to host. Firmware is notified(UEPn.EPSTALL, UIR.STALLIF)
 
In above explanation, I didn't touch to data toggle, to make it simple.
For data toggle, refer to BDnSTAT.DTS and DTSEN of the PIC datasheet.
Also, see these sections of the USB2.0 spec
8.5.2 Bulk Transactions
8.5.3 Control Transfers
8.5.4 Interrupt Transactions
8.6 Data Toggle Synchronization and Retry
 
2) Bus event detection
These bus events are monitored by SIE
SIE notifies firmware of these events at detection.
- Bus reset (UIR.URSTIF)
- Suspend and Resume (UIR.IDLEIF, .ACTVIF)
Also, SIE may put Remote Wakeup signaling by firmware request (UCON.RESUME).
 
Tsuneo
post edited by chinzei - 2012/04/18 09:52:49
#6
Jump to:
© 2017 APG vNext Commercial Version 4.5