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.
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.
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.
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.
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
ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.