View previous topic :: View next topic |
Author |
Message |
Tre
Joined: 03 Jun 2005 Posts: 21
|
USB CDC printf is hanging |
Posted: Wed Feb 06, 2008 12:49 pm |
|
|
I have been having this problem for a while and it has been driving me crazy, after a while the PIC will hang when sending out data over USB and CDC. It occurs after maybe an hour of sending/receiving data making it incredibly annoying to debug. However, after putting in some lines of code (and lots of trial/error), I found where the problem is occurring.
The code will stall indefinitely at this point:
printf(usb_cdc_putc, Message);
I have tried everything. I have snooped the serial line, usb, etc... and the PIC just hangs. It does this after about an hour of sending 25 bytes of data every 5 seconds.
Initially I had written the host software in LabView, but being suspicious of LabView's ability to handle serial comm without a hitch, I wrote a program in C# where I am much more confident that I know what is going on. The same problem occurs in both situations.
I've read all the other posts on the forum about adding decoupling capacitors and what not. This board has a 1uF tant cap and a 0.1uF ceramic cap right next to the chip. The device is powered over USB and has a 1uF tant cap at the +5V input along with an addition of a 10uF tant, 1uF tant, and 0.1uF decoupling cap at the output of the 3.3V regulator.
Each IC on this board also has nearby 0.1uF decoupling caps. Needless to say, I would be surprised if it was a decoupling cap issue.
The Vusb pin is tied directly to the 3.3V Vdd and the PIC is an 18LF4455.
I'd be more than happy to share source/schematics/etc.. with anyone if they have any ideas as to what is causing this problem, it is driving me CRAZY......
|
|
|
crystal_lattice
Joined: 13 Jun 2006 Posts: 164
|
USB problems |
Posted: Fri Feb 08, 2008 12:19 am |
|
|
Hi, this is somewhat of a dual reply to you and other peoples USB problems: I would agree with the other members that it could very possible be a buffer related problem, so try and adjust your FIFO buffer values of the PC's UART and see if the problem persists or if the period/interval changes.
Secondly what is the power consumption of your device, windows likes shutting down the USB port when the device is too power hungry, could be that it takes a while for the port to respond to the power issue, although an hour sounds a bit long... Getting back to the buffer issue, what happens if you send double the amount of data, does the "working time" decrease??
Kind Regards |
|
|
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
Posted: Fri Feb 08, 2008 10:42 am |
|
|
Quote: | The Vusb pin is tied directly to the 3.3V Vdd and the PIC is an 18LF4455. |
I never worked with a LF type PIC but i know that regular pic use the Vusb with a ~330nf ceramic cap in parallel with ground. Maybe this should be also applicable even if it's already 3.3V on the line... If a spike or a small voltage deviation... do occur on the 3.3v power line this could hang the usb because you plugged it straight.
hope this help!
Best Regards,
Laurent |
|
|
nuwavedc
Joined: 06 Feb 2008 Posts: 17
|
|
Posted: Mon Feb 11, 2008 10:36 am |
|
|
I am very sure this is not hardware related and not windows shutting down the USB port. In our application the device is not USB powered. We have proper bypassing of the processor problem is still present.
Driving us nutZ...
http://www.ccsinfo.com:80/forum/viewtopic.php?t=33586 _________________ Thanks,
NuWaveDC |
|
|
Tre
Joined: 03 Jun 2005 Posts: 21
|
|
Posted: Thu Feb 14, 2008 12:09 pm |
|
|
I do no think it is hardware or power related either. I believe it is a firmware issue with CCS's implementation of the CDC stack. |
|
|
Tre
Joined: 03 Jun 2005 Posts: 21
|
update |
Posted: Sat Feb 16, 2008 1:31 pm |
|
|
So instead of battling with the CCS CDC implementation and figuring out where the problem is, I converted my code to use USB Bulk transfers and rewrote the PC software to use the microchip DLL. It works flawlessly and is not much more difficult than serial comm (in fact the PC side is actually easier in my opinion since you don't need to parse).
So, the HW stayed the same and the PC side SW changed. I changed the FW to use USB Bulk tarnsfers instead of the CDC. I am almost entirely convinced now that the problem that others and myself were having is related to the CCS implementation of the CDC driver. The HW did not change, I won't bring myself to believe that the windows CDC driver is the problem, really only leaving the CDC firmware. Hopefully someone else with more time can figure out where the problem is and fix it for everyone else. In the meantime, I suggest using bulk transfers unless you absolutely need the serial.... |
|
|
pappastech Guest
|
Bulk transfers |
Posted: Wed May 28, 2008 12:11 pm |
|
|
Could someone point me in the direction to some examples of this bulk transfer firmware? I'm just getting into the USB side of the 18F4550 and have had similar 'PIC locking' issues with printf'ing to the PC using CCS's CDC stack.
Thanks. |
|
|
|