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

about setup_timer_2.. please help

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



Joined: 25 Mar 2011
Posts: 3

View user's profile Send private message

about setup_timer_2.. please help
PostPosted: Fri Mar 25, 2011 7:03 am     Reply with quote

I have a gear motor.. rpm: 50
What parameter i should put in setup_timer_2()
For example setup_timer_2(T2_DIV_BY_4, 255, 1);
How to make the calculation?
Kindly please help me..
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 25, 2011 1:44 pm     Reply with quote

1. What interrupt rate do you want from Timer2 ? 50 rpm is 3000 Hz.
Do you want a 3 KHz interrupt rate ?

2. Or do you even want interrupts ? Do you actually want to run PWM ?

3. Also, what is the oscillator frequency of your PIC ?

To get help on this forum, you need to post information about your
project.

---------------
In case your question is about PWM, here are the links to previous threads:

PWM frequency formula:
http://www.ccsinfo.com/forum/viewtopic.php?t=17993

Duty cycle formula:
http://www.ccsinfo.com/forum/viewtopic.php?t=42417&start=1

PWM postscaler explanation:
http://www.ccsinfo.com/forum/viewtopic.php?t=29786&start=1
Sample code for PWM postscaler:
http://www.ccsinfo.com/forum/viewtopic.php?t=41473&start=3

Link to a PWM calculator program:
http://www.ccsinfo.com/forum/viewtopic.php?t=40450
huiching



Joined: 25 Mar 2011
Posts: 3

View user's profile Send private message

PostPosted: Thu Mar 31, 2011 10:38 am     Reply with quote

cycle time has an equation of (1/clock)*4*t2div*(period+1).
in my program, clock = 20 MHz and period equal 255
so, cycle time = 1/20M) * 4 * 4 * 256

Is the above statement true?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 31, 2011 11:53 am     Reply with quote

You still didn't say what you're using Timer2 for.
Is it for Timer2 interrupts, or is it for hardware PWM ?
So, I can't help you.
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