BAT32G1x9 user manual | Chapter 7 Timer A
250 / 1149
Rev.1.02
7.4.6
Pulse period measurement mode
This is the mode for measuring the pulse period of the external signal at the input of the TAIO pin.
The counter counts down by selecting the count source from TCK0 to TCK2 bits of the TAMR0 register. If the
TAIO pin is given a pulse for the specified period of the TEDGSEL bit of the TAIOC0 register, the count value is
transmitted to the read buffer on the rising edge of the counting source, and the value of the reload register is loaded
to the counter on the next rising edge, while TACR0 The TEDGF bit of the register becomes "1" (with a valid edge)
and the interrupt request is generated. At this point, the TA0 register (read buffer) is read, and the difference between
the read value and the reload value is the periodic data of the input pulse. The period data is held until the buffer is
read. If the counter underflows, the TUNDF bit of the TACR0 register becomes "1" (underflow occurs) and an interrupt
request is generated. An example of the operation of the pulse-period measurement mode is shown in Fig. 7-15.
A pulse must be input that is 2 times the period of the counting source, and both the input "L" level and the width
of the "H" level must be greater than the pulse of the counting source period. If the input pulse period and width do
not meet these conditions, the input pulse may be overlooked.
Fig. 7-15 An example of the operation of the pulse period measurement mode
TUNDF bit of TACR0
register
TEDGF bit of TACR0
register
INTTMA interrupt flag bit
TSTART bit of
TACR0 register
Counter of TIMER A
This is the scenario done while TA0 register initial value as "0300H" and TEDGSEL bit of TAIOC0 register set to 0 and measur ement done before
pulse arises.
Note1.reading TA0 register must be done from the moment TEDGF bit changes to 1 till next valid edge input. Content of the read buffer will be
preserved till reading TA0 regsiter, thus, if the TA0 register is not read before the input valid edge, it will remain the me asurement result of previous
cycle.
2.if reading TA0 register in pulse period measurement mode, the read value is the content of read buffer.
3.TEDGF bit of the TACR0 register will change to 1 (valid edge), if specified edge of external pulse input occurs after the input mesurement
pulse valid edge.
4. TEDGF bit of the TACR0 register must be set to 0 via 8 bit operation instruction if program wants to set it to 0.
5. TUNDF bit of the TACR0 register must be set to 0 via 8 bit operation instruction if program wants to set it to 0.
read content of buffer
measure pulse input
read signal of the
counter
read data
accept interrupt request
set "0" via program
(Note5)
set "0" via program
(Note4)
read counter value
(NOTE1)
counting source
reload counter
(Note2)
(Note2)
(Note3)
(Note3)