cancel
Showing results for 
Search instead for 
Did you mean: 

Counters in ST7LITE

lseletron
Associate II
Posted on December 07, 2006 at 18:36

Counters in ST7LITE

3 REPLIES 3
lseletron
Associate II
Posted on December 06, 2006 at 20:25

Hi,

I find it very frustrating that the counters in the ST7DALI (I guess the whole ST7LITE family is like this) cannot be reset (and their reload value readjusted on the fly). Not only this but some counters cannot be stopped. There are many applications where there is a need for a counter to be reset on the fly, to load it with another value, start it again and when it overflows, to do something. Is there some software technique that can be used to achieve this? All I want is to measure the time interval between two external interrupts and do something after the second interrupt.

I do this:

I set auto reload value to 0. Lt2Counter will count from 0 to 255 and I enable counter interrupt.

When I get ext interrupt A I record the current value of the Lt2Counter.

When I get ext interrupt B I calculate the interval between A and B by examining the current value of Lt2Counter and the recorded one. Now I want to call a function 10 usec after ext interrupt B. Ideally I would reset the Lt2Counter, load another value in it and start it again and when I get the counter interrupt I would call the function. But I cant do this. I have to wait until it overflows, which breaks all my timing and renders the whole exercise pointless.

Is there a way to solve this problem or workaround?

Thank you

wolfgang2399
Associate II
Posted on December 07, 2006 at 08:03

Hi,

I read the DALI datasheet as you did: The DALI is a controller with an extreme poor timer structure. Other ST7, even ST7Lite controllers have more sophisticated timers with OutputCompare Registers you can set (more or less) at any time.

But I think, it doesn't solve your problem to know this...

Only 10µs is a very short time (80 cpu-cycles @8MHz fcpu) and in most applications it will not bother to wait in a loop after getting the external interrupt B. Above all you should take into account that the interrupt reaction time can take up to 22 cpu cycles (see datasheet chap. 13.5.1 General Timings).

Regards

WoRo

lseletron
Associate II
Posted on December 07, 2006 at 18:36

Hi WoRo,

Thank you for your reply. At least it shows I did not miss something important about this chip. I always had the nagging feeling that maybe I did not understand the chip. As for the 10 usec, yes, I can wait in a loop, but it could be 100 usec and then it makes a difference.

Regards

zsavov