Академический Документы
Профессиональный Документы
Культура Документы
(b7-b6)
TOPCR RW
TOENA RW
RW
TIPF0
RW
TIPF1
RW
TRAIO polarity switch bit
0
Set to 0 in timer mode.
TRAIO output control bit
Nothing is assigned. If necessary, set to 0.
When read, the content is 0.
TRAO output enable bit
TRAIO input filter select bits Set to 0 in timer mode.
Timer RA Control Register
(4)
Symbol Address After Reset
TRACR 0100h 00h
Bit Symbol Bit Name Function RW
NOTES:
1.
2.
3.
4.
5.
TUNDF
0: Count stops
1: Count starts
Timer RA count status flag
(1)
TSTOP
Timer RA count start bit
(1)
Timer RA count forcible stop
bit
(2)
Active edge judgment
flag
(3, 5)
TSTART
Timer RA underflow flag
(3, 5)
0 : No underflow
1 : Underflow
b7 b6 b5 b4
RW
b3 b2
When this bit is set to 1, the count is forcibly
stopped. When read, its content is 0.
(b3)
b1 b0
RW
TCSTF
RW
RW
0: Count stops
1: During count
Nothing is assigned. If necessary, set to 0.
When read, the content is 0.
RO
Bits TEDGF and TUNDF can be set to 0 by writing 0 to these bits by a program. However, their value remains
unchanged when 1 is written.
In pulse width measurement mode and pulse period measurement mode, use the MOV instruction to set the TRACR
register. If it is necessary to avoid changing the values of bits TEDGF and TUNDF, write 1 to them.
Set to 0 in timer mode, pulse output mode, and event counter mode.
TEDGF
0 : Active edge not received
1 : Active edge received
( d f i d)
When the TSTOP bit is set to 1, bits TSTART and TCSTF and registers TPRAPRE and TRA are set to the values after
a reset.
Nothing is assigned. If necessary, set to 0.
When read, the content is 0.
(b7-b6)
TCK0 RW
When both the TSTART and TCSTF bits in the TRACR register are set to 0 (count stops), rewrite this register.
RW
Timer RA count source
cutoff bit
0: Provides a count source
1: Cuts off a count source
TCK2
RW
TMOD1 RW
0
TMOD0
Timer RA operating mode
select bits
b2 b1 b0
0 0 0 : Timer mode
TMOD2
b7 b6 b5 b4
RW
Timer RA count source
select bits
b6 b5 b4
0 0 0: f1
0 0 1: f8
0 1 0: fOCO
0 1 1: f2
1 0 0: fC32
1 0 1:
1 1 0: Do not set.
1 1 1:
Nothing is assigned. If necessary, set to 0.
When read, the content is 0.
RW
TCKCUT
TCK1
b3 b2
(b3)
b1 b0
0 0
REJ 05B0827-0100/Rev.1.00 September 2006 Page 6 of 13
R8C/25 Group
Timer RA in Timer Mode
3.3 Timer Write Control during Count Operation
Timer RA has a prescaler and a timer (which counts the prescaler underflows). The prescaler and timer each
consist of a reload register and a counter. When writing to the prescaler or timer, values are written to both the
reload register and counter.
However, values are transferred from the reload register to the counter of the prescaler in synchronization with the
count source. In addition, values are transferred from the reload register to the counter of the timer in
synchronization with prescaler underflows. Therefore, if the prescaler or timer is written to when count operation
is in progress, the counter value is not updated immediately after the WRITE instruction is executed. Figure 14.5
shows an Operating Example of Timer RA when Counter Value is Rewritten during Count Operation.
Figure 3.4 Operating Example of Timer RA when Counter Value is Rewritten during Count Operation
Count source
Reloads register of
timer RA prescaler
IR bit in TRAIC
register 0
Counter of
timer RA prescaler
Reloads register of
timer RA
Counter of timer RA
Set 01h to the TRAPRE register and 25h to
the TRA register by a program.
After writing, the reload register is
written to at the first count source.
Reload at
second count
source
Reload at
underflow
After writing, the reload register is
written to at the first underflow.
Reload at the second underflow
The IR bit remains unchanged until underflow is
generated by a new value.
05h 04h 01h 00h 01h 00h 01h 00h 01h 00h 06h
New value (01h) Previous value
New value (25h) Previous value
03h 24h 02h 25h
The above applies under the following conditions.
Both bits TSTART and TCSTF in the TRACR register are set to 0 (During count).
REJ 05B0827-0100/Rev.1.00 September 2006 Page 7 of 13
R8C/25 Group
Timer RA in Timer Mode
3.4 Notes on Timer RA
Timer RA stops counting after a reset. Set the values in the timer RA and timer RA prescalers before the
count starts.
Even if the prescaler and timer RA are read out in 16-bit units, these registers are read 1 byte at a time by the
MCU. Consequently, the timer value may be updated during the period when these two registers are being
read.
In pulse period measurement mode, bits TEDGF and TUNDF in the TRACR register can be set to 0 by
writing 0 to these bits by a program. However, these bits remain unchanged if 1 is written. When using the
READ-MODIFY-WRITE instruction for the TRACR register, the TEDGF or TUNDF bit may be set to 0
although these bits are set to 1 while the instruction is being executed. In this case, write 1 to the TEDGF or
TUNDF bit which is not supposed to be set to 0 with the MOV instruction.
When changing to pulse period measurement mode from another mode, the contents of bits TEDGF and
TUNDF are undefined. Write 0 to bits TEDGF and TUNDF before the count starts.
The TEDGF bit may be set to 1 by the first timer RA prescaler underflow generated after the count starts.
When using the pulse period measurement mode, leave two or more periods of the timer RA prescaler
immediately after the count starts, then set the TEDGF bit to 0.
The TCSTF bit retains 0 (count stops) for 0 to 1 cycle of the count source after setting the TSTART bit to 1
(count starts) while the count is stopped.
During this time, do not access registers associated with timer RA
(1)
other than the TCSTF bit. Timer RA
starts counting at the first valid edge of the count source after The TCSTF bit is set to 1 (during count).
The TCSTF bit remains 1 for 0 to 1 cycle of the count source after setting the TSTART bit to 0 (count stops)
while the count is in progress.
During this time, do not access registers associated with timer RA
(1)
other than the TCSTF bit.
Timer RA counting is stopped when the TCSTF bit is set to 0.
NOTE:
1. Registers associated with timer RA: TRACR, TRAIOC, TRAMR, TRAPRE, and TRA.
REJ 05B0827-0100/Rev.1.00 September 2006 Page 8 of 13
R8C/25 Group
Timer RA in Timer Mode
4. Program Overview
This program can be used on timer RA to underflow at 1 ms.
1 ms=fOCO(1) (TRAPRE register setting value +1) (TRA register setting value +1)
=25 ns (40MHz) 4 (FRA2 =0x02: divide-by-4 mode) (99 +1) (99 +1)
NOTE:
1. fOCO is an operating clock generated by the high-speed on-chip oscillator. It is applied with at the divide ratio
set by the high-speed on-chip oscillator control register (FRA2).
4.1 Function Table
Table 4.1
Declaration void timer_ra_init(void)
Overview SFR initial setting associated with timer RA
Argument Argument name Meaning
None
Variable used
(global)
Variable name Usage
None
Return value Type Value Meaning
None
Function Initialize the SFR registers associated with time RA
REJ 05B0827-0100/Rev.1.00 September 2006 Page 9 of 13
R8C/25 Group
Timer RA in Timer Mode
4.2 Flow Chart
4.2.1 Main functions
asm(FCLR I)
prc0 1
fra00 1
System control register protect cancelled
main()
cm16 0
Interrupt disabled
prc0 0 System control register protect
High-speed on-chip oscillator on
Select high-speed on-chip oscillator
Main clock frequency: no divide
cm14 0 Low-speed on-chip oscillator on
fra01 1
fra2 0x02
High-speed on-chip oscillator clock:
divide-by-4 mode
cm06 0 CM16 and CM17 enabled
asm(FSET I)
Yes
Interrupt enabled
Set timer RA interrupt request bit to 0
(Use MOV instruction to set IR bit to 0)
cm17 0
Timer RA SFR initial setting
timer_ra_init()
Initialize timer RA SFR setting
(Set to timer mode)
ir_traic 0
No
Timer RA interrupt request ?
traic 0x00
REJ 05B0827-0100/Rev.1.00 September 2006 Page 10 of 13
R8C/25 Group
Timer RA in Timer Mode
4.2.2 Timer RA SFR Initial Setting
tstart_tracr 0
trapre 100 - 1
Underflow period: set to 1 ms (40 MHz 4 100 100 =1 ms)
timer_ra_init()
tcstf_tracr =0 ?
traic 0x00 Timer RA interrupt disabled
Yes
No
Timer RA operation stops
tstop_tracr 1
Initialize registers TRAPRE and TRA,
and bits TSTART and TCSTF in TRACR register
return
topcr_traioc 0
tedgsel_traioc 0 Set to 0 in timer mode
tra 100 - 1
toena_traioc 0 Set to 0 in timer mode
tstart_tracr 1
tcstf_tracr =1 ?
Yes
No
Timer RA operation starts
Set to 0 in timer mode
tmod0_tramr 0
tipf0_traioc 0 Set to 0 in timer mode
tmod1_tramr 0
tck0_tramr 0
Timer RA count source: fOCO tck1_tramr 1
tckcut_tramr 0 Provide count source
Set to 000 in timer mode
tipf1_traioc 0 Set to 0 in timer mode
tmod2_tramr 0
tck2_tramr 0
REJ 05B0827-0100/Rev.1.00 September 2006 Page 11 of 13
R8C/25 Group
Timer RA in Timer Mode
5. Reference Document
Hardware Manual
R8C/25 Group Hardware Manual
(Download the latest version from the Renesas Technology website.)
Technical News/Technical Update
(Download the latest information from the Renesas Technology website.)
6. Sample Programming Code
Download a sample program on the Renesas Technology website.
To download, click Application Notes in the left-hand side menu on the top page of the R8C/Tiny Series.
REJ 05B0827-0100/Rev.1.00 September 2006 Page 12 of 13
R8C/25 Group
Timer RA in Timer Mode
Website and Support
Renesas Technology website
http://www.renesas.com/
Inquiries
http://www.renesas.com/inquiry
csc@renesas.com
REVISION HISTORY R8C/25 Group Timer RA in Timer Mode
Rev. Date Description
Page Summary
1.00 Sep 15, 2006 First Edition issued
REJ 05B0827-0100/Rev.1.00 September 2006 Page 13 of 13
R8C/25 Group
Timer RA in Timer Mode
2006. Renesas Technology Corp., All rights reserved. Printed in J apan.
Keep safety first in your circuit designs!
Notes regarding these materials
1. Renesas Technology Corp. puts the maximum effort into making semiconductor products
better and more reliable, but there is always the possibility that trouble may occur with
them. Trouble with semiconductors may lead to personal injury, fire or property damage.
Remember to give due consideration to safety when making your circuit designs, with ap-
propriate measures such as (i) placement of substitutive, auxiliary circuits, (ii) use of non-
flammable material or (iii) prevention against any malfunction or mishap.
1. These materials are intended as a reference to assist our customers in the selection of the
Renesas Technology Corp. product best suited to the customer's application; they do not
convey any license under any intellectual property rights, or any other rights, belonging to
Renesas Technology Corp. or a third party.
2. Renesas Technology Corp. assumes no responsibility for any damage, or infringement of
any third-party's rights, originating in the use of any product data, diagrams, charts, pro-
grams, algorithms, or circuit application examples contained in these materials.
3. All information contained in these materials, including product data, diagrams, charts, pro-
grams and algorithms represents information on products at the time of publication of these
materials, and are subject to change by Renesas Technology Corp. without notice due to
product improvements or other reasons. It is therefore recommended that customers con-
tact Renesas Technology Corp. or an authorized Renesas Technology Corp. product dis-
tributor for the latest product information before purchasing a product listed herein.
The information described here may contain technical inaccuracies or typographical errors.
Renesas Technology Corp. assumes no responsibility for any damage, liability, or other
loss rising from these inaccuracies or errors.
Please also pay attention to information published by Renesas Technology Corp. by vari-
ous means, including the Renesas Technology Corp. Semiconductor home page (http://
www.renesas.com).
4. When using any or all of the information contained in these materials, including product
data, diagrams, charts, programs, and algorithms, please be sure to evaluate all informa-
tion as a total system before making a final decision on the applicability of the information
and products. Renesas Technology Corp. assumes no responsibility for any damage, liabil-
ity or other loss resulting from the information contained herein.
5. Renesas Technology Corp. semiconductors are not designed or manufactured for use in a
device or system that is used under circumstances in which human life is potentially at
stake. Please contact Renesas Technology Corp. or an authorized Renesas Technology
Corp. product distributor when considering the use of a product contained herein for any
specific purposes, such as apparatus or systems for transportation, vehicular, medical,
aerospace, nuclear, or undersea repeater use.
6. The prior written approval of Renesas Technology Corp. is necessary to reprint or repro-
duce in whole or in part these materials.
7. If these products or technologies are subject to the Japanese export control restrictions,
they must be exported under a license from the Japanese government and cannot be im-
ported into a country other than the approved destination.
Any diversion or reexport contrary to the export control laws and regulations of Japan and/
or the country of destination is prohibited.
8. Please contact Renesas Technology Corp. for further details on these materials or the
products contained therein.