PDA

View Full Version : USBMOUSE Example Help



Kamikaze47
- 9th June 2007, 13:23
Hi,

I'm trying to get the USBMOUSE.BAS example working on a 18F4550 and not having much luck.

When I plug it in, windows XP says "USB Device Not Recognized" and shows up as an "Unknown Device"

I have:

4Mhz crystal with 22pF caps
10k between MCLR and +5v
0.1uF between each Vdd and Vss
470nF between Vusb and Gnd
100Uf between Vdd and Vss

Anyone have ideas?

Darrel Taylor
- 9th June 2007, 20:26
Oscillator Configs?
<br>

Kamikaze47
- 9th June 2007, 20:31
Just the default that came with PBP:


__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L

i'm new to 18Fxxxx chips. I'm not overly familiar with these configs.

Is there 2 different clocks at different speeds for the 4550? In mister_e's USB Demo program, the OSC is defined as 48, but a 4Mhz oscillator is used.

Darrel Taylor
- 9th June 2007, 20:55
That would work for 20Mhz.

For 4Mhz try _PLLDIV_1_1L inplace of _PLLDIV_5_1L
<br>

Kamikaze47
- 10th June 2007, 06:07
Thanks. Works like a charm.

Im trying to familiarize myself with the CONFIG settings now.

Dos you have any insight on the 2 different oscillator settings? I.e. "DEFINE OSC 48" in the code, and defining 4Mhz in CONFIG.

Darrel Taylor
- 10th June 2007, 10:29
The 2550/4550 etc type chips have a really nice PLL in the oscillator stage.

The PLL always ends up running at 96 Mhz, and to do so, it needs a reference of 4mhz. So if you're using a 20Mhz crystal, it has to be divided by 5 with the prescaler to get back down to 4Mhz. That's the _PLLDIV_?_1L


Crystal
4 - _PLLDIV_1_1L
8 - _PLLDIV_2_1L
12 - _PLLDIV_3_1L
16 - _PLLDIV_4_1L
20 - _PLLDIV_5_1L
24 - _PLLDIV_6_1L

External Oscillator
40 - _PLLDIV_10_1L
48 - _PLLDIV_12_1L


Then once you have the 4 Mhz reference, the PLL will run at 96 Mhz.
A postscaler can divide that by 2 to give 48 Mhz to the USB. _USBDIV_2_1L

And a seperate postscaler can give the CPU 48, 32, 24 or 16 Mhz depending on the _CPUDIV_OSC1_PLL2_1L config setting.

In effect, you can get any of these frequencies, no matter which one of the (multiple of 4Mhz) crystal you use.

You can have a 4Mhz crystal supplying 48Mhz to the USB and 16 Mhz to the CPU, or both USB and CPU at 48Mhz.

Clear as Mud, right. :)
<br>

Kamikaze47
- 10th June 2007, 18:52
Thanks for clearing that up for me.