Page 1 of 1

detect if usb is connected....

Posted: Sun Oct 03, 2010 8:47 pm
by dzairo
Hi all.
I'm here again and have question :
how detect if device is plug in usb or not.
If I have powered my PCB from differ power source I need detect if is plug in to usb or not.
If yes then I internal enable usb function , if not then I use different mode.
I create small PCB like avr butterfly but support USB boot-loader and usb to serial port converter with internal function (LCD ,RFID, may SDcard, I2C relay ... ).
there is more solution how to detect if usb is plug.
1. logic state of power line of usb (but need one free pin)
2. every 100 or more ms control INT0 flag , if every time change it's mean so mcu communicate , or use (atmega168) pin change interrupt flag
but exist any function in V-USB where can I check if mcu is plug in to USB or not? or how can I check it.
I want use usb as charger for internal li-ion cell and can using solution 1.

regards

Re: detect if usb is connected....

Posted: Mon Oct 04, 2010 3:25 am
by ulao
There may be a built in usb-v funciotn for this not sure but why not just watch the pin state? Or use a pin-change interrupt.

Re: detect if usb is connected....

Posted: Mon Oct 04, 2010 1:05 pm
by dzairo
Hi .
I thinks so easy will be use pin change interrupt flag.
OK .

thats all ..

regards