Worst day of my life


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2006
    Posts
    70

    Default Worst day of my life

    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/arch...hp/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"?

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    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.

    DT

  3. #3
    Join Date
    Nov 2006
    Posts
    70

    Default Still stumped

    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.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    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 ...
    Code:
     
      __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?

    DT

  5. #5
    Join Date
    Nov 2006
    Posts
    70

    Default A new day

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

  6. #6
    Join Date
    Nov 2006
    Posts
    70

    Default Some success

    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.

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default

    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.

    DT

Similar Threads

  1. picbasic-l Calculating the day of Week from a date
    By Melanie in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd August 2012, 00:09
  2. Happy Fathers Day.....
    By Dave in forum Off Topic
    Replies: 3
    Last Post: - 17th June 2007, 09:45
  3. EEPROM life expectancy?
    By muddy0409 in forum General
    Replies: 3
    Last Post: - 1st May 2007, 12:44
  4. Bad Eeprom write on '628???
    By bethr in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 17th March 2007, 07:21
  5. Battery Life Calculation???
    By manumenzella in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 24th February 2007, 19:26

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts