PDA

View Full Version : USB on 18F2455 funky problem



Mark J
- 23rd February 2011, 23:55
Hi guys,

Ive got a bit of a strange problem that I cant seem to fathom out.

Ive got an 18F2455 using the USB and on the breadboard it works fine, plug in a USB to the project and I can read and write the settings etc. but earlier today, I transferred the project onto an etched PCB (checked the PCB for any shorts etc all checked out fine) now here's the problem, it all works as it should BUT whenever I hook it upto the USB windowz comes up with the error saying something like 'theres a problem with the USB divice (sorry cant remember exactly but you'll probably know lol!)

I tried rewiring the USB port, changing the wire I used, even tried ultra short wires and nothing!
I tested the lines with my meter, and sticking one probe onto each pin individually on the USB port and the other on the actual pins of the pic chip and theres no breaks on either track so im at a complete loss!! (GND obviously to the GND line and shows continuity)

Im not using the 5V from the USB, as im using 24v PSU split down to 5V for the logic side etc, but I am obviously using the GND so that the PC and the project are grounded, and the D- D+ are correctly connected too.

So does anyone have any suggestions? I can add a schematic if needed, but everything else is working fine.

Many thanks,

Mark:confused:

Darrel Taylor
- 24th February 2011, 00:07
Do you have a capacitor on VUSB? 0.22uF or greater?
And is the regulator turned on in the configs?

Mark J
- 24th February 2011, 00:15
Hi Darrel,

Yeah ive got a cap on the VUSB, same on both the breadboard and the project.
regulator? youve got me there!

Here is my config settings from my project, and I think it was from a thread about USB that I think maybe you had written (but dont quote me on that lol!)
It all works fine when its sat on the breadbaord, just not when its on my PCB.


'************************************************* ***************
' Config settings
'************************************************* ***************

asm
__CONFIG _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
; ; ; USB clock source comes from the 96 MHz PLL divided by 2
; ; [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
; No prescale (4 MHz oscillator input drives PLL directly)


__CONFIG _CONFIG1H, _FOSC_XTPLL_XT_1H & _FCMEM_OFF_1H & _IESO_OFF_1H
; ; ; Oscillator Switchover mode disabled
; ; Fail-Safe Clock Monitor disabled
; XT oscillator, PLL enabled, XT used by USB

__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
endasm
DEFINE OSC 48
clear


Hope that helps.

Darrel Taylor
- 24th February 2011, 00:26
The _VREGEN_ON_2L turns on the regulator, so you're ok there.

Does your PCB have a 4mhz crystal? That's what the configs are set for.

Are you running USBSERVICE often enough? ~1-2mS.

Mark J
- 24th February 2011, 00:31
yeah im using a 4mhz xtal as theyre what I had handy at the time lol.
Im using your USB ints for controlling the USB and its set to 10ms interval on both the USB_POLLIN and USB_POLLOUT

Edit: USB interupts are running on TMR1

Darrel Taylor
- 24th February 2011, 01:05
Edit: USB interupts are running on TMR1

That should not be the case. They should run off of the USB interrupts.

PJALM
- 24th February 2011, 02:25
I don't know if this helps but I have had similar problems in the past and simply putting a capacitor from the USB V+ to GND worked every time. I always use a 0.1uF but it probably doesn't really matter what value.

Mark J
- 24th February 2011, 23:22
That should not be the case. They should run off of the USB interrupts.

Sorry Darrel, my mistake, the USB is running under the USB_HANDLER interupt, its my sub routine thats using TMR1 (late at night I posted that lol)

Will try the cap across the pins and see if that remedies the problem as it is a bit of a headache having to remove the LED light unit from where it is to access the pic so I can edit the settings etc.

Edit: just realised, do you mean the 5V to GND of the USB? as on my pcb (and breadboard) I never wired up the 5V as I dont need to use the 5v from the USB so thought better to be safe and not connect it anywhere on the PCB just in case the 2 different 5v sources made things go pop etc! Only pins wired on the PCB side for the usb port are the D+/D- and GND.

PJALM
- 25th February 2011, 01:27
Yes for some reason I have the same problem happen. Putting a cap across the USB V+ and GND seemd to fix it for me, I thought maybe it just needed some sort of load to make it work.

I don't seem to need it on breadboards either, very wierd.

Mark J
- 25th February 2011, 12:02
Will have to try that but agree that it is very weird!! Will let you know if it does it for me too.

Mark J
- 26th February 2011, 11:48
Amazing!! rebuilt the USB breakout board and put a cap across the 5v and GND and blow me it works! weird! but MANY MANY thanks for the info!!!

One (Almost) happy chappy :)