Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > USB NRZI encoding and bit stuffing question

Reply
Thread Tools

USB NRZI encoding and bit stuffing question

 
 
cxu_dl@yahoo.com
Guest
Posts: n/a
 
      06-27-2007

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

 
Reply With Quote
 
 
 
 
Mike Treseler
Guest
Posts: n/a
 
      06-27-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> is it that
> I misunderstood the NRZI encoding and bitstuffing?


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

-- Mike Treseler
 
Reply With Quote
 
 
 
 
ghelbig@lycos.com
Guest
Posts: n/a
 
      06-27-2007
On Jun 27, 9:46 am, Mike Treseler <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > is it that
> > I misunderstood the NRZI encoding and bitstuffing?

>
> 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.



 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      06-27-2007
(E-Mail Removed) wrote:

> 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
 
Reply With Quote
 
cxu_dl@yahoo.com
Guest
Posts: n/a
 
      06-27-2007
On 6 28 , 12 46 , Mike Treseler <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > is it that
> > I misunderstood the NRZI encoding and bitstuffing?

>
> 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?

 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      06-27-2007
(E-Mail Removed) wrote:
> On 6 28 , 12 46 , Mike Treseler <(E-Mail Removed)> wrote:
>> (E-Mail Removed) wrote:
>>> is it that
>>> I misunderstood the NRZI encoding and bitstuffing?

>> 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?



"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
 
Reply With Quote
 
Pinhas
Guest
Posts: n/a
 
      06-28-2007
On Jun 27, 7:50 pm, Mike Treseler <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > On 6 28 , 12 46 , Mike Treseler <(E-Mail Removed)> wrote:
> >> (E-Mail Removed) wrote:
> >>> is it that
> >>> I misunderstood the NRZI encoding and bitstuffing?
> >> 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?

>
> "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 started to document a USB full speed project.
NRZI is discussed at http://bknpk.no-ip.biz/usb_8_tx_nrzi.html.
Some waves are at http://bknpk.no-ip.biz/usb_8_tx_wave_1.html.

Some un-finished data on the receive as well.
regards,
Pinhas
http://bknpk.no-ip.biz

 
Reply With Quote
 
cxu_dl@yahoo.com
Guest
Posts: n/a
 
      06-28-2007
On 6 28 , 7 50 , Mike Treseler <(E-Mail Removed)> wrote:
> (E-Mail Removed) wrote:
> > On 6 28 , 12 46 , Mike Treseler <(E-Mail Removed)> wrote:
> >> (E-Mail Removed) wrote:
> >>> is it that
> >>> I misunderstood the NRZI encoding and bitstuffing?
> >> 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?

>
> "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?

 
Reply With Quote
 
Pascal Peyremorte
Guest
Posts: n/a
 
      06-28-2007
(E-Mail 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
 
Reply With Quote
 
Andy Peters
Guest
Posts: n/a
 
      07-03-2007
On Jun 28, 6:46 am, (E-Mail Removed) wrote:
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A question on HDLC bit stuffing ferrero General Computer Support 0 05-16-2009 08:13 AM
bit stuffing blackpadme VHDL 5 08-25-2008 10:29 AM
Bit stuffing in a Crc encoder jpereira VHDL 4 05-31-2005 04:57 AM
Bit stuffing in C Language sarath1111@gmail.com C Programming 4 03-03-2005 07:26 PM
Bit-Stuffing on parallel 8 bit data kumar VHDL 8 02-17-2004 07:54 AM



Advertisments