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

Rtcc

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



Joined: 08 Sep 2003
Posts: 21

View user's profile Send private message

Rtcc
PostPosted: Tue Jul 15, 2003 7:37 am     Reply with quote

In my project I use a 32Khz quartz connected to pin rc0/t1oso/T1CKI (PIC18F452).
In my software I use the rtcc interrupt to count the seconds number.
In CCS example there is the definition :


#define INTS_PER_SECOND 76 // (20000000/(4*256*256))

where 20000000 is the clock frequency.
Why the INT_PER_SECONDS is the clock frequency / 4*256*256 ?

4*256*256 ????

Do you known why ?
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515999
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

Re: Rtcc
PostPosted: Tue Jul 15, 2003 8:26 am     Reply with quote

<font face="Courier New" size=-1>:=In my project I use a 32Khz quartz connected to pin rc0/t1oso/T1CKI (PIC18F452).
:=In my software I use the rtcc interrupt to count the seconds number.
:=In CCS example there is the definition :
:=
:=
:=#define INTS_PER_SECOND 76 // (20000000/(4*256*256))
:=
:=where 20000000 is the clock frequency.
:=Why the INT_PER_SECONDS is the clock frequency / 4*256*256 ?
:=

There is an explanation in the manual on page 181...you really should look there first.

Basically it takes 4 clocks to get an instruction done
so the timer is icremented at (clock/4)/prescaler
an interrupt occurs every 256 increments
so that is why you have 4*256( prescaler)*256 clocks to an interrupt.

:=4*256*256 ????
:=
:=Do you known why ?</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516002
Flavio58



Joined: 08 Sep 2003
Posts: 21

View user's profile Send private message

Re: Rtcc
PostPosted: Tue Jul 15, 2003 8:31 am     Reply with quote

Page 181 ???
At page 181 of C Compiler Reference there is the Standard C definition .... (C Compiler Referrence Manual - MAY 2003)
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516003
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Re: Rtcc
PostPosted: Tue Jul 15, 2003 10:19 am     Reply with quote

You say that you are using the RTCC int which is actually the Timer0 int. You also state that you are using a 32KHz crystal connected to the timer1 osc. If your intention is to use the 32KHz to derive your seconds, then you should be either using the timer1 int or change the crystal to provide the clock to timer0. In either of these cases, your 20MHz osc should not be used to figure the INTS_PER_SECOND.

Regards
Mark

:=In my project I use a 32Khz quartz connected to pin rc0/t1oso/T1CKI (PIC18F452).
:=In my software I use the rtcc interrupt to count the seconds number.
:=In CCS example there is the definition :
:=
:=
:=#define INTS_PER_SECOND 76 // (20000000/(4*256*256))
:=
:=where 20000000 is the clock frequency.
:=Why the INT_PER_SECONDS is the clock frequency / 4*256*256 ?
:=
:=4*256*256 ????
:=
:=Do you known why ?
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516005
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

Re: Rtcc
PostPosted: Tue Jul 15, 2003 12:24 pm     Reply with quote

:=Page 181 ???
:=At page 181 of C Compiler Reference there is the Standard C definition .... (C Compiler Referrence Manual - MAY 2003)

My reference was to the manual dated july 2002 ...the good news is you at least have a manual so you should be able to find the information you need to answer you basic questions even if the page numbers have changed.
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516008
thomas
Guest







Re: Rtcc
PostPosted: Tue Jul 15, 2003 12:59 pm     Reply with quote

Could you please explain why people usually use 32K crystal for Real Time Clock rather than any crystal speed? I thought as long as the timer interrupt setting is configured correctly, any crystal speed could be used. Am I completely wrong here?

:=You say that you are using the RTCC int which is actually the Timer0 int. You also state that you are using a 32KHz crystal connected to the timer1 osc. If your intention is to use the 32KHz to derive your seconds, then you should be either using the timer1 int or change the crystal to provide the clock to timer0. In either of these cases, your 20MHz osc should not be used to figure the INTS_PER_SECOND.
:=
:=Regards
:=Mark
:=
:=:=In my project I use a 32Khz quartz connected to pin rc0/t1oso/T1CKI (PIC18F452).
:=:=In my software I use the rtcc interrupt to count the seconds number.
:=:=In CCS example there is the definition :
:=:=
:=:=
:=:=#define INTS_PER_SECOND 76 // (20000000/(4*256*256))
:=:=
:=:=where 20000000 is the clock frequency.
:=:=Why the INT_PER_SECONDS is the clock frequency / 4*256*256 ?
:=:=
:=:=4*256*256 ????
:=:=
:=:=Do you known why ?
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516010
Sherpa Doug
Guest







Re: Rtcc
PostPosted: Tue Jul 15, 2003 1:51 pm     Reply with quote

<font face="Courier New" size=-1>:=Could you please explain why people usually use 32K crystal for Real Time Clock rather than any crystal speed? I thought as long as the timer interrupt setting is configured correctly, any crystal speed could be used. Am I completely wrong here?
:=

People use 32.768kHz crystals because they divide by an even power of 2 to get 1Hz. Also because they are so slow and low powered they can run for years off of a small battery.

The down side is they are so slow they can't be used as the main clock for anything smarter than a washing machine. They are so low power they are susceptable to EMI. They can take as long as several seconds to stabalize after power is applied. Even the output of a CMOS gate can supply enough power to electrically damage them if misapplied. They are fragile, so they should not be hard mounted to a PCB unless the PCB itself is cushoned. They are frequency stable at the temperature of the human wrist, but may drift badly over commercial temperatures. They come in many unlabled types and only run reliably on frequency if you get the correct type.

As cystals go...THEY SUCK!

Sorry, it is a georgous day outside and I am stuck in this little tin cave :(


</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516015
Flavio58



Joined: 08 Sep 2003
Posts: 21

View user's profile Send private message

Re: Rtcc
PostPosted: Wed Jul 16, 2003 1:05 am     Reply with quote

:=People use 32.768kHz crystals because they divide by an even power of 2 to get 1Hz. Also because they are so slow and low powered they can run for years off of a small battery.
:=


This is the answer....
Using a 32 KHZ clock the pic need a low power ....
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516045
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