[SOLVED]: Restart cascaded timers

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm using timers D0 and D1 in cascaded mode, to have a 32-bit counter:

 

EVSYS.CH0MUX = EVSYS_CHMUX_TCD0_OVF_gc;
TC_EnableEventDelay(&TCD1);
TC1_ConfigClockSource(&TCD1, TC_CLKSEL_EVCH0_gc);
TC0_ConfigClockSource(&TCD0, TC_CLKSEL_DIV1_gc);

when a criteria is met, I need to restart the counter, that is to reset it to 0, losing as little time as possible.

Because TCD0 is the least significant timer and TCD1 the most one, I think to reset first TCD0, then TCD1.

 

From the datasheet I'm not sure if I can just write the CNT register even if the time is running or I need to stop it first.

 

This topic has a solution.
Last Edited: Wed. Aug 9, 2017 - 09:23 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Issue a RESTART command to TCD0, then TCD1.  This is faster than writing CNT (single byte vs, two bytes).

 

Greg Muth

Portland, OR, US

Xplained Boards mostly

Atmel Studio 7.0 on Windows 8.1

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Greg_Muth wrote:

Issue a RESTART command to TCD0, then TCD1.  This is faster than writing CNT (single byte vs, two bytes).

 

I'm not sure it's faster:

 

 

A reset can be given only when the timer/counter is not running (OFF).

So I have to:

 

- turn TCD0 off

- reset timer TCD0

- reset timer TCD1

- turn TCD0 on

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

RESTART does not require the clock to be disabled, only RESET requires that.

Greg Muth

Portland, OR, US

Xplained Boards mostly

Atmel Studio 7.0 on Windows 8.1