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.

Counter and Interrupts

Status
Not open for further replies.

ZaeemAhmad

Junior Member level 2
Joined
Dec 24, 2009
Messages
20
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,452
Using 8051, how can I achieve the following thing:

During the normal execution of a code (in an infinite while loop), I am simultaneously counting pulses from Timer 1 and as soon as the count reaches a particular value, I want to stop the normal execution of program (i.e. the while loop and call an interrupt) and go to a particular code (probably a custom interrupt handler)?

Thanks!
 

Yes, you can do that. continously read the value of the timer in the while loop. As soon as it reaches set point call another function.
 

Thanks brother! Another question: Can the counting go faster than the execution of a single line of code (e.g. count increases by 10, but only one assembly line code is executed by that time). What to do in that case? Can I use some kind of interrupt for that situation, because I want to terminate the loop at some exact count of the counter?
 

what is the speed of the pulses? like 200 pulse per second.. You can use an external interrupt to count pulses. So you can easily program it to stop the count at exact number.

---------- Post added at 04:09 ---------- Previous post was at 04:07 ----------

count() interrupt 0
{
pulse++;
if(pulse >= setpoint)
required_function();
}
// you can write like this
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top