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 bug?

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



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

USB bug?
PostPosted: Fri Jul 11, 2014 7:48 am     Reply with quote

I have a PIC18F67J50 running at 48MHz and sometimes, not all devices do it, but the USB CDC port appears as COM port on Windows device manager but the device don't answer to any command; it looks like the code doesn't read the data from the USB buffer because the PC application get halted on the line that send the data to the serial port.

I'm using PCH compiler 5.025

It's strange because most devices works OK but 1 in 100 get stuck, the rest of the program works ok, just doesn't answer to USB commands.
If I restart the program works fine.
_________________
Electric Blue
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Fri Jul 11, 2014 7:53 am     Reply with quote

Sounds more like a hardware issue actually.
Ttelmah



Joined: 11 Mar 2010
Posts: 19467

View user's profile Send private message

PostPosted: Fri Jul 11, 2014 8:00 am     Reply with quote

I'm afraid I'd say 'something in your code/hardware'.
Are you sure the device clock is really accurate (full speed USB requires 2500ppm or better)?. I've seen oddities like this when the oscillator was slightly overdriven, and the PLL would intermittently 'squeegee' slightly out of frequency. A quick restart and the oscillator then worked right....
There are also sometimes problems with the standard code handling USB suspend operations, but this would be specific to the PC being used.
There can be problems with bus reflections if the impedance on the PCB is out of spec, giving similar behaviour.
temtronic



Joined: 01 Jul 2010
Posts: 9207
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Jul 11, 2014 8:08 am     Reply with quote

re: the clock...

I've also seen 'marginal' clocks as well. Real nasty ones didn't like the room they were in getting just a wee bit 'hot'. Just +2*C was enough to change the frequency of the clock off. When room got a bit cooler...it was fine.....
Assuming all 100 boards have all the same parts and 'batch' numbers it could be improper cleaning of the board, bad solder joint (pin not soldered...THAT was frustrating !), 'fuzzy' trace, slight corrosion in USB connector. The list is endless.
Sometimes a 'fresh' set of eyes will see what is oblivious to you, but obvious to the new guy !

hth
jay
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Fri Jul 11, 2014 8:26 am     Reply with quote

I have two version of the same device, the board is very different each other; the second version have more inputs and one more output, and the board have a bigger surface.
The second version is which have more troubles, the tiny version only one in 500 has failed.

The external clock is 8MHz and I'm using the PLL to get the 48MHz

I will check the clock stability but if the problem is the clock, why remains connected to the PC?
Can be that possible?
Shouldn't the PC kick out the device?
_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19467

View user's profile Send private message

PostPosted: Sat Jul 12, 2014 12:45 pm     Reply with quote

How long are the traces between the USB connector and the chip?.
How thick are the traces?.
How are they spaced?.
Do you have series resistors in the lines?.
Is this a four layer board?.

The drive impedance of the transceivers is actually below the impedance required to make a good match to the bus. This can cause signalling problems. Something like a 20R series resistor in each line improves the match.
Have a look at:
<www.ti.com/lit/an/spraar7a/spraar7a.pdf>

For suggestions on the PCB layout.

That the larger board is worse, suggests this may well be the problem.
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Mon Jul 14, 2014 6:37 am     Reply with quote

D-
Width 0.26mm
27.709mm Routed

D+
Width 0.26mm
22.5854mm Routed

1oz. Four layer board.

Distance between traces 12mils.

No resistors.
_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19467

View user's profile Send private message

PostPosted: Mon Jul 14, 2014 8:34 am     Reply with quote

You are out of spec on the difference in length (recommended no more than 3.81mm difference between the two traces - most people recommend closer than this), for 12Mbps may be OK. The recommended trace thickness is 0.4mm, and the spacing 0.18mm (why do you switch units between imperial and metric!...). Your spacing is rather wide, and traces thin. Do you have any vias in the traces?. These can cause reflections. Is the ground plane continuous under the traces?. A break in this can cause real problems. Right angle bends also cause similar problems to vias, and should be avoided (45 degree bends are much better, and smooth curves even better).
So you are 'out of spec' multiple ways on this. Now USB is often quite tolerant, but it may well be that the combination is just a step too far....
You might want to try calculating the impedance that the traces would give, and see how far out they are. USB wants 90R. It depends on the board material as well (FR4?).
The resistors may well help. They reduce reflections on any miss-match. Try cutting the traces and adding these on a board that is bad.
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Tue Jul 15, 2014 12:51 pm     Reply with quote

No vias on traces.
D+ and D- are in the TOP layer
The ground plane is not continuous under the traces but I reallocated the trace that was cutting the ground plane on the layer below D+ and D- and will add the resistors footprints to the next version.

Traces have no right angles.

I don't know how to calculate the impedance of the traces.

I'm using FR4.

I will try to add the resistors to the actual PCB version but is a bit complex to know if work properly because the same board work ok if I reset the PIC microcontroller.
_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19467

View user's profile Send private message

PostPosted: Thu Jul 17, 2014 1:44 am     Reply with quote

Just one question.
What capacitor do you have on Vusb (type, and value)?.

The formula for trace impedance is published online, and there are also dozens of calculators that can work out the impedance for you. Remember that it is the differential impedance between the pair that you are interested in.

A trace 'across' the USB lines, in the ground plane, is one of the real 'never do' things....
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