View previous topic :: View next topic |
Author |
Message |
Will Guest
|
Internal Oscillator modes on a 16F627A |
Posted: Fri Feb 06, 2004 5:01 am |
|
|
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
|
|
Posted: Fri Feb 06, 2004 3:37 pm |
|
|
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
|
|
Posted: Sat Feb 07, 2004 3:00 am |
|
|
Thanks again PCM, what would this group do without you!
Keep well,
Will |
|
|
|