Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

What happens to timer counter after output compare?

What happens to timer counter after output compare?

2005-04-15 by arhodes19044

I am setting up a timer. I am trying to measure milliseconds. I have 
set the output compare on timer 1 (prescale of 1) to 16000. 

I get the interrupt triggered, and I am able to increment the 
millisecond counter. Does the timer's counter get reset to zero 
automatically and immediately? I suppose it does not. What do I do to 
force it to reset? 

Do I write zero to the counter? Doesn't the timer lose a few ticks in 
this process? 

I did not notice a setting to cause the timer to reset automatically 
when the outputcompare interrupt is triggered, but I would have 
thought one exists. 

-Tony

Re: [AVR-Chat] What happens to timer counter after output compare?

2005-04-15 by Mark Jordan

On 15 Apr 2005 at 11:27, arhodes19044 wrote:

> I get the interrupt triggered, and I am able to increment the 
> millisecond counter. Does the timer's counter get reset to zero 
> automatically and immediately? 

	The timer resets IF it is in CTC mode.

> Do I write zero to the counter? Doesn't the timer lose a few ticks in 
> this process? 

	Just write "a few ticks" instead of zero to the counter.

> I did not notice a setting to cause the timer to reset automatically 
> when the outputcompare interrupt is triggered, but I would have 
> thought one exists. 

	Look for the CTC mode.

	Mark Jordan

Re: [AVR-Chat] What happens to timer counter after output compare?

2005-04-15 by David Kelly

On Fri, Apr 15, 2005 at 11:27:05AM -0000, arhodes19044 wrote:
> 
> I am setting up a timer. I am trying to measure milliseconds. I have 
> set the output compare on timer 1 (prescale of 1) to 16000. 
> 
> I get the interrupt triggered, and I am able to increment the 
> millisecond counter. Does the timer's counter get reset to zero 
> automatically and immediately? I suppose it does not. What do I do to 
> force it to reset? 

Atmel's doc2505.pdf covers what you need to read.

-- 
David Kelly N4HHE, dkelly@HiWAAY.net
========================================================================
Whom computers would destroy, they must first drive mad.

Re: What happens to timer counter after output compare?

2005-04-17 by arhodes19044

Got it.  The Atmel docs are very good IF you already understand what 
you need to do.  Otherwise it is not too easy to figure it all out.  A 
set of well commented examples would do wonders.  Comments of ehst is 
being set and WHY.

I have asked a new question on this board.  I have the millisecond 
interrupt working well, I now want to get a 1 second interrupt without 
dedicating another timer for that function.  I suspect I will have to 
use a separate timer, though

-Tony

--- In AVR-Chat@yahoogroups.com, "Mark Jordan" <mark@c...> wrote:
Show quoted textHide quoted text
> On 15 Apr 2005 at 11:27, arhodes19044 wrote:
> 
> > I get the interrupt triggered, and I am able to increment the 
> > millisecond counter. Does the timer's counter get reset to zero 
> > automatically and immediately? 
> 
> 	The timer resets IF it is in CTC mode.
> 
>> 	Look for the CTC mode.
> 
> 	Mark Jordan

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.