To start using the timer/counter in basic mode, follow these steps:
  1. 1.Write a TOP value to the Period (TCAn.PER) register.
  2. 2.Enable the peripheral by writing a ‘1’ to the 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 the TCAn.CTRLA register.

  3. 3.Optional: By writing a ‘1’ to the Enable Count on Event Input (CNTEI) bit in the Event Control (TCAn.EVCTRL) register, events are counted instead of clock ticks.
  4. 4.The counter value can be read from the Counter (CNT) bit field in the Counter (TCAn.CNT) register.