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

What clock frequency to use if using internal RC with respec

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



Joined: 07 Sep 2003
Posts: 5
Location: Abbotsford, BC, Canada

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

What clock frequency to use if using internal RC with respec
PostPosted: Sun Apr 20, 2003 12:07 pm     Reply with quote

Quick question:

Which clock frequency should I use if I'm using the internal RC clock of a PIC12F675 and am using #use delay()?

#use delay(clock = 4000000) //Fosc of internal RC.

or

#use delay(clock = 1000000) //Fosc/4

I'm getting strange timing if I use 4 MHz, all seems fine at 1 MHz (this could be misleading as the delay routines are faster). I would think that I should be using the Fosc (4 MHz)as described in the CCS manual.

If anyone can confirm that I should be using 4 MHz, I'll look elsewhere in my code for problems.

Regards,

Shawn.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13833
liche
Guest







Re: What clock frequency to use if using internal RC with re
PostPosted: Mon Apr 21, 2003 6:32 am     Reply with quote

Check out the PIC datasheet. You should be able to find the frequency (+/-) range of the internal oscillator. Its not going to be real accurate (assuming you're using internal oscillator you don't need accuracy anyways). If you do need accurate timing, you'll need to go to a crystal oscillator.




:=Quick question:
:=
:=Which clock frequency should I use if I'm using the internal RC clock of a PIC12F675 and am using #use delay()?
:=
:=#use delay(clock = 4000000) //Fosc of internal RC.
:=
:= or
:=
:=#use delay(clock = 1000000) //Fosc/4
:=
:=I'm getting strange timing if I use 4 MHz, all seems fine at 1 MHz (this could be misleading as the delay routines are faster). I would think that I should be using the Fosc (4 MHz)as described in the CCS manual.
:=
:=If anyone can confirm that I should be using 4 MHz, I'll look elsewhere in my code for problems.
:=
:=Regards,
:=
:=Shawn.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13861
Shawn Cherewick



Joined: 07 Sep 2003
Posts: 5
Location: Abbotsford, BC, Canada

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

Re: What clock frequency to use if using internal RC with re
PostPosted: Mon Apr 21, 2003 11:58 am     Reply with quote

Thanks, but that's not what I'm after. The question I'm asking is about the compiler and the "#use delay" directive.

Normally, using an external crystal (say 11.0952 MHz) I would put #use delay(clock = 11059200) and everything will be happy.

When using an internal oscillator, should I use the actual oscillator frequency (4 MHz) or should I use what the operation frequency will be (1 MHz, Fosc/4)?

Shawn.


:=Check out the PIC datasheet. You should be able to find the frequency (+/-) range of the internal oscillator. Its not going to be real accurate (assuming you're using internal oscillator you don't need accuracy anyways). If you do need accurate timing, you'll need to go to a crystal oscillator.
:=
:=
:=
:=
:=:=Quick question:
:=:=
:=:=Which clock frequency should I use if I'm using the internal RC clock of a PIC12F675 and am using #use delay()?
:=:=
:=:=#use delay(clock = 4000000) //Fosc of internal RC.
:=:=
:=:= or
:=:=
:=:=#use delay(clock = 1000000) //Fosc/4
:=:=
:=:=I'm getting strange timing if I use 4 MHz, all seems fine at 1 MHz (this could be misleading as the delay routines are faster). I would think that I should be using the Fosc (4 MHz)as described in the CCS manual.
:=:=
:=:=If anyone can confirm that I should be using 4 MHz, I'll look elsewhere in my code for problems.
:=:=
:=:=Regards,
:=:=
:=:=Shawn.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13877
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: What clock frequency to use...
PostPosted: Mon Apr 21, 2003 12:16 pm     Reply with quote

<font face="Courier New" size=-1>:=Thanks, but that's not what I'm after. The question I'm asking is about the compiler and the "#use delay" directive.
:=
:=Normally, using an external crystal (say 11.0952 MHz) I would put #use delay(clock = 11059200) and everything will be happy.
:=
:=When using an internal oscillator, should I use the actual oscillator frequency (4 MHz) or should I use what the operation frequency will be (1 MHz, Fosc/4)?
:=
------------------------------------------------------
The following program makes an LED on GP2 (pin 5)
turn on for 1 second and then off for 1 second.
I checked this with a stop watch.

(12F629 is similar to 12F675).

So the answer is, use 4 MHz.

If you're getting weird results, I would check:

1. Has Osccal setting at 0x3FF been trashed ?
Read the ROM using your programmer and check it.

2. Are the config bits correct ?
Read them with your programmer. Compare them to
the ones in the .HEX file. Compare both to the
data sheet.

3. Possibly your compiler has a bug. I tested the
following program with PCM vs. 3.148. What is
your version ?

<PRE>
#include <12F629.h>
#fuses INTRC, NOWDT, NOPROTECT, NOMCLR
#use delay(clock = 4000000)
<BR>
//=============================================================
main()
{
<BR>
while(1)
{
output_low(PIN_A2);
delay_ms(1000);
output_high(PIN_A2);
delay_ms(1000);
}
<BR>
}
</PRE>


--</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 13884
Shawn Cherewick



Joined: 07 Sep 2003
Posts: 5
Location: Abbotsford, BC, Canada

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

Re: What clock frequency to use...
PostPosted: Mon Apr 21, 2003 12:29 pm     Reply with quote

:=<font face="Courier New" size=-1>:=Thanks, but that's not what I'm after. The question I'm asking is about the compiler and the "#use delay" directive.
:=:=
:=:=Normally, using an external crystal (say 11.0952 MHz) I would put #use delay(clock = 11059200) and everything will be happy.
:=:=
:=:=When using an internal oscillator, should I use the actual oscillator frequency (4 MHz) or should I use what the operation frequency will be (1 MHz, Fosc/4)?
:=:=
:=------------------------------------------------------
:=The following program makes an LED on GP2 (pin 5)
:=turn on for 1 second and then off for 1 second.
:=I checked this with a stop watch.
:=
:=(12F629 is similar to 12F675).
:=
:=So the answer is, use 4 MHz.
:=
:=If you're getting weird results, I would check:
:=
:=1. Has Osccal setting at 0x3FF been trashed ?
:= Read the ROM using your programmer and check it.
:=
:=2. Are the config bits correct ?
:= Read them with your programmer. Compare them to
:= the ones in the .HEX file. Compare both to the
:= data sheet.
:=
:=3. Possibly your compiler has a bug. I tested the
:= following program with PCM vs. 3.148. What is
:= your version ?
:=
:=<PRE>
:=#include <12F629.h>
:=#fuses INTRC, NOWDT, NOPROTECT, NOMCLR
:=#use delay(clock = 4000000)
:=<BR>
:=//=============================================================
:=main()
:={
:=<BR>
:=while(1)
:={
:=output_low(PIN_A2);
:=delay_ms(1000);
:=output_high(PIN_A2);
:=delay_ms(1000);
:=}
:=<BR>
:=}
:=</PRE>
:=
:=
:=--</font>

I'm using PCM 3.152, maybe I'll roll back to 3.148 and check again. I will look at each item you described to see if there is a problem somewhere.

Thanks,

Shawn.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13886
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