PICcoder.co.uk Forum  


::post new topic::
PIC Device Detection
Date: 2006/04/13 20:26 By: Chips Status: User  
Karma: 2  
Posts: 17
graphgraph
Posted this on the Microchip Forum, but felt it might be of help to visitors here too..maybe start a Troubleshooting FAQ for us newbies on this ?

18F4550 application not working! Not again.. but wait.. now it is!

Noting at how many folk have had the same problems/fun as me trying to get their device 18F4550 device stable/detected thought I would post my journey, and eventual arrival at stability.
I'm using the example from www.piccoder.co.uk, and I built my own circuit on some vero board.

1. Oscillator frequency - set this wrong in the programmer and you will have pain, or rather it wont work. The pain comes from banging your head against the wall after you realise you have set them wrong. I use winpic800 and you have to be careful that it gets the right settings when you load your hex file.

For a 20mhz crystal I use:
HS Oscillator, PLL enabled, HS Used by USB
96MHZ PLL div 2
Oscillator Divide by 5, 20Mhz

2. Connecting pullup resistors to things you shouldnt do.
The PIC 18F4550 has internal pullups, no need to connect external resistor to D+ unless you have explicitly turned off the internal pullups.

Many thanks to Matt @ www.piccoder.co.uk for resolving those 2!

3. USB cable
Is your USB cable up to the job? This may be an manufacturer myth, but apparently there are USB 1.0 and USB 2.0 compliant cables, the USB 2.0 ones being extra specially nice for high speed.... a bit like gold plated audio leads for hi-fi enthusiasts I guess..
Anyway I replaced mine as this was causing the device to drop out if I moved it in a way it found unacceptable.

4. Vusb capacitor.
Tried a few combinations here.. eventually settled on a 0.47uF electrolytic, the solder bridge just wasnt doing the job.

5. USB vdd/vgnd capacitor
I use a 10uF electrolytic cap and a 120pf ceramic cap in parallel across these USB power pins.


6. BUS power.. or not BUS power
In the microchip code, if your device is bus powered then comment out the the line in usbcfg.h
#define USE_SELF_POWER_SENSE_IO

and alter the line in io_cfg.h
#define self_power 1

to
#define self_power 0

I also commented out the line
#define USE_USB_BUS_SENSE_IO
because i wanted some pins back!

7. Windows 2000 - The FINAL STRAW!
I'm running windoze 2000, I wonder how many folk are running XP instead and not having these problems.
I found that if i booted the machine then the device was generally detected ok in W2K but then went away again.
Anyway following this, I updated and patched W2K up to the hilt. If you trawl around Microsofts knowledge base there are many patchlets and discussions for USB related problems.

http://support.microsoft.com/kb/328580/en-us
http://support.microsoft.com/kb/242062/en-us
http://support.microsoft.com/kb/822568/en-us
http://support.microsoft.com/kb/330892/en-us

and so on..
just put USB problem in microsofts knowledge base and filter for 2000 and you will see what I mean.

Anyway read all that lot if you feel fit.. alternatively install W2K SP4 and make sure your operating system is well up to date, or try it on XP instead if you can get access to a machine. Go to the windows update centre, scan your system etc. The works.

Dont forget to uninstall the "?" device, unplug it and reboot at this point, and then try pointing at the drivers once more.

Hope this helps somebody out there, I totally sympathise with the frustration of having the thing not work at all ...to almost work.. and then work for a bit.. and finally work.. please add other *gotchas* to this!!

These things are so cool once you get them working, and if you're starting out like I was/am the first hurdle seems more like a high jump.

Have plenty of coffee on standby though!
Pixelchip
*come on led, flash! flash dammit!*
reply | quote

Re:PIC Device Detection
Date: 2006/04/13 22:18 By: Mat Status: Admin  
Karma: 7  
Posts: 211
graph
Thanks mate, great post consider it stickied!

Also worth trying....

Ensure that the connection between the PIC and USB connector are made as short as possible, to avoid picking up interference.

Mat
reply | quote

