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

Timer clock

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



Joined: 30 Mar 2008
Posts: 109
Location: New Jersey

View user's profile Send private message

Timer clock
PostPosted: Thu Jan 13, 2011 2:15 pm     Reply with quote

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
wind88



Joined: 29 Dec 2010
Posts: 37

View user's profile Send private message

PostPosted: Thu Jan 13, 2011 2:24 pm     Reply with quote

Code:
Period = (256 - TMR0)*(4/fosc)*(Prescaler)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 13, 2011 2:37 pm     Reply with quote

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.
russk2txb



Joined: 30 Mar 2008
Posts: 109
Location: New Jersey

View user's profile Send private message

PostPosted: Thu Jan 13, 2011 3:16 pm     Reply with quote

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
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Thu Jan 13, 2011 4:38 pm     Reply with quote

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. Shocked

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
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