USB attach event at code start up

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

USB attach event at code start up

855件の閲覧回数
richl
Contributor I

Dear NXP community,

I have a customer struggling a little with the Kinetis USB stack.  Looks like everything is working except at power up the USB stick isn't always recognized if it is already attached.  Here is the note from the customer:

We are using the baremetal USB stack in our SubDrive design
(this is in KDS but does not use KSDK).  We recently moved it to newer
micros and the USB was working fairly well until we put optimization on in the
code.  We started to get watchdog resets due to the USB stack.  We
investigated this some and moved the USB_host_init() into the startup
components_init() section of the code.  The reset issue is resolved, but
now it sometimes does not recognize an attached USB thumb drive during power
up.

We don’t believe the attach event is occurring but don’t
understand in the USB stack what generates the attached event.  Is there
any documentation on what generates this event?

Anyone have any helpful suggestions?

Thanks in advance.

Rich

0 件の賞賛
返信
2 返答(返信)

594件の閲覧回数
bobpaddock
Senior Contributor III

"was working fairly well until we put optimization on in the

code"

This is almost always a sign that the keyword 'volatile' is missing from someplace that it is required.

The optimizer removes code that it thinks has no side effects, for example reading a register without using the read value.

To the compiler that is wasted time.  It does not know that the reading that register actually changes a bit in the register.

'volatile' forces the read or write to happen even if the compiler does not think it is required.

There can also be the obscure case of Code Motion where memory barrier instructions are required, and missing, to prevent the optimizer from reordering code.  For example moving a disable interrupt instruction to someplace it will have no effect.

A lot of inline assembly instructions I see will have this problem, they also need to be marked volatile.

0 件の賞賛
返信

594件の閲覧回数
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Rich,

The attach event happens when the attach interrupt occurs, with Host mode enabled. Signaled by USB Device pullup

resistor changing the state of DPLUS or DMINUS from 0 to 1 (SE0 to J or K state). so if you found attach event didn't happen, please check if the condition meets. Usually a USB Device should detect the VBUS line and gives the pull-up signal on D+/D- when VBUS line has power, or the device has power from VBUS and give the signal during its initialization, so that the Host may know there is a device attached on the USB bus.

Hope that helps,


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信