View previous topic :: View next topic |
Author |
Message |
discoboy
Joined: 11 Jul 2004 Posts: 1
|
internal oscillator for PIC16F819 |
Posted: Sun Jul 11, 2004 3:37 pm |
|
|
Hello,
As everybody in this forum i use the CCS compiler.
I have problems selecting the internal 4 MHz osc block.
It seems alwas to be the 31250 Hz wich is selected.
Maybe someone has an idea to help me out.
The device is an PIC16F819
Thanks in advance
Kind Regards |
|
![](templates/subSilver/images/spacer.gif) |
jds-pic
Joined: 17 Sep 2003 Posts: 205
|
Re: internal oscillator for PIC16F819 |
Posted: Thu Jul 15, 2004 9:27 am |
|
|
discoboy wrote: | Hello,
I have problems selecting the internal 4 MHz osc block.
|
please read the forum policy for the "Code Library".
this is not the place to ask questions.
the right place is here:
http://www.ccsinfo.com/forum/viewforum.php?f=1
jds-pic |
|
![](templates/subSilver/images/spacer.gif) |
valemike Guest
|
|
Posted: Thu Jul 15, 2004 11:27 am |
|
|
He is in the right forum, unless the original post was moved.
Anyways, I had the exact same question in mind 2 weeks ago. But "PCM Programmer" (Thanks!!) had a code snippet a while back which helped me 100%. Here is the similiar code snippet:
Code: |
#include <16F627A.h>
#fuses INTRC_IO,WDT,NOLVP, NOBROWNOUT
#use delay(clock=4000000)
#use fast_io(a)
#use fast_io(b)
#bit OSCF_BIT = 0x8E.3
// function to set oscillator frequency
#define set_osc_freq(value) OSCF_BIT = value
// Two possible speeds, based on the datasheet's values
// for OSCF bit, in the PCON register.
#define OSC_4_MHZ 1
#define OSC_37_KHZ 0
#byte port_a = 0x05
#byte port_b = 0x06
void main(void)
{
set_osc_freq(OSC_4_MHZ);
//The rest of your code goes here.
}
|
Note that the #use delay(clock=4000000) must be selected if you will be running your internal oscillator at 4Mhz. Also notice the INTRC_IO in the #fuses directive.
-Mike |
|
![](templates/subSilver/images/spacer.gif) |
|