RX210, RX21A, and RX220 Groups Application Note Pulse Period

APPLICATION NOTE
RX210, RX21A, and RX220 Groups
Pulse Period Measurement Using MTU2a
R01AN1011EJ0111
Rev. 1.11
July 1, 2014
Abstract
This document describes a method to measure a pulse period input to the input capture input pin (MTIOC0A) using
multi-function timer pulse unit 2 (hereinafter referred to as MTU) in the RX210, RX21A, and RX220 Groups.
Products
- RX210, RX21A, and RX220 Groups
When using this application note with other Renesas MCUs, careful evaluation is recommended after making
modifications to comply with the alternate MCU.
R01AN1011EJ0111 Rev. 1.11
July 1, 2014
Page 1 of 17
RX210, RX21A, and RX220 Groups
Pulse Period Measurement Using MTU2a
Contents
1.
Specifications ..................................................................................................................................... 3
2.
Operation Confirmation Conditions .................................................................................................... 4
3.
Reference Application Note ................................................................................................................ 4
4.
Hardware ............................................................................................................................................ 5
4.1 Pins Used ..................................................................................................................................... 5
5.
Software ............................................................................................................................................. 5
5.1 Operation Overview ..................................................................................................................... 6
5.1.1 Measuring a Pulse Period..................................................................................................... 6
5.1.2 Operation When an Input Capture and Overflow Occur Simultaneously ............................. 7
5.2 File Composition .......................................................................................................................... 8
5.3 Option-Setting Memory ................................................................................................................ 8
5.4 Constants ..................................................................................................................................... 8
5.5 Variables ...................................................................................................................................... 9
5.6 Functions...................................................................................................................................... 9
5.7 Function Specifications .............................................................................................................. 10
5.8 Flowcharts .................................................................................................................................. 12
5.8.1 Main Processing ................................................................................................................. 12
5.8.2 Port Initialization ................................................................................................................. 12
5.8.3 Peripheral Function Initialization ......................................................................................... 13
5.8.4 Error Processing ................................................................................................................. 14
5.8.5 MTU0 Input Capture A Interrupt Handler............................................................................ 14
5.8.6 MTU0 Overflow Interrupt Handler ....................................................................................... 15
6.
Applying This Application Note to the RX21A or RX220 Group ....................................................... 16
7.
Sample Code .................................................................................................................................... 17
8.
Reference Documents ...................................................................................................................... 17
R01AN1011EJ0111 Rev. 1.11
July 1, 2014
Page 2 of 17
RX210, RX21A, and RX220 Groups
1.
Pulse Period Measurement Using MTU2a
Specifications
Using the input capture function of the MTU, measure the period of two consecutive rising edges of the pulse input to
the MTIOC0A pin. Measurement starts from the first rising edge of the input pulse and a period is calculated from the
second rising edge.
Details
- Resolution: 160 ns
- Maximum measurable period: Approximately 687 seconds
Table 1.1 lists the Peripheral Function and Its Application and Figure 1.1 shows the Connection Diagram.
Table 1.1 Peripheral Function and Its Application
Peripheral Function
MTU2a channel 0 (hereinafter referred to as MTU0)
RX210
Application
Measure a pulse period
Resolution: 160 ns
Maximum measurement period: Approximately 687 seconds
MTIOC0A pin
P17 pin
Error signal
Figure 1.1 Connection Diagram
R01AN1011EJ0111 Rev. 1.11
July 1, 2014
Page 3 of 17
RX210, RX21A, and RX220 Groups
2.
Pulse Period Measurement Using MTU2a
Operation Confirmation Conditions
The sample code accompanying this application note has been run and confirmed under the conditions below.
Table 2.1 Operation Confirmation Conditions
Item
MCU used
Operating frequencies
Operating voltage
Integrated development
environment
C compiler
iodefine.h version
Endian
Operating mode
Processor mode
Sample code version
Board used
3.
Contents
R5F52108ADFP (RX210 Group)
- Main clock: 20 MHz
- PLL: 100 MHz (main clock divided by 2 and multiplied by 10)
- System clock (ICLK): 50 MHz (PLL divided by 2)
- Peripheral module clock B (PCLKB): 25 MHz (PLL divided by 4)
5.0 V
Renesas Electronics Corporation
High-performance Embedded Workshop Version 4.09.01
Renesas Electronics Corporation
C/C++ Compiler Package for RX Family V.1.02 Release 01
Compile options
-cpu=rx200 -output=obj="$(CONFIGDIR)¥$(FILELEAF).obj" -debug -nologo
(The default setting is used in the integrated development environment.)
Version 1.2A
Little endian
Single-chip mode
Supervisor mode
Version 1.10
Renesas Starter Kit for RX210 (product part no.:R0K505210C000BE)
Reference Application Notes
For additional information associated with this document, refer to the following application notes.
- RX210 Group Initial Setting Rev. 2.00 (R01AN1002EJ)
- RX21A Group Initial Setting Rev. 1.10 (R01AN1486EJ)
- RX220 Group Initial Setting Rev. 1.10 (R01AN1494EJ)
The initial setting functions in the reference application notes are used in the sample code in this application note. The
revision numbers of the reference application notes are current as of when this application note was made. However the
latest version is always recommended. Visit the Renesas Electronics Corporation website to check and download the
latest version.
R01AN1011EJ0111 Rev. 1.11
July 1, 2014
Page 4 of 17
RX210, RX21A, and RX220 Groups
4.
4.1
Pulse Period Measurement Using MTU2a
Hardware
Pins Used
Table 4.1 lists the Pins Used and Their Functions.
The pins described here are for 100-pin products. When the product with less than 100-pin is used, select appropriate
pins for the product used.
Table 4.1 Pins Used and Their Functions
Pin Name
PB3/MTIOC0A
P17
5.
I/O
Input
Output
Function
Input a measurement pulse
Output an error signal
Software
This software calculates the period between two consecutive rising edges of a pulse input to the MTIOC0A pin. The
number of overflows is counted in the overflow interrupt handler of the MTU0.TCNT register. When the number of
overflows exceeds 65,535, an error signal is output and measurement stops. The pulse period is calculated in the MTU0
input capture A interrupt handler based on the number of overflows and the MTU0.TGRA register value.
Formula for calculating a pulse period: 160 ns × (number of overflows × 10000h + MTU0.TGRA)
Below are the settings for the peripheral functions used in the software.
MTU0
- Count clock: Rising edge of PCLKB/4 (PCLKB = 25 MHz)
- Operating mode: Normal mode
- Synchronous operation: Not used
- Counter clear: Input capture of TGRA
- Timer general register (TGRA): Use as the input capture register
Input capture at a rising edge of the MTIOC0A pin
Interrupts
- Input capture A interrupt (TGIA0)
Interrupt priority level: 3
Interrupt source: MTU0.TGRA input capture
- Overflow interrupt (TCIV0)
Interrupt priority level: 4
Interrupt source: MTU0.TCNT overflow
R01AN1011EJ0111 Rev. 1.11
July 1, 2014
Page 5 of 17
RX210, RX21A, and RX220 Groups
5.1
Pulse Period Measurement Using MTU2a
Operation Overview
5.1.1
Measuring a Pulse Period
(1) When the TSTR.CST0 bit is set to 1, the MTU0 counter starts counting.
(2) When the MTIOC0A pin level changes from low to high, the MTU0.TCNT register value is transferred to the
MTU0.TGRA register and the counter is cleared. At the same time, an MTU0 input capture A interrupt request is
generated.
(3) In the input capture A interrupt handler, the measurement start flag is set to 1 (measurement starts) and the number
of overflows is cleared.
(4) When the MTIOC0A pin level changes from low to high, the same operation as (2) is performed.
(5) A pulse period is calculated (pulse period 1 in Figure 5.1) based on the number of overflows of the MTU0.TCNT
register (0 in (5) of Figure 5.1) and the MTU0.TGRA register value ((B) in Figure 5.1) in the input capture A
interrupt handler. Then the number of overflows is cleared.
(6) When the MTU0.TCNT register overflows, an overflow interrupt request is generated.
(7) The number of overflows is counted in the overflow interrupt handler.
(8) When the MTIOC0A pin level changes from low to high, the same operation as (2) is performed.
(9) A pulse period is calculated (pulse period 2 in Figure 5.1) based on the number of overflows in the MTU0.TCNT
register (1 in (9) of Figure 5.1) and the MTU0.TGRA register value ((C) in Figure 5.1) in the input capture A
interrupt handler. Then the number of overflows is cleared.
Figure 5.1 shows the Timing Diagram of the Pulse Period Measurement. (1) to (9) in the figure correspond to (1) to (9)
in the description above.
MTU0.TCNT register value
(1)
(2) (3)
(8) (9)
(6) (7)
(4) (5)
Pulse period 1
Pulse period 2
FFFFh
(B)
(C)
(A)
0000h
Input signal to
the MTIOC0A pin
TSTR.CST0 bit
Measurement
start flag
MTU0.TGRA register
(input capture A)
Time
High
Low
1
0
1
0
Value of (A)
Number of overflows
IR flag of the input
capture A interrupt
IR flag of the overflow
interrupt
Value of (B)
0
Interrupt request accepted
1
0
1
0
Value of (C)
1
0
Interrupt request accepted
Interrupt request
accepted
Figure 5.1 Timing Diagram of the Pulse Period Measurement
R01AN1011EJ0111 Rev. 1.11
July 1, 2014
Page 6 of 17
RX210, RX21A, and RX220 Groups
5.1.2
Pulse Period Measurement Using MTU2a
Operation When an Input Capture and Overflow Occur Simultaneously
(1) When a rising edge occurs on the signal input to the MTIOC0A pin while the MTU0.TCNT register value is FFFFh,
the MTU0.TCNT register is cleared and the input capture A interrupt request is generated after FFFFh in the
MTU0.TCNT register is transferred to the MTU0.TGRA register.
(2) In the input capture A interrupt handler, the number of overflows is cleared.
(3) When the MTU0.TCNT register value overflows while an interrupt handler (hereinafter referred to as interrupt
handler A) other than the overflow interrupt handler and input capture A interrupt handler is being executed, the
overflow interrupt handler is delayed.
(4) When a rising edge occurs on the signal input to the MTIOC0A pin while interrupt handler A is being executed, the
MTU0.TCNT register value is transferred to the MTU0.TGRA register and the input capture A interrupt request is
generated (input capture A interrupt handler is delayed).
(5) When interrupt handler A is completed, the overflow interrupt which has the higher interrupt priority level is
executed first. In the overflow interrupt handler, the number of overflows increments by 1. In the input capture A
interrupt handler which is subsequently accepted, the pulse period is calculated. Then the number of overflows is
cleared.
Figure 5.2 shows the Timing Diagram When an Input Capture and Overflow Occur Simultaneously. (1) to (5) in the
figure correspond to (1) to (5) in the description above.
(1) (2)
MTU0.TCNT register value
(3)
(4) (5)
FFFFh
(A)
0000h
MTIOC0A pin
Time
High
Low
MTU0.TGRA register
(input capture A)
FFFFh
X
Number of overflows
N
Value of (A)
1
0
0
Interrupt request accepted
IR flag of the input
capture A interrupt
IR flag of the overflow
interrupt
1
0
1
0
Interrupt A
TCNT is cleared without
generating the overflow
interrupt request
Interrupt handler
being executed
Figure 5.2 Timing Diagram When an Input Capture and Overflow Occur Simultaneously
R01AN1011EJ0111 Rev. 1.11
July 1, 2014
Page 7 of 17
RX210, RX21A, and RX220 Groups
Pulse Period Measurement Using MTU2a
Notes when embedding the sample codes
When embedding the sample code of this application note in the user system, note the following:
- When an interrupt used in this application note is delayed for a prolonged time due to other interrupt handlers, the
sample code may not be executed properly.
- When the measured pulse period is short, the software cannot perform the processes in time and the pulse period
cannot be measured properly.
5.2
File Composition
Table 5.1 lists the Files Used in the Sample Code. Files generated by the integrated development environment are not
included in this table.
Table 5.1 Files Used in the Sample Code
File Name
main.c
r_init_stop_module.c
r_init_stop_module.h
r_init_non_existent_port.c
r_init_non_existent_port.h
r_init_clock.c
r_init_clock.h
5.3
Outline
Main processing
Stop processing for active peripheral functions after a reset
Header file for r_init_stop_module.c
Nonexistent port initialization
Header file for r_init_non_existent_port.c
Clock initialization
Header file for r_init_clock.c
Remarks
Option-Setting Memory
Table 5.2 lists the Option-Setting Memory Configured in the Sample Code. When necessary, set a value suited to the
user system.
Table 5.2 Option-Setting Memory Configured in the Sample Code
Symbol
Address
Setting Value
OFS0
FFFF FF8Fh to FFFF FF8Ch
FFFF FFFFh
OFS1
FFFF FF8Bh to FFFF FF88h
FFFF FFFFh
MDES
FFFF FF83h to FFFF FF80h
FFFF FFFFh
5.4
Contents
The IWDT is stopped after a reset.
The WDT is stopped after a reset.
The voltage monitor 0 reset is disabled
after a reset.
HOCO oscillation is disabled after a
reset.
Little endian
Constants
Table 5.3 lists the Constants Used in the Sample Code.
Table 5.3 Constants Used in the Sample Code
Constant Name
P_OVF_ERR
PD_OVF_ERR
R01AN1011EJ0111 Rev. 1.11
July 1, 2014
Setting Value
PORT1.PODR.BIT.B7
PORT1.PDR.BIT.B7
Contents
Port output data register for error signal output
Port direction register for error signal output
Page 8 of 17
RX210, RX21A, and RX220 Groups
5.5
Pulse Period Measurement Using MTU2a
Variables
Table 5.4 lists the Global Variables.
Table 5.4 Global Variables
Type
Variable
Name
unsigned short
mtu0_ovf_cnt
Overflow counter of the MTU0.TCNT register
unsigned long
pulse_cnt
unsigned char
start_flag
unsigned char
error_flag
Pulse period measurement counter
Measurement start flag 0: Measurement stopped
1: Measurement starts
Measurement error flag 0: Normal
1: Error
5.6
Contents
Function Used
Excep_MTU0_TGIA0,
Excep_MTU0_TCIV0
Excep_MTU0_TCIV0
Excep_MTU0_TGIA0,
Excep_MTU0_TCIV0
Excep_MTU0_TGIA0
Functions
Table 5.5 lists the Functions Used in the Sample Code.
Table 5.5 Functions Used in the Sample Code
Function Name
main
port_init
R_INIT_StopModule
R_INIT_NonExistentPort
R_INIT_Clock
peripheral_init
error_proc
Excep_MTU0_TGIA0
Excep_MTU0_TCIV0
R01AN1011EJ0111 Rev. 1.11
July 1, 2014
Outline
Main processing
Port initialization
Stop processing for active peripheral functions after a reset
Nonexistent port initialization
Clock initialization
Peripheral function initialization
Error processing
MTU0 input capture A interrupt handler
MTU0 overflow interrupt handler
Page 9 of 17
RX210, RX21A, and RX220 Groups
5.7
Pulse Period Measurement Using MTU2a
Function Specifications
The following tables list the sample code function specifications.
main
Outline
Header
Declaration
Description
Arguments
Return Value
Main processing
None
void main(void)
Start the count operation for MTU0 after initialization.
None
None
port_init
Outline
Header
Declaration
Description
Arguments
Return Value
Port initialization
None
void port_init(void)
Initialize ports.
None
None
R_INIT_StopModule
Outline
Header
Declaration
Description
Arguments
Return Value
Stop processing for active peripheral functions after a reset
r_init_stop_module.h
void R_INIT_StopModule(void)
Configure the setting to enter the module-stop state.
None
None
Transition to the module-stop state is not performed in the sample code. For details
Remarks
on this function, refer to the Initial Setting application note for the product used.
R_INIT_Non_ExistentPort
Nonexistent port initialization
Outline
r_init_non_existent_port.h
Header
void R_INIT_NonExistentPort(void)
Declaration
Initialize the port direction registers for ports that do not exist in products with less
Description
than 100 pins.
None
Arguments
None
Return Value
The number of pins in the sample code is set for the 100-pin package
Remarks
(PIN_SIZE=100). After this function is called, when writing in byte units to the PDR
registers or PODR registers which have nonexistent ports, set the corresponding bits
for nonexistent ports as follows: set the I/O select bits in the PDR registers to 1 and
set the output data store bits in the PODR registers to 0. For details on this function,
refer to the Initial Setting application note for the product used.
R01AN1011EJ0111 Rev. 1.11
July 1, 2014
Page 10 of 17
RX210, RX21A, and RX220 Groups
R_INIT_Clock
Outline
Header
Declaration
Description
Arguments
Return Value
Remarks
Pulse Period Measurement Using MTU2a
Clock initialization
r_init_clock.h
void R_INIT_Clock(void)
Initialize clocks.
None
None
The sample code selects processing which uses PLL as the system clock without
using the sub-clock. For details on this function, refer to the Initial Setting application
note for the product used.
peripheral_init
Outline
Header
Declaration
Description
Arguments
Return Value
Peripheral function initialization
None
void peripheral_init(void)
Initialize peripheral functions used.
None
None
error_proc
Outline
Header
Declaration
Description
Arguments
Return Value
Error processing
None
void error_proc(void)
Output an error signal and enter an infinite loop.
None
None
Excep_MTU0_TGIA0
Outline
Header
Declaration
Description
Arguments
Return Value
Excep_MTU0_TCIV0
Outline
Header
Declaration
Description
Arguments
Return Value
MTU0 input capture A interrupt handler
None
void Excep_MTU0_TGIA0(void)
When the measurement start flag is 1 (measurement starts), calculate a pulse period
and reset the overflow counter.
None
None
MTU0 overflow interrupt handler
None
void Excep_MTU0_TCIV0(void)
When the measurement start flag is 1 (measurement starts), the number of overflows
is counted. When the number of overflows exceeds 65535, the MCU enters error
processing.
None
None
R01AN1011EJ0111 Rev. 1.11
July 1, 2014
Page 11 of 17
RX210, RX21A, and RX220 Groups
5.8
5.8.1
Pulse Period Measurement Using MTU2a
Flowcharts
Main Processing
Figure 5.3 shows the Main Processing.
main
Disable maskable interrupts
I flag ← 0
Port initialization
port_init()
Stop processing for active
peripheral functions after a reset
R_INIT_StopModule()
Nonexistent port initialization
R_INIT_NonExistentPort()
Clock initialization
R_INIT_Clock()
Peripheral function initialization
peripheral_init()
Enable maskable interrupts
Start the MTU0 count operation
I flag ← 1
TSTR register
CST0 bit ← 1
Figure 5.3 Main Processing
5.8.2
Port Initialization
Figure 5.4 shows the Port Initialization.
port_init
Initialize ports that output signals
when an error occurs
PORT1.PODR register
B7 bit ← 1: Output high
PORT1.PDR register
B7 bit ← 1: Function as an output port
return
Figure 5.4 Port Initialization
R01AN1011EJ0111 Rev. 1.11
July 1, 2014
Page 12 of 17
RX210, RX21A, and RX220 Groups
5.8.3
Pulse Period Measurement Using MTU2a
Peripheral Function Initialization
Figure 5.5 shows the Peripheral Function Initialization.
peripheral_init
Cancel the module stop state
Disable interrupts
Stop the MTU0 count operation
PRCR register ← A502h
PRC1 bit = 1: Enable writing to the registers related to the low power consumption
MSTPCRA register
MSTPA9 bit ← 0: The module stop state is canceled
PRCR register ← A500h
PRC1 bit = 0: Disable writing to the registers related to the low power consumption
IER0E register
IEN2 bit ← 0 : The MTU0.TGIA0 interrupt request is disabled
IER0E register
IEN6 bit ← 0 : The MTU0.TCIV0 interrupt request is disabled
TIER register
TGIEA bit ← 0: Interrupt requests (TGIA) disabled
TIER register
TCIEV bit ← 0: Interrupt requests (TCIV) disabled
TSTR register
CST0 bit ← 0
MTU0 counter operates
independently
TSYR register
SYNC0 bit ← 0
Clear the MTU0 counter
TCNT register ← 0000h
TGRA register ← 0000h
Set the ports to input pulses
Set the MTU0 count clock
PORTB.PDR register
B3 bit ← 0: Functions as an input pin
PORTB.PMR register
B3 bit ← 0: Use as a general I/O port
MPC.PWPR register
B0WI bit ← 0: Writing to the PFSWE bit is enabled
MPC.PWPR register
PFSWE bit ← 1: Writing to the PFS register is enabled
MPC.PB3PFS register ← 01h
PSEL[3:0] bits = 0001b: Use as the MTIOC0A pin
MPC.PWPR register
PFSWE bit ← 0: Writing to the PFS register is disabled
MPC.PWPR register
B0WI bit ← 1: Writing to the PFSWE bit is disabled
PORTB.PMR register
B3 bit ← 1: Use as peripheral functions
TCR register ← 21h
TPSC[2:0] bits = 001b: Internal clock: Count with PCLKB/4
CKEG[1:0] bits = 00b: Count at the rising edge
CCLR[2:0] bits = 001b: TCNT is cleared by input capture of TGRA
Set the MTU0 I/O function
TIORH register ← 08h
IOA[3:0] bits = 1000b: Input capture at the rising edge of the MTIOC0A pin
Set MTU0 operation mode
TMDR register ← 00h
MD[3:0] bits = 0000b: Normal mode
Set interrupt priority levels
Clear interrupt requests
Enable the MTU0 interrupt
request
Enable interrupt requests
IPR114 register
IPR[3:0] bits ← 0011b: MTU0.TGIA0 interrupt priority level 3
IPR118 register
IPR[3:0] bits ← 0100b: MTU0.TCIV0 interrupt priority level 4
IR114 register
IR flag ← 0: MTU0.TGIA0 interrupt not requested
IR118 register
IR flag ← 0: MTU0.TCIV0 interrupt not requested
TIER register
TGIEA bit ← 1: The interrupt request (TGIA) enabled
TIER register
TCIEV bit ← 1: The interrupt request (TCIV) enabled
IER0E register
IEN2 bit ← 1 : The MTU0.TGIA0 interrupt request is enabled
IER0E register
IEN6 bit ← 1 : The MTU0.TCIV0 interrupt request is enabled
return
Figure 5.5 Peripheral Function Initialization
R01AN1011EJ0111 Rev. 1.11
July 1, 2014
Page 13 of 17
RX210, RX21A, and RX220 Groups
5.8.4
Pulse Period Measurement Using MTU2a
Error Processing
Figure 5.6 shows the Error Processing.
error_proc
Change the level of the port
that outputs signals
when an error occurs
PORT1.PODR register
B7 bit ← 0
Figure 5.6 Error Processing
5.8.5
MTU0 Input Capture A Interrupt Handler
Figure 5.7 shows the MTU0 Input Capture A Interrupt Handler.
Excep_MTU0_TGIA0
No
Is the measurement
start flag 0?
Yes
Set the measurement start flag
Calculate a pulse period
Pulse period measurement counter
← The number of overflows << 16 + MTU0.TGRA register value
Reset the number of overflows
return
Figure 5.7 MTU0 Input Capture A Interrupt Handler
R01AN1011EJ0111 Rev. 1.11
July 1, 2014
Page 14 of 17
RX210, RX21A, and RX220 Groups
5.8.6
Pulse Period Measurement Using MTU2a
MTU0 Overflow Interrupt Handler
Figure 5.8 shows the MTU0 Overflow Interrupt Handler.
Excep_MTU0_TCIV0
No
Is the measurement start
flag 1?
Yes
Is the number of overflows
less than FFFFh?
No
Yes
Increment the number of
overflows by 1
Set the measurement error flag
Error processing
error_proc()
return
Figure 5.8 MTU0 Overflow Interrupt Handler
R01AN1011EJ0111 Rev. 1.11
July 1, 2014
Page 15 of 17
RX210, RX21A, and RX220 Groups
Pulse Period Measurement Using MTU2a
6. Applying This Application Note to the RX21A or RX220 Group
The sample code accompanying this application note has been confirmed to operate with the RX210 Group. To make
the sample code operate with the RX21A or RX220 Group, use this application note in conjunction with the Initial
Setting application note for each group.
For details on using this application note with the RX21A and RX220 Groups, refer to “5. Applying the RX210 Group
Application Note to the RX21A Group” in the RX21A Group Initial Setting application note, and “4. Applying the
RX210 Group Application Note to the RX220 Group” in the RX220 Group Initial Setting application note.
R01AN1011EJ0111 Rev. 1.11
July 1, 2014
Page 16 of 17
RX210, RX21A, and RX220 Groups
7.
Pulse Period Measurement Using MTU2a
Sample Code
Sample code can be downloaded from the Renesas Electronics website.
8.
Reference Documents
User’s Manual: Hardware
RX210 Group User's Manual: Hardware Rev.1.50 (R01UH0037EJ)
RX21A Group User's Manual: Hardware Rev.1.00 (R01UH0251EJ)
RX220 Group User's Manual: Hardware Rev.1.10 (R01UH0292EJ)
The latest versions can be downloaded from the Renesas Electronics website.
Technical Update/Technical News
The latest information can be downloaded from the Renesas Electronics website.
User’s Manual: Development Tools
RX Family C/C++ Compiler Package V.1.01 User’s Manual Rev.1.00 (R20UT0570EJ)
The latest version can be downloaded from the Renesas Electronics website.
Website and Support
Renesas Electronics website
http://www.renesas.com
Inquiries
http://www.renesas.com/contact/
R01AN1011EJ0111 Rev. 1.11
July 1, 2014
Page 17 of 17
RX210, RX21A, and RX220 Groups Application Note
Pulse Period Measurement Using MTU2a
REVISION HISTORY
Rev.
Date
1.00
1.10
Sep. 1, 2012
Mar. 1, 2013
Page
—
1
4
5
6
7
8
9
10
12
13
14
15
1.11
July 1, 2014
1
4
10, 11
16
17
Description
Summary
First edition issued
Added details in the Products
Table 2.1 Operation Confirmation Conditions:
Updated information
4.1 Pins Used:
Added the explanation
5 Software:
Changed interrupt priority levels of input capture A interrupt (TGIA0)
and overflow interrupt (TCIV0)
5.1.1 Measuring a Pulse Period: Changed explanations.
5.1.2 Operation When an Input Capture and Overflow Occur
Simultaneously: Changed explanations
Figure 5.2: Revised
File names revised
Table 5.4 Global Variables:
Changed function names in the Function Used
Table 5.5 Functions Used in the Sample Code:
Changed function names
5.7 Function Specifications:
- R_INIT_StopModule: Added the specification
- Changed names and the explanations of the following functions:
- non_existent_port_init to R_INIT_NonExistentPort
- clock_init to R_INIT_Clock
Figure 5.3:
Added R_INIT_StopModule.
Changed the names of the following functions:
- non_existent_port_init to R_INIT_NonExistentPort
- clock_init to R_INIT_Clock
Figure 5.5:
Changed interrupt priority levels of input capture A interrupt (TGIA0)
and overflow interrupt (TCIV0)
Fixed typo in MPC.PB3PFS register (PSEL bits)
Figure 5.7: Changed a function name, and the processing.
Figure 5.8: Changed a function name
7. Reference Documents:
Updated the revision of the User’s Manual: Hardware
Products: Added the RX21A and RX220 Groups.
3. Reference Application Notes: Added the Initial Setting application
notes for the RX21A and RX220 Groups.
Modified the description of reference application note in the
following functions: R_INIT_StopModule, R_INIT_NonExistentPort,
and R_INIT_Clock.
6. Applying This Application Note to the RX21A or RX220 Group:
Added.
8. Reference Documents: Added the User’s Manual: Hardware for
the RX21A and RX220 Groups.
All trademarks and registered trademarks are the property of their respective owners.
A-1
General Precautions in the Handling of MPU/MCU Products
The following usage notes are applicable to all MPU/MCU products from Renesas. For detailed usage notes on the
products covered by this document, refer to the relevant sections of the document as well as any technical updates that
have been issued for the products.
1. Handling of Unused Pins
Handle unused pins in accordance with the directions given under Handling of Unused Pins in the
manual.
 The input pins of CMOS products are generally in the high-impedance state. In operation with an
