CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

USB enumerated sense function

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Wizard



Joined: 27 Mar 2006
Posts: 9

View user's profile Send private message Send e-mail MSN Messenger

USB enumerated sense function
PostPosted: Tue Jun 06, 2006 5:16 am     Reply with quote

Hi there, I'm using a 18F4550 with an USB connection.

I have came to the conclusion that If I don't use the sense pin (100k resistor to ground and 100k to the pin, from the Vbus), the
Code:

usb_enumerated()

function has a bug, because it inform when the pic has been enumerated by the host(PC), but not when I disconnect the device from the PC and it's no more enumerated, in that case the function still gives a 1.

the descripction of the funtion in the library is as follows:
Code:

/* usb_enumerated()
/*
/* Input: Global variable USB_Curr_Config
/* Returns: Returns a 1 if device is configured / enumerated,
/*          Returns a 0 if device is un-configured / not enumerated.


I'm having problems because I want to know when the device it's no more enumerated by the PC, but I'm not using the sense PIN.
Any ideas you guys??
Any ideas you guys,
_________________
Tomas L.
Ttelmah
Guest







PostPosted: Tue Jun 06, 2006 6:33 am     Reply with quote

You need the sense pin to do this. Once a device is connected, it _is_ 'enumerated', and this remains true, even if the device is then disconnected. This is normal behaviour for USB devices (even hubs and things respond the same in this regard). 'Enumeration', does not mean that there is a live connection, but that the device has been connected to a system that recognised it, and loaded drivers to support it.
If you don't have a spare pin (which is presumably why you don't want to use connection sense), then consider having the PC driver code send a transfer at regular intervals. Then have a timer on the USB device, which flags an error if a transfer is not received in a reasonable time.

Best Wishes
daveh
Guest







PostPosted: Wed May 14, 2008 2:25 pm     Reply with quote

*Solved - see end*
Is there any way to reset the enumeration flag?

I am using a sense pin however that only indicates that 5v is present. If the device is plugged into a powered hub not connected to a computer or a computer when it's starting up/shutting down or a computer that doesn't yet have the driver installed there will be 5v present. Once I sense that the 5v is removed i'd like to reset the usb_enumerated() flag.

I have a red & green LED, Red indicates that the USB is plugged in (sense pin high) and Green indicates a valid connection (sense pin high AND enumerated) both are off if there's no connection.

If I initially plug this in to a powered hub (not connected to computer) it works correctly (red light) however if I plug it into a computer (get the green light) then plug it into the unconnected powered hub I still get green. If I re-issue the usb_init() command it resets ok.

I notice that when I plug this into a computer it goes from red to green, then when I unplug it and re-plug it in it goes Green then red then green. So it appears to be re-enumerating?

Is there a way to reset the usb_enumerated() w/o using the full usb_init()? Or maybe it is best to re-initalize it?

Ok with a little more research I found the answer. With the connection sense pin defined as "USB_CON_SENSE_PIN" I periodically call usb_task().
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group