21.3.2 Initialization
To start using the timer/counter in a basic mode, follow these steps:
- Write a TOP value to the Period (TCAn.PER) register.
- Enable the peripheral by writing a
‘
1
’ to the Enable (ENABLE) bit in the Control A (TCAn.CTRLA) register.The counter will start counting clock ticks according to the prescaler setting in the Clock Select (CLKSEL) bit field in TCAn.CTRLA.
- Optional: By writing a
‘
1
’ to the Enable Counter Event Input A (CNTAEI) bit in the Event Control (TCAn.EVCTRL) register, events are counted instead of clock ticks. - The counter value can be read from the Counter (CNT) bit field in the Counter (TCAn.CNT) register.