View previous topic :: View next topic |
Author |
Message |
vinceykw
Joined: 16 Dec 2008 Posts: 3
|
How to do setting and use internal clock for PIC16F887 |
Posted: Wed Dec 17, 2008 9:26 pm |
|
|
As stated in topic. May I know how to do setting and use internal clock for PIC16F887?
Let say I want to set the internal clock running at 8MHZ.
Question 1
Do I need to write "setup_oscillator(OSC_8MHZ)" in order to use internal clock?
If yes, then is this the all setting for internal clock? or I miss some other part?
for #fuses do I need to type in INTRC ?
Question 2
How I going to run my internal clock?
I read from datasheet, it said the internal clock will automatically start when it goes into main().
Is it true? If not can anyone tell me how to run the internal clock?
Thx a lot ~~~ |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 17, 2008 9:46 pm |
|
|
Here is an example program. It uses the internal oscillator at 8 MHz.
It blinks an LED on pin B0.
Code: |
#include <16F887.h>
#fuses INTRC_IO, NOWDT, PUT, BROWNOUT, MCLR, NOLVP
#use delay(clock=8000000)
//===============================
void main()
{
while(1)
{
output_high(PIN_B0);
delay_ms(500);
output_low(PIN_B0);
delay_ms(500);
}
} |
|
|
|
vinceykw
Joined: 16 Dec 2008 Posts: 3
|
|
Posted: Wed Dec 17, 2008 9:52 pm |
|
|
Thx... dude~ If I face any question, I will be back~ |
|
|
maaply Guest
|
delay is not 500 ms |
Posted: Thu Jan 22, 2009 5:34 am |
|
|
Hi,
I tried above code for 16f727. the delay is not 500ms. I got approximatly 3 sec instead of 500ms. Can any one tell me, what I am doing wrong?
thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 22, 2009 2:00 pm |
|
|
Post your compiler version. |
|
|
|