Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

USB in a PIC18F2550 not recognized

Status
Not open for further replies.
Hello and thanks always

I would appreciate your help on a problem I have
I have succesfully programmed a board containing a PIC18F2553 with 20MHz crystal and 22pF capacitors in it
K-08010.jpg


https://akizukidenshi.com/img/goods/C/K-08010.jpg
now I am trying to do the same with a PIC 18F2550 but this time I will be building my board.
First trying it on a breadboard I am using a 24MHz crystal
https://pdf1.alldatasheet.com/datasheet-pdf/view/70113/KSS/HC-49U-S.html

with either 18pF or 20pF capacitors.
I of course, according to the datasheet changed the PLLDIV settings from 5 (for 20MHz) to 6 (24MHz) so that the PLL part gets the required 4MHz.

The thing is that the PC does not recognize this as a USB device. First it was recognized as an "unknown device"
Now it doesnt even recognize there is something attached to it...

At first I thought maybe the crystal in the breadboard was not working well, but I programmed a non-USB program in the pIC and it worked well (although much faster than my previous internal oscillator experience)

Now my guess is that maybe the crystal is not providing the required frequency.

1) How can I make sure the frequency is the correct one
2) I am confused, what is the difference between a crystal and a crystal oscillator?
3) if I use something like
**broken link removed**
do you think it would be better? No capacitors to use
4) what is an "external clock" and how do I get one just in case



Any possible help on this will be greatly appreciated.
 
What program have you put inside the pic.... HID , CDC ???
Without a good software USB interface, the PC won't recognize it..

Have you a 4Mhz crystal to try!! once you have the USB talking then once you bounce it up to 24Mhz you know its only settings..
 
Thank you for your reply. I really appreciate it.
I have programmed the PIC with a HID program using microchip USB framework.
The program runs very well on my PIC18F2553 board (with the pre-soldered 20MHz crystal). The PC can recognize it. A program running on the PC can recognize it and communication between PIC board and PC runs smoothly. Very happy.
The problem is when I try to reproduce that pre-built board with my PIC18F2550 and a crystal and some capacitors.
Since the crystal is 24Mhz the only change I do to the program is to change PLLDIV from 5 to 6 (as necessary 20/5=24/6=4)
Then the PC cant recognize it.
 
At a quick guess, I think that the breadboard capacitance is likely playing havoc with your clock. As Ian said, drop your frequency way way down and try it, if it works fine there, but not at full speed, you'll know the likely culprit is the breadboard :)
 
What cap did you put on the VUSB pin???

I am using 0.1μF (the same that is used in the pre-built board)

Today I checked the Vusb and the OSC1 pin in a oscilloscope. This is what I go
001.jpg
or more clearly
000.jpg
So it seems the Vusb is fine (3.3V) and the crystal is giving 24MHz...
I am lost now at what could be wrong.
Before the device was recognized by the pC as a "unknown device"
Now it doesnt even acknowledge its existence....
 
Before the device was recognized by the pC as a "unknown device"
Now it doesnt even acknowledge its existence....
Yeah! That happens... Windows stores the info.. so until it changes, it wont report!! If you go into properties while the device is plugged in and delete it from device manager then immediately unplug the device... When you plug it back in then windows will try and enumerate it again..
 
This is a clip from my 18F2550 USB weigh scale, uses a 20mHz xtal

Clip of CONFIG:

Code:
CONFIG PLLDIV=5,CPUDIV=OSC1_PLL2,USBDIV=2,FOSC=HSPLL_HS,IESO=OFF
CONFIG VREGEN=ON,CCP2MX=ON,WDT=OFF,WDTPS=32768,PBADEN=OFF ,PWRT=OFF,MCLRE=ON
CONFIG LPT1OSC=OFF,BOR=ON,BORV=2,STVREN=ON,LVP=OFF,ICPRT= OFF,XINST=OFF,DEBUG=OFF
CONFIG WRTB=ON

PLLDIV=5 ' This sets the PLL Postscaler to divide the primary osc input by 5
providing 4MHz to the 96MHz PLL. The 96MHz PLL input must always be 4MHz
as shown in the data sheet.

CPUDIV=OSC1_PLL2 ' This sets the PLL Postscaler to divide the 96MHz PLL
output by 2 providing a 48MHz clock to the CPU.

USBDIV=2 ' This divides the 96MHz PLL output by 2 providing 48MHz to the USB core.

FOSC=HSPLL_HS ' This enables HSPLL for high-speed crystal/resonator.

BTW:
The 20mHz xtal and USB also run OK on a project board
 

Attachments

  • AAesp01.gif
    AAesp01.gif
    5.6 KB · Views: 213
I wonder why it is not being recognized :(

ericgibbs, my settings are the same. (although USBDIV... isnt this to select if the USB comes from the PLL or directly from the crystal??

any other ideas what I could be doing wrong....?:oops:
 
I only found a 8MHz not a 4Mhz crystal here... guess I am gonna try it...

ooops I dont have the required capacitors (22~28pF)... would it be bad if I use only 20pF?? too low?
 
Yeah! That happens... Windows stores the info.. so until it changes, it wont report!! If you go into properties while the device is plugged in and delete it from device manager then immediately unplug the device... When you plug it back in then windows will try and enumerate it again..

the problem is the device does not even appear in the device manager....
 
First I would like to thank you all who help me. And contribute to solve this problem

For some reason now it started working. I have two theories why.

First, I have here two breadboards. When I tried it on breadboard 1 with 18pf caps it got recognized as "unknown device"
when I tried it on breadboard 2 it didnt get recognized and sometimes even pickit had problems

My take is Breadboard 2 is damaged and I should throw it away
Now I tried it on breadboard 1 again BUT with 20pf capacitors and it got recognized as HID correctly

Plus I also reboot the PC

I suppose that is it? I hope it gets recognized from now on :confused:

Now I am going to build a soldered board and see how it goes
 
My take is Breadboard 2 is damaged and I should throw it away

The breadboard is probably fine, it just can't cope with higher frequency circuits where stray capacitance becomes more of an issue. I rarely build any circuit on breadboard that is above 8Mhz, but I have seen really cheap breadboards cause havoc at anything over about 6Mhz. The original Vero stuff was really good, it happily went up to around 16Mhz, but the new far eastern stuff is pretty poor. Expecting 24Mhz to be reliable on any breadboard is a stretch imo. Anyway, I'm glad you got it going :)
 
Please stop blaming breadboards. I have built lots of USB circuits using pic chips on breadboards without ever having a problem.

Mike.

Yes Pommie, I do realise that it is all too easy to lay the blame on a breadboard, I simply gave the op a way to rule it out and see if that was indeed his issue, I didn't actually blame anything, I took a reasonable guess given his operating frequency. I too have prototyped loads of USB stuff on breadboards and never had a problem, but never with a 24Mhz clock. Perhaps with really good quality breadboard and a very dry climate you would get away with it, but I would be surprised if it was even remotely reliable at that frequency on any breadboard :)
 
Please stop blaming breadboards. I have built lots of USB circuits using pic chips on breadboards without ever having a problem.

Mike.
The real thing here is.... You know what you are doing.... But I doubt even you would try a 24Mhz crystal on breadboard..
 
Built it on a perfboard (well, here nobody knows what a "perfboard" is, we call it "universal board:wideyed:) , corrected some small soldering mishaps with the programmer connector and voila! it works!
(The system has 12v and 5v part, so far only tried the 5v part. -see my other thread about whether I should connect the 12v part as well):woot:

Thank you again!
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top