Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

measuring Time btw interrups

Status
Not open for further replies.

farhatwael

Newbie level 2
Joined
Jun 6, 2007
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,294
hello am using microcontroller : pic16f877 and i want do the following:

when interrupt occurs on RB0 timer must start ( seconds )
then when i reach a specific number of interrupts on RB0 (10 interrupts for example ) i need the timer to stop then displaying the time...

can any body help ??
plzzzzzzzzz So important for my project
 

In the ISR I would just decrement a counter every time I get an interrupt. When that counter reaches zero I would read the timer and display (update) the time.
 

mmmm ok so how do i do it ... someone told me that i should do it by CCP but i dont knw how ...!!

if i just decrement a counter do i get the exact time ?
plz can u help me more .. am using Pic C " CCS " .. plzzz
 

It depends on the precision you need. Usually the time it takes to enter the ISR is short and it can be accounted for, so you can correct the dispalyed time if that is a concern.

You are right, if the CCP is available, you can use it. See section 8.1 of the datasheet. Set it to capture mode, on every rising or falling edge, depending on what you need, and enable the CCP interrupt. In the ISR you simply read CCPRxH and CCPRxL, which will contain whatever TMR1H and TMR1L contained when the edge occurred, because when the CCP detects the correct edge it "captures" , that is, it latches the contents of the TMR1 register in the CCP registers.
So make sure timer 1 is running and set the prescaler according to what you expect the time between the interrupts will be, so that TMR1 does not roll over.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top