CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Need to switch from External Osc to Internal, problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
iso9001



Joined: 02 Dec 2003
Posts: 262

View user's profile Send private message

Need to switch from External Osc to Internal, problem
PostPosted: Thu Jun 22, 2006 5:15 pm     Reply with quote

Hi,

Much as the subject says. I've searched this but only found a little info telling me to use the setup_oscillator() command and adjust the Use Delay if I do infact need delays.

I'm using a 18F4680 w/ 10Mhz xtal with PLL On (H4 fuse). Problem is I read to use:

Code:

setup_oscillator(OSC_31KHZ);

//and then later

setup_oscillator(OSC_NORMAL);


I checked my device header and found this:
Code:

#define OSC_31KHZ   0
//and
#define OSC_NORMAL  0


So either way I'd be setting setup_osc(0);

That can be right, can it ? Confused
heath.g



Joined: 20 Jun 2006
Posts: 6

View user's profile Send private message

PostPosted: Thu Jun 22, 2006 9:34 pm     Reply with quote

If you look at the constants in the header file you will notice that there is a line between the groups of parameters:

// The following may be OR'ed in with the above using |

They are all using different bits of the same byte.

If you look in the data sheet for the micro have a look at the OSCCON and OSCTUNE registers These will give you an idea of what the parameters for setup_oscillator are doing.

Basically you are passing an INT16 to setup_oscillator. LSB is OSCCON and MSB is OSCTUNE.

Hope this helps.
iso9001



Joined: 02 Dec 2003
Posts: 262

View user's profile Send private message

PostPosted: Fri Jun 23, 2006 12:03 am     Reply with quote

I saw that, but 0 | 0 == 0

I'll need to take a better look at the datasheet.

But this is possible it seems.

Anyone know of the top of thier head how much power the internal RC at 32khz draws ?
Ttelmah
Guest







PostPosted: Fri Jun 23, 2006 4:52 am     Reply with quote

The three values for OSC_NORMAL, OSC_INTRC etc., select the oscillator 'source'. The values for OSC_31KHZ etc, then select the prescaler to use. _Normal_, implies the external oscillator. The values affect different nibbles of the data word, and it just happens that the combination of 'normal' (external oscillator), with the prescaler turned off, requires zero in both parts.
For the internal oscillator at 31KHz, you need:
OSC_INTRC | OSC_31KHZ

To run the external oscillator, with the PLL turned on, you require:

OSC_NORMAL | OSC_PLL_ON

The nibble for the prescaler has no effect when the external oscilator is selected, so 'oring' in the bits for this do not affect the final operation.

Best Wishes
iso9001



Joined: 02 Dec 2003
Posts: 262

View user's profile Send private message

PostPosted: Fri Jun 23, 2006 8:19 pm     Reply with quote

Thanks,

That changed the clock but its no good to me now. I was hoping to use the slow clock for a low-power wake-on-can but it didn't work on anything other then what the BCON registers are set to. I even turned off WakeFilter so I guess it just can't be done.

By the way, I noticed about a 100uA rise in current when the clock was set to 31khz vs clock off. I'll have to remember that trick for other projects.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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