Reply by September 29, 20042004-09-29
On Wednesday, in article
     <b6a69320b58517c2165465c3a04c6f83@localhost.talkaboutelectronicequipment.com>
     icurmtdude@yahoo.com "icurmtdude" wrote:

>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.
In which case if it is not created as a 'volatile' variable that is most likely to be your problem.
>Thanks for the urls. They look very helpful.
Not a problem.. -- Paul Carpenter | paul@pcserviceselectronics.co.uk <http://www.pcserviceselectronics.co.uk/> PC Services <http://www.gnuh8.org.uk/> GNU H8 & mailing list info <http://www.badweb.org.uk/> For those web sites you hate
Reply by icurmtdude September 29, 20042004-09-29
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.


Reply by September 29, 20042004-09-29
On Wednesday, in article
     <0b6937058c87a644c82f392c5110257f@localhost.talkaboutelectronicequipment.com>
     icurmtdude@yahoo.com "icurmtdude" wrote:

>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: > >#define TMRX_ICRAH (* (volatile unsigned char *) (0xf778)) /* Input >capture AH */ > >#define TMRX_ICRAL (* (volatile unsigned char *) (0xf779)) /* Input >capture AL */ > > >#pragma interrupt (count_pulses)
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).
>void count_pulses( void) >{ > UINT8 count[2];
Defining local scope variables (on the stack) inside an interupt routine means nothing else will see them.
> .. /* code to disable & clear input D timerx interrupt */ > .. > .. > count[0] = TMRX_ICRAH; > count[1] = TMRX_ICRAL; > .. > .. /* clear timer overflow flag */ > .. /* enable interrupt D */ >} > >Let me know if this is the way to do it..I am not getting the correct >result when reading this counter.
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 <http://www.pcserviceselectronics.co.uk/> PC Services <http://www.gnuh8.org.uk/> GNU H8 & mailing list info <http://www.badweb.org.uk/> For those web sites you hate
Reply by icurmtdude September 29, 20042004-09-29
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:

#define TMRX_ICRAH (* (volatile unsigned char *)    (0xf778))  /* Input
capture AH */

#define TMRX_ICRAL (* (volatile unsigned char *)    (0xf779))  /* Input
capture AL */


#pragma interrupt (count_pulses)
void count_pulses( void) 
{
  UINT8 count[2];
  
  .. /* code to disable & clear input D timerx interrupt */
  ..
  ..
  count[0] = TMRX_ICRAH; 
  count[1] = TMRX_ICRAL;
  ..
  .. /* clear timer overflow flag */
  .. /* enable interrupt D */
}

Let me know if this is the way to do it..I am not getting the correct
result when reading this counter. 

thanks.


Reply by Michael Biere September 3, 20042004-09-03
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
Reply by icurmt September 2, 20042004-09-02
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.



Hans-Bernhard Broeker <broeker@physik.rwth-aachen.de> wrote in message news:<2po3fdFmr57tU4@uni-berlin.de>...
> icurmt <icurmtdude@yahoo.com> wrote: > > > 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".
Reply by Hans-Bernhard Broeker September 2, 20042004-09-02
icurmt <icurmtdude@yahoo.com> wrote:

> 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.
Reply by icurmt September 2, 20042004-09-02
Hi,

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.