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

Internal Oscillator modes on a 16F627A

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







Internal Oscillator modes on a 16F627A
PostPosted: Fri Feb 06, 2004 5:01 am     Reply with quote

Hi all,
I am trying to set a 16F627A up to use it's nice 4MHz internal oscillator. The datasheet says "Run-time selectable between 4MHz and 37kHz". I am using the #fuses INTRC and set the #use delay to 4,000,000 Is the CCS compiler setting things up for me automatically to use the 4MHz internal oscillator option. I can't see a command to switch between the two speeds. Do I have to do it manually?

Keep well all,

Will
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 06, 2004 3:37 pm     Reply with quote

Use the #bit statement to define the OSCF bit. Example:

#bit OSCF_BIT = 0x8E.3

// Now create your own function with a macro.
#define set_osc_freq(value) OSCF_BIT = value

// Define the two possible speeds, based on the data sheet's
// values for OSCF bit, in the PCON register.
#define OSC_4_MHZ 1
#define OSC_37_KHZ 0

// Now use them like this:

main()
{
set_osc_freq(OSC_4_MHZ); // Start at 4 MHz

// Put some other code in here.

set_osc_freq(OSC_37_KHZ); // Change to low speed clock

while(1);
}
Will Reeve



Joined: 30 Oct 2003
Posts: 209
Location: Norfolk, England

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Sat Feb 07, 2004 3:00 am     Reply with quote

Thanks again PCM, what would this group do without you!

Keep well,

Will
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