LPC11u37h usb DEVCMDSTAT register.. cannot change the DEV_ADDR bits...

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC11u37h usb DEVCMDSTAT register.. cannot change the DEV_ADDR bits...

630 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by siangming on Wed Dec 10 23:26:05 MST 2014
Hi all,

i am trying to implement a simple USB device on the lpc11u37h.

i am writing my own device drivers on the lpc, but my program got stuck at the Set Address request from the host PC (win 7).

1. i am getting a valid new address from the host.
2. i am writing the new address into DEVCMDSTAT register inside the ISR of the endpoint0 IN interrupt (which correspond to the STATUS stage completion). i know for sure that i am writing the new address in the STATUS stage completion because i set a flag during the SETADDRESS request handling and check for this flag in my endpoint0 IN ISR before i proceed to set the new address.

Here comes the problem.. upon inspection of the register values, i realised i cannot write to the DEV_ADDR (bit0..6) of the DEVCMDSTAT.

ptrToUSB->DEVCMDSTAT |= 0x7F; has no effect on the last 7bits of the register.

- To investigate further, i loaded an example USB HID application by NXP into my LPC chip and it can enumerate ok on the same host pc. This proves my LPC hardware is ok.
- Next, i tried to write to the DEV_ADDR (bit0..6) of the DEVCMDSTAT at the beginning of my program (just after reset_handler)..i also cannot change the bit0..6 at all.. but i can change the other bits of the DEVCMDSTAT register...

Can anyone advise if the LPC11u37h is hard-wired such that we need to satisfy some conditions/settings in some registers before we can write to the DEV_ADDR (bit0..6) of the DEVCMDSTAT??

i am so lost.... HELP!!!
Labels (1)
0 Kudos
2 Replies

539 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by siangming on Thu Dec 11 19:32:34 MST 2014
Thank you for the reply..

i have moved the setting of address to the point when i am handling the SETUP request. Also i noticed that i must clear the SETUP bit in DEVCMDSTAT before i set the new address. Previously, i clear the SETUP bit very late at the last step just before i left the SETUP request ISR..now i am clearing the SETUP bit the moment i enter into the SETUP request ISR...

Anyway, now i can write a new address into my LPC11U37.. but now the host reseting my device back to address 0 after the set address request and a get device descriptor request. During debugging, i put a breakpoint at get device descriptor and each time i stop at the breakpoint, my device address will switch between 0 and the new address.

i am guessing some thing went wrong in the get descriptor step after the new address and the host resets my device back to address 0. I learnt this from another post i found on the internet...
http://libusb.6.n5.nabble.com/USB-bus-reset-td5521893.html

i am guessing its related to some problems in the descriptors... or some problems in the EPSKIP... see my previous post on EPSKIP registers
http://www.lpcware.com/content/forum/lpc11u37-usb-device-register-endpoint-skip

Thank you.
0 Kudos

539 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Tsuneo on Thu Dec 11 02:01:13 MST 2014

Quote:
2. i am writing the new address into DEVCMDSTAT register inside the ISR of the endpoint0 IN interrupt (which correspond to the STATUS stage completion).



When your firmware sees the completion ISR on the IN EP0, the STATUS stage has finished on the bus.  I know you are faithful to the USB2.0 spec, 9.2.6.3 Set Address Processing ;-)
But the user manual of this MCU states as follows,

11.6.1 USB Device Command/Status register (DEVCMDSTAT)
DEV_ADDR
When receiving a SetAddress Control Request from the USB host, software must program the new address before completing the status phase of the SetAddress Control Request.


Your firmware has to write to DEV_ADDR, when it sees SETUP stage of Set_Address request.

The process of Set_Address depends on SIE design so much. To implement your own stack, always refer to the MCU manual, if it would require specific sequence or not.

Tsuneo
0 Kudos