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 CCS Technical Support

Sustaining USB Connection - CDC Implementation
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
javick82



Joined: 12 Jul 2007
Posts: 43

View user's profile Send private message

Sustaining USB Connection - CDC Implementation
PostPosted: Wed Jun 08, 2011 11:59 am     Reply with quote

I have seen a couple of posts about this but from what I can tell, no good solutions.

I am sending data back and forth via USB intermittently - a quick handshake and response:
PC sends 8 bytes
FW responds with 2 bytes (handshake)
FW does something
FW responds with 2 bytes (response)

After 30 minutes or so, the handshakes stop. However, the firmware is still running. A couple of the posts I saw alluded to a buffer issue in the CDC implementation. Has anyone else come across this problem? If so, what did you do to resolve it?

Thanks and I appreciate the information.

Jason
vinniewryan



Joined: 29 Jul 2009
Posts: 154
Location: at work

View user's profile Send private message MSN Messenger

PostPosted: Wed Jun 08, 2011 1:31 pm     Reply with quote

can you check/ clear the buffer? What device are you using?
_________________
Vinnie Ryan
javick82



Joined: 12 Jul 2007
Posts: 43

View user's profile Send private message

PostPosted: Wed Jun 08, 2011 1:38 pm     Reply with quote

I am on a PIC18F2550.

I adapted my USB handling from the CDC example provided with the USB demo board. Everything works fine for about an hour, then just goes kaput.
javick82



Joined: 12 Jul 2007
Posts: 43

View user's profile Send private message

PostPosted: Wed Jun 08, 2011 2:38 pm     Reply with quote

OK, so I poked around in the examples a little more and found this comment:

Quote:
usb_task() must be called periodically in your main loop. If it is not called faster than once per millisecond, USB may not work (PIC18 and PIC24 only).


I am running something that outputs some text every 1000 calls of usb_task() to make sure it happens quicker than one millisecond, which it does. Note that I have included a call to usb_task() before, but with no different results. Hopefully I will know something in about an hour.
javick82



Joined: 12 Jul 2007
Posts: 43

View user's profile Send private message

PostPosted: Wed Jun 08, 2011 3:12 pm     Reply with quote

20 minutes later (actually 18), communication ceased.

I am going to try a couple more things to see if there is something in the usb_cdc driver that will help diagnose the issue at hand.
javick82



Joined: 12 Jul 2007
Posts: 43

View user's profile Send private message

PostPosted: Thu Jun 09, 2011 5:37 pm     Reply with quote

Maybe some other info that would help...

My client program is written in C#. I am using the System.IO.Ports namespace to handle the data transfer on the PC side. All that happens when I get this connection issue is the port basically gets "lost", and it can no longer be talked to. However, the USB device (PIC) remains enumerated.

It seems that if I pull the USB plug and put it back in, the connection comes back most of the time, re-enumerating itself, without reinitializing USB nor any other fancy tricks.

I'll post my code tomorrow when I get back to work.

Could it be the CDC driver?
vinniewryan



Joined: 29 Jul 2009
Posts: 154
Location: at work

View user's profile Send private message MSN Messenger

PostPosted: Thu Jun 09, 2011 5:42 pm     Reply with quote

You might check out this thread:

http://www.ccsinfo.com/forum/viewtopic.php?t=45145&highlight=pic18f2550+usb

I'm not sure if it will be any help, but I honestly don't know enough about USB comms to troubleshoot your problem.

Good luck!
_________________
Vinnie Ryan
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Fri Jun 10, 2011 4:51 am     Reply with quote

One thing not said, what USB chipset on the PC, and what OS?.
There have been a number of chipsets, with some USB oddities. One is one of the Intel chipset's, which if running under XP or Vista, can forget completely about an attached device, and stop polling it, yet still show it as enumerated.... On these installing the Intel drivers (older than the ones that come with Vista, supposedly only for XP), fixes the problem completely. W7 seems to have this fixed. Have seen some similar problems with the USB stack, on other systems.
So worth 'ruling this out', by trying a different computer, with a different motherboard chipset, and if this changes the problem start investigating whether alternative drivers exist....

Best Wishes
javick82



Joined: 12 Jul 2007
Posts: 43

View user's profile Send private message

PostPosted: Fri Jun 10, 2011 7:47 am     Reply with quote

Unfortunately, I am using Windows 7, but 64-bit.
My chipset is the Intel ICH10.
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Fri Jun 10, 2011 8:43 am     Reply with quote

I would try another completely different system.

<http://www.maximumpc.com/forums/viewtopic.php?f=1&t=103046>
In this case the problem seems to be caused by the drivers for another component, causing a USB hang only affecting certain devices!...

You really need to rule this out by testing.

There are a couple of known issues with the ICH10, if you are powering the device off the USB (current available is below spec for example).

Best Wishes
javick82



Joined: 12 Jul 2007
Posts: 43

View user's profile Send private message

PostPosted: Fri Jun 10, 2011 12:34 pm     Reply with quote

I ran example 12 from the USB exercise book. On two different machines.
First - Windows 7 - 64 bit, Intel ICH10 USB controller
Second - Windows XP - 32 bit, Intel IC7 USB Controller

Sadly, I got the same result both times. I am working with my IS group to get a PCI USB port.
javick82



Joined: 12 Jul 2007
Posts: 43

View user's profile Send private message

PostPosted: Fri Jun 10, 2011 1:14 pm     Reply with quote

Another thought (moving away from PIC programming and into PC HW architecture and settings), but could there be something with the port powering down when the PC locks or idles or something?
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Fri Jun 10, 2011 2:49 pm     Reply with quote

OK.
How big/what type is the capacitor on the Vusb pin?.
Commonest cause for a hang of this type is a problem with this. There was a fault on some chips with them requiring about twice the capacitance listed in the data sheet for reliability. I generally run a 1uF ceramic with 100% reliability. Anything under 0.47uF is 'worrying', and the capacitor must be something like a polyester or a ceramic. Electrolytic's are _not_ reliable here.

Best Wishes
javick82



Joined: 12 Jul 2007
Posts: 43

View user's profile Send private message

PostPosted: Fri Jun 10, 2011 3:00 pm     Reply with quote

0.47 µF ceramic cap.

I'll see if I can track down a 1 µF cap see if the issue comes up again.
javick82



Joined: 12 Jul 2007
Posts: 43

View user's profile Send private message

PostPosted: Fri Jun 10, 2011 4:43 pm     Reply with quote

Same issue, even with a 1 µF capacitor in place for VUSB.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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