Re:PIC Device Detection
Date: 2006/07/19 09:45 By: Mat Status: Admin  
Karma: 7  
Posts: 211
graph
Oh one more thing, if you get device not recognised, check the oscillator settings.

Mat
reply | quote

Re:PIC Device Detection
Date: 2007/01/12 11:36 By: goldscott Status: User  
Karma: 0  
Posts: 3
graphgraph
Hi,
I read the "Basic USB - Using Microchip Stack and C#.Net - Hardware" article and am using that code to try to get a PIC18F2550 (rather than the 4550) to connect via USB to my computer. I changed the linker script to the appropriate pic as well as commented out the code required for the bootloader, as per microchip's instructions.

//extern void _startup (void); // See c018i.c in your C18 compiler dir
//#pragma code _RESET_INTERRUPT_VECTOR = 0x000800
//void _reset (void)
//{
// _asm goto _startup _endasm
//}
//#pragma code


Also, I'm using a 4MHz crystal (with 22pF caps to ground), these are my osc config settings:

//Using a 4MHz crystal
#pragma config USBDIV = 2 //USB clock source comes from the 96 MHz PLL divided by 2
#pragma config CPUDIV = OSC1_PLL2 //[OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
#pragma config PLLDIV = 1 //No prescale (4 MHz oscillator input drives PLL directly)
#pragma config FOSC = HSPLL_HS //HS oscillator, PLL enabled, HS used by USB


Are these values correct?


I'm using a 1uF cap for Vusb (didn't have 0.47uF). Using 1uF and 10uF decoupling caps from VDD to VSS. 10K pullup on MCLR. 1K to VDD for RA1.

I plug the USB cable in to my computer and RB0 and RB1 LEDs both light up, but Windows XP Service Pack 2 does not recognize it. Nothing appears in the device manager and no chime is played when the cable is plugged in.

Any tips or help would be much appreciated.

Thank you,
Scott
reply | quote

Re:PIC Device Detection
Date: 2007/01/12 12:16 By: goldscott Status: User  
Karma: 0  
Posts: 3
graphgraph
Some strange behavior:

I powered up the circuit without using the USB power, and both LEDs light up.

-Scott
reply | quote

Re:PIC Device Detection
Date: 2007/01/12 12:44 By: goldscott Status: User  
Karma: 0  
Posts: 3
graphgraph
Ahh! What a little reading will do.
After RTFM I figured out I needed to enable the internal pull-ups and enable full speed, as well as enable the USB voltage regulator.

Thanks for a great article, Mat, I'm sure I'll be back shortly with more questions.

-Scott
reply | quote

Re:PIC Device Detection
Date: 2007/08/15 08:25 By: Curly Status: Visitor  
 
Hi

Firstly great article mat, really good stuff.

I am having trouble with the USB device detection. Presently when I connect the PIC to the USB LED2 lights up only and a yellow bubble pops up on my PC telling me that an unkown device has been detected. When i try to point windows in the right direction for the drivers it doesn't install them.

I have read and re-read this forum several times now and have tried adjusting the oscillator settings, commenting out the

"#define USE_SELF_POWER_SENSE_IO"

and my usb cable is very close to the pic.

The only difference is that i don't have RA1 connected to anything, but i have tried setting "#define usb_bus_sense" to 1 in the code to simulate it, but this also doesn't help.

I am using a 20Mhz crystal and my oscillator settings are

HS Oscillator, PLL enabled, HS Used by USB
96MHZ PLL div 2
Oscillator Divide by 5, 20Mhz

I've been stumped on this for a while now any help would be greatly appreciated, Thanks
reply | quote

Re:PIC Device Detection
Date: 2008/02/17 04:48 By: Darrel Status: Visitor  
 
goldscott wrote:
Ahh! What a little reading will do.
After RTFM I figured out I needed to enable the internal pull-ups and enable full speed, as well as enable the USB voltage regulator.

Thanks for a great article, Mat, I'm sure I'll be back shortly with more questions.

-Scott


How do i enable internal pull-ups [UPUEN] and the full speed [FSEN]?
@usbdrv.h or @usbcfg.h
reply | quote

