Normal Mode (Counter Mode)

In this mode, the TCA is used as an up/down counter having peripheral clock or events as a clock source. Depending on the mode of operation used, the internal counter is cleared, incremented, or decremented at each timer clock or event. The Counter (TCAn.CNT) Register value can be read by the CPU anytime. The write access to TCAn.CNT has a higher priority than count, clear or reload, and will be immediate. The direction of the counter can also be changed during normal operation by writing to DIR in TCAn.CTRLE.

In Normal mode, the TCA Overflow output is not present on the pin, but the TCA can be used to generate an interrupt when the number of counting events reached the TCAn.CMPn value. The following code shows the configuration of TCA to generate periodic interrupts (interrupt code not included):

AVR® Dx - TCA Initialization, Periodic Interrupt Enabled

voidTCA0_init(void){/* enable overflow interrupt */
    TCA0.SINGLE.INTCTRL = TCA_SINGLE_OVF_bm;/* set Normal mode */
    TCA0.SINGLE.CTRLB = TCA_SINGLE_WGMODE_NORMAL_gc;/* disable event counting */
    TCA0.SINGLE.EVCTRL &=~(TCA_SINGLE_CNTEI_bm);/* set the period */
    TCA0.SINGLE.PER = PERIOD_EXAMPLE_VALUE;  
    
    TCA0.SINGLE.CTRLA = TCA_SINGLE_CLKSEL_DIV256_gc         /* set clock source (sys_clk/256) */| TCA_SINGLE_ENABLE_bm;/* start timer */}