USB NRZI encoding and bit stuffing question

C

cxu_dl

I'm Looking at the USB D+ line with a Tektronix digital storage scope,
the connection is from a PC
to a fake "USB function" (by pulling up the D+ line with a 1.5k
resistor to 3.3V supply, and nothing else). The enumeration process
starts and I observed this pattern shortly after SYNC field:
---------------_____________----------------------_____________
|<--664ns ------>|<---664ns----->|<---664ns------->|
that is , D+ is high for 664ns, then low for 664ns, then high for
another 664ns. This happens in one
single packet right after the SOF packet. I can not understand this,
since 664ns is precisely EIGHT bit-time. so that's a bit stuffing
error, according to USB spec 2.0, page 157, which says "if the
receiver see SEVEN consecutive ones anywhere in the packet, then a bit
stuffing error has occured...". I don't believe this is a error
because it seems to happen for every packet except the SOF packet. The
signal quality is fairly good, with rise time and fall time of about
6ns, some over shoot and no under shoot. To verify it is not a bad
link, I hooked up a USB flash disk, and observed the same pattern, and
the computer was able to detect the flash disk with no problem. Has
anyone actually seen this and know why it is happening? or is it that
I misunderstood the NRZI encoding and bitstuffing? Thanks in
advance...

Xu
 
G

ghelbig

Yes. I have to decode the NRZI before I
can even see the bits.

-- Mike Treseler

While we're on the subject; I'm confused about NRZI and how it's used
with USB.

In the "encoding dictionary" (http://www.interfacebus.com/
Definitions.html) it says:
"NRZI [Non-Return-to-Zero-Inverted Encoding]: A '0' is encoded as no
change in the level."

In a USB Protocol specification (http://www.faculty.iu-bremen.de/birk/
lectures/PC101-2003/14usb/FINAL%20VERSION/usb_protocol.html):
"In NRZI encoding, a 1 is represented by no change in level "

Which is it?

Thanks,
G.
 
M

Mike Treseler

In the "encoding dictionary" (http://www.interfacebus.com/
Definitions.html) it says:
"NRZI [Non-Return-to-Zero-Inverted Encoding]: A '0' is encoded as no
change in the level."

In a USB Protocol specification (http://www.faculty.iu-bremen.de/birk/
lectures/PC101-2003/14usb/FINAL%20VERSION/usb_protocol.html):
"In NRZI encoding, a 1 is represented by no change in level "

Which is it?


The first is used for telcom,
the second for usb, but the
difference is just an inverter.

Stir in some active high, active low,
D+, D- etc. for extra confusion.

-- Mike Treseler
 
C

cxu_dl

Yes. I have to decode the NRZI before I
can even see the bits.

-- Mike Treseler


------------__________________----------------__________________
|<--664ns ------>|<---664ns----->|<---664ns------->|
the above NRZI encoded sequence docodes to:
011111110111111101111111
a 0 is inserted after every 7 consecutive ones, instead of the
expected six ones. the standard says a 0 should be inserted for every
6 consecutive ones. where am I wrong?
 
M

Mike Treseler

------------__________________----------------__________________
|<--664ns ------>|<---664ns----->|<---664ns------->|
the above NRZI encoded sequence docodes to:
011111110111111101111111
a 0 is inserted after every 7 consecutive ones, instead of the
expected six ones. the standard says a 0 should be inserted for every
6 consecutive ones. where am I wrong?


"if the receiver see SEVEN consecutive
ones anywhere in the packet, then a
bit stuffing error has occured...".

Maybe that sample is not inside a packet.
Could be idle flags.

-- Mike Treseler
 
P

Pinhas

C

cxu_dl

"if the receiver see SEVEN consecutive
ones anywhere in the packet, then a
bit stuffing error has occured...".

Maybe that sample is not inside a packet.
Could be idle flags.

-- Mike Treseler

I just discovered it's a preamble packet followed by low speed
signaling.
that's why it's 8 times longer.
But why does the computer send me low speed packets when the connected
device
is full speed? I tried a hp printer,
a video camera, a flash disk, and my fake device, all the same...
does anyone know the reason?
 
P

Pascal Peyremorte

(e-mail address removed) a écrit :
[...]
But why does the computer send me low speed packets when the connected
device
is full speed? I tried a hp printer,
a video camera, a flash disk, and my fake device, all the same...
does anyone know the reason?

Probably for compatibility with slow speed USB.

A low speed pattern is always reconized, by the fast USB devices as by the
slower one.

This is very common in multi-speed busses and comunications.

Pascal
 
A

Andy Peters

I just discovered it's a preamble packet followed by low speed
signaling.
that's why it's 8 times longer.
But why does the computer send me low speed packets when the connected
device
is full speed? I tried a hp printer,
a video camera, a flash disk, and my fake device, all the same...
does anyone know the reason?

Because the host needs to determine whether the new device is a low-
speed or full-speed device before it can communicate.
-a
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top