View previous topic :: View next topic |
Author |
Message |
Flavio58
Joined: 08 Sep 2003 Posts: 21
|
Rtcc |
Posted: Tue Jul 15, 2003 7:37 am |
|
|
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
|
Re: Rtcc |
Posted: Tue Jul 15, 2003 8:26 am |
|
|
<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
|
Re: Rtcc |
Posted: Tue Jul 15, 2003 8:31 am |
|
|
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
|
Re: Rtcc |
Posted: Tue Jul 15, 2003 10:19 am |
|
|
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
|
Re: Rtcc |
Posted: Tue Jul 15, 2003 12:24 pm |
|
|
:=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 |
Posted: Tue Jul 15, 2003 12:59 pm |
|
|
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 |
Posted: Tue Jul 15, 2003 1:51 pm |
|
|
<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
|
Re: Rtcc |
Posted: Wed Jul 16, 2003 1:05 am |
|
|
:=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 |
|
|
|