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 CDC printf is hanging

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



Joined: 03 Jun 2005
Posts: 21

View user's profile Send private message

USB CDC printf is hanging
PostPosted: Wed Feb 06, 2008 12:49 pm     Reply with quote

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......


Evil or Very Mad
crystal_lattice



Joined: 13 Jun 2006
Posts: 164

View user's profile Send private message

USB problems
PostPosted: Fri Feb 08, 2008 12:19 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Feb 08, 2008 10:42 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 11, 2008 10:36 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Feb 14, 2008 12:09 pm     Reply with quote

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

View user's profile Send private message

update
PostPosted: Sat Feb 16, 2008 1:31 pm     Reply with quote

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
PostPosted: Wed May 28, 2008 12:11 pm     Reply with quote

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.
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