View previous topic :: View next topic |
Author |
Message |
ccesaretto
Joined: 03 Mar 2009 Posts: 5
|
It works but I don't know how! |
Posted: Tue Jul 21, 2009 4:08 pm |
|
|
I have been using the 18F2550 connected to the USB port, configured has a low speed device. These are the fuses:
Code: |
#define __USB_PIC_PERIF__ 1
#include <18F2550.h>
#FUSES NOWDT
#FUSES WDT128
#FUSES HSPLL
#FUSES NOPROTECT
#FUSES NOBROWNOUT
#FUSES BORV20
#FUSES PUT
#FUSES NOCPD
#FUSES STVREN
#FUSES NODEBUG
#FUSES NOLVP
#FUSES NOWRT
#FUSES NOWRTD
#FUSES IESO
#FUSES FCMEN
#FUSES NOPBADEN
#FUSES NOWRTC
#FUSES NOWRTB
#FUSES NOEBTR
#FUSES NOEBTRB
#FUSES NOCPB
#FUSES NOMCLR
#FUSES LPT1OSC
#FUSES XINST
#FUSES PLL2
#FUSES CPUDIV3
#FUSES USBDIV
#FUSES VREGEN
#define USB_USE_FULL_SPEED FALSE
#use delay(clock=24000000)
|
The external crystal works at 8 Mhz, the PLL prescaler is set to DIV2.
I would set the PLL postscaler to DIV4 to get a clock at 24Mhz for the core and 6 Mhz for the USB module, but it doesn't work.
I tried to set the PLL postscaler to DIV3, getting 32 Mhz for the core and 8Mhz for the USB module and everything works fine.
I don't understand why. The USB in LOW SPEED mode requires a clock at 6 Mhz and I don't know how it can work at 8 Mhz. Even the datasheet states the PLL postscaler should be set to DIV4.
Any thoughts?
Thanks. |
|
![](templates/subSilver/images/spacer.gif) |
ccesaretto
Joined: 03 Mar 2009 Posts: 5
|
|
Posted: Tue Jul 21, 2009 4:26 pm |
|
|
Ok. maybe it's just late and I should sleep.
The configuration bits are OK, and actually the PLL postscaler divides the PLL clock by 4.
CPUDIV3 just sets the configuration bits CONFIG1L[4:3] to 10, which means "divide by 3" if using the postscaler as the oscillator postscaler, but it means "divide by 4" if the postscaler is used as PLL postscaler.
Hope this make sense for you guys.
The reason I am setting the device to work at low speeds rather than full speeds is because I need to transfer few bytes every second and I was having troubles connecting the pic to some USB hubs.
I found out that the type of cable used matters and low speed devices work with any cable, even the longest. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jul 21, 2009 6:10 pm |
|
|
The extended instruction set is not supported by CCS. This fuse will
cause the program to behave in an erratic way. Change it to NOXINST.
Do this in all your programs. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Wed Jul 22, 2009 2:18 am |
|
|
On the USB clock, for low speed, there is a /4 division, between the internal USB clock, and the USB device itself. Low speed, requires an internal USB clock at 24MHz, and full speed, 96MHz (divided by two to give 48MHz). The PLL, cannot be used with low speed operation. Section 2.3 of the data sheet. Low speed operation, is _only_ supported with a 24MHz crystal, and USBDIV set to zero. When the PLL is used, you can only select full speed operation, and the output of the PLL, _must_ be 4MHz.
Limitation of the hardware.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
bkamen
Joined: 07 Jan 2004 Posts: 1611 Location: Central Illinois, USA
|
|
Posted: Wed Jul 22, 2009 10:29 pm |
|
|
PCM programmer wrote: |
The extended instruction set is not supported by CCS. This fuse will
cause the program to behave in an erratic way. Change it to NOXINST.
Do this in all your programs. |
I've wondered about that. I've seen it in the datasheets, but I never use the extended instruction set -- and only just now did I look at what it does..
Is it worth it? The datasheet describes it as being good for 'C'... but is it just a hassle?
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Thu Jul 23, 2009 2:38 am |
|
|
It would potentially give some performance improvements, but CCS does not support it, so you would have to switch to another compiler....
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|