R8C/38T-A Group
15. Timer RJ
Under development Preliminary document
Specifications in this document are tentative and subject to change.
R01UH0241EJ0010 Rev.0.10
Page 242 of 730
Aug 05, 2011
15.4.6
Pulse Period Measurement Mode
In this mode, the pulse period of an external signal input to the TRJIO pin is measured.
The counter is decremented by the count source selected by bits TCK0 to TCK2 in the TRJMR register. When a
pulse with the period specified by the TEDGSEL bit in the TRJIOC register is input to the TRJIO pin, the count
value is transferred to the read-out buffer at the rising edge of the count source. The value of the reload register
is loaded into the counter at the next rising edge. Simultaneously, the TEDGF bit in the TRJCR register is set to
1 (active edge received) and an interrupt is generated. The read-out buffer (TRJ register) is read at this time and
the difference from the reload value (refer to 15.5 Notes on Timer RJ (5)) is the period data of the input pulse.
The period data is retained until the read-out buffer is read. When the counter underflows, the TUNDF bit in the
TRJCR register is set to 1 (underflow) and an interrupt is generated.
Only input pulses with a period longer than twice the period of the count source. Also, the low-level and high-
level widths must both be longer than the period of the count source. If a pulse period shorter than these
conditions is input, the input may be ignored.
Figure 15.7
Operation Timing Example in Pulse Period Measurement Mode
Read-out buffer
Count source
TSTART bit in
TRJCR register
Measurement
pulse input
Read-out data
IR bit in
TRJIC register
When the initial value of the TRJ register is set to 0300h and the TEDGSEL bit in the TRJIOC register is set to 0 (measure from one
rising edge to the next rising edge)
0300h
02FEh
Timer RJ counter
02FFh 02FEh02FDh02FCh 02FBh 02FAh 02F9h 02F8h 02F7h
0001h 0000h 0300h 02FFh 02FEh
0300h
02FEh
02FFh
02FFh 02FEh
02FBh 02FAh 02F9h 02F8h
0001h 0000h 0300h 02FFh
02F7h
Counter
read signal
(Note 2)
02FEh
02F7h
TEDGF bit in
TRJCR register
TUNDF bit in
TRJCR register
(Note 3)
Acknowledgement of an interrupt request
Notes:
1. Reading from the TRJ register must be performed during the period from when the TEDGF bit is set to 1 (active edge
received) until the next active edge is input. The content of the read-out buffer is retained until the TRJ register is read.
If it is not read before the active edge is input, the measurement result of the previous period is retained .
2. When the TRJ register is read in pulse period measurement mode , the content of the read-out buffer is read.
3. When the active edge of the measurement pulse is input and then the set edge of an external pulse is input , the TEDGF bit in
the TRJCR register is set to 1 (active edge received).
4. To set to 0 by a program, use the MOV instruction to write 0 to the TEDGF bit in the TRJCR register.
5. To set to 0 by a program, use the MOV instruction to write 0 to the TUNDF bit in the TRJCR register.
Set to 0 by a program
(4)
Set to 0 by a program
(5)
The counter value is read
(1)