View previous topic :: View next topic |
Author |
Message |
russk2txb
Joined: 30 Mar 2008 Posts: 109 Location: New Jersey
|
Timer clock |
Posted: Thu Jan 13, 2011 2:15 pm |
|
|
Maybe a dumb question, but I cannot find a clear answer. When using timer0 on RTCC, with #use delay(clock=40M, oscillator=10M), is the clock cycle 40M/4 or is it 10M/4 ?
Thanks, Russ |
|
![](templates/subSilver/images/spacer.gif) |
wind88
Joined: 29 Dec 2010 Posts: 37
|
|
Posted: Thu Jan 13, 2011 2:24 pm |
|
|
Code: | Period = (256 - TMR0)*(4/fosc)*(Prescaler) |
|
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 13, 2011 2:37 pm |
|
|
The Timer0 is clocked at 1/4 of the PIC's oscillator speed. The oscillator
is running at 40 MHz, so the Timer is clocked at 10 MHz.
The fact that the oscillator speed is specified by the "clock=" statement
is given in the CCS manual:
Quote: | #USE DELAY
Syntax: #USE DELAY (options))
Elements: Options may be any of the following separated by commas:
clock=speed speed is a constant 1-100000000 (1 hz to 100 mhz).
This number can contains commas. This number also supports the
following denominations: M, MHZ, K, KHZ. This specified the clock the
CPU runs at. |
|
|
![](templates/subSilver/images/spacer.gif) |
russk2txb
Joined: 30 Mar 2008 Posts: 109 Location: New Jersey
|
|
Posted: Thu Jan 13, 2011 3:16 pm |
|
|
Thanks PCM. Maybe you can see why it is confusing. The equation says use 4/fosc, but it is really 4/clock (as used in the #use delay function).
Regards, Russ |
|
![](templates/subSilver/images/spacer.gif) |
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Thu Jan 13, 2011 4:38 pm |
|
|
Hey Russ don't feel bad - I've been bitten with that one before too. Somehow I either end up with too many or too few "/4"parts of my equation when figuring things out.
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
![](templates/subSilver/images/spacer.gif) |
|