TCB - Timer/Counter Type B

The Timer/Counter type B (TCB) of the AVR Dx devices can be used to replace all the functionalities of Timer 1 from the megaAVR devices.

The capabilities of the TCB include frequency and waveform generation and input capture on an event with time and frequency measurement of the digital signals. The TCB consists of a base counter and control logic that can be set in one of eight different modes, each mode providing unique functionality.

Figure 1. AVR® Dx - TCB Block Diagram
The TCB can be clocked from the Peripheral Clock (CLK_PER), from a 16-bit Timer/Counter type A (CLK_TCAn) or the Event System (EVSYS), selectable through the Clock Select (CLKSEL) bit field in the Control A (TCBn.CTRLA) register:
Figure 2. AVR® Dx - TCB Clock Logic

If the waveform output (WO) is required to be available on a pin, the Compare/Capture Output Enable (CCMPEN) from the Control B (TCBn.CTRLB) register must be written to ‘1’. The location of WO is also selectable using the PORTMUX.TCBROUTEA register, but the direction of the WO pin needs to be configured as an output (the TCB overwrites the functionality of the output pin but does not overwrite the pin direction).

The following code snippets show the TCB initialization examples for a few use cases.