unused pin in the open-circuit state, extra electromagnetic noise is induced in the vicinity of LSI, an
associated shoot-through current flows internally, and malfunctions occur due to the false
recognition of the pin state as an input signal become possible. Unused pins should be handled as
described under Handling of Unused Pins in the manual.
2. Processing at Power-on
The state of the product is undefined at the moment when power is supplied.
 The states of internal circuits in the LSI are indeterminate and the states of register settings and
pins are undefined at the moment when power is supplied.
In a finished product where the reset signal is applied to the external reset pin, the states of pins
are not guaranteed from the moment when power is supplied until the reset process is completed.
In a similar way, the states of pins in a product that is reset by an on-chip power-on reset function
are not guaranteed from the moment when power is supplied until the power reaches the level at
which resetting has been specified.
3. Prohibition of Access to Reserved Addresses
Access to reserved addresses is prohibited.
 The reserved addresses are provided for the possible future expansion of functions. Do not access
these addresses; the correct operation of LSI is not guaranteed if they are accessed.
4. Clock Signals
After applying a reset, only release the reset line after the operating clock signal has become stable.
When switching the clock signal during program execution, wait until the target clock signal has
stabilized.
 When the clock signal is generated with an external resonator (or from an external oscillator)
during a reset, ensure that the reset line is only released after full stabilization of the clock signal.
Moreover, when switching to a clock signal produced with an external resonator (or by an external
oscillator) while program execution is in progress, wait until the target clock signal is stable.
5. Differences between Products
Before changing from one product to another, i.e. to a product with a different part number, confirm
that the change will not lead to problems.
 The characteristics of an MPU or MCU in the same group but having a different part number may
