Go Down

Topic: interrupts (Read 104 times) previous topic - next topic

steelman1

I need some guidance, at this time this project is in the concept stage. I need to count the pauses on up to 3 pins. I plan to use input interrupts to increment counters. I would have a timer interrupt that would do calculations on the counters on the pins. This is where I am confused will the pin interrupts stop the timer interrupt when they increment the counters? That would cause a invalid time base for the calculation and make the whole thing useless.

larryd

Don't use interrupts !

Just scan the inputs and do things based on changes on these inputs.






No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

GolamMostafa

If you plan that the pin change interrupts be continued until the timer interrupt occurs, then there is no problem. When timer interrupt will occur, all pin counters will stop their counting automatically due to deactivation of the global interrupt flag.   

Robin2

I need to count the pauses on up to 3 pins.
What is the interval between pauses?

What exactly do you mean by "pause"?  An I/O pin just registers HIGH or LOW.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Paul__B

As a beginner, it is incredibly unlikely that interrupts will be useful to you.  Also an "XY problem".

A common "newbie" misunderstanding is that an interrupt is a mechanism for altering the flow of a program - to execute an alternate function.  Nothing could be further from the truth!  :smiley-eek:

An interrupt is a mechanism for performing an action which can be executed in "no time at all" with an urgency that it must be performed immediately or else data - information - will be lost or some harm will occur.  It then returns to the main task without disturbing that task in any way though the main task may well check at the appropriate point for a "flag" set by the interrupt.

Now these criteria are in a microprocessor time scale - microseconds.  This must not be confused with a human time scale of tens or hundreds of milliseconds or indeed, a couple of seconds.  A switch operation is in this latter category and a mechanical operation perhaps several milliseconds; the period of a 6000 RPM shaft rotation is ten milliseconds.

Unless it is a very complex procedure, you would expect the loop() to cycle many times per millisecond.  If it does not, there is most likely an error in code planning; while the delay() function is provided for testing purposes, its action goes strictly against effective programming methods.  The loop() will be successively testing a number of contingencies as to whether each requires action, only one of which may be whether a particular timing criteria has expired.  Unless an action must be executed in the order of microseconds, it will be handled in the loop().

So what sort of actions do require such immediate attention?  Well, generally those which result from the computer hardware itself, such as high speed transfer of data in UARTs(, USARTs) or disk controllers.

An alternate use of interrupts, for context switching in RTOSs, is rarely relevant to this category of microprocessors as it is more efficient to write cooperative code as described above.


Still reading?  Need a proper description of your purpose.

Go Up