![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
jlatas
Joined: 29 Nov 2007 Posts: 2
|
18F4550 clock sources |
Posted: Thu Nov 29, 2007 6:34 pm |
|
|
I am running a 18F4550 pic using the USB engine as a CDC device. I have a 4MHz oscillator on the OSC1,OSC2 pins. I have USB working...no probs!
Since this a battery operated handheld device I want to incorporate some power saving techniques. If I use my primary oscillator of 4Mhz the lowest core clock I can run with is 16MHz while on USB.
According to the datasheet...I should be able to run 2 different clock sources...my primary oscillator for the required 48MHz of USB and the internal oscillator block at, say 500KHz, for the core and other peripherals.
I am having trouble achieving this. When I write to OSCCON to setup the internal block for 500KHz it seems to kill my primary oscillator and then USB can't enumerate any longer!
My fuses for normal operation are here:
Code: |
#fuses HSPLL // HS PLL for USB at 48MHz
#fuses USBDIV // USB clock source comes from PLL divide by 2
#fuses PLL1 // No PLL PreScaler
#fuses VREGEN // USB Voltage Regulator Enabled
#fuses CPUDIV4 // System Clock by 4
#fuses NOWDT // No Watch Dog Timer
#fuses NOPROTECT // No Code Protect
#fuses NOLVP // No Low Voltage Programming
#fuses NODEBUG // No ICD Debugger Enabled
// If either '#device ICD-true' or 'DEBUG' fuse is
// set, debugger information is loaded.
#fuses BROWNOUT_NOSL // Brown-out Reset enabled in hardware only and disabled
// in Sleep mode (SBOREN is disabled)
#fuses BORV20 // Brown Out Reset Voltage at 2.0 Volts (minimum)
#fuses NOFCMEN // Fail-safe clock monitor disabled
#fuses NOCPD // No EE protection
#fuses NOICPRT // ICPRT disabled
#fuses NOXINST // Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#fuses NOPBADEN // PORTB pins are configured as digital I/O on RESET
#fuses NOIESO // No Internal/External Oscillator Switchover
|
This works great...
I am now trying to change the first fuse to
to run the USB engine from my XT primary osc and use the internal block for the PIC's core. I write to OSCCON first thing in main:
to change over to 500KHz.
Does anyone know if I can do this, if so, how...
What am I doing wrong to seem to kill the primary clock source???
Thanks!!! |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Fri Nov 30, 2007 3:26 am |
|
|
There are two basic routes you can use, the first selected by 'HS' (which feeds the CPU divider from the master clock, instead of the USB PLL - which still runs), or 'INTHS', which again leaves the USB PLL still running, but feeds the CPU clock from the internal RC.
Now there is a big caveat. You _may_ find, that if you run too slowly, that the CPU has trouble handling the USB transactions fast enough. This will be down to some experimentation. Another user reported recently, that when he dropped the CPU clock, the device was 're-recognised' by the PC.
Options for you are:
Fuses
HS
CPUDIV4
USBDIV
PLL1
Will give you a 1MHz clock from the master oscillator for the CPU, and 96MHz to the USB. I'd possibly recommend this one.
INTHS
USBDIV
PLL1
With the clock selected as 500KHz, will give you the CPU running from 500K off the internal oscillator, and the USB off the 96MHz PLL.
You don't need to change OSCCON. The compiler will do this for you if you set the clock rate correctly in the clock statement (or you can use 'setup_oscillator' to do this).
However it may be that the rate is too slow for the USB to enumerate properly, rather than the USB oscillator stopping....
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
jlatas
Joined: 29 Nov 2007 Posts: 2
|
|
Posted: Fri Nov 30, 2007 9:52 am |
|
|
Thanks for the reply.
I've tried both methods over the last few days but I tried it again today just to be sure.
It must be a USB enumeration issue at these lower speeds. I finally got it to work again using 48MHz for the USB clock and 8MHz of internal Oscillator Block for the cpu. Right now, if I try to run the PIC core at anything less than 8Mhz the USB will not enumerate. Here are my current fuses:
Code: |
#fuses INTHS // HS crystal for USB engine, internal osc for core
#fuses USBDIV // USB clock source comes from PLL divide by 2
#fuses PLL1 // No PLL PreScaler (direct 4Mhz input)
#fuses VREGEN // USB Voltage Regulator Enabled
|
I am also using this snippet in main():
Code: |
setup_oscillator(OSC_8MHZ | OSC_INTRC);
|
Any other help would be greatly appreciated.
Jerry |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|