differ in terms of the internal memory capacity, layout pattern, and other factors, which can affect
the ranges of electrical characteristics, such as characteristic values, operating margins, immunity
to noise, and amount of radiated noise. When changing to a product with a different part number,
implement a system-evaluation test for the given product.
Notice
1.
Descriptions of circuits, software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples. You are fully responsible for
the incorporation of these circuits, software, and information in the design of your equipment. Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from the
use of these circuits, software, or information.
2.
Renesas Electronics has used reasonable care in preparing the information included in this document, but Renesas Electronics does not warrant that such information is error free. Renesas Electronics
assumes no liability whatsoever for any damages incurred by you resulting from errors in or omissions from the information included herein.
3.
Renesas Electronics does not assume any liability for infringement of patents, copyrights, or other intellectual property rights of third parties by or arising from the use of Renesas Electronics products or
technical information described in this document. No license, express, implied or otherwise, is granted hereby under any patents, copyrights or other intellectual property rights of Renesas Electronics or
others.
4.
You should not alter, modify, copy, or otherwise misappropriate any Renesas Electronics product, whether in whole or in part. Renesas Electronics assumes no responsibility for any losses incurred by you or
third parties arising from such alteration, modification, copy or otherwise misappropriation of Renesas Electronics product.
5.
Renesas Electronics products are classified according to the following two quality grades: "Standard" and "High Quality". The recommended applications for each Renesas Electronics product depends on
the product's quality grade, as indicated below.
"Standard": Computers; office equipment; communications equipment; test and measurement equipment; audio and visual equipment; home electronic appliances; machine tools; personal electronic
equipment; and industrial robots etc.
"High Quality": Transportation equipment (automobiles, trains, ships, etc.); traffic control systems; anti-disaster systems; anti-crime systems; and safety equipment etc.
Renesas Electronics products are neither intended nor authorized for use in products or systems that may pose a direct threat to human life or bodily injury (artificial life support devices or systems, surgical
implantations etc.), or may cause serious property damages (nuclear reactor control systems, military equipment etc.). You must check the quality grade of each Renesas Electronics product before using it
in a particular application. You may not use any Renesas Electronics product for any application for which it is not intended. Renesas Electronics shall not be in any way liable for any damages or losses
incurred by you or third parties arising from the use of any Renesas Electronics product for which the product is not intended by Renesas Electronics.
6.
You should use the Renesas Electronics products described in this document within the range specified by Renesas Electronics, especially with respect to the maximum rating, operating supply voltage
range, movement power voltage range, heat radiation characteristics, installation and other product characteristics. Renesas Electronics shall have no liability for malfunctions or damages arising out of the
use of Renesas Electronics products beyond such specified ranges.
7.
Although Renesas Electronics endeavors to improve the quality and reliability of its products, semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and
malfunctions under certain use conditions. Further, Renesas Electronics products are not subject to radiation resistance design. Please be sure to implement safety measures to guard them against the
possibility of physical injury, and injury or damage caused by fire in the event of the failure of a Renesas Electronics product, such as safety design for hardware and software including but not limited to
redundancy, fire control and malfunction prevention, appropriate treatment for aging degradation or any other appropriate measures. Because the evaluation of microcomputer software alone is very difficult,
please evaluate the safety of the final products or systems manufactured by you.
8.
Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product. Please use Renesas Electronics
products in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled substances, including without limitation, the EU RoHS Directive. Renesas Electronics assumes
no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations.
9.
Renesas Electronics products and technology may not be used for or incorporated into any products or systems whose manufacture, use, or sale is prohibited under any applicable domestic or foreign laws or
regulations. You should not use Renesas Electronics products or technology described in this document for any purpose relating to military applications or use by the military, including but not limited to the
development of weapons of mass destruction. When exporting the Renesas Electronics products or technology described in this document, you should comply with the applicable export control laws and
regulations and follow the procedures required by such laws and regulations.
10. It is the responsibility of the buyer or distributor of Renesas Electronics products, who distributes, disposes of, or otherwise places the product with a third party, to notify such third party in advance of the
contents and conditions set forth in this document, Renesas Electronics assumes no responsibility for any losses incurred by you or third parties as a result of unauthorized use of Renesas Electronics
products.
11. This document may not be reproduced or duplicated in any form, in whole or in part, without prior written consent of Renesas Electronics.
12. Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Electronics products, or if you have any other inquiries.
(Note 1)
"Renesas Electronics" as used in this document means Renesas Electronics Corporation and also includes its majority-owned subsidiaries.
(Note 2)
"Renesas Electronics product(s)" means any product developed or manufactured by or for Renesas Electronics.
SALES OFFICES
http://www.renesas.com
Refer to "http://www.renesas.com/" for the latest and detailed information.
Renesas Electronics America Inc.
2801 Scott Boulevard Santa Clara, CA 95050-2549, U.S.A.
Tel: +1-408-588-6000, Fax: +1-408-588-6130
Renesas Electronics Canada Limited
1101 Nicholson Road, Newmarket, Ontario L3Y 9C3, Canada
Tel: +1-905-898-5441, Fax: +1-905-898-3220
Renesas Electronics Europe Limited
Dukes Meadow, Millboard Road, Bourne End, Buckinghamshire, SL8 5FH, U.K
Tel: +44-1628-585-100, Fax: +44-1628-585-900
Renesas Electronics Europe GmbH
Arcadiastrasse 10, 40472 Düsseldorf, Germany
Tel: +49-211-6503-0, Fax: +49-211-6503-1327
Renesas Electronics (China) Co., Ltd.
Room 1709, Quantum Plaza, No.27 ZhiChunLu Haidian District, Beijing 100191, P.R.China
Tel: +86-10-8235-1155, Fax: +86-10-8235-7679
Renesas Electronics (Shanghai) Co., Ltd.
Unit 301, Tower A, Central Towers, 555 Langao Road, Putuo District, Shanghai, P. R. China 200333
Tel: +86-21-2226-0888, Fax: +86-21-2226-0999
Renesas Electronics Hong Kong Limited
Unit 1601-1613, 16/F., Tower 2, Grand Century Place, 193 Prince Edward Road West, Mongkok, Kowloon, Hong Kong
Tel: +852-2265-6688, Fax: +852 2886-9022/9044
Renesas Electronics Taiwan Co., Ltd.
13F, No. 363, Fu Shing North Road, Taipei 10543, Taiwan
Tel: +886-2-8175-9600, Fax: +886 2-8175-9670
Renesas Electronics Singapore Pte. Ltd.
80 Bendemeer Road, Unit #06-02 Hyflux Innovation Centre, Singapore 339949
Tel: +65-6213-0200, Fax: +65-6213-0300
Renesas Electronics Malaysia Sdn.Bhd.
Unit 906, Block B, Menara Amcorp, Amcorp Trade Centre, No. 18, Jln Persiaran Barat, 46050 Petaling Jaya, Selangor Darul Ehsan, Malaysia
Tel: +60-3-7955-9390, Fax: +60-3-7955-9510
Renesas Electronics Korea Co., Ltd.
12F., 234 Teheran-ro, Gangnam-Ku, Seoul, 135-920, Korea
Tel: +82-2-558-3737, Fax: +82-2-558-5141
© 2014 Renesas Electronics Corporation. All rights reserved.
Colophon 4.0