I am trying to count the number of pulses through timerx.
Infact, I need to observe two input pulses. I need to obtain the pulses received on A between every input pulses to B. For example, whenever I receive pulse on say B, I need to reset the counter A and start counting the pulses A receives until B's next input.
Does it make sense to do it w/o setting any interrupts on A or B.
Some code example will be helpful.
Thanks.
Didn't find your answer? Ask the community — no account required.
H
Hans-Bernhard Broeker
Only if your "pulses" are considerably longer than the instruction cycle time on your CPU, so you can afford to poll the pin states in a close loop. And then only if your CPU has nothing else to do during that time. Since the latter is rather unlikely to be the case, I guess that means the overall answer is "no".
Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.
I
icurmt
So I guess I need to just one interrupt, here on B, and so each time that interrupt occurs, I can note down the counter value of A and use the difference from the last value recorded.
M
Michael Biere
Hi,
depending on your effective Interrupt latency (you may have some code that may not be interrupted) it could be useful to capture the value of TimerA with the edge of TimerB input and in parallel trigger the interrupt. So you gain a lot of time to read out the TimerA value.
I think that should be possible though i'm not absolutely familiar with the 3642/3644 peripherals.
Greetings from michael
I
icurmtdude
Hi there,
This is a question on implementation.
Since am counting the number of input pulses on A between each input pulse on D through timerx, I have the following lines of code:
Let me know if this is the way to do it..I am not getting the correct result when reading this counter.
thanks.
P
Paul Carpenter
This style suggests an older version of GNU compiler, if you are using the GNU compiler, then there are two sources for the latest versions sourceforge and kpit, both are linked from the site in my sig.
You also might get answers from those who have used the H8 Tiny series (3642/3644), in C and the timer interupts.
Theer is nothing wrong with asking questions here, but you might get more help from the GNUH8 mailing list (URL in sig).
Defining local scope variables (on the stack) inside an interupt routine means nothing else will see them.
Because nothing else is seeing the same variable. This also suggests you have a different variable count[2] somewhere else otherwise there should have been linking errors to undefined variables.
You need to define a file scope (at minimum) or global variable -
volatile UINT8 count[2];
The 'volatile' is crucial as the compiler is forced to reread the memory location rather than rely on compiler optimisations to assume it has the current value when the interupt routine has changed it.
The web site below for GNUH8 should be useful to you (even if using a different compiler) for lots of ideas, samples and ability to join the mailing list of similar users.
Paul Carpenter | paul@pcserviceselectronics.co.uk
PC Services
GNU H8 & mailing list info
For those web sites you hate
I
icurmtdude
Paul,
I am sorry the variable is defined globally. It was just a cut-paste error. I wanted to include some code to just give an idea of what I was doing.
Thanks for the urls. They look very helpful.
P
Paul Carpenter
In which case if it is not created as a 'volatile' variable that is most likely to be your problem.
Not a problem..
Paul Carpenter | paul@pcserviceselectronics.co.uk
PC Services
GNU H8 & mailing list info
For those web sites you hate
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.