PDA

View Full Version : Worst day of my life



brid0030
- 11th March 2008, 23:09
OK, this was not the worst day of my life, but it was pretty bad.

I'm trying to implement USB for the first time, and I don't have much hair left. Everything has failed miserably and I am not even trying to write code yet. Using a PIC18F2455, first I tried that cool USBdemo thing (the one specifically for the 2455). It compiled fine and the PC (windows xp pro) recognized the pic as and HID mouse. But the Vbasic program showed no evidence of a connection (no input from the pic and no control over lights or pulse modulators, etc). Some of the LEDs came on randomly in some attempts--seemed like complete chaos. I added in some blinky code to illuminate things (ooo, bad pun...), and got the leds to blink intially but it soon froze up.

So I gave up on the USBdemo and went for the very clear and simple instructions on the post "USB CDC Communications for Dummies!" (http://www.picbasic.co.uk/forum/archive/index.php/t-5806.html). Again, no trouble compiling, but the PC would not recognize the "Unknown USB device" and did not ask me about installing the driver (pbpcdc.inf). Attempts to install the driver manually also failed--that stupid wizard insists on searching for the driver and it never finds it.

Then I tried the USBmouse example in PBP. Result: "USB device not recognized...."

I'm not even sure how to ask for help here. I feel like I've tried almost everything (tried several factory fresh pics, used a different PC, quadruple checked the wiring...) What could I be doing wrong? I have no compiling problems so I would guess that I have fuses set correctly (and I didn't alter the supposedly working code anyway). The pic gets recognized with the USBdemo, so I think I have the physical usb connection configured correctly. I've reinstalled and updated PBP, microcode, and MPASM. I can run simple blinky programs, no problem. I've been pouring over the forum all day and can't find instances of similar problems.

I'm going home.....

Could somebody please post "USB CDC Communications for Hopeless Dimwits"?

Darrel Taylor
- 11th March 2008, 23:51
The thing that gets most people is the capacitor on VUSB.
Should be at least .22uF (bigger works too, it's just a DC filter)

Second most popular failure is with the oscillator configuration.
The PLL structure in those chips is fairly complicated, and it has to be right to work.
What crystal are you using? and, what do your configs look like?

But first, your explanation is a little confusing.
Which type of communications are you trying to achieve? HID, CDC, or mouse.
<br>

brid0030
- 12th March 2008, 03:05
I have .47uF on Vusb, and a 4Mhz crystal. The configs are either default (those in the include file for 18F2455) or those from the USBdemo code (with the include file configs commented out). Basically I'm following the design in the USBdemo pbp code. Does the fact that the pc sometimes appears to recognize the PIC imply that the hardware is OK?

As for what I am trying to do, at this point I just want to get something working--some means of sending text over a usb cable. The end goal is to have a simple data logging device that joe schmoe can plug into a computer and download stored data. Either CDC or HID would be good at this point.

Darrel Taylor
- 12th March 2008, 03:55
The default configs for the 2455 are for a 20mhz crystal.
But you say you also commented those and used the ones in USBdemo which are for a 4mhz crystal, so it may be unlikely, but you may want to verify the settings in the programmer before downloading just to make sure.

@ 4mhz, Should be ...

__CONFIG _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_XTPLL_XT_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L


Does the fact that the pc sometimes appears to recognize the PIC imply that the hardware is OK?No. Not really.
Especially if it reported being a "HID Mouse".
Shouldn't have said anything about a mouse with USBdemo.

USBdemo definitely works, so the problems not in the program (assuming you haven't modified it).

Have you verified that D+ goes to Pin 3 of the USB connector, D- is on Pin 2, Pin 4 is grounded, and Pin 1 is left Open?
<br>

brid0030
- 12th March 2008, 15:03
Thanks for the suggestions, Darrel. It is helpful to know that HID Mouse was not what I should have been seeing. I'm going to try a complete rebuild today and see what happens. I'll try switching out some 20 and 4 MHz crystals. That seems to be a likely explanation since I kept a 4MHz on the board all day yesterday.

Also I was generally using pin 1 on the USB connector to supply power. I only tried a few times with an external source. I'll give that another shot.

I didn't mean to imply that USBdemo does not work. There are a lot of success stories on the forum. Props to mister_e.

More later......

brid0030
- 12th March 2008, 20:08
So I tore down the breadboard and tested all the components. Found a capacitor marked at 10uF that only read off at 0.7uF. I replaced it and tried again. This time when I tried USBdemo, the PC recognized it as a USB CDC device and let me install the driver. BUT, I still could not get any communication between the Vbasic program and the PIC. Then I tried the CDC for dummies thing again (now with a 20 MHz crystal) and it worked just fine. So, I am off and running now. Too bad about USBdemo...would have been fun to play with.

Darrel Taylor
- 12th March 2008, 23:27
Great, glad you found it. Kind of hard to find those things from this end. :)

If you have both the USBdemo and the CDC for dummies projects in the same folder, the files will conflict.
Since you tried CDC after HID failed, the files are probably still set up for CDC.

A fresh install of USBdemo in it's own folder would probably fix it.
<br>