detect if usb is connected....

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
dzairo
Rank 1
Rank 1
Posts: 35
Joined: Wed Sep 22, 2010 3:31 pm

detect if usb is connected....

Post by dzairo » Sun Oct 03, 2010 8:47 pm

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

ulao
Rank 4
Rank 4
Posts: 481
Joined: Mon Aug 25, 2008 8:45 pm

Re: detect if usb is connected....

Post by ulao » Mon Oct 04, 2010 3:25 am

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.

dzairo
Rank 1
Rank 1
Posts: 35
Joined: Wed Sep 22, 2010 3:31 pm

Re: detect if usb is connected....

Post by dzairo » Mon Oct 04, 2010 1:05 pm

Hi .
I thinks so easy will be use pin change interrupt flag.
OK .

thats all ..

regards

Post Reply