Overview
790
SPNU503C – March 2018
Copyright © 2018, Texas Instruments Incorporated
High-End Timer (N2HET) Module
20.1.4 Timer Module Structure and Execution
The timer consists of a specialized micromachine that operates a reduced instruction set. Two 25-bit
registers and three 32-bit registers are available to manipulate information such as time, event counts, and
angle values. System performance is improved by a wide instruction format (96 bits) that allows the
N2HET to fetch the instructional operation code and data in one system cycle, thus increasing the speed
at which data can be processed. The typical operations performed in the ALU are additions (count),
compares, and magnitude compares (higher or same).
Each instruction is made up of a 32-bit program field, a 32-bit control field and a 32-bit data field. The
N2HET execution unit fetches the complete 96-bit instruction in one cycle and executes it. All instructions
include a 9-bit field for specifying the address of the next instruction to be executed. Some instructions
also include a 9-bit conditional address, which is used as the next address whenever a particular condition
is true. This makes controlling the flow of an N2HET program inexpensive; in many cases a separate
branch instruction is not required.
The interface to the host CPU is based on both communication memory and control registers. The
communication memory includes timer instructions (program and data). This memory is typically initialized
by the CPU or DMA after reset before the timer starts execution. Once the timer program is loaded into
the memory, the CPU starts the timer execution, and typically data parameters are then read or written
into the timer memory. The control registers include bits for selecting timer clock, configuring I/O pins, and
controlling the timer module.
The programmer implements timer functions by combining instructions in specific sequences. For
instance, a single count (CNT) instruction implements a timer. A simple PWM generator can be
implemented with a two instruction sequence: CNT and compare (ECMP or MCMP). A complex time
function may include many instructions in the sequence. The total timer program is a set of instructions
executed sequentially, one after the other. Reaching the end, the program must roll to the first instruction
so that it behaves as a loop. The time for a loop to execute is referred to as a
loop resolution clock cycle
or
loop resolution period (LRP).
When the N2HET rolls over to the first instruction, the timer waits for the
loop resolution clock to restart the execution of the loop to ensure that only one loop is executed for each
loop resolution clock.
The longest path through an N2HET program must be completed within the loop resolution clock (LRP).
Otherwise, the program will execute unpredictably because some instructions will not be executed each
time through the loop. This effect creates a strong link between the accuracy of the timer functions and the
number of functions (the number of instructions) the timer can perform. High resolution (HR) hardware
timer extensions are available for each of the N2HET pins to help overcome this limitation.
The high resolution hardware timers operate from the
high resolution clock
, which may be configured for
frequency multiples between 2 and 128 times the loop resolution clock frequency. This extending the
resolution of timer events and measurements well beyond what is possible with only loop resolution
instructions.
Most of the commonly used N2HET instructions can operate either at loop resolution or high resolution;
with the restriction that for each pin at most one high resolution instruction can be executed per loop
resolution period.
Certain instructions (MOV32, ADM32, ...) can modify the data fields of other instructions. This feature
enables the N2HET program to implement double buffering on capture and compare functions. For
example, an ECMP compare instruction can be followed by a MOV32 instruction that is conditionally
executed when the ECMP instruction matches. The host CPU can update the next compare value by
writing asynchronously to the data field of the MOV32 instruction instead of writing directly to the data field
of the ECMP instruction. The copy from the buffer (MOV32 data field) to the compare register (ECMP data
field) will occur when the MOV32 instruction is actually executed which occurs after the ECMP instruction
matches its current compare value. This is the same behavior as one would expect from a double buffered
hardware compare register.