Disconnect USB by Software in LPC1343

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Disconnect USB by Software in LPC1343

2,478 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wsyuen on Fri Jun 17 04:26:15 MST 2011
Dear All,

I'm using the USBHID example code to work as a USB keyboard.
The code will initial USB when power on (plug the USB cable to computer) so it will be recognised as a USB keyboard.
In my program, I have an update process. I will self-reset (by WatchDog) the system after I have done an update process.

However, in the status of USB already initialised and connected, if I self-reset the system again, it will run again the USB initialisation code:
USBIOClkConfig();
USB_Init();
USB_Connect(TRUE);

In this case, the USB will be damaged.
How can I keep the USB works in this case?
May be I can first disconnect the USB by software before the self-reset, but how to do that?
In the hardware, I don't have a SOFT_CONNECT pin which connect to the D+ of the USB pin. The D+ of USB pin is always pull-high with a resistor.
Please advise.
Thank you.

wsyuen.
0 项奖励
回复
11 回复数

2,346 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Tue Jun 21 05:36:59 MST 2011

Quote: whitecoe
I personally would suggest being wary of using the CMSIS project zips from the NXP LPCXpresso support website. These often seem to be out of date compared to the version shipping with LPCXpresso 3.6.3.

Typically there is a file called history.txt within the CMSIS project which can be used to confirm its "recentness".

HTH!



To save any future confusion, we've added a wiki page to provide the latest versions of the CMSIS library projects. For details see:

http://knowledgebase.nxp.com/showthread.php?p=9550

Regards,
CodeRedSupport
0 项奖励
回复

2,347 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by serge on Tue Jun 21 03:42:20 MST 2011
What if you would read section 9.6.6 of the user manual? yep indeed RTFM. It would help you a great deal because it explains in detail how to handle a software reset of the USB bus.

Quote:
Re-initialization of the USB bus connection can also be performed without having to unplug the cable.
To use the SoftConnect feature, the USB_CONNECT signal should control an external switch that connects the 1.5 kOhm resistor between USB_DP and 3.3 V. Software can then control the USB_CONNECT signal by writing to the CON bit using the SIE Set Device Status command.



This seems to me the only right way to acomplish things.:p

If you don't want to use the softconnect thingy then i whish you good luck since the pc is checking the state of the USB D- (low speed devices) and D+ (high speed devices) lines to see if another USB device has been plugged in. So as long as your D+ line is connected to 3.3V (or 5V) via a 1.5k ohm resistor, the pc will NOT notice a USB-device change. So you might really consider to use the softconnect feature. Once again if you want to play with USB read the manuals. And here i mean the manual of how the pc is warned internaly of a device change especialy the USB device. Sometimes they really do contain usefull info...:eek:
0 项奖励
回复

2,347 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by whitecoe on Tue Jun 21 02:25:14 MST 2011

Quote: Rob65

The function is defined in core_cm3.h as stated by Zero (in CMSISv1p30_LPC13xx\inc\core_cm3.h at line 1719). Please download the latest version (v1.30) from the LPCXpresso support website to be sure that you have the correct CMSIS.


I personally would suggest being wary of using the CMSIS project zips from the NXP LPCXpresso support website. These often seem to be out of date compared to the version shipping with LPCXpresso 3.6.3.

Typically there is a file called history.txt within the CMSIS project which can be used to confirm its "recentness".

HTH!
0 项奖励
回复

2,347 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wsyuen on Mon Jun 20 23:32:09 MST 2011
I can call NVIC_SystemReset() directly and it can reset the code to start of main.
However, it cannot disconnect and re-connect the USB connection.
I don't have a Soft_Connect pin at the D+ of USB pin, so I cannot use USB_Connect(TRUE) and USB_Connect(FALSE) to do that, right?
Any suggestions?
Thank you very much.
0 项奖励
回复

2,347 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Mon Jun 20 22:44:56 MST 2011

Quote: Zero
NVIC_SystemReset() is part of CMSIS and defined in core_cm3.h :eek:

It's described in User manual: 3.5.10 System reset status register: SYSRST



Nope, nothing in the user manual, blame it to NXP if you want :eek:
The chapter that Zero is referring to only contains a description of the System Reset Status Register.

The UMs for the lpc11xx and the lpc17xx contain a complete chapter called "Chapter 21: Appendix LPC111x/LPC11C1x ARM Cortex-M0
reference" and "Chapter 34: Appendix: Cortex-M3 user guide" but in the User Manual for the lpc13xx this is missing.
Just check the lpc17xx user manual (34.4.2.10.1 NVIC programming hints), it contains the same Cortex M3 as the lpc13xx and all descriptions in that chapter also apply to the lpc13xx processors.

I am not sure who messed up the CMSIS functions but why this function is called NVIC_SystemReset() is unclear to me. This function has nothing to do with the NVIC, the only register being used is the AIRCR register in the System Control Block.

The function is defined in core_cm3.h as stated by Zero (in CMSISv1p30_LPC13xx\inc\core_cm3.h at line 1719). Please download the latest version (v1.30) from the LPCXpresso support website to be sure that you have the correct CMSIS.

Rob
0 项奖励
回复

2,347 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wsyuen on Mon Jun 20 20:48:02 MST 2011
Thanks.
I can find NVIC_SystemReset in core_cm3.h and can call directly.
It can reset the code to start of main.
However, it cannot disconnect and re-connect the USB connection.
I don't have a Soft_Connect pin at the D+ of USB pin, so I cannot use USB_Connect(TRUE) and USB_Connect(FALSE) to do that, right?
Any suggestions?
Thank you very much.
0 项奖励
回复

2,347 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jun 20 03:37:10 MST 2011
NVIC_SystemReset() is part of CMSIS and defined in core_cm3.h :eek:

It's described in User manual: 3.5.10 System reset status register: SYSRST
0 项奖励
回复

2,347 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wsyuen on Mon Jun 20 03:26:48 MST 2011
However, my example code does not have the function "NVIC_SystemReset()".
What does it exactly do?
Thank you.
0 项奖励
回复

2,347 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jun 20 03:03:33 MST 2011

Quote:
May be I can first disconnect the USB by software before the self-reset, but how to do that?

A full connected USB and NVIC_SystemReset() is exactly doing that :eek:
Reset and reconnect USB again. In your Device Manager you can see your USB device disappear and appear again


Note: There a also functions like:
(*rom)->pUSBD->connect(TRUE);     //connect USB 
(*rom)->pUSBD->connect(FALSE;     //disconnect USB 

or

USB_Connect(TRUE);              //connect USB 
USB_Connect(FALSE);             //disconnect USB 
0 项奖励
回复

2,347 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wsyuen on Mon Jun 20 02:48:31 MST 2011
Sorry.
I mean how to use software to disconnect the USB connection, just like plug out the USB cable but in fact the USB cable is still plugged in physically.
Thank you.
0 项奖励
回复

2,347 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Fri Jun 17 06:17:07 MST 2011

Quote:

...I don't have a SOFT_CONNECT pin which...

Use it :eek:


Quote:

...self-reset(by WatchDog)...

Use NVIC_SystemReset(); :)
0 项奖励
回复