Re:PIC Device Detection
Date: 2008/04/30 04:02 By: quocdatbk Status: Visitor  
 
Chips wrote:
Posted this on the Microchip Forum, but felt it might be of help to visitors here too..maybe start a Troubleshooting FAQ for us newbies on this ?

<b style="color:black;background-color:#ff9999">18F4550</b> application <b style="color:black;background-color:#a0ffff">not</b> working! <b style="color:black;background-color:#a0ffff">Not</b> again.. but wait.. now it is!

Noting at how many folk have had the same problems/fun as me trying to get their device <b style="color:black;background-color:#ff9999">18F4550</b> device stable/detected thought I would post my journey, and eventual arrival at stability.
I'm using the example from www.piccoder.co.uk, and I built my own circuit on some vero board.

1. Oscillator frequency - set this wrong in the programmer and you will have pain, or rather it wont work. The pain comes from banging your head against the wall after you realise you have set them wrong. I use winpic800 and you have to be careful that it gets the right settings when you load your hex file.

For a 20mhz crystal I use:
HS Oscillator, PLL enabled, HS Used by USB
96MHZ PLL div 2
Oscillator Divide by 5, 20Mhz

2. Connecting pullup resistors to things you shouldnt do.
The PIC <b style="color:black;background-color:#ff9999">18F4550</b> has internal pullups, no need to connect external resistor to D+ unless you have explicitly turned off the internal pullups.

Many thanks to Matt @ www.piccoder.co.uk for resolving those 2!

3. USB cable
Is your USB cable up to the job? This may be an manufacturer myth, but apparently there are USB 1.0 and USB 2.0 compliant cables, the USB 2.0 ones being extra specially nice for high speed.... a bit like gold plated audio leads for hi-fi enthusiasts I guess..
Anyway I replaced mine as this was causing the device to drop out if I moved it in a way it found unacceptable.

4. Vusb capacitor.
Tried a few combinations here.. eventually settled on a 0.47uF electrolytic, the solder bridge just wasnt doing the job.

5. USB vdd/vgnd capacitor
I use a 10uF electrolytic cap and a 120pf ceramic cap in parallel across these USB power pins.


6. BUS power.. or <b style="color:black;background-color:#a0ffff">not</b> BUS power
In the microchip code, if your device is bus powered then comment out the the line in usbcfg.h
#define USE_SELF_POWER_SENSE_IO

and alter the line in io_cfg.h
#define self_power 1

to
#define self_power 0

I also commented out the line
#define USE_USB_BUS_SENSE_IO
because i wanted some pins back!

7. Windows 2000 - The FINAL STRAW!
I'm running windoze 2000, I wonder how many folk are running XP instead and <b style="color:black;background-color:#a0ffff">not</b> having these problems.
I found that if i booted the machine then the device was generally detected ok in W2K but then went away again.
Anyway following this, I updated and patched W2K up to the hilt. If you trawl around Microsofts knowledge base there are many patchlets and discussions for USB related problems.

http://support.microsoft.com/kb/328580/en-us
http://support.microsoft.com/kb/242062/en-us
http://support.microsoft.com/kb/822568/en-us
http://support.microsoft.com/kb/330892/en-us

and so on..
just put USB problem in microsofts knowledge base and filter for 2000 and you will see what I mean.

Anyway read all that lot if you feel fit.. alternatively install W2K SP4 and make sure your operating system is well up to date, or try it on XP instead if you can get access to a machine. Go to the windows update centre, scan your system etc. The works.

Dont forget to uninstall the "?" device, unplug it and reboot at this point, and then try pointing at the drivers once more.

Hope this helps somebody out there, I totally sympathise with the frustration of having the thing <b style="color:black;background-color:#a0ffff">not</b> work at all ...to almost work.. and then work for a bit.. and finally work.. please add other *gotchas* to this!!

These things are so cool once you get them working, and if you're starting out like I was/am the first hurdle seems more like a high jump.

Have plenty of coffee on standby though!
Pixelchip
*come on led, flash! flash dammit!*
reply | quote

