USB Set Address command need help

Post
jier
New Member
2007/02/13 03:09:26
Hi all,
 
i had sucessfully receive the all the descriptor from a USB device but i facing some difficulties on the Set Address Command. From the information, the command is abit different from other where the quote below get from USB in a Nutshell document:
 
"this request is unique in that the device does not set its address until after the completion of the status stage. all other request must complete before the status stage."
 
first, i sent a setup token than follow by 8 bytes of Set address command:
0X0000, 0X0005, 0X0000, 0X0001, 0X0000, 0X0000, 0X0000, 0X0000;
assume set the device to address 1.
 
after sent a ack handshake returned. after i receive the ACKed what stage should i do? follow by a IN token and waiting to receive zero length packet or OUT token and sent a zero length packet to indicate the completion of status stage?
 
OR i should directly send another setup token to request the device descriptor, wait until all my device descriptor received and complete of it status stage than only the device will set the it address to 1?
 
hope to hear and feedback from u guys out there...really appreciate the help...thanks alot...
 
B.Regard
JIER
 
 
Pacer
Super Member
RE: USB Set Address command need help 2007/02/13 05:01:18
after sent a ack handshake returned. after i receive the ACKed what stage should i do?


Send an IN token packet to address 0, wait for the DATA1 packet with zero bytes, send ACK to acknowledge receipt. Wait at least 2ms before sending the next setup which will be to the new device address.
jier
New Member
RE: USB Set Address command need help 2007/02/13 21:03:05
Thanks again, Pacer...
 
i had another questions, if i had a USB 1.1 host and a USB 2.0 device. when my device plug it in to the host controller,do the host need to set the USB device to full speed device rather than the high speed device? please provide some information, thanks alot..
Pacer
Super Member
RE: USB Set Address command need help 2007/02/14 01:12:29
Yes. The device starts as full speed, then attempts to get the hub to switch to high speed during the reset state. If it doesn't succeed (which it won't with a 1.1 host) it remains in full speed. Depending on the device it may then function normally, but at full speed, or it may not provide any useful functionality it it is relying on having a high speed connection.
jier
New Member
RE: USB Set Address command need help 2007/02/14 19:51:51
oic.... i see the USP 2.0 spec, the high speed operation had a 12bit sync pattern of (KJKJKJKJKJKK) which is different from the low/full speed sync pattern. so does it mean that the host will try to send a high speed packet to test the device compatible with a high speed operation? or the hub play an important role here where the hub will switch the device to high speed operation so it can isolate the full speed operation between host and hub and high speed between hub and the device.
 
wow...thanks again, pacer....learn alot from u...appriciate it lot..
lbodnar
Super Member
RE: USB Set Address command need help 2007/02/15 01:52:54
The hub will not try to talk to HS device until they have made successful contact at FS and agreed to proceed to HS. 

HS sync pattern generates the highest density of state transitions possibly to allow internal sync oscillators to phase-lock.  I suspect LS and FS devices just use oversampling so they can start reception almost immediately after the first state transition.  At 480Mbps oversampling is not really a practical option so I guess they employ PLL that locks to the transmitter's before actual reception starts and this is what HS SYNC pattern is for.  This is purely speculation from my part.
jier
New Member
RE: USB Set Address command need help 2007/02/15 02:59:18
Hi Ibodnar,
thx for the infomation. what an interesting information u provide. i really hope to test and handle the HS device but too bad my Host controller does not support HS speed, really sad that i only able to keep the FS setting. If not i can share my experience here. thx alot...

another noob question again, i had successfully set the configuration for the USB device, do i need to set interface as well? if my device only hv 1 configuration,1 interface, and 2 endpoint descriptor. izzit by default when i set the configuration, it will automatically select the default interface, and the endpoint?

for some device have afew different interface..on that case than only i need to used the set interface command if i need to select a different interface? am i right?
 
there something is confuse me is the bNumInterfaces field in configuration descriptor and bInterfaceNumber field in interface descriptor.
 
the bNumInterfaces contain a value 0x01, does it mean i had 1 interface and bInterfaceNumber contain a value 0x00, so does it mean that the only 1 interface number is 0x00? hope i dint get it wrong here...
post edited by jier - 2007/02/15 03:07:28
lbodnar
Super Member
RE: USB Set Address command need help 2007/02/15 03:13:19
SET_INTERFACE actually selects alternative setting for the interface which means after configuring the device it does not need this command if there are no alternative settings or default setting is OK.  Most devices without slternative settings will STALL the request without looking inside it (I do :) .)
lbodnar
Super Member
RE: USB Set Address command need help 2007/02/15 03:20:58
Yes, number of interfaces is 1 but the numbering is zero based so the first interface is number zero.

Can I have a nosey at what platform you are writing host on?  Is it a host chip controlled from a PIC?
jier
New Member
RE: USB Set Address command need help 2007/02/15 03:38:32
Hi Ibodnar,
 
Oic, pretty happy so than i no need do another step for the set interface command. thx very much for the info...
 
actually i'm developing a driver for the host controller which able to read and write data throught the Mass Storage Device.
 
nop,i'm not using PIC controller...actually i'm using our own company DSP controller which support USB function. so that it can perform DSP task like MP3 encoding/decoding, JPEG encoding/decoding...etc.
senthil_kumar
New Member
RE: USB Set Address command need help 2011/10/13 00:01:44
Pacer

after sent a ack handshake returned. after i receive the ACKed what stage should i do?


Send an IN token packet to address 0, wait for the DATA1 packet with zero bytes, send ACK to acknowledge receipt. Wait at least 2ms before sending the next setup which will be to the new device address.





after sending SET_address command it is mentioned that there is some status stage ? moreover after the set_address command sends the address it can be verified by reading the FADDR register in case of USB2.0 ,is there any other way to verify ?
Terry Lawson
New Member
Re:USB Set Address command need help 2011/10/13 10:57:01
For Control transfers, you have three stages, the setup stage, the data stage (optional), and the status stage. The setup stage is a transaction that starts with the setup token packet, then gives the data for which type of control transfer it will be (in this case, SET_ADDRESS), and ends with an ACK handshake. After the setup stage you do not have a data stage, since there is no data that needs to be sent. So you go straight to the status stage. This starts with an IN token packet, then an empty data packet, and ends with an ACK handshake. Those are the only two stages for a SET_ADDRESS control transfer.

Attached Image(s)

gopintj
New Member
Re:USB Set Address command need help 2013/06/04 00:35:15
Hi Jier. 
I am dealing with USB protocol in which i struck in the same place where u got locked while creating this post. 
 
I use PIC24FJ256DA206 as usb host and a USB mouse as device.
 
Of course, As like you, i also have got the same problem. I could get Device Descriptor from usb device. After that, we are supposed to set address to usb device. 
 
I have sent the Set address command and got ACK frm device. Following this, i send an IN token to device to receive zero length byte. This is also success(my BD0STAT is loaded with PID as DATA 1 with Count byte as zero). After a few milliseconds of gap, i set U1ADDR register with the device address; i send GET_Configuration command to get configuration descriptor from device. But, i couldn't get it.
 
Please help me to overcome this.
 
Note: I see a strange thing while i debug my program. The JSTAT bit in control register is clear to zero while i connect my device. and becomes set in middle of the program. I use a usb mouse which i am not sure whether is a LS or FS device.
post edited by gopintj - 2013/06/04 00:38:06