PC Is Not Seeing My PIC 18F2550 [USB Connection]

Thread Starter

ajm113

Joined Feb 19, 2011
174
Hello all I'm trying to get a basic PIC such as the PIC 18F2550 to be read as a USB device on my Windows 7, but so far no matter what I do, my PC can't seem to see it.

I have the data+ and Data- pins connected to a USB cable that goes to my PC and of course have the positive and negative connected to the PIC, my programmer isn't having any issues programming the PIC. I've build and ran this gentlemen's code on my PIC. I've also attached the outputting hex file I've used and even ran he's program that's supposed to talk to the PIC, but it can't even see it.

http://www.waitingforfriday.com/index.php/Building_a_PIC18F_USB_device

The only thing I'm doing differently with that guys work is that I'm not using a crystal for the OSC pins. Don't PICs have a internal cystal they use for timing? Is the external crystal needed for USB communication?

Of course I have the VUSB pin connected to a .1 uF capacitor that goes to ground, so I'm not sure what I'm doing wrong.
 

Attachments

Markd77

Joined Sep 7, 2009
2,806
If you aren't using the crystal you need to set the configuration of the PIC so that it uses the internal one instead and make sure the change in speed doesn't affect the operation. Much easier just to get a crystal.
 

ErnieM

Joined Apr 24, 2011
8,377
That crystal is vital to run the USB module at the correct speed.

Sorry mate, you have to get the same crystal as he used for his code to work.

I've used a resonator there of same frequency, cheaper and saves the 2 caps, but in a worst case analysis they will violate the USB timing spec. So that's OK to breadboard but don't use it in a product.
 

t06afre

Joined May 11, 2009
5,934
I you change the code it may be that you can do without a crystal. I see in the code that the 20 MHz clock is pumped up to 48 MHz using the internal PLL. And I think you may also be able to generate 48 MHz using the internal oscillator and the PLL. Not 100% sure. So you must confer with the data sheet about this. If you use the code as is. You must use a 20 MHz crystal.
 

CraigHB

Joined Aug 12, 2011
127
The internal oscillator for a PIC is the RC type. These can suffer from fairly wide fluctuations due to external conditions and manufacturing tolerances. For many applications it's not an issue, but for some it is.

Some PICs have an oscillator tuning function that can compensate for variances in the internal oscillator. The oscillator can be calibrated initially then a temperature sensor can be utilized to compensate the RC oscillator on the fly. However, that's a lot of trouble to go through just to use the internal oscillator.

For precise timing, an external crystal or resonator is typcially employed. Crystals are somewhat less sensitive to variation, but resonators are cheaper and usually can provide the required tolerance.

For PICs, the maximum operating frequency is going to be an absolute limitation. Unlike a micro-processor, PICs are intolerant to over-clocking. For example a PIC with a max clock speed of 40MHz would not run properly with a crystal over 10MHz when using PLL.
 

Thread Starter

ajm113

Joined Feb 19, 2011
174
Thank you all for your swift replies! All very helpful, I had a feeling that was the problem. I don't suppose you all know where I can maybe find a crystal 20mhz for a good deal? Or perhaps a few in a grab bag?
 
Last edited:

Thread Starter

ajm113

Joined Feb 19, 2011
174
What hobby stores have you been going to that sell crystals? 0.o I've been to a lot of them in my life and I haven't seen one store that even sells LEDs, but then again that was in Arizona, so idk what the hobby stores are like here.
 

Thread Starter

ajm113

Joined Feb 19, 2011
174
Hey thank you very much! :) I'll defiantly order it sometime next week or so. I kinda started up a second project at the moment.

I'm playing around to get my PIC to interact with my synthesizer so it has brains. ;)
 
Hey thank you very much! :) I'll defiantly order it sometime next week or so. I kinda started up a second project at the moment.

I'm playing around to get my PIC to interact with my synthesizer so it has brains. ;)
I have looked at the waitingforfriday site before, it has some interesting projects like the FFT synthesizer. I took a short cut and used the MSGEQ7 chip, for a seven channel analyser.
 
Thank you all for your swift replies! All very helpful, I had a feeling that was the problem. I don't suppose you all know where I can maybe find a crystal 20mhz for a good deal? Or perhaps a few in a grab bag?
Your project requires 20MHz crystal with two 15pf capacitors.
The PIC then PLL's the frequency up to 48MHz.
 

Thread Starter

ajm113

Joined Feb 19, 2011
174
Well after sometime and finally getting back to this thing I have it so it's using a 20 mhz crystal and it's connected ground using 2 22pf capacitors. (I'm not sure if thats a big difference for the chip or not) but I've seen some people using 22 instead of 15 and of course I'm getting the same results. Is it necessarily best to use 15? Or maybe I do have this correct and just to make my life easier I should install a boot loader in this pic?
 
Last edited:

thatoneguy

Joined Feb 19, 2009
6,359
For PICs, the maximum operating frequency is going to be an absolute limitation. Unlike a micro-processor, PICs are intolerant to over-clocking. For example a PIC with a max clock speed of 40MHz would not run properly with a crystal over 10MHz when using PLL.
They can be overclocked to about 10%, roughly the same as PCs, but that 10% isn't much when you are starting with 20MHz. :(
 

Thread Starter

ajm113

Joined Feb 19, 2011
174
Okay so if I'm not overclocking it too much, should I test my PIC with a USB bootloader or something to make sure it's working?

Any recommendations for bootloaders?
 

thatoneguy

Joined Feb 19, 2009
6,359
I'd suggest a PICKit 2 or 3 (PICKit 2 if you aren't going to be using the 16/32 bit or DSP PICs).

You need to get the bootloader onto the pic somehow anyway, so it's easier just to dump the program on whenever you like using a PICKit
 

Thread Starter

ajm113

Joined Feb 19, 2011
174
Sorry I didn't explain it properly what I'm trying to accomplish. What I mean was are there programs already compiled for the PIC18F that tell the pic to use the USB connection to program it or to manipulate the PIC or to read values on a desktop computer such as Windows.

Such as turning a pin high or low or reading the state of a button from software running on a desktop computer?

My first program all I want to do is turn a LED on or off for starters using C++ on Windows.
 

spinnaker

Joined Oct 29, 2009
7,830
Sorry I didn't explain it properly what I'm trying to accomplish. What I mean was are there programs already compiled for the PIC18F that tell the pic to use the USB connection to program it or to manipulate the PIC or to read values on a desktop computer such as Windows.

Such as turning a pin high or low or reading the state of a button from software running on a desktop computer?

My first program all I want to do is turn a LED on or off for starters using C++ on Windows.

Maybe I don't understand what you are trying to do but.....

You still need to be able to program the PIC somehow. That can be down two ways that I know of.

First a programmer such as the PICKit2 or PICKit3 as ThatOneGuy mentioned. And I would only buy a PicKit leaning toward the PICKit3. Don't even waste your time on 3rd party programmers.

The second method is without a programmer via RS232 and I would assume USB. But this is going to require a special reprogrammed PIC with something called a bootloader. The PICAxe is one type of PIC that will do this.

There are no C++ compilers for PIC as far as I know. You need to use C. You can also program in assembler, BASIC and there are even a couple of RAD type compilers I have seen.
 
Top