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 support@ccsinfo.com

How to do setting and use internal clock for PIC16F887

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



Joined: 16 Dec 2008
Posts: 3

View user's profile Send private message

How to do setting and use internal clock for PIC16F887
PostPosted: Wed Dec 17, 2008 9:26 pm     Reply with quote

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 ~~~ Very Happy
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 17, 2008 9:46 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Dec 17, 2008 9:52 pm     Reply with quote

Thx... dude~ If I face any question, I will be back~ Rolling Eyes
maaply
Guest







delay is not 500 ms
PostPosted: Thu Jan 22, 2009 5:34 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 22, 2009 2:00 pm     Reply with quote

Post your compiler version.
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