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 CCS Technical Support

two timers in the same time? how may i do this

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



Joined: 28 Apr 2004
Posts: 18

View user's profile Send private message

two timers in the same time? how may i do this
PostPosted: Mon May 03, 2004 5:24 am     Reply with quote

i want to trig two timers in the same time, what's the solution.
timer_1 to count 2 second and test therefore the input voltage if it changes or no. the second timer is the timer_2 who will sample the same voltage input in every 100µs.
this two timers must be one time which a led will be high.
if anyone help me, i give him an additionnal information
_________________
nfs
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Mon May 03, 2004 5:34 am     Reply with quote

If I understand correctly, you want both timers to have the same source. Configure Timer1 or Timer2 module of the PIC to overflow every 100us. Enable the timer interrupt. In the ISR, increment a long counter and set a flag. In your main(), in a loop check if the flag is set. If it is do whatever you want your timer_2 to do and reset the flag. Also in the same loop check the value of the counter, when it reaches 2000000 it means 2 seconds have passed. Do your timer_1 action there and clear the counter.
nfs



Joined: 28 Apr 2004
Posts: 18

View user's profile Send private message

re
PostPosted: Mon May 03, 2004 6:33 am     Reply with quote

the source is the same but the problem is: how can i program the two timers to start on the same time?
_________________
nfs
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Mon May 03, 2004 7:42 am     Reply with quote

So you want ot take 20K samples and then do a compare? Load a counter with 20000 and decrement in the timer interupt every 100uS. When it gets to zero do the compare and load the counter again. You don't need to use two timers.
nfs



Joined: 28 Apr 2004
Posts: 18

View user's profile Send private message

re
PostPosted: Mon May 03, 2004 8:04 am     Reply with quote

in this case i will use the timer_1 as a counter!!!!
_________________
nfs
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