Event Counter Mode - Renesas M16C Series User Manual

16-bit single-chip microcomputer
Hide thumbs Also See for M16C Series:
Table of Contents

Advertisement

M30240 Group

1.2.21.2 Event counter mode

In this mode, the timer counts an external signal or an internal timer's overflow. Timers A0 and A1 can
count a single-phase external signal. Timers A2, A3, and A4 can count a single-phase and a two-
phase external signal. Table 1.19 lists the timer specifications when counting a single-phase external
signal. Figure 1.64 shows Timer Ai mode register in event counter mode, Note: Timer Ai register's val-
ue can be indeterminate when the count starts.
Table 1.19:
Timer specification in event counter mode (when not processing two-phase pulse signal)
Item
• External signals input to TAi
Count source
• TB2 overflow, TAj overflow
• Up count or down count can be selected by external signal of software
Count operation
• When the timer overflows or underflows, it loads the reload register contents before continuing counting
(However, this does not apply when the free-run function is selected)
1/(FFFF
Divide ratio
1/(n+1) for down count
Count start condition
Count start flag is set (= 1)
Count stop condition
Count start flag is reset (= 0)
Interrupt request
When the timer underflows or underflows
generation timing
TAi
pin function
Programmable I/O port or count source input
IN
TAi
pin function
Programmable I/O port, pulse output, or up/down count select input
OUT
Read from timer
Count value can be read out by reading Timer Ai register
• When counting is stopped and a value is written to Timer Ai register, it is written to both reload register and
counter
Write to timer
• When counting is in progress and a value is written to Timer Ai register, it is written only to reload register
(to be transferred to counter at the next reload time)
• Free-run count function (Note)
When the timer overflows or underflows, the reload register's content is not reloaded.
Select function
• Pulse output function
Each time the timer underflows, the TAi
Note: Timer Ai register's value can be indeterminate when the count starts.
Timer Ai mode register
Timer Ai mode register
b7
b7
b6
b6
Figure 1.64: Timer Ai mode register in event counter mode, single signal
Rev.1.00 Sep 24, 2003 Page 70 of 360
pin (effective edge can be selected by software)
IN
-n+1) for up count
16
b5
b5
b4
b4
b3
b3
b2
b2
b1
b1
b0
b0
Symbol
Symbol
0 1
0 1
0
0
TAiMR(i = 0, 1)
TAiMR(i = 0, 1)
Bit symbol
Bit symbol
Bit name
Bit name
TMOD0
TMOD0
Operation mode select bit
Operation mode select bit
TMOD1
TMOD1
MR0
MR0
Pulse output function
Pulse output function
select bit
select bit
MR1
MR1
Count polarity
Count polarity
select bit (Note 3)
select bit (Note 3)
MR2
MR2
Up/down switching
Up/down switching
cause select bit
cause select bit
MR3
MR3
0 (Must always be fixed to "0" in event counter mode)
0 (Must always be fixed to "0" in event counter mode)
TCK0
TCK0
Count operation type
Count operation type
select bit
select bit
TCK1
TCK1
Invalid in event counter mode
Invalid in event counter mode
Can be "0" or "1"
Can be "0" or "1"
Note 1: In event counter mode, the count source is selected by the event / trigger select bit
Note 1: In event counter mode, the count source is selected by the event / trigger select bit
(addresses 0382
(addresses 0382
16
16
Note 2: The settings of the corresponding port register and port direction register are invalid.
Note 2: The settings of the corresponding port register and port direction register are invalid.
Note 3: Valid only when counting an external signal.
Note 3: Valid only when counting an external signal.
Note 4: When an "L" signal is input to the TAi
Note 4: When an "L" signal is input to the TAi
the upcount is activated. Set the corresponding port direction register to "0".
the upcount is activated. Set the corresponding port direction register to "0".
Note 5: This value can be indeterminate when the count starts.
Note 5: This value can be indeterminate when the count starts.
Specification
n: Set value
pin's polarity is reversed
OUT
Address
Address
When reset
When reset
0396
0396
, 0397
, 0397
00
00
16
16
16
16
16
16
Function
Function
b1 b0
b1 b0
0 1 : Event counter mode (Note 1)
0 1 : Event counter mode (Note 1)
0 : Pulse is not output
0 : Pulse is not output
(TA
(TA
pin is a normal port pin)
pin is a normal port pin)
iOUT
iOUT
1 : Pulse is output (Note 2)
1 : Pulse is output (Note 2)
(TA
(TA
pin is a pulse output pin)
pin is a pulse output pin)
iOUT
iOUT
0 : Counts external signal's falling edge
0 : Counts external signal's falling edge
1 : Counts external signal's rising edge
1 : Counts external signal's rising edge
0 : Up/down flag's content
0 : Up/down flag's content
1 : TA
1 : TA
pin's input signal (Note 4)
pin's input signal (Note 4)
iOUT
iOUT
0 : Reload type
0 : Reload type
1 : Free-run type (Note 5)
1 : Free-run type (Note 5)
and 0383
and 0383
).
).
16
16
pin, the downcount is activated. When "H",
pin, the downcount is activated. When "H",
OUT
OUT
R W
R W
R
R
W
W
Timer A

Advertisement

Table of Contents
loading

Table of Contents