Re:PIC Device Detection
Date: 2008/04/30 04:18 By: quocdatbk Status: Visitor  
 
Chips wrote:
Posted this on the Microchip Forum, but felt it might be of help to visitors here too..maybe start a Troubleshooting FAQ for us newbies on this ?

<b style="color:black;background-color:#ff9999">18F4550</b> application <b style="color:black;background-color:#a0ffff">not</b> working! <b style="color:black;background-color:#a0ffff">Not</b> again.. but wait.. now it is!

Noting at how many folk have had the same problems/fun as me trying to get their device <b style="color:black;background-color:#ff9999">18F4550</b> device stable/detected thought I would post my journey, and eventual arrival at stability.
I'm using the example from www.piccoder.co.uk, and I built my own circuit on some vero board.

1. Oscillator frequency - set this wrong in the programmer and you will have pain, or rather it wont work. The pain comes from banging your head against the wall after you realise you have set them wrong. I use winpic800 and you have to be careful that it gets the right settings when you load your hex file.

For a 20mhz crystal I use:
HS Oscillator, PLL enabled, HS Used by USB
96MHZ PLL div 2
Oscillator Divide by 5, 20Mhz

2. Connecting pullup resistors to things you shouldnt do.
The PIC <b style="color:black;background-color:#ff9999">18F4550</b> has internal pullups, no need to connect external resistor to D+ unless you have explicitly turned off the internal pullups.

Many thanks to Matt @ www.piccoder.co.uk for resolving those 2!

3. USB cable
Is your USB cable up to the job? This may be an manufacturer myth, but apparently there are USB 1.0 and USB 2.0 compliant cables, the USB 2.0 ones being extra specially nice for high speed.... a bit like gold plated audio leads for hi-fi enthusiasts I guess..
Anyway I replaced mine as this was causing the device to drop out if I moved it in a way it found unacceptable.

4. Vusb capacitor.
Tried a few combinations here.. eventually settled on a 0.47uF electrolytic, the solder bridge just wasnt doing the job.

5. USB vdd/vgnd capacitor
I use a 10uF electrolytic cap and a 120pf ceramic cap in parallel across these USB power pins.


6. BUS power.. or <b style="color:black;background-color:#a0ffff">not</b> BUS power
In the microchip code, if your device is bus powered then comment out the the line in usbcfg.h
#define USE_SELF_POWER_SENSE_IO

and alter the line in io_cfg.h
#define self_power 1

to
#define self_power 0

I also commented out the line
#define USE_USB_BUS_SENSE_IO
because i wanted some pins back!

7. Windows 2000 - The FINAL STRAW!
I'm running windoze 2000, I wonder how many folk are running XP instead and <b style="color:black;background-color:#a0ffff">not</b> having these problems.
I found that if i booted the machine then the device was generally detected ok in W2K but then went away again.
Anyway following this, I updated and patched W2K up to the hilt. If you trawl around Microsofts knowledge base there are many patchlets and discussions for USB related problems.

http://support.microsoft.com/kb/328580/en-us
http://support.microsoft.com/kb/242062/en-us
http://support.microsoft.com/kb/822568/en-us
http://support.microsoft.com/kb/330892/en-us

and so on..
just put USB problem in microsofts knowledge base and filter for 2000 and you will see what I mean.

Anyway read all that lot if you feel fit.. alternatively install W2K SP4 and make sure your operating system is well up to date, or try it on XP instead if you can get access to a machine. Go to the windows update centre, scan your system etc. The works.

Dont forget to uninstall the "?" device, unplug it and reboot at this point, and then try pointing at the drivers once more.

Hope this helps somebody out there, I totally sympathise with the frustration of having the thing <b style="color:black;background-color:#a0ffff">not</b> work at all ...to almost work.. and then work for a bit.. and finally work.. please add other *gotchas* to this!!

These things are so cool once you get them working, and if you're starting out like I was/am the first hurdle seems more like a high jump.

Have plenty of coffee on standby though!
Pixelchip
*come on led, flash! flash dammit!*
reply | quote

::post new topic::