10-27
TIMER/COUNTER UNIT
10.3.4 Reading the Counter
To read the counter you can perform a simple read operation or send a latch command to the
counter. TMRCON contains two formats that allow you to send latch commands to individual
counters: the counter-latch and read-back format. The counter-latch command latches the count
of a specific counter. The read-back command latches the count and/or status of one or more spec-
ified counters.
10.3.4.1 Simple Read
To perform a simple read operation in modes 0, 2, 3 and 4, suspend the counter’s operation (using
the counter’s GATEn signal), then read the counter’s TMRn register. To read an accurate value,
you must disable the counter so that the count is not in the process of changing when it is read.
However, in modes 1 and 5, where the counter’s operation can not be suspended, the counter can
still be read. But since the counter is running, there is a minor inaccuracy in the read value.
10.3.4.2 Counter-latch Command
Use the counter-latch format of TMRCON (Figure 10-27) to latch the count of a specific counter.
To issue a counter-latch command to a counter, write to the TMRCON register with bits 5-4 reset
and SC1 and SC0 (bits 7-6) programmed appropriately. A counter continues to run even after the
count is latched. The counter-latch command allows reading the count without disturbing the
count in progress.