3.10.7.5 Timer4
Timer4 is a copy of Timer3.
The 16-bit timer/counter unit allows accurate program execution timing (event management), wave generation and signal timing measurement. The main features are:
- Four different selectable input clocks
- One output compare unit
- One input capture unit
- Input capture noise canceller
- Clear timer on compare match or capture event
- Variable PWM period
- Frequency generator
- External event counter
- Three independent interrupt sources (T4CAP, T4COM, T4OVF)
Timer 4 consists of a 6-bit prescaler and a 16-bit up counter with two compare registers (T4CORH, T4CORL) and two capture registers (T4ICRH, T4ICRL). The timer can be used as an event counter, timer or signal generator. Its output can be programmed as modulator. The compare registers enable it for various modes of signal generation and modulation. The counter can be driven by several clock sources. It has a programmable edge sensitive input logic for the capture input signal. The current counter value is readable via its capture register after a software capture event. In the capture mode, the counter value can also be captured by a programmable capture event from the Timer2 clock output (CLKT2), transparent RX path A (TRPA), transparent RX path B (TRPB) from the UHF receiver or the slow RC oscillator clock (CLKSRC).
The comparator output is controlled by a control register (T4CR) which contains mask bits for the actions (counter reset, output toggle, timer interrupt) that can be triggered by a compare match event, capture event or the counter overflow. The output compare registers (T4CORH, T4CORL) are compared with the counter value at all times. The result of the compare can be routed to the PC3 output pin by the TX modulator.
Interrupt request signals are all visible in the timer interrupt flag register (T4IFR). All interrupts are individually maskable with the timer interrupt mask register (T4IMR).
The counter input clock (CL4) can be supplied via the T clock of the system clock prescaler (CLKT), the XTO based clock (CLKXTO6), the internal SRC-clock (CLKSRC) or the internal fast oscillator clock (CLKFRC).
The 6-bit prescaler works together with the counter stage (T4CNT). The counter stage has six input signals (CL4, CLKT2, TRPA, TRPB, TICP, CLKSRC) and four output signals (T4CAP, T4OVF, T4COM and CLKT4). The CL4 supplies the 6-bit prescaler with a clock. The CLKT2, the UHF-receiver transparent RX path A/B outputs (TRPA, TRPB), the external input capture signal (TICP) or the CLKSRC can capture the counter value in the capture register. The CLKT4 is the output clock and T4CAP, T4OVF and T4COM are the interrupt request signals of the counter stage.
Signal description of Timer4 (internal signals):
CLKT2 – Timer2 counter stage clock input
TRPA – Transparent UHF receiver data path A input signal TRPB Transparent UHF receiver data path B input signal
TICP – Timer4 external input capture
CLKSRC – Slow RC oscillator clock input
CL4 – Selected prescaler input clock
CL4P – Counter input clock
CMR – Counter compare register match
RES – Counter reset (clear all bits)
OVF – Counter overflow
CP – Capture event signal
CPR – Capture event reset signal
CLKT4 – Counter stage clock output
T4CAP – Timer4 capture event interrupt
T4OVF – Timer4 counter overflow interrupt
T4COM – Timer4 compare match interrupt
M4 – Modulator output toggle flip-flop
Modulator Toggle Flip-Flop (T4)
The toggle flip-flop (T4) consists of a flip-flop with a preset input signal (T4TOP), an
input clock (CLKT4) and an output signal (M4). The T4TOP bit in the T4CR register
allows the programmer to initialize the toggle flip-flop output (M4) only if Timer4 is not
running (T4ENA = 0
). The output signal (M4) is inverted with every rising
edge of the input clock (CLKT4). The following figure shows the toggle flip-flop
(T4).