Note 1: The products with Flash memory (86FH46,86FH46A,86FH46B) contain the Flash control register (FLSCR) at 0FFFH
DBR area. The products with mask ROM or OTP and the emulation chip do not have the FLSCR register. In
in the
these devices,therefore, a program that accesses the FLSCR register cannot function properly (executes differently
as in the case of a Flash product).
Note 2: The TXD and RXD pins to be used in Serial PROM mode differ between the 86FH46 and the 86FH46A,86FH46B.
Take this into consideration in your board design when you replace the product. Details of the function refer to the chapter of the 86FH46,86FH46A,86FH46B data sheet.
Note 1: The products with Flash memory (86FH47,86FH47A,86FH47B) contain the Flash control register (FLSCR) at 0FFFH
DBR area. The products with mask ROM or OTP and the emulation chip do not have the FLSCR register. In
in the
these devices,therefore, a program that accesses the FLSCR register cannot function properly (executes differently
as in the case of a Flash product).
Note 2: The TXD and RXD pins to be used in Serial PROM mode differ between the 86FH47 and the 86FH47A,86FH47B.
Take this into consideration in your board design when you replace the product. Details of the function refer to the chapter of the 86FH47,86FH47A,86FH47B data sheet.
Note 3: P21,P22 combine XTIN,XTOUT and port.
Differences in Electrical Characteristics (TMP86xx46 Series)
5.5
4.5
2.7
1.8
1 4.2 816 [MHz]
[V]
(a)
5.5
4.5
2.7
1.8
2.0
0.030
0.034
1 4.2 816 [MHz]
[V]
(a)
(b)
(Note1)
5.5
4.5
2.7
1.8
1 4.2 816 [MHz]
[V]
(a)
5.5
4.5
3.0
2.7
1.8
0.030
0.034
1 4.2 8 16
(a)
(b)
(Note2)
[MHz]
[V]
5.5
4.5
2.7
1.8
0.030
0.034
1 4.2 8 16 [MHz]
[V]
(a)
5.5
4.5
2.7
1.8
2 4 8 16 [MHz]
[V]
(a)
5.5
4.5
2.7
1.8
0.030
0.034
2 4.2 8 16 [MHz]
[V]
(a)
TMP86FH47BUG
Operating condition
(MCU
mode)
Read/
Fetch
Erase/
Program
86C846 / 86CH46 / 86CM46
86CM46A
86PM46
86PH46
86CH46A
(a) 1.8V to 5.5V (-40 to 85 °C) (a) 2.0V to 5.5V (-40 to 85 °C)
(b) 1.8V
to 2.0V (-20 to 85 °C)
---
86FH46
(a) 2.7V to 5.5V (-40 to 85 °C)
86FH46A
86FH46B
TMP86FH46A
(a) 3.0V
to 5.5V (-40 to 85 °C)
(b) 2.7V to 3.0V (-20 to 85 °C)
TMP86FH46B
(a) 2.7V to 5.5V (-40 to 85 °C)
Operating condition
(Serial PROM
mode)
Supply voltage
(Absolute Maxi-
mum
Ratings)
Operating current
Note 1: With The 86CH46A,PH46 the operating temperature (Topr) is -20 °C to 85 °C when the supply voltage VDD is less
2: With The 86FH46A, the operating temperature (Topr) is -20 °C to 85 °C when the supply voltage VDD is less than
Note
Note 3: With The 86FH46A,86FH46B when a program is executing in the Flash memory or when data is being read from the
Note 4: About the measurement condition of supply current, VIN level of TEST pin is deffrent between 86FH46B and the oth-
(a) 4.5V to 5.5V (-10 to 40 °C)
--
(a) 4.5V to 5.5V (20 to 30 °C) (a) 4.5V to 5.5V (-10 to 40 °C)
86FH46A
−0.3 ~ 6.5
(a)−0.3 ~
6.5
86FH46B
(a)−0.3 ~ 6.0
Operating current varies with each product. For details, refer to the datacheet (electrical chracteristics) of each product.(Note4)
(Note3)
than 2.0V.
3.0V.
Flash memory, the Flash memory operates in an intermittent manner causing peak currents in the Flash memory momentarily, as shown in Figure. in this case, the supply current IDD(in NORMAL1,NORMAL2 and SLOW1 mode) is defined as the sum of the average peak current and MCU current.
er 86xx46 series MCUs. The supply current is defined as follows; VIN of TEST pin: VIN ≤ 0.1V(86FH46B), VIN ≤ 0.2V(others) It is described in the section "Electrical characteristics" of TMP86FH46B in detail.
n
Program counter (PC)
n+1n+2n+3
1 machine cycle(4/fc or 4/fs)
MCU current
I
[mA]
DDP-P
Typ. current
Momentary Flash current
Max. current
Sum of average momentary
Flash current and MCU curren
t
Intermittent Operation of Flash Memory
TMP86FH47BUG
Differences in Electrical Characteristics (TMP86xx47 Series)
5.5
4.5
2.7
1.8
1 4.2 816 [MHz]
[V]
(a)
5.5
4.5
2.7
1.8
2.0
0.030
0.034
1 4.2 816 [MHz]
[V]
(a)
(b)
(Note1)
5.5
4.5
2.7
1.8
1 4.2 816 [MHz]
[V]
(a)
5.5
4.5
3.0
2.7
1.8
0.030
0.034
1 4.2 8 16
(a)
(b)
(Note2)
[MHz]
[V]
5.5
4.5
2.7
1.8
0.030
0.034
1 4.2 8 16 [MHz]
[V]
(a)
5.5
4.5
2.7
1.8
2 4 8 16 [MHz]
[V]
(a)
5.5
4.5
2.7
1.8
0.030
0.034
2 4.2 8 16 [MHz]
[V]
(a)
TMP86FH47BUG
Operating condition
(MCU
mode)
Read/
Fetch
Erase/
Program
86C847 / 86CH47 / 86CM47
86CM47A
86PM47
(a) 1.8V to 5.5V (-40 to 85 °C)
---
86PH47
86CH47A
(a) 2.0V to 5.5V (-40 to 85 °C)
(b) 1.8V
to 2.0V (-20 to 85 °C)
86FH47
(a) 2.7V to 5.5V (-40 to 85 °C)
86FH47A
86FH47B
86FH47A
(a) 3.0V
to 5.5V (-40 to 85 °C)
(b) 2.7V to 3.0V (-20 to 85 °C)
86FH47B
(a) 2.7V to 5.5V (-40 to 85 °C)
Operating condition
(Serial PROM
mode)
Supply voltage
(Absolute Maxi-
mum
Ratings)
Operating current
Note 1: With The 86CH47A, PH47 the operating temperature (Topr) is -20 °C to 85 °C when the supply voltage VDD is less
2: With The 86FH47A, the operating temperature (Topr) is -20 °C to 85 °C when the supply voltage VDD is less than
Note
Note 3: With The 86FH47A,86FH47B when a program is executing in the Flash memory or when data is being read from the
Note 4: About the measurement condition of supply current, VIN level of TEST pin is deffrent between 86FH47B and the oth-
(a) 4.5V to 5.5V (-10 to 40 °C)
--
(a) 4.5V to 5.5V (20 to 30 °C) (a) 4.5V to 5.5V (-10 to 40 °C)
86FH47A
−0.3 ~ 6.5
(a)−0.3 ~
6.5
86FH47B
(a)−0.3 ~ 6.0
Operating current varies with each product. For details, refer to the datacheet (electrical chracteristics) of each product.(Note4)
(Note3)
than 2.0V.
3.0V.
Flash memory, the Flash memory operates in an intermittent manner causing peak currents in the Flash memory momentarily, as shown in Figure. in this case, the supply current IDD(in NORMAL1,NORMAL2 and SLOW1 mode) is defined as the sum of the average peak current and MCU current.
er 86xx47 series MCUs. The supply current is defined as follows; VIN of TEST pin: VIN ≤ 0.1V(86FH47B), VIN ≤ 0.2V(others) It is described in the section "Electrical characteristics" of TMP86FH47B in detail.
n
Program counter (PC)
n+1n+2n+3
1 machine cycle(4/fc or 4/fs)
MCU current
I
[mA]
DDP-P
Typ. current
Momentary Flash current
Max. current
Sum of average momentary
Flash current and MCU curren
2.2.3Operation Mode Control Circuit ......................................................................................................................................11
2.2.3.1Single-clock mode
2.2.3.2Dual-clock mode
2.2.3.3STOP mode
2.2.4Operating Mode Control ..................................................................................................................................................16
3.4.1Interrupt acceptance processing is packaged as follows. ................................................................................................35
6.3.1Selection of Address Trap in Internal RAM (ATAS) .....................................................................................................56
6.3.2Selection of Operation at Address Trap (ATOUT) .........................................................................................................56
10.3.2Transfer bit direction.....................................................................................................................................................108
11.9.4Receive Data Buffer Full..............................................................................................................................................129
11.9.5Transmit Data Buffer Empty.........................................................................................................................................129
12.6.1Analog input pin voltage range.....................................................................................................................................139
14.2.4Product ID Entry...........................................................................................................................................................146
14.2.5Product ID Exit..............................................................................................................................................................146
14.3Toggle Bit (D6)...................................................................................................................147
14.4Access to the Flash Memory Area......................................................................................148
14.4.1Flash Memory Control in the Serial PROM Mode......................................................................................................148
14.4.1.1How to write to the flash memory by executing the control program in the RAM area (in the RAM loader mode within the
14.4.2Flash Memory Control in the MCU mode...................................................................................................................150
14.4.2.1How to write to the flash memory by executing a user write control program in the RAM area (in the MCU mode)
15.3.1Serial PROM Mode Control Pins.................................................................................................................................154
15.3.4Activating the Serial PROM Mode...............................................................................................................................156
15.10.2Handling of Password Error........................................................................................................................................177
15.10.3Password Management during Program Development..............................................................................................177
15.11Product ID Code................................................................................................................178
15.12Flash Memory Status Code...............................................................................................178
15.13Specifying the Erasure Area..............................................................................................180
15.14Port Input Control Register...............................................................................................180
is a single-chip 8-bit high-speed and high-functionality microcomputer incorporating
16384 bytes of Flash Memory. It is pin-compatible with the TMP86CH47AUG/TMP86C847UG (Mask ROM version). The TMP86FH47BUG can realize operations equivalent to those of the TMP86CH47AUG/TMP86C847UG
by programming the on-chip Flash Memory.
This product uses the Super Flash® technology under the licence of Silicon Storage Technology, Inc. Super Flash® is registered trademark of Silicon Storage
Technology, Inc.
Page 1
RA000
1.1 Features
TMP86FH47BUG
10. 10-bit successive approximation type AD converter
has MCU mode, parallel PROM mode, and serial PROM mode. Table 1-1 shows the
pin functions in MCU mode. The serial PROM mode is explained later in a separate chapter.
Table 1-1 Pin Names and Functions(1/3)
Pin Name
P07
INT4
P06
SCK
P05
SI
P04
SO
P03
TXD
P02
RXD
BOOT
P01
TC4
PDO4/PWM4/PPG4
Pin NumberInput/OutputFunctions
17
16
15
14
13
12
11
IOIPORT07
External interrupt
IOIOPORT06
Serial clock
IOIPORT05
Serial data
IOOPORT04
Serial data
IOOPORT03
UART data
IO
PORT02
I
UART data
I
Serial PROM mode control input
IO
PORT01
I
TC4 input
O
PDO4/PWM4/PPG4
input/output
input
output
output
input
4 input
output
P00
INT0
P1718IOPORT17
P1619IOPORT16
P15
INT3
P14
PPG
P13
DVO
P12
INT2
TC1
P11
INT1
P10
PDO3/PWM3
TC3
P22
XTOUT
10
20
21
22
23
24
25
7
IOIPORT00
External interrupt
IOIPORT15
External interrupt
IOOPORT14
PPG output
IOOPORT13
Divider Output
IO
PORT12
I
External interrupt
TC1 input
I
IOIPORT11
External interrupt
IO
PORT10
O
PDO3/PWM3 output
I
IO
O
input
TC3
PORT22
Resonator connecting
nal clock
0 input
3 input
2 input
1 input
pins(32.768kHz) for inputting exter-
RA000
P21
XTIN
PORT21
6
IO
Resonator connecting
I
nal clock
pins(32.768kHz) for inputting exter-
Page 5
1.4 Pin Names and Functions
Table 1-1 Pin Names and Functions(2/3)
TMP86FH47BUG
P20
STOP
INT5
P37
AIN7
STOP5
P36
AIN6
STOP4
P35
AIN5
STOP3
P34
AIN4
STOP2
P33
AIN3
P32
AIN2
P31
AIN1
Pin Name
Pin NumberInput/OutputFunctions
IO
PORT20
9
33
32
31
30
29
28
27
I
STOP mode
External interrupt 5 input
I
IO
PORT37
I
Analog Input7
I
STOP5
IO
PORT36
I
Analog Input6
I
STOP4
IO
PORT35
I
Analog Input5
I
STOP3
IO
PORT34
I
Analog Input4
I
STOP2
IOIPORT33
Analog Input3
IOIPORT32
Analog Input2
IOIPORT31
Analog Input1
release signal input
input
input
input
input
P30
AIN0
P4744IOPORT47
P4643IOPORT46
P4542IOPORT45
P4441IOPORT44
P4340IOPORT43
P4239IOPORT42
P4138IOPORT41
P4037IOPORT40
XIN2IResonator connecting pins for high-frequency clock
XOUT3OResonator connecting pins for high-frequency clock
RESET8IOReset signal
TEST4ITest pin for out-going test. Normally, be fixed to low.
VAREF34IAnalog Base Voltage Input Pin for A/D Conversion
26
IOIPORT30
Analog Input0
Table 1-1 Pin Names and Functions(3/3)
Pin NamePin NumberInput/OutputFunctions
AVDD35IAnalog Power Supply
AVSS36IAnalog Power Supply
VDD5I+5V
VSS1I0(GND)
Page 6
RA000
2.Operational Description
TMP86FH47BUG
2.1 CPU
Core Functions
The CPU core consists of a CPU, a system clock controller, and an interrupt controller.
This section provides a description of the CPU core, the program memory, the data memory, and the reset circuit.
2.1.1 Memory Address Map
The TMP86FH47BUG memory is composed Flash, RAM, DBR(Data buffer register) and SFR(Special function register). They are all mapped in 64-Kbyte address space. Figure 2-1 shows the TMP86FH47BUG memory address map.
SFR
RAM
DBR
0FFF
C000
Flash
FFC0
FFDF
FFE0
FFFF
0000
H
003F
H
0040
H
023F
H
0F80
H
H
H
H
H
H
H
64 bytes
512
bytes
128
bytes
16384
bytes
SFR:
Vector table for vector call instructions
(32 bytes)
Vector table for interrupts
(32 bytes)
Special function register includes:
I/O ports
Peripheral
Peripheral status registers
System control registers
Program status word
RAM:
Random access memory includes:
Data memory
Stack
DBR: Data buffer register includes:
Peripheral control
Peripheral status registers
Flash: Program memory
control registers
registers
Figure 2-1 Memory Address Map
2.1.2 Program
The TMP86FH47BUG has a 16384 bytes (Address C000H to FFFFH) of program memory (Flash).
Memory (Flash)
2.1.3 Data Memory (RAM)
The TMP86FH47BUG has 512bytes (Address 0040H to 023FH) of internal RAM. The first 192 bytes
(0040H to 00FFH) of the internal RAM are located in the direct area; instructions with shorten operations
are available against such an area.
Page 7
2. Operational Description
2.2 System Clock Controller
The data memory contents become unstable when the power supply is turned on; therefore, the data memory should be initialized by an initialization routine.
Example :Clears RAM to “00H”. (TMP86FH47BUG)
SRAMCLR:LD(HL), A
2.2 System Clock Controller
TMP86FH47BUG
LDHL, 0040H; Start address setup
LDA, H; Initial value (00H) setup
LDBC, 01FFH
INCHL
DECBC
JRSF, SRAMCLR
The system clock controller consists of a clock generator, a timing generator, and a standby controller.
Timing generator control register
TBTCR
0036
H
Timing
generator
System clocks
Standby controller
0038
H
0039
System control registers
XIN
XOUT
XTIN
XTOUT
Clock
generator
fc
High-frequency
clock oscillator
fs
Low-frequency
clock oscillator
Clock generator control
Figure 2-2 System Clock Control
2.2.1 Clock Generator
The clock generator generates the basic clock which provides the system clocks supplied to the CPU core
and peripheral hardware. It contains two oscillation circuits: One for the high-frequency clock and one for
the low-frequency clock. Power consumption can be reduced by switching of the standby controller to low-power operation based on the low-frequency clock.
H
SYSCR2SYSCR1
The high-frequency (fc) clock and low-frequency (fs) clock can easily be obtained by connecting a resonator between the XIN/XOUT and XTIN/XTOUT pins respectively. Clock input from an external oscillator is also possible. In this case, external clock is applied to XIN/XTIN pin with XOUT/XTOUT pin not connected.
Page 8
TMP86FH47BUG
(a) Crystal/Ceramic
resonator
Note:The function to monitor the basic clock directly at external is not provided for hardware, however,
High-frequency clock
XOUTXIN
(b) External oscillator
XOUTXIN
(Open)
XTIN
(c) Crystal(d) External oscillator
Low-frequency clock
XTOUT
XTIN
XTOUT
(Open)
Figure 2-3 Examples of Resonator Connection
with disabling all interrupts and watchdog timers, the oscillation frequency can be adjusted by monitoring the pulse which the fixed frequency is outputted to the port by the program.
The system to require the adjustment of the oscillation frequency should create the program for the adjustment in advance.
Page 9
2. Operational Description
2.2 System Clock Controller
2.2.2 Timing Generator
The timing generator generates the various system clocks supplied to the CPU core and peripheral hardware from the basic clock (fc or fs). The timing generator provides the following functions.
TMP86FH47BUG
1. Generation of main system clock
2. Generation of divider output (DVO) pulses
3. Generation of source clocks for time base timer
4. Generation of source clocks for watchdog timer
5. Generation of internal source clocks for timer/counters
6. Generation of warm-up clocks for releasing STOP mode
2.2.2.1 Configuration of timing generator
The timing generator consists of a 2-stage prescaler, a 21-stage divider, a main system clock generator,
and machine cycle counters.
An input clock to the 7th stage of the divider depends on the operating mode, SYSCR2<SYSCK> and
TBTCR<DV7CK>, that is shown in Figure 2-4. As reset and STOP mode started/canceled, the prescaler
and the divider are cleared to “0”.
SYSCK
DV7CK
High-frequency
clock fc
Low-frequency
clock fs
fc/4
12143287109121114131615
5 617 18 19 20 21
S
A
Y
B
Multi-
plexer
fc or fs
Machine cycle countersMain system clock generator
Divider
B0
B1
A0
A1
S
Y0
Y1
Multiplexer
Warm-up
controller
Watchdog
timer
Timer counter, Serial interface, Time-base-timer, divider output, etc. (Peripheral functions)
Figure 2-4 Configuration of Timing Generator
Page 10
Timing Generator Control Register
TMP86FH47BUG
TBTCR
(0036H)
Note 1: In single clock mode, do not set DV7CK to “1”.
Note 2: Do not set “1” on DV7CK while the low-frequency clock is not operated stably.
Selection of input to the 7th stage
of the divider
0: fc/28 [Hz]
1: fs
2.2.2.2 Machine cycle
Instruction execution and peripheral hardware operation are synchronized with the main system clock.
The minimum instruction execution unit is called an “machine cycle”. There are a total of 10 different
types of instructions for the TLCS-870/C Series: Ranging from 1-cycle instructions which require one machine cycle for execution to 10-cycle instructions which require 10 machine cycles for execution. A machine cycle consists of 4 states (S0 to S3), and each state consists of one main system clock.
R/W
1/fc or 1/fs [s]
Main system clock
State
Machine cycle
Figure 2-5 Machine Cycle
2.2.3 Operation Mode Control Circuit
The operation mode control circuit starts and stops the oscillation circuits for the high-frequency and low-frequency clocks, and switches the main system clock. There are three operating modes: Single clock mode, dual clock mode and STOP mode. These modes are controlled by the system control registers (SYSCR1 and
SYSCR2). Figure 2-6 shows the operating mode transition diagram.
2.2.3.1 Single-clock mode
Only the oscillation circuit for the high-frequency clock is used, and P21 (XTIN) and P22 (XTOUT)
pins are used as input/output ports. The main-system clock is obtained from the high-frequency clock. In
the single-clock mode, the machine cycle time is 4/fc [s].
S3S2S1S0S3S2S1S0
(1) NORMAL1 mode
In this mode, both the CPU core and on-chip peripherals operate using the high-frequency clock.
The TMP86FH47BUG is placed in this mode after reset.
Page 11
2. Operational Description
2.2 System Clock Controller
TMP86FH47BUG
(2) IDLE1 mode
In this mode, the internal oscillation circuit remains active. The CPU and the watchdog timer are hal-
ted; however
on-chip peripherals remain active (Operate using the high-frequency clock).
IDLE1 mode is started by SYSCR2<IDLE> = "1", and IDLE1 mode is released to NORMAL1
mode by an interrupt request from the on-chip peripherals or external interrupt inputs. When the
IMF (Interrupt master enable flag) is “1” (Interrupt enable), the execution will resume with the acceptance of the interrupt, and the operation will return to normal after the interrupt service is completed.
When the IMF is “0” (Interrupt disable), the execution will resume with the instruction which follows the IDLE1 mode start instruction.
(3) IDLE0 mode
In this mode, all the circuit, except oscillator and the timer-base-timer, stops operation.
This mode is enabled by SYSCR2<TGHALT> = "1".
When IDLE0 mode starts, the CPU stops and the timing generator stops feeding the clock to the peripheral circuits other than TBT. Then, upon detecting the falling edge of the source clock selected
with TBTCR<TBTCK>, the timing generator starts feeding the clock to all peripheral circuits.
When returned from IDLE0 mode, the CPU restarts operating, entering NORMAL1 mode back
again. IDLE0 mode is entered and returned regardless of how TBTCR<TBTEN> is set. When IMF
= “1”, EF6 (TBT interrupt individual enable flag) = “1”, and TBTCR<TBTEN> = “1”, interrupt processing is performed. When IDLE0 mode is entered while TBTCR<TBTEN> = “1”, the INTTBT interrupt latch is set after returning to NORMAL1 mode.
2.2.3.2 Dual-clock mode
Both the high-frequency and low-frequency oscillation circuits are used in this mode. P21 (XTIN) and
P22 (XTOUT) pins cannot be used as input/output ports. The main system clock is obtained from the highfrequency clock in NORMAL2 and IDLE2 modes, and is obtained from the low-frequency clock in
SLOW and SLEEP modes. The machine cycle time is 4/fc [s] in the NORMAL2 and IDLE2 modes, and
4/fs [s] (122 μs at fs = 32.768 kHz) in the SLOW and SLEEP modes.
The TLCS-870/C is placed in the single-clock mode during reset. To use the dual-clock mode, the lowfrequency oscillator should be turned on at the start of a program.
(1) NORMAL2 mode
In this mode, the CPU core operates with the high-frequency clock. On-chip peripherals operate us-
ing the high-frequency clock and/or low-frequency clock.
(2) SLOW2 mode
In this mode, the CPU core operates with the low-frequency clock, while both the high-frequency
clock and the low-frequency clock are operated. As the SYSCR2<SYSCK> becomes "1", the hardware changes into SLOW2 mode. As the SYSCR2<SYSCK> becomes “0”, the hardware changes into NORMAL2 mode. As the SYSCR2<XEN> becomes “0”, the hardware changes into SLOW1
mode. Do not clear SYSCR2<XTEN> to “0” during SLOW2 mode.
(3) SLOW1 mode
This mode can be used to reduce power-consumption by turning off oscillation of the high-frequency clock. The CPU core and on-chip peripherals operate using the low-frequency clock.
Page 12
TMP86FH47BUG
Switching back and forth between SLOW1 and SLOW2 modes are performed by
SYSCR2<XEN>. In SLOW1 and SLEEP modes, the input clock to the 1st stage of the divider is stopped; output
from the 1st to 6th stages is also stopped.
(4) IDLE2 mode
In this mode, the internal oscillation circuit remain active. The CPU and the watchdog timer are halted; however, on-chip peripherals remain active (Operate using the high-frequency clock and/or the
low-frequency clock). Starting and releasing of IDLE2 mode are the same as for IDLE1 mode, except that operation returns to NORMAL2 mode.
(5) SLEEP1 mode
In this mode, the internal oscillation circuit of the low-frequency clock remains active. The CPU,
the watchdog timer, and the internal oscillation circuit of the high-frequency clock are halted; however, on-chip peripherals remain active (Operate using the low-frequency clock). Starting and releasing of SLEEP mode are the same as for IDLE1 mode, except that operation returns to SLOW1
mode. In SLOW1 and SLEEP1 modes, the input clock to the 1st stage of the divider is stopped; output from the 1st to 6th stages is also stopped.
(6) SLEEP2 mode
The SLEEP2 mode is the idle mode corresponding to the SLOW2 mode. The status under the
SLEEP2 mode is same as that under the SLEEP1 mode, except for the oscillation circuit of the highfrequency clock.
(7) SLEEP0 mode
In this mode, all the circuit, except oscillator and the timer-base-timer, stops operation. This
mode is enabled by setting “1” on bit SYSCR2<TGHALT>.
When SLEEP0 mode starts, the CPU stops and the timing generator stops feeding the clock to
the peripheral circuits other than TBT. Then, upon detecting the falling edge of the source clock selected with TBTCR<TBTCK>, the timing generator starts feeding the clock to all peripheral circuits.
When returned from SLEEP0 mode, the CPU restarts operating, entering SLOW1 mode back
again. SLEEP0 mode is entered and returned regardless of how TBTCR<TBTEN> is set. When
IMF = “1”, EF6 (TBT interrupt individual enable flag) = “1”, and TBTCR<TBTEN> = “1”, interrupt processing is performed. When SLEEP0 mode is entered while TBTCR<TBTEN> = “1”, the
INTTBT interrupt latch is set after returning to SLOW1 mode.
2.2.3.3 STOP mode
In this mode, the internal oscillation circuit is turned off, causing all system operations to be halted.
The internal status immediately prior to the halt is held with a lowest power consumption during STOP
mode.
STOP mode is started by the system control register 1 (SYSCR1), and STOP mode is released by a inputting (Either level-sensitive or edge-sensitive can be programmable selected) to the
warm-up period
is completed, the execution resumes with the instruction which follows the STOP mode
STOP pin. After the
start instruction.
Page 13
2. Operational Description
2.2 System Clock Controller
TMP86FH47BUG
IDLE1
mode
(a) Single-clock mode
IDLE2
mode
SLEEP2
mode
SLEEP1
mode
(b) Dual-clock mode
SYSCR2<TGHALT> = "1"
SYSCR2<IDLE> = "1"
Interrupt
SYSCR2<XTEN> = "0"
SYSCR2<IDLE> = "1"
Interrupt
SYSCR2<SYSCK> = "0"
SYSCR2<IDLE> = "1"
Interrupt
SYSCR2<XEN> = "1"
SYSCR2<IDLE> = "1"
Interrupt
Note 2
IDLE0
mode
NORMAL1
mode
NORMAL2
mode
SLOW2
mode
SLOW1
mode
Reset release
Note 2
SYSCR1<STOP> = "1"
STOP pin input
SYSCR2<XTEN> = "1"
SYSCR1<STOP> = "1"
STOP pin input
SYSCR2<SYSCK> = "1"
SYSCR2<XEN> = "0"
SYSCR1<STOP> = "1"
STOP pin input
SYSCR2<TGHALT> = "1"
RESET
STOP
SLEEP0
mode
Note 1: NORMAL1 and NORMAL2 modes are generically called NORMAL; SLOW1 and SLOW2 are called SLOW;
IDLE0, IDLE1 and IDLE2 are called IDLE; SLEEP0, SLEEP1 and SLEEP2 are called SLEEP.
Note 2: The mode is released by falling edge of TBTCR<TBTCK> setting.
and watchdog timer are stopped (Start IDLE1/2 and SLEEP1/2
feeding clock to peripherals except TBT from TG
10
clock (SLOW1/SLOW2/SLEEP1/SLEEP2)
R/W
R/W
Page 15
2. Operational Description
2.2 System Clock Controller
Note 6: When IDLE1/2 or SLEEP1/2 mode is released, IDLE is automatically cleared to “0”.
Note 7: When
Note 8: Before setting TGHALT to “1”, be sure to stop peripherals. If peripherals are not stopped, the interrupt latch of periph-
2.2.4 Operating Mode Control
2.2.4.1 STOP mode
TMP86FH47BUG
IDLE0 or SLEEP0 mode is released, TGHALT is automatically cleared to “0”.
erals may be set after IDLE0 or SLEEP0 mode is released.
STOP mode is controlled by the system control register 1, the
put (STOP5
The
to STOP2) which is controlled by the STOP mode release control register (STOPCR).
STOP pin is also used both as a port P20 and an INT5 (external interrupt input 5) pin. STOP
STOP pin input and key-on wakeup in-
mode is started by setting SYSCR1<STOP> to “1”. During STOP mode, the following status is maintained.
1. Oscillations are
turned off, and all internal operations are halted.
2. The data memory, registers, the program status word and port output latches are all held in the
status in effect before STOP mode was entered.
3. The prescaler and the divider of the timing generator are cleared to “0”.
4. The program counter holds the address 2 ahead of the instruction (e.g., [SET (SYSCR1).7])
which started STOP mode.
STOP mode includes a level-sensitive mode and an edge-sensitive mode, either of which can be selected with the SYSCR1<RELM>. Do not use any key-on wakeup input (STOP5 to STOP2) for releasing
STOP mode in edge-sensitive mode.
Note 1: The STOP mode can be released by either the STOP or key-on wakeup pin (STOP5 to STOP2). How-
Note 2: During STOP period (from start of STOP mode to end of warm up), due to changes in the external in-
ever, because the STOP pin is different from the key-on wakeup and can not inhibit the release input, the STOP pin must be used for releasing STOP mode.
terrupt pin signal, interrupt latches may be set to “1” and interrupts may be accepted immediately after STOP mode is released. Before starting STOP mode, therefore, disable interrupts. Also, before enabling interrupts after STOP mode is released, clear unnecessary interrupt latches.
(1) Level-sensitive release mode (RELM = “1”)
In this mode, STOP mode is released by setting the
STOP2 pin
input which is enabled by STOPCR. This mode is used for capacitor backup when the
STOP pin high or setting the STOP5 to
main power supply is cut off and long term battery backup.
Even if an instruction for starting STOP mode is executed while
STOP pin input is high or
STOP5 to STOP2 input is low, STOP mode does not start but instead the warm-up sequence starts immediately. Thus,
gram to first confirm that the
ing two
methods can be used for confirmation.
to start STOP mode in the level-sensitive release mode, it is necessary for the pro-
STOP pin input is low and STOP5 to STOP2 input is high. The follow-
1. Testing a port.
2. Using an external interrupt input
INT5 (INT5 is a falling edge-sensitive input).
Page 16
Example 1 :Starting STOP mode from NORMAL mode by testing a port P20.
LD(SYSCR1), 01010000B; Sets up the level-sensitive release mode
SSTOPH:TEST(P2PRD). 0; Wait until the
JRSF, SSTOPH
DI; IMF ← 0
SET(SYSCR1). 7; Starts STOP mode
STOP pin input goes low level
Example 2 :Starting STOP mode from NORMAL mode with an INT5 interrupt.
PINT5:TEST(P2PRD). 0; To reject noise, STOP mode does not start if
JRSF, SINT5port P20 is at high
LD(SYSCR1), 01010000B; Sets up the level-sensitive release mode.
DI; IMF ← 0
SET(SYSCR1). 7; Starts STOP mode
SINT5:RETI
V
STOP pin
IH
TMP86FH47BUG
XOUT pin
NORMAL
operation
STOP
operation
Confirm by program that the
STOP pin input is low and start
STOP mode.
Warm up
STOP mode is released by the hardware.
Always released if the STOP
pin input is high.
NORMAL
operation
Figure 2-7 Level-sensitive Release Mode
Note 1: Even if the
Note 2: In this case of changing to the level-sensitive mode from the edge-sensitive mode, the release mode
is not switched until a rising edge of the
(2) Edge-sensitive release mode (RELM = “0”)
In this mode, STOP mode is released by a rising edge of the
cations where a relatively short program is executed repeatedly at periodic intervals. This periodic signal (for example, a clock from a low-power consumption oscillator) is input to the STOP pin. In the
edge-sensitive release mode, STOP mode is started even when the STOP pin input is high level. Do
not use any STOP5 to STOP2 pin input for releasing STOP mode in edge-sensitive release mode.
STOP pin input is low after warm-up start, the STOP mode is not restarted.
STOP pin input is detected.
STOP pin input. This is used in appli-
Example :Starting STOP mode from NORMAL mode
DI; IMF ← 0
LD(SYSCR1), 10010000B; Starts after specified to the edge-sensitive release mode
Page 17
2. Operational Description
2.2 System Clock Controller
STOP pin
XOUT pin
TMP86FH47BUG
V
IH
NORMAL
operation
STOP mode started
by the program.
STOP mode is released by the following sequence.
1. In the dual-clock mode, when returning to NORMAL2, both the high-frequency and low-frequency clock oscillators are turned on; when returning to SLOW1 mode, only the low-frequency clock oscillator is turned on. In the single-clock mode, only the high-frequency
clock oscillator is turned on.
2. A warm-up period is inserted to allow oscillation time to stabilize. During warm up, all internal operations remain halted. Six different warm-up times can be selected with the
SYSCR1<WUT> in accordance with the resonator characteristics.
3. When the warm-up time has elapsed, normal operation resumes with the instruction following the STOP mode start instruction.
STOP
operation
Warm up
NORMAL
operation
STOP mode is released by the hardware at the rising
edge of STOP pin input.
Figure 2-8 Edge-sensitive Release Mode
STOP
operation
Note 1: When the STOP mode is released, the start is made after the prescaler and the divider of the tim-
Note 2: STOP mode can also be released by inputting low level on the
Note 3: When STOP mode is released with a low hold voltage, the following cautions must be ob-
ing generator are cleared to "0".
performs the normal reset operation.
served. The power supply voltage must be at the operating voltage level before releasing
STOP mode. The
ply voltage. In this case, if an external time constant circuit has been connected, the RESET
pin input voltage will increase at a slower pace than the power supply voltage. At this time,
there is a danger that a reset may occur if input voltage level of the RESET pin drops below
the non-inverting high-level input voltage (Hysteresis input).
RESET pin input must also be “H” level, rising together with the power sup-
RESET pin, which immediately
Table 2-2 Warm-up Time Example (at fc = 16.0 MHz, fs = 32.768 kHz)
WUT
000
010
100
110
*01
*11
Note 1: The warm-up time is obtained by dividing the basic clock by the divider. Therefore, the warm-
up time may include a certain amount of error if there is any fluctuation of the oscillation frequency when STOP mode is released. Thus, the warm-up time must be considered as an approximate value.
Return to NORMAL ModeReturn to SLOW Mode
12.288
4.096
3.072
1.024
0.192
0.064
Warm-up Time [ms]
750
250
5.85
1.95
5.9
2.0
Page 18
Turn off
TMP86FH47BUG
a + 3
Halt
0n
n + 2n + 3n + 4
a + 6
Instruction address a + 4
a + 5
Instruction address a + 3
a + 4
Instruction address a + 2
3
2
1
(b) STOP mode release
0
Turn on
Oscillator
circuit
Main
system
clock
a + 2
Program
counter
Instruction
SET (SYSCR1). 7
(a) STOP mode start (Example: Start with SET (SYSCR1). 7 instruction located at address a)
n + 1
Warm up
Turn on
Turn off
execution
Divider
STOP pin
input
Oscillator
circuit
Main
system
Figure 2-9 STOP Mode Start/Release
clock
a + 3
Halt
Program
counter
Count up
0
Instruction
execution
Divider
Page 19
2. Operational Description
2.2 System Clock Controller
2.2.4.2 IDLE1/2 mode and SLEEP1/2 mode
TMP86FH47BUG
IDLE1/2 and SLEEP1/2 modes are controlled by the system control register 2 (SYSCR2) and maska-
ble interrupts. The following status is maintained during these modes.
1. Operation of the CPU and watchdog timer (WDT) is halted. On-chip peripherals continue to operate.
2. The data memory, CPU registers, program status word and port output latches are all held in
the status in effect before these modes were entered.
3. The program counter holds the address 2 ahead of the instruction which starts these modes.
Starting IDLE1/2 and
SLEEP1/2 modes by
instruction
Normal
release mode
CPU and WDT are halted
Reset input
No
No
Interrupt request
Yes
“0”
Execution of the instruc-
IDLE1/2 and SLEEP1/2
modes start instruction
IMF
Interrupt processing
tion which follows the
Yes
Reset
“1” (Interrupt release mode)
Figure 2-10 IDLE1/2 and SLEEP1/2 Modes
Page 20
TMP86FH47BUG
・
Start the
IDLE1/2 and SLEEP1/2 modes
After IMF is set to "0", set the individual interrupt enable flag (EF) which releases IDLE1/2
and SLEEP1/2 modes. To start IDLE1/2 and SLEEP1/2 modes, set SYSCR2<IDLE> to “1”.
Release the IDLE1/2 and SLEEP1/2 modes
・
IDLE1/2 and SLEEP1/2 modes include a normal release mode and an interrupt release
mode. These modes are selected by interrupt master enable flag (IMF). After releasing
IDLE1/2 and SLEEP1/2 modes, the SYSCR2<IDLE> is automatically cleared to “0” and the operation mode is returned to the mode preceding IDLE1/2 and SLEEP1/2 modes.
IDLE1/2 and SLEEP1/2 modes can also be released by inputting low level on the
pin. After
releasing reset, the operation mode is started from NORMAL1 mode.
RESET
(1) Normal release mode (IMF = “0”)
IDLE1/2 and SLEEP1/2 modes are released by any interrupt source enabled by the individual interrupt enable flag (EF). After the interrupt is generated, the program operation is resumed from the instruction following the IDLE1/2 and SLEEP1/2 modes start instruction. Normally, the interrupt latches (IL) of the interrupt source used for releasing must be cleared to “0” by load instructions.
(2) Interrupt release mode (IMF = “1”)
IDLE1/2 and SLEEP1/2 modes are released by any interrupt source enabled with the individual interrupt enable flag (EF) and the interrupt processing is started. After the interrupt is processed, the program operation is resumed from the instruction following the instruction, which starts IDLE1/2 and
SLEEP1/2 modes.
Note:When a watchdog timer interrupts is generated immediately before IDLE1/2 and SLEEP1/2
modes are started, the watchdog timer interrupt will be processed but IDLE1/2 and
SLEEP1/2 modes will not be started.
Page 21
2. Operational Description
2.2 System Clock Controller
TMP86FH47BUG
Halt
a + 3
a + 2
Operate
SET (SYSCR2). 4
a + 4 a + 3
Instruction address a + 2
Operate
Acceptance of interrupt
Operate
Operate
(b) IDLE1/2 and SLEEP1/2 modes release
㽲㩷Normal release mode
(a) IDLE1/2 and SLEEP1/2 modes start (Example: Starting with the SET instruction located at address a)
Halt
Halt
a + 3
Halt
㽳㩷Interrupt release mode
Halt
Main
system
clock
Interrupt
request
Program
counter
Instruction
execution
Watchdog
timer
Main
system
clock
Interrupt
request
Program
counter
Instruction
execution
Watchdog
timer
Main
system
clock
Interrupt
Figure 2-11 IDLE1/2 and SLEEP1/2 Modes Start/Release
Page 22
request
Program
counter
Instruction
execution
Watchdog
timer
2.2.4.3 IDLE0 and SLEEP0 modes (IDLE0, SLEEP0)
IDLE0 and SLEEP0 modes are controlled by the system control register 2 (SYSCR2) and the time
base timer control register (TBTCR). The following status is maintained during IDLE0 and SLEEP0
modes.
1. Timing generator stops feeding clock to peripherals except TBT.
2. The data memory, CPU registers, program status word and port output latches are all held in
the status in effect before IDLE0 and SLEEP0 modes were entered.
3. The program counter holds the address 2 ahead of the instruction which starts IDLE0 and
SLEEP0 modes.
Note:Before starting IDLE0 or SLEEP0 mode, be sure to stop (Disable) peripherals.
Stopping peripherals
by instruction
TMP86FH47BUG
(Normal release mode)
Starting IDLE0, SLEEP0
modes by instruction
CPU and WDT are halted
Reset input
No
No
No
No
No
TBT
source clock
falling
edge
Yes
TBTCR<TBTEN>
= "1"
Yes
TBT interrupt
enable
Yes
IMF = "1"
Yes (Interrupt release mode)
Yes
Reset
Interrupt processing
Execution of the instruction
which follows the IDLE0,
SLEEP0 modes start
instruction
Figure 2-12 IDLE0 and SLEEP0 Modes
Page 23
2. Operational Description
2.2 System Clock Controller
TMP86FH47BUG
・
Start the
IDLE0 and SLEEP0 mode s
Stop (Disable) peripherals such as a timer counter.
To start IDLE0 and SLEEP0 mode s, set SYSCR2<TGHALT> to “1”.
Release the IDLE0 and SLEEP0 mode s
・
IDLE0 and SLEEP0 mode s include a normal release mode and an interrupt release mode.
These modes are selected by interrupt master flag (IMF), the individual interrupt enable
flag of TBT and TBTCR<TBTEN>.
After releasing IDLE0 and SLEEP0 mode s, the SYSCR2<TGHALT> is automatically
cleared to “0” and the operation mode is returned to the mode preceding IDLE0 and SLEEP0
mode s. Before starting the IDLE0 or SLEEP0 mode, when the TBTCR<TBTEN> is set to
“1”, INTTBT interrupt latch is set to “1”.
IDLE0 and SLEEP0 mode s can also be released by inputting low level on the
ter releasing
Note:IDLE0 and SLEEP0 mode s start/release without reference to TBTCR<TBTEN> setting.
reset, the operation mode is started from NORMAL1 mode.
RESET pin. Af-
(1) Normal release mode (IMF・EF6・TBTCR<TBTEN> = “0”)
IDLE0 and SLEEP0 mode s are released by the source clock falling edge, which is setting by the
TBTCR<TBTCK>. After the falling edge is detected, the program operation is resumed from the instruction following the IDLE0 and SLEEP0 mode s start instruction. Before starting the IDLE0 or
SLEEP0 mode, when the TBTCR<TBTEN> is set to “1”, INTTBT interrupt latch is set to “1”.
IDLE0 and SLEEP0 mode s are released by the source clock falling edge, which is setting by the
TBTCR<TBTCK> and INTTBT interrupt processing is started.
Note 1: Because returning from IDLE0, SLEEP0 to NORMAL1, SLOW1 is executed by the asynchro-
Note 2: When a watchdog timer interrupt is generated immediately before IDLE0/SLEEP0 mode is star-
nous internal clock, the period of IDLE0, SLEEP0 mode might be the shorter than the period setting by TBTCR<TBTCK>.
ted, the watchdog timer interrupt will be processed but IDLE0/SLEEP0 mode will not be started.
Page 24
a + 3
TMP86FH47BUG
Halt
a + 2
SET (SYSCR2). 2
Operate
(a) IDLE0 and SLEEP0 modes start (Example: Starting with the SET instruction located at address a
a + 4 a + 3
Instruction address a + 2
Operate
Halt
Halt
㽲㩷Normal release mode
Acceptance of interrupt
a + 3
Halt
Halt
Operate
㽳㩷Interrupt release mode
(b) IDLE and SLEEP0 modes release
system
clock
Interrupt
request
Program
counter
Instruction
execution
Figure 2-13 IDLE0 and SLEEP0 Modes Start/Release
2.2.4.4 SLOW mode
SLOW mode is controlled by the system control register 2 (SYSCR2).
Watchdog
timer
Main
system
clock
TBT clock
Program
counter
Page 25
Instruction
execution
Watchdog
timer
Main
system
clock
TBT clock
Program
counter
Instruction
execution
Watchdog
timer
2. Operational Description
2.2 System Clock Controller
TMP86FH47BUG
The following is the methods to switch the mode with the warm-up counter.
(1) Switching
from NORMAL2 mode to SLOW1 mode
First, set SYSCR2<SYSCK> to switch the main system clock to the low-frequency clock for
SLOW2 mode. Next, clear SYSCR2<XEN> to turn off high-frequency oscillation.
Note:The high-frequency clock can be continued oscillation in order to return to NORMAL2 mode
from SLOW mode quickly. Always turn off oscillation of high-frequency clock when switching
from SLOW mode to stop mode.
Example 1 :Switching from NORMAL2 mode to SLOW1 mode.
SET(SYSCR2). 5
CLR(SYSCR2). 7; SYSCR2<XEN> ← 0 (Turns off high-frequency oscillation)
; SYSCR2<SYSCK> ← 1 (Switches the main system clock to the lowfrequency clock
for SLOW2)
Example 2 :Switching to the SLOW1 mode after low-frequency clock has stabilized.
SET(SYSCR2). 6; SYSCR2<XTEN> ← 1
LD(TC3CR), 43H; Sets mode for TC4, 3 (16-bit mode, fs for source)
LD(TC4CR), 05H; Sets warming-up counter mode
LDW(TTREG3), 8000H; Sets warm-up time (Depend on oscillator accompanied)
DI; IMF ← 0
SET(EIRH). 1; Enables INTTC4
EI; IMF ← 1
SET(TC4CR). 3; Starts TC4, 3
:
PINTTC4:CLR(TC4CR). 3; Stops TC4, 3
SET(SYSCR2). 5
CLR(SYSCR2).
RETI
:
VINTTC4:DWPINTTC4; INTTC4 vector table
7; SYSCR2<XEN> ← 0 (Turns off high-frequency oscillation)
; SYSCR2<SYSCK> ← 1 (Switches the main system clock to the lowfrequency
clock)
Page 26
TMP86FH47BUG
(2) Switching from SLOW1 mode to NORMAL2 mode
First, set SYSCR2<XEN> to turn on the high-frequency oscillation. When time for stabilization (Warm up) has been taken by
the timer/counter (TC4,TC3), clear SYSCR2<SYSCK> to switch the main system clock to the high-frequency clock.
SLOW mode can also be released by inputting low level on the
ted from NORMAL1 mode.
RESET pin. After releasing reset, the operation mode is star-
Note:After SYSCR2<SYSCK> is cleared to 0, instructions are executed continuously by the low-fre-
quency clock during synchronization period for high-frequency and low-frequency clocks.
High-frequency clock
Low-frequency clock
Main system clock
SYSCK
Example :Switching from the SLOW1 mode to the NORMAL2 mode (fc = 16 MHz, warm-up time is 4.0 ms).
LD(TC3CR), 63H; Sets mode for TC4, 3 (16-bit mode, fc for source)
LD(TC4CR), 05H; Sets warming-up counter mode
LD( TTREG4), 0F8H; Sets warm-up time
DI; IMF ← 0
SET(EIRH). 1; Enables INTTC4
EI; IMF ← 1
SET(TC4CR). 3; Starts TC4, 3
:
PINTTC4:CLR(TC4CR). 3; Stops TC4, 3
CLR(SYSCR2). 5
RETI
:
VINTTC4:DWPINTTC4; INTTC4 vector table
; SYSCR2<SYSCK> ← 0 (Switches the main system clock to the highfrequency clock)
Page 27
High-
2. Operational Description
2.2 System Clock Controller
Turn off
SLOW1 mode
TMP86FH47BUG
NORMAL2
mode
CLR (SYSCR2). 7
SLOW2 mode
(a) Switching to the SLOW mode
SET (SYSCR2). 5
CLR (SYSCR2). 5
Warm up during SLOW2 mode
(b) Switching to the NORMAL2 mode
SET (SYSCR2). 7
NORMAL2
mode
frequency
clock
Low-
frequency
clock
Main
system
clock
SYSCK
XEN
Instruction
execution
High-
frequency
clock
Low-
frequency
clock
Main
system
clock
SYSCK
XEN
Instruction
execution
Figure 2-14 Switching between the NORMAL2 and SLOW Modes
Page 28
SLOW1 mode
TMP86FH47BUG
2.3 Reset Circuit
The TMP86FH47BUG has four types of reset generation procedures: An external reset input, an address trap reset, a watchdog timer reset and a system clock reset. Of these reset, the address trap reset, the watchdog timer and
the system clock reset are a malfunction reset. When the malfunction reset request is detected, reset occurs during
the maximum 24/fc[s] (The RESET pin outputs "L" level).
The malfunction reset circuit such as watchdog timer reset, address trap reset and system clock reset is not initialized when power is turned on. Therefore, reset may occur during maximum 24/fc[s] (1.5μs at 16.0 MHz) when power is turned on.
Table 2-3 shows on-chip hardware initialization by reset action.
Table 2-3 Initializing Internal Status by Reset Action
RESET pin outputs "L" level during maximum 24/fc[s] (1.5μs at 16.0MHz).
On-chip Hardware
Program counter(PC)(FFFEH)
Stack pointer(SP) Not initialized
General-purpose registers
(W, A, B, C, D, E, H, L, IX, IY)
Jump status flag(JF) Not initialized Watchdog timerEnable
Zero flag(ZF) Not initialized
Carry flag(CF) Not initialized
Half carry flag(HF) Not initialized
Sign flag(SF) Not initialized
Overflow flag(VF) Not initialized
Interrupt master enable flag(IMF)0
Interrupt individual enable flags(EF)0
Interrupt latches(IL)0
RAMNot initialized
2.3.1 External Reset Input
RESET pin contains a Schmitt trigger (Hysteresis) with an internal pull-up resistor.
The
Initial ValueOn-chip HardwareInitial Value
Prescaler and divider of timing generator0
Not initialized
Output latches of I/O portsRefer to I/O port circuitry
Control registers
Refer to each of control
register
When the
RESET pin is held at “L” level for at least 3 machine cycles (12/fc [s]) with the power supply volt-
age within the operating voltage range and oscillation stable, a reset is applied and the internal state is initialized.
Whenthe
RESET pin input goes high, the reset operation is released and the program execution starts at
the vector address stored at addresses FFFEH to FFFFH.
VDD
RESET
Internal reset
Malfunction
reset output
circuit
Watchdog timer reset
Address trap reset
System clock reset
Figure 2-15 Reset Circuit
Page 29
Instruction
2. Operational Description
2.3 Reset Circuit
2.3.2 Address trap reset
tion from the on-chip RAM (when WDTCR1<ATAS> is set to “1”), DBR or the SFR area, address trap reset will be generated. The reset time is maximum 24/fc[s] (1.5μs at 16.0 MHz). Then, the
puts "L" level during maximum 24/fc[s].
TMP86FH47BUG
If the CPU should start looping for some cause such as noise and an attempt be made to fetch an instruc-
RESET pin out-
Note:The operating mode under address trapped is alternative of reset or interrupt. The address trap area
is alternative.
execution
RESET output
Internal reset
signal
Note 1: Address “a” is in the SFR, DBR or on-chip RAM (WDTCR1<ATAS> = “1”) space.
Note 2: During reset release, reset vector “r” is read out, and an instruction at address “r” is fetched and decoded.
Note 3: Varies on account of external condition: voltage or capacitance
JP a
Address trap is occurred
("L" output)
4/fc to 12/fc [s]
Note 3
Reset release
16/fc [s]Maximum 24/fc [s]
Instruction at address r
Figure 2-16 Address Trap Reset
2.3.3 Watchdog timer reset
Refer to Section “Watchdog Timer”.
2.3.4 System clock reset
If the condition as follows is detected, the system clock reset occurs automatically to prevent dead lock of
the CPU. (The oscillation is continued without stopping.)
-In case of clearing SYSCR2<XEN> and SYSCR2<XTEN> simultaneously to “0”.
-In case of clearing SYSCR2<XEN> to “0”, when the SYSCR2<SYSCK> is “0”.
-In case of clearing SYSCR2<XTEN> to “0”, when the SYSCR2<SYSCK> is “1”.
The reset time is maximum 24/fc (1.5 μs at 16.0 MHz). Then, the
RESET pin outputs "L" level during max-
imum 24/fc[s] (1.5μs at 16.0MHz).
Page 30
3.Interrupt Control Circuit
TMP86FH47BUG
The TMP86FH47BUG
has a total of 18 interrupt sources excluding reset, of which 2 source levels are multiplexed. Interrupts can be nested with priorities. Four of the internal interrupt sources are non-maskable while the
rest are maskable.
Interrupt sources are provided with interrupt latches (IL), which hold interrupt requests, and independent vectors. The interrupt latch is set to “1” by the generation of its interrupt request which requests the CPU to accept
its interrupts. Interrupts are enabled or disabled by software using the interrupt master enable flag (IMF) and interrupt enable flag (EF). If more than one interrupts are generated simultaneously, interrupts are accepted in order
which is dominated by hardware. However, there are no prioritized interrupt factors among non-maskable interrupts.
INTUNDEF (Executed the undefined instruction
interrupt)
Enable Condition
Non-maskable-FFFC2
IMF・ EF4 = 1, INT0EN = 1
IMF・ EF5 = 1
IMF・
EF6 = 1
IMF・ EF7 = 1
IMF・ EF8 = 1
IMF・ EF9 = 1
IMF・ EF10 = 1
IMF・ EF11 = 1
IMF・ EF12 = 1
IMF・ EF13 = 1
IMF・ EF14 = 1, IL14ER = 0
IMF・ EF14 = 1, IL14ER = 1
IMF・ EF15 = 1, IL15ER = 0
IMF・ EF15 = 1, IL15ER = 1
Interrupt
Latch
IL4FFF65
IL5FFF46
IL6FFF27
IL7FFF08
IL8FFEE9
IL9FFEC10
IL10FFEA11
IL11FFE812
IL12FFE613
IL13FFE414
IL14FFE215
IL15FFE016
Vector Ad-
dress
Priority
Note 1: The INTSEL register is used to select the interrupt source to be enabled for each multiplexed source level (see 3.3 In-
terrupt Source
Selector (INTSEL)).
Note 2: To use the address trap interrupt (INTATRAP), clear WDTCR1<ATOUT> to “0” (It is set for the “reset request” after re-
set is cancelled). For details, see “Address Trap”.
Note 3: To use the watchdog timer interrupt (INTWDT), clear WDTCR1<WDTOUT> to "0" (It is set for the "Reset request" af-
ter reset is released). For details, see "Watchdog Timer".
3.1 Interrupt latches (IL15 to IL2)
An interrupt
fined instruction interrupt. When interrupt request is generated, the latch is set to “1”, and the CPU is requested
to accept the interrupt if its interrupt is enabled. The interrupt latch is cleared to "0" immediately after accepting interrupt. All interrupt latches are initialized to “0” during reset.
The interrupt latches are located on address 003CH and 003DH in SFR area. Each latch can be cleared to "0" individually by instruction. However, IL2 and IL3 should not be cleared to "0" by software. For clearing the interrupt latch, load instruction should be used and then IL2 and IL3 should be set to "1". If the read-modify-write instructions such as bit manipulation or operation instructions are used, interrupt request would be cleared inadequately
if interrupt is requested while such instructions are executed.
Interrupt latches are not set to “1” by an instruction.
latch is provided for each interrupt source, except for a software interrupt and an executed the unde-
Page 31
3. Interrupt Control Circuit
3.2 Interrupt enable register (EIR)
Since interrupt latches can be read, the status for interrupt requests can be monitored by software.
TMP86FH47BUG
Note:In main
program, before manipulating the interrupt enable flag (EF) or the interrupt latch (IL), be sure to
clear IMF to "0" (Disable interrupt by DI instruction). Then set IMF newly again as required after operating
on the EF or IL (Enable interrupt by EI instruction)
In interrupt service routine, because the IMF becomes "0" automatically, clearing IMF need not execute normally on interrupt service routine. However, if using multiple interrupt on interrupt service routine, manipulating
EF or IL should be executed before setting IMF="1".
Example 1 :Clears interrupt latches
DI; IMF ← 0
LDW(ILL), 1110100000111111B; IL12, IL10 to IL6 ← 0
EI; IMF ← 1
Example 2 :Reads interrupt latches
LDWA, (ILL); W ← ILH, A ← ILL
Example 3 :Tests interrupt latches
TEST(ILL). 7; if IL7 = 1 then jump
JRF, SSET
3.2 Interrupt enable register (EIR)
The interrupt enable register (EIR) enables and disables the acceptance of interrupts, except for the non-maskable interrupts (Software interrupt, undefined instruction interrupt, address trap interrupt and watchdog interrupt).
Non-maskable interrupt is accepted regardless of the contents of the EIR.
The EIR consists of an interrupt master enable flag (IMF) and the individual interrupt enable flags (EF). These registers are located on address 003AH and 003BH in SFR area, and they can be read and written by an instructions
(Including read-modify-write instructions such as bit manipulation or operation instructions).
3.2.1 Interrupt master enable flag (IMF)
The interrupt enable register (IMF) enables and disables the acceptance of the whole maskable interrupt.
While IMF = “0”, all maskable interrupts are not accepted regardless of the status on each individual interrupt enable flag (EF). By setting IMF to “1”, the interrupt becomes acceptable if the individuals are enabled.
When an interrupt is accepted, IMF is cleared to “0” after the latest status on IMF is stacked. Thus the maskable interrupts which follow are disabled. By executing return interrupt instruction [RETI/RETN], the stacked
data, which was the status before interrupt acceptance, is loaded on IMF again.
The IMF is located on bit0 in EIRL (Address: 003AH in SFR), and can be read and written by an instruction. The IMF is normally set and cleared by [EI] and [DI] instruction respectively. During reset, the IMF is initialized to “0”.
3.2.2 Individual interrupt enable flags (EF15 to EF4)
Each of these flags enables and disables the acceptance of its maskable interrupt. Setting the corresponding bit of an individual interrupt enable flag to “1” enables acceptance of its interrupt, and setting the bit to
“0” disables acceptance. During reset, all the individual interrupt enable flags (EF15 to EF4) are initialized
to “0” and all maskable interrupts are not accepted until they are set to “1”.
Note:In main program, before manipulating the interrupt enable flag (EF) or the interrupt latch (IL), be
sure to clear IMF to "0" (Disable interrupt by DI instruction). Then set IMF newly again as required after operating on the EF or IL (Enable interrupt by EI instruction)
Page 32
In interrupt service routine, because the IMF becomes "0" automatically, clearing IMF need not execute normally
on interrupt service routine. However, if using multiple interrupt on interrupt service rou-
tine, manipulating EF or IL should be executed before setting IMF="1".
Example 1 :Enables interrupts individually and sets IMF
DI; IMF ← 0
LDW
:
:
EI; IMF ← 1
(EIRL), 1110100010100000B
Example 2 :C compiler description example
unsigned int _io (3AH) EIRL;/* 3AH shows EIRL address */
_DI();
EIRL = 10100000B;
:
_EI();
TMP86FH47BUG
; EF15 to EF13, EF11, EF7, EF5 ← 1
Note: IMF should not be set.
Interrupt Latches
(Initial value: 00000000 000000**)
ILH,ILL
(003DH,
003CH)
ILH (003DH)ILL (003CH)
1514
IL15
13121110987654
IL14IL13IL12IL11IL10IL9IL8IL7IL6IL5IL4IL3IL2
IL15 to IL2
Interrupt latches
at RD
interrupt request
0: No
1: Interrupt request
at WR
0: Clears
1: (Interrupt latch is not set.)
32
the interrupt request
Note 1: To clear any one of bits IL7 to IL4, be sure to write "1" into IL2 and IL3.
Note 2: In main program, before manipulating the interrupt enable flag (EF) or the interrupt latch (IL), be sure to clear IMF to
"0" (Disable interrupt by DI instruction). Then set IMF newly again as required after operating on the EF or IL (Enable
interrupt by EI instruction)
In interrupt service routine, because the IMF becomes "0" automatically, clearing IMF need not execute normally on interrupt service routine. However, if using multiple interrupt on interrupt service routine, manipulating EF or IL should
be executed before setting IMF="1".
Note 3: Do not clear IL with read-modify-write instructions such as bit operations.
not set IMF and the interrupt enable flag (EF15 to EF4) to “1” at the same time.
Do
Individual-interrupt enable flag
(Specified for
IMFInterrupt master enable flag
each bit)
Page 33
0:1:Disables the acceptance of each maskable interrupt.
Enables the
0:1:Disables the acceptance of all maskable interrupts
Enables the
acceptance of each maskable interrupt.
acceptance of all maskable interrupts
R/W
3. Interrupt Control Circuit
3.2 Interrupt enable register (EIR)
TMP86FH47BUG
Note 3: In main program, before manipulating the interrupt enable flag (EF) or the interrupt latch (IL), be sure to clear IMF to
"0" (Disable interrupt
interrupt by EI instruction)
In interrupt service routine, because the IMF becomes "0" automatically, clearing IMF need not execute normally on interrupt service routine. However, if using multiple interrupt on interrupt service routine, manipulating EF or IL should
be executed before setting IMF="1".
by DI instruction). Then set IMF newly again as required after operating on the EF or IL (Enable
Page 34
3.3 Interrupt Source Selector (INTSEL)
TMP86FH47BUG
Each interrupt
source that shares the interrupt source level with another interrupt source is allowed to enable
the interrupt latch only when it is selected in the INTSEL register. The interrupt controller does not hold interrupt
requests corresponding to interrupt sources that are not selected in the INTSEL register. Therefore, the INTSEL register must be set appropriately before interrupt requests are generated.
The following interrupt sources share their interrupt source level; the source is selected on the register INTSEL.
1. INT4 and INTTXD share the interrupt source level whose priority is 15.
2.
INT5 and INTADC share the interrupt source level whose priority is 16.
Interrupt source selector
INTSEL
(003EH)
7
-
6543210
-----IL14ERIL15ER (Initial value: **** **00)
IL14ER
IL15ERSelects INT5 or INTADC
Selects INT4 or INTTXD
0: INT4
1: INTTXD
0: INT5
1: INTADC
R/W
R/W
3.4 Interrupt Sequence
An interrupt request, which raised interrupt latch, is held, until interrupt is accepted or interrupt latch is cleared
to “0” by resetting or an instruction. Interrupt acceptance sequence requires 8 machine cycles (2 μs @16 MHz) after the completion of the current instruction. The interrupt service task terminates upon execution of an interrupt return instruction [RETI] (for maskable interrupts) or [RETN] (for non-maskable interrupts). Figure 3-1 shows the timing chart of interrupt acceptance processing.
3.4.1 Interrupt acceptance processing is packaged as follows.
a. The interrupt master enable flag (IMF) is cleared to “0” in order to disable the acceptance of any fol-
lowing interrupt.
b. The interrupt latch (IL) for the interrupt source accepted is cleared to “0”.
c. The contents of the program counter (PC) and the program status word, including the interrupt mas-
ter enable flag (IMF), are saved (Pushed) on the stack in sequence of PSW + IMF, PCH, PCL. Meanwhile, the stack pointer (SP) is decremented by 3.
d. The entry address (Interrupt vector) of the corresponding interrupt service program, loaded on the vec-
tor table, is transferred to the program counter.
e. The instruction stored at the entry address of the interrupt service program is executed.
Note:When the contents of PSW are saved on the stack, the contents of IMF are also saved.
Page 35
3. Interrupt Control Circuit
3.4 Interrupt Sequence
TMP86FH47BUG
Interrupt service task
c+1
Execute RETI instruction
c+2
a
a+2a+1
n
Interrupt
request
Interrupt
latch (IL)
IMF
Execute
instruction
PC
SP
1-machine cycle
Execute
instruction
a − 1
b+1
Execute
instruction
b+2
b + 3
Interrupt acceptance
a+1a
a
b
n − 2n - 3n − 2 n − 1n − 1n
Note 1: a: Return address, b: Entry address, c: Address which RETI instruction is stored
Note 2: On condition that interrupt is enabled, it takes 38/fc [s] or 38/fs [s] at maximum (If the interrupt latch is set at the
first machine cycle on 10 cycle instruction) to start interrupt acceptance processing since its interrupt latch is set.
Figure 3-1 Timing Chart of Interrupt Acceptance/Return Interrupt Instruction
Example: Correspondence between vector table address for INTTBT and the entry address of the interrupt
service program
Vector table addressEntry address
FFF2H
FFF3H
03HD203H
Vector
D2H
Figure 3-2 Vector table address,Entry address
A maskable interrupt is not accepted until the IMF is set to “1” even if the maskable interrupt higher than
the level of current servicing interrupt is requested.
In order to utilize nested interrupt service, the IMF is set to “1” in the interrupt service program. In this
case, acceptable interrupt sources are selectively enabled by the individual interrupt enable flags.
To avoid overloaded nesting, clear the individual interrupt enable flag whose interrupt is currently serviced, before setting IMF to “1”. As for non-maskable interrupt, keep interrupt service shorten compared with
length between interrupt requests; otherwise the status cannot be recovered as non-maskable interrupt would
simply nested.
3.4.2 Saving/restoring general-purpose registers
0FH
D204H06H
Interrupt
service
program
During interrupt acceptance processing, the program counter (PC) and the program status word (PSW, includes IMF) are automatically saved on the stack, but the accumulator and others are not. These registers are
saved by software if necessary. When multiple interrupt services are nested, it is also necessary to avoid using the same data memory area for saving registers. The following methods are used to save/restore the generalpurpose registers.
Page 36
3.4.2.1 Using PUSH and POP instructions
If only a specific register is saved or interrupts of the same source are nested, general-purpose registers
can be saved/restored using the PUSH/POP instructions.
Example :Save/store register using PUSH and POP instructions
PINTxx:PUSHWA; Save WA register
(interrupt processing)
POPWA; Restore WA register
RETI; RETURN
TMP86FH47BUG
Address
(Example)
SP
A
SP
At acceptance of
an interrupt
PCL
PCH
PSW
At execution of
PUSH instruction
W
PCL
PCH
PSW
Figure 3-3 Save/store register using PUSH and POP instructions
3.4.2.2 Using data transfer instructions
To save only a specific register without nested interrupts, data transfer instructions are available.
Example :Save/store register using data transfer instructions
PINTxx:LD(GSAVA), A; Save A register
(interrupt processing)
LDA, (GSAVA); Restore A register
RETI; RETURN
SP
At execution of
POP instruction
PCL
PCH
PSW
SP
b-5
b-4
b-3
b-2
b-1
b
At execution of
RETI instruction
Page 37
3. Interrupt Control Circuit
3.4 Interrupt Sequence
Figure 3-4 Saving/Restoring General-purpose Registers under Interrupt Processing
3.4.3 Interrupt return
Main task
Interrupt
acceptance
Interrupt return
Saving/Restoring general-purpose registers using PUSH/POP data transfer instruction
Interrupt
service task
Saving
registers
Restoring
registers
TMP86FH47BUG
Interrupt return instructions [RETI]/[RETN] perform as follows.
[RETI]/[RETN] Interrupt Return
1. Program counter (PC) and program status word
(PSW, includes IMF) are restored from the stack.
2. Stack pointer (SP) is incremented by 3.
As for address trap interrupt (INTATRAP), it is required to alter stacked data for program counter (PC) to
restarting address, during interrupt service program.
Note:If [RETN] is executed with the above data unaltered, the program returns to the address trap area
and INTATRAP occurs again. When interrupt acceptance processing has completed, stacked data
for PCL and PCH are located on address (SP + 1) and (SP + 2) respectively.
Example 1 :Returning from address trap interrupt (INTATRAP) service program
PINTxx:POPWA; Recover SP by 2
LDWA, Return Address;
PUSHWA; Alter stacked data
(interrupt processing)
RETN; RETURN
Example 2 :Restarting without returning interrupt
(In this case, PSW (Includes IMF) before interrupt acceptance is discarded.)
PINTxx:INCSP; Recover SP by 3
INCSP;
INCSP;
(interrupt processing)
LDEIRL, data; Set IMF to “1” or clear it to “0”
JPRestart Address; Jump into restarting address
Interrupt requests are sampled during the final cycle of the instruction being executed. Thus, the next interrupt can be accepted immediately after the interrupt return instruction is executed.
Page 38
TMP86FH47BUG
Note 1: It is recommended that stack pointer be return to rate before INTATRAP (Increment 3 times), if return in-
Note
terrupt instruction [RETN] is not utilized during interrupt service program under INTATRAP (such as Example 2).
2: When the interrupt processing time is longer than the interrupt request generation time, the interrupt serv-
ice task is performed but not the main task.
3.5 Software Interrupt (INTSW)
Executing the SWI instruction generates a software interrupt and immediately starts interrupt processing
(INTSW is highest prioritized interrupt).
Use the SWI instruction only for detection of the address error or for debugging.
3.5.1 Address error detection
FFH is read if for some cause such as noise the CPU attempts to fetch an instruction from a non-existent memory address during single chip mode. Code FFH is the SWI instruction, so a software interrupt is generated
and an address error is detected. The address error detection range can be further expanded by writing FFH
to unused areas of the program memory. Address trap reset is generated in case that an instruction is fetched
from RAM, DBR or SFR areas.
3.5.2 Debugging
Debugging efficiency can be increased by placing the SWI instruction at the software break point setting address.
3.6 Undefined Instruction Interrupt (INTUNDEF)
Taking code which is not defined as authorized instruction for instruction causes INTUNDEF. INTUNDEF is generated when the CPU fetches such a code and tries to execute it. INTUNDEF is accepted even if non-maskable interrupt is in process. Contemporary process is broken and INTUNDEF interrupt process starts, soon after it is requested.
Note:The undefined instruction interrupt (INTUNDEF) forces CPU to jump into vector address, as software inter-
rupt (SWI) does.
3.7 Address Trap Interrupt (INTATRAP)
Fetching instruction from unauthorized area for instructions (Address trapped area) causes reset output or address trap interrupt (INTATRAP). INTATRAP is accepted even if non-maskable interrupt is in process. Contemporary process is broken and INTATRAP interrupt process starts, soon after it is requested.
Note:The operating mode under address trapped, whether to be reset output or interrupt processing, is selected
on watchdog timer control register (WDTCR).
3.8 External Interrupts
The TMP86FH47BUG has 6 external interrupt inputs. These inputs are equipped with digital noise reject circuits (Pulse inputs of less than a certain time are eliminated as noise).
Edge selection is also possible with INT1 to INT4. The
terrupt input
Edge selection, noise reject control and
control register
pin or an input/output port, and is configured as an input port during reset.
INT0/P00 pin function selection are performed by the external interrupt
(EINTCR).
Page 39
INT0/P00 pin can be configured as either an external in-
Pulses of less than 2/fc [s] are eliminated as
noise. Pulses
ered to be signals. In the SLOW or the SLEEP
mode, pulses of less than 1/fs [s] are eliminated as noise. Pulses of 3.5/fs [s] or more are
considered to be signals.
Pulses of less than 15/fc or 63/fc [s] are eliminated as
more are considered to be signals. In the
SLOW or the SLEEP mode, pulses of less
than 1/fs [s] are eliminated as noise. Pulses of
3.5/fs [s] or more are considered to be signals.
Pulses of less than 7/fc [s] are eliminated as
noise. Pulses
ered to be signals. In the SLOW or the SLEEP
mode, pulses of less than 1/fs [s] are eliminated as noise. Pulses of 3.5/fs [s] or more are
considered to be signals.
Pulses of less than 7/fc [s] are eliminated as
noise. Pulses
ered to be signals. In the SLOW or the
SLEEP mode, pulses of less than 1/fs [s] are
eliminated as noise. Pulses of 3.5/fs [s] or
more are considered to be signals.
Pulses of less than 7/fc [s] are eliminated as
noise. Pulses
ered to be signals. In the SLOW or the
SLEEP mode, pulses of less than 1/fs [s] are
eliminated as noise. Pulses of 3.5/fs [s] or
more are considered to be signals.
Pulses of less than 2/fc [s] are eliminated as
noise. Pulses
ered to be signals. In the SLOW or the SLEEP
mode, pulses of less than 1/fs [s] are eliminated as noise. Pulses of 3.5/fs [s] or more are
considered to be signals.
of 7/fc [s] or more are consid-
noise. Pulses of 49/fc or 193/fc [s] or
of 25/fc [s] or more are consid-
of 25/fc [s] or more are consid-
of 25/fc [s] or more are consid-
of 7/fc [s] or more are consid-
Note 1: In NORMAL1/2 or IDLE1/2 mode, if a signal with no noise is input on an external interrupt pin, it takes a maximum of
"signal establishment
Note 2: When INT0EN = "0", IL4 is not set even if a falling edge is detected on the
Note 3: When
a pin with more than one function is used as an output and a change occurs in data or input/output status, an in-
time + 6/fs[s]" from the input signal's edge to set the interrupt latch.
INT0 pin input.
terrupt request signal is generated in a pseudo manner. In this case, it is necessary to perform appropriate processing such as disabling the interrupt enable flag.
0: Pulses of less than 63/fc [s] are eliminated as noise
1: Pulses
0: P00 input/output port
1: INT0 pin (Port P00 should be set to an input mode)
00: Rising edge
01: Falling
10: Rising edge and Falling edge
11: H level
0: Rising edge
1: Falling
0: Rising edge
1: Falling
0: Rising edge
1: Falling edge
of less than 15/fc [s] are eliminated as noise
edge
edge
edge
R/W
R/W
R/W
R/W
R/W
R/W
Page 40
Note 1: fc: High-frequency clock [Hz], *: Don’t care
Note 2: When
Note 3: The maximum time from modifying INT1NC until a noise reject time is changed is 26/fc.
Note 4: In case
the system clock frequency is switched between high and low or when the external interrupt control register
(EINTCR) is overwritten, the noise canceller may not operate normally. It is recommended that external interrupts are
disabled using the interrupt enable register (EIR).
RESET pin is released while the state of INT4 pin keeps "H" level, the external interrupt 4 request is not gen-
erated even
if the INT4 edge select is specified as "H" level. The rising edge is needed after
TMP86FH47BUG
RESET pin is released.
Page 41
3. Interrupt Control Circuit
3.8 External Interrupts
TMP86FH47BUG
Page 42
4.Special Function Register (SFR)
TMP86FH47BUG
The TMP86FH47BUG
adopts the memory mapped I/O system, and all peripheral control and data transfers are
performed through the special function register (SFR) or the data buffer register (DBR). The SFR is mapped on address 0000H to 003FH, DBR is mapped on address 0F80H to 0FFFH.
This chapter shows the arrangement of the special function register (SFR) and data buffer register (DBR) for
TMP86FH47BUG.
4.1 SFR
Address
0000HP0DR
0001HP1DR
0002HP2DR
0003HP3DR
0004HP4DR
0005HReserved
0006HReserved
0007HReserved
0008HP0PRD-
0009HReserved
000AHP2PRD-
000BHReserved
000CHReserved
000DHP1CR
000EHP3CR
000FHP4CR
0010HTC1DRAL
0011HTC1DRAH
0012HTC1DRBL
0013HTC1DRBH
0014HTC1CR
0015HReserved
0016HTC3CR
0017HTC4CR
0018HTTREG3
0019HTTREG4
001AHPWREG3
001BHPWREG4
001CHADCCR1
001DHADCCR2
001EHADCDR2-
001FHADCDR1-
0020HUARTSRUARTCR1
0021H-UARTCR2
0022HRDBUFTDBUF
0023HReserved
0024HReserved
0025HReserved
ReadWrite
Page 43
4. Special Function Register (SFR)
4.1 SFR
TMP86FH47BUG
AddressReadWrite
0026HSIOCR1
0027HSIOSR
0028HSIORDBSIOTDB
0029HReserved
002AHReserved
002BHReserved
002CHReserved
002DHReserved
002EHReserved
002FHReserved
0030HReserved
0031H-STOPCR
0032HReserved
0033HReserved
0034H-WDTCR1
0035H-WDTCR2
0036HTBTCR
0037HEINTCR
0038HSYSCR1
0039HSYSCR2
003AHEIRL
003BHEIRH
003CHILL
003DHILH
003EHINTSEL
003FHPSW
Note 1: Do not access reserved areas by the program.
Note 2: −
; Cannot be accessed.
Note 3: Write-only registers and interrupt latches cannot use the read-modify-write instructions (Bit manipulation instructions
such as SET, CLR, etc. and logical operation instructions such as AND, OR, etc.).
Page 44
4.2 DBR
TMP86FH47BUG
Address
0F80HReserved
: :: :
0F9FHReserved
AddressReadWrite
0FA0HReserved
: :: :
0FBFHReserved
AddressReadWrite
0FC0HReserved
: :: :
0FDFHReserved
AddressReadWrite
0FE0HReserved
0FE1HReserved
0FE2HReserved
0FE3HReserved
0FE4HReserved
0FE5HReserved
0FE6HReserved
0FE7HReserved
0FE8HReserved
0FE9H-FLSSTB
0FEAHSPCR
0FEBHReserved
0FECHReserved
0FEDHReserved
0FEEHReserved
0FEFHReserved
0FF0HReserved
0FF1HReserved
0FF2HReserved
0FF3HReserved
0FF4HReserved
0FF5HReserved
0FF6HReserved
0FF7HReserved
0FF8HReserved
0FF9HReserved
0FFAHReserved
0FFBHReserved
0FFCHReserved
0FFDHReserved
0FFEHReserved
ReadWrite
Page 45
4. Special Function Register (SFR)
4.2 DBR
Note 1: Do not access reserved areas by the program.
Note 2: −
Note 3: Write-only registers and interrupt latches cannot use the read-modify-write instructions (Bit manipulation instructions
; Cannot be accessed.
such as SET, CLR, etc. and logical operation instructions such as AND, OR, etc.).
TMP86FH47BUG
AddressReadWrite
0FFFHFLSCR
Page 46
5.Time Base Timer (TBT)
fc/223 or fs/2
15
fc/221 or fs/2
13
fc/216 or fs/2
8
fc/214 or fs/2
6
fc/213 or fs/2
5
fc/212 or fs/2
4
fc/211 or fs/2
3
fc/29 or fs/2
TBTCR
TBTENTBTCK
3
MPX
Source clock
Falling edge
detector
Time base timer control register
INTTBT
interrupt request
IDLE0, SLEEP0
release request
TMP86FH47BUG
The time
base timer generates time base for key scanning, dynamic displaying, etc. It also provides a time base
timer interrupt (INTTBT).
5.1 Time Base Timer
5.1.1 Configuration
Figure 5-1 Time Base Timer configuration
5.1.2 Control
Base Timer is controlled by Time Base Timer control register (TBTCR).
Note:Selection of divider output frequency (DVOCK) must be made while divider output is disabled (DVOEN="0").
Also, in other words, when changing the state of the divider output frequency from enabled (DVOEN="1") to disable(DVOEN="0"), do
not change the setting of the divider output frequency.
Page 49
5. Time Base Timer (TBT)
5.2 Divider Output (
DVO)
Example :1.95 kHz pulse output (fc = 16.0 MHz)
TMP86FH47BUG
Setting port
LD(TBTCR) , 00000000B; DVOCK ← "00"
LD(TBTCR) , 10000000B; DVOEN ← "1"
Table 5-2 Divider Output Frequency ( Example : fc = 16.0 MHz, fs = 32.768 kHz )
Divider Output Frequency [Hz]
DVOCK
001.953 k1.024 k1.024 k
013.906 k2.048 k2.048 k
107.813 k4.096 k4.096 k
1115.625 k8.192 k8.192 k
NORMAL1/2, IDLE1/2 Mode
DV7CK = 0DV7CK = 1
SLOW1/2, SLEEP1/2
Mode
Page 50
6.Watchdog Timer (WDT)
Watchdog timer control registers
The watchdog timer is a fail-safe system to detect rapidly the CPU malfunctions such as endless loops due to spu-
rious noises or the deadlock conditions, and return the CPU to a system recovery routine.
The watchdog timer signal for detecting malfunctions can be programmed only once as “reset request” or “inter-
rupt request”. Upon the reset release, this signal is initialized to “reset request”.
When the watchdog timer is not used to detect malfunctions, it can be used as the timer to provide a periodic in-
terrupt.
Note:Care must be taken in system design since the watchdog timer functions are not be operated completely
due to effect of disturbing noise.
6.1 Watchdog Timer Configuration
fc/223 or fs/2
fc/221 or fs/2
fc/219 or fs/2
fc/217 or fs/2
Internal reset
15
13
11
9
Selector
2
Binary counters
Clock
Clear
12
Overflow
WDT output
Reset release
R
S
Interrupt request
TMP86FH47BUG
Q
Reset
request
INTWDT
interrupt
request
WDTT
Q
SR
WDTEN
0034
H
WDTCR1WDTCR2
Writing
disable code
Controller
0035
Writing
clear code
H
WDTOUT
Figure 6-1 Watchdog Timer Configuration
Page 51
6. Watchdog Timer (WDT)
6.2 Watchdog Timer Control
6.2 Watchdog Timer Control
The watchdog timer is controlled by the watchdog timer control registers (WDTCR1 and WDTCR2). The watch-
dog timer
6.2.1 Malfunction Detection Methods Using the Watchdog Timer
The CPU malfunction is detected, as shown below.
If the CPU malfunctions such as endless loops or the deadlock conditions occur for some reason, the watchdog timer output is activated by the binary-counter overflow unless the binary counters are cleared. When
WDTCR1<WDTOUT> is set to “1” at this time, the reset request is generated and the
low-level signal,
dog timer interrupt (INTWDT) is generated.
TMP86FH47BUG
is automatically enabled after the reset release.
1. Set the detection time, select the output, and clear the binary counter.
2. Clear the binary counter repeatedly within the specified detection time.
RESET pin outputs a
then internal hardware is initialized. When WDTCR1<WDTOUT> is set to “0”, a watch-
The watchdog timer temporarily stops counting in the STOP mode including the warm-up or IDLE/
SLEEP mode, and automatically restarts (continues counting) when the STOP/IDLE/SLEEP mode is inactivated.
Note:The watchdog timer consists of an internal divider and a two-stage binary counter. When the clear
code 4EH is written, only the binary counter is cleared, but not the internal divider. The minimum binary-counter overflow time, that depends on the timing at which the clear code (4EH) is written to the
WDTCR2 register, may be 3/4 of the time set in WDTCR1<WDTT>. Therefore, write the clear code using a cycle shorter than 3/4 of the time set to WDTCR1<WDTT>.
Example :Setting the watchdog timer detection time to 221/fc [s], and resetting the CPU malfunction detection
LD(WDTCR2), 4EH: Clears the binary counters.
LD(WDTCR1), 00001101B: WDTT ← 10, WDTOUT ← 1
LD(WDTCR2), 4EH: Clears the binary counters (always clears immediately before and
0: Disable (Writing the disable code to WDTCR2 is required.)
1: Enable
NORMAL1/2 mode
DV7CK = 0DV7CK = 1
Watchdog timer detection time
[s]
00225/fc217/fs217/fs
01223/fc215/fs215fs
10221fc213/fs213fs
11219/fc211/fs211/fs
0: Interrupt request
request
1: Reset
SLOW1/2
mode
Note 1: After clearing WDTOUT to “0”, the program cannot set it to “1”.
Note 2: fc:
High-frequency clock [Hz], fs: Low-frequency clock [Hz], *: Don’t care
Note 3: WDTCR1 is a write-only register and must not be used with any of read-modify-write instructions. If WDTCR1 is
read, a don’t care is read.
Note 4: To activate the STOP mode, disable the watchdog timer or clear the counter immediately before entering the STOP
mode. After clearing the counter, clear the counter again immediately after the STOP mode is inactivated.
Note 5: To clear WDTEN, set the register in accordance with the procedures shown in “6.2.3 Watchdog Timer Disable”.
Watchdog Timer Control Register 2
Write
only
Write
only
Write
only
WDTCR2
(0035H)
7
(Initial value: **** ****)
WDTCR2
6543210
Write
Watchdog timer
control code
Note 1: The disable code is valid only when WDTCR1<WDTEN> = 0.
Note 2: *:
Don’t care
Note 3: The binary counter of the watchdog timer must not be cleared by the interrupt task.
Note 4: Write the clear code 4EH using a cycle shorter than 3/4 of the time set in WDTCR1<WDTT>.
6.2.2 Watchdog Timer Enable
Setting WDTCR1<WDTEN> to “1” enables the watchdog timer. Since WDTCR1<WDTEN> is initialized
to “1” during reset, the watchdog timer is enabled automatically after the reset release.
4EH: Clear the watchdog timer binary counter (Clear code)
B1H: Disable
D2H: Enable assigning address trap area
Others: Invalid
the watchdog timer (Disable code)
Write
only
Page 53
6. Watchdog Timer (WDT)
6.2 Watchdog Timer Control
6.2.3 Watchdog Timer Disable
To disable
ister in other procedures causes a malfunction of the micro controller.
Example :Disabling the watchdog timer
TMP86FH47BUG
the watchdog timer, set the register in accordance with the following procedures. Setting the reg-
1. Set the interrupt master flag (IMF) to “0”.
2. Set WDTCR2 to the clear code (4EH).
3. Set WDTCR1<WDTEN> to “0”.
4. Set WDTCR2 to the disable code (B1H).
Note:While the watchdog timer is disabled, the binary counters of the watchdog timer are cleared.
Table 6-1 Watchdog Timer Detection Time (Example: fc = 16.0 MHz, fs = 32.768 kHz)
Watchdog Timer Detection Time[s]
WDTT
DV7CK = 0DV7CK = 1
002.09744
01524.288 m11
10131.072 m250 m250 m
1132.768 m62.5 m62.5 m
NORMAL1/2 mode
6.2.4 Watchdog Timer Interrupt (INTWDT)
When WDTCR1<WDTOUT>
ated by the binary-counter overflow.
A watchdog timer interrupt is the non-maskable interrupt which can be accepted regardless of the interrupt
master flag (IMF).
is cleared to “0”, a watchdog timer interrupt request (INTWDT) is gener-
SLOW
mode
When a watchdog timer interrupt is generated while the other interrupt including a watchdog timer interrupt is already accepted, the new watchdog timer interrupt is processed immediately and the previous interrupt is held pending. Therefore, if watchdog timer interrupts are generated continuously without execution of
the RETN instruction, too many levels of nesting may cause a malfunction of the microcontroller.
To generate a watchdog timer interrupt, set the stack pointer before setting WDTCR1<WDTOUT>.
Example :Setting watchdog timer interrupt
LDSP, 023FH: Sets the stack pointer
LD(WDTCR1), 00001000B: WDTOUT ← 0
Page 54
6.2.5 Watchdog Timer Reset
When a binary-counter overflow occurs while WDTCR1<WDTOUT> is set to “1”, a watchdog timer reset
request is generated. When a watchdog timer reset request is generated, the RESET pin outputs a low-level signal and the internal hardware is reset. The reset time is maximum 24/fc [s] (1.5 μs @ fc = 16.0 MHz).
Note:When a watchdog timer reset is generated in the SLOW1 mode, the reset time is maximum 24/fc
(high-frequency clock) since the high-frequency clock oscillator is restarted. However, when crystals
have inaccuracies upon start of the high-frequency clock oscillator, the reset time should be considered as an approximate value because it has slight errors.
Clock
TMP86FH47BUG
219/fc [s]
217/fc
(WDTT=11)
Binary counter
Overflow
INTWDT interrupt request
(WDTCR1<WDTOUT>= "0")
Internal reset
(WDTCR1<WDTOUT>= "1")
WDT reset output
1
2
Write 4E
301230
(High-Z)
to WDTCR2
H
Figure 6-2 Watchdog Timer Interrupt/Reset
A reset occurs
Page 55
6. Watchdog Timer (WDT)
6.3 Address Trap
6.3 Address Trap
TMP86FH47BUG
The Watchdog
Timer Control Register 1 and 2 share the addresses with the control registers to generate ad-
D2H: Enable address trap area selection (ATRAP control code)
4EH: Clear
B1H: Disable the watchdog timer (WDT disable code)
Others: Invalid
address traps (After setting ATAS to “1”, writing the control code
request
the watchdog timer binary counter (WDT clear code)
Write
only
Write
only
6.3.1 Selection of Address Trap in Internal RAM (ATAS)
WDTCR1<ATAS> specifies
cute an instruction in the internal RAM area, clear WDTCR1<ATAS> to “0”. To enable the
WDTCR1<ATAS> setting, set WDTCR1<ATAS> and then write D2H to WDTCR2.
Executing an instruction in the SFR or DBR area generates an address trap unconditionally regardless of
the setting in WDTCR1<ATAS>.
whether or not to generate address traps in the internal RAM area. To exe-
6.3.2 Selection of Operation at Address Trap (ATOUT)
When an address trap is generated, either the interrupt request or the reset request can be selected by
WDTCR1<ATOUT>.
6.3.3 Address Trap Interrupt (INTATRAP)
While WDTCR1<ATOUT> is “0”, if the CPU should start looping for some cause such as noise and an attempt be made to fetch an instruction from the on-chip RAM (while WDTCR1<ATAS> is “1”), DBR or the
SFR area, address trap interrupt (INTATRAP) will be generated.
An address trap interrupt is a non-maskable interrupt which can be accepted regardless of the interrupt master flag (IMF).
When an address trap interrupt is generated while the other interrupt including an address trap interrupt is already accepted, the new address trap is processed immediately and the previous interrupt is held pending. Therefore, if address trap interrupts are generated continuously without execution of the RETN instruction, too
many levels of nesting may cause a malfunction of the microcontroller.
To generate address trap interrupts, set the stack pointer beforehand.
Page 56
6.3.4 Address Trap Reset
While WDTCR1<ATOUT>
tempt be made to fetch an instruction from the on-chip RAM (while WDTCR1<ATAS> is “1”), DBR or the
SFR area, address trap reset will be generated.
TMP86FH47BUG
is “1”, if the CPU should start looping for some cause such as noise and an at-
When an address trap reset request is generated, the
hardware is
Note:When an address trap reset is generated in the SLOW1 mode, the reset time is maximum 24/fc (high-
reset. The reset time is maximum 24/fc [s] (1.5 μs @ fc = 16.0 MHz).
frequency clock) since the high-frequency clock oscillator is restarted. However, when crystals have inaccuracies upon start of the high-frequency clock oscillator, the reset time should be considered as
an approximate value because it has slight errors.
RESET pin outputs a low-level signal and the internal
Page 57
6. Watchdog Timer (WDT)
6.3 Address Trap
TMP86FH47BUG
Page 58
7.I/O Ports
! " # ! " # ! " #
$
%
! " # ! " # ! " #
&'
$&'
TMP86FH47BUG
The TMP86FH47BUG
Port P08-bit I/O port
Port P18-bit I/O portExternal interrupt input, timer/counter input/output, and divider output
Port P23-bit I/O port
Port P38-bit I/O portAnalog input, and STOP mode release signal input
Port P48-bit I/O port
have 5 parallel input/output ports (35 pins) as follows.
Primary FunctionSecondary Functions
External interrupt input, Serial PROM mode control input, serial and
timer/counter input/output
Low-frequency resonator connections, external interrupt input, and
STOP mode
release signal input
Each output port contains a latch, which holds the output data. All input ports do not have latches, so the external input data should be externally held until the input data is read from outside or reading should be performed several times
before processing. Figure 7-1 shows input/output timing examples.
External data is read from an I/O port in the S1 state of the read cycle during execution of the read instruction.
This timing cannot be recognized from outside, so that transient input such as chattering must be processed by the
program.
Output data changes in the S2 state of the write cycle during execution of the instruction which writes to an I/
O port.
Note:The positions of the read and write cycles may vary, depending on the instruction.
Figure 7-1
Input/Output Timing (Example)
Page 59
7. I/O Ports
7.1 Port P0 (P07 to P00)
7.1 Port P0 (P07 to P00)
TMP86FH47BUG
Port P0
is an 8-bit input/output port which is also used as an external interrupt input, Serial PROM mode con-
trol input, serial interface input/output and timer/counter input/output.
When used as an input port or a secondary function pins, the respective output latch (P0DR) should be set to
“1”. When used as an output port, the respective P0DR bit should be set data. During reset, the output latch is initialized to “1”.
P0 port output latch (P0DR) and P0 port terminal input (P0PRD) are located on their respective address.
When read the output latch data, the P0DR should be read and when read the terminal input data, the P0PRD register should be read. P00 port (
INT0EN (bit
6 in EINTCR). During reset, P00 port (
INT0) can be configured as either an I/O port or as external interrupt input with
INT0) is configured as an input port.
P0DR
(0000H)
R/W
P0PRD
(0008H)
Read only
Figure 7-2 Port P0
76543210
P07
INT4
76543210
P07P06P05P04P03P02P01P00
P06
SCK
P05
SI
P04
SO
P03
TXD
P02
RXD
BOOT
P01
PWM4
TC4
PDO4
PPG4
P00
INT0
(Initial value: 1111 1111)
Page 60
7.2 Port P1 (P17 to P10)
TMP86FH47BUG
Port P1
is an 8-bit input/output port which can be configured as an input or an output in one-bit unit under software control. Input/output mode is specified by the corresponding bit in the port P1 input/output control register
(P1CR). Port P1 is configured as an input if its corresponding P1CR bit is cleared to “0”, and as an output if its corresponding P1CR bit is set to “1”.
During reset, the P1CR is initialized to “0” and port P1 is input mode. The P1 output latches are also initial-
ized to “0”.
Port P1 is also used as an external interrupt input, a timer/counter input/output, and a divider output. When
used as an input port, an external interrupt input or a timer/counter input, the corresponding bit of P1CR is
cleared to “0”.
When used as a timer/counter output or divider output, the corresponding bit of P1CR is set to “1” and beforehand the corresponding output latch should be set to “1”. Data can be written into the output latch regardless of
P1CR contents, therefore initial output data should be written into the output latch before setting P1CR.
Figure 7-3 Port P1
76543210
P1DR
(0001H)
R/W
P1CR
(000DH)
P17
7
P1CR
P16
6543210
(Initial value: 0000 0000)
I/O port for P1 port
(specified for
P15
INT3
each bit)
P14
PPG
P13
DVO
0: Input mode
1: Output
P12
INT2
TC1
mode
P11
INT1
PWM3
PDO3
Note:Ports set to the input mode read the pin states. Ports set to the output mode read the output latch. When in-
and output pin exist in port P1 together, the contents of the output latch which is specified as an in-
put pin
put mode may be rewritten by executing the bit manipulation instructions.
P10
(Initial value: 0000 0000)
TC3
R/W
Page 61
!
"#$#
%&
%&
%&
7. I/O Ports
7.3 Port P2 (P22 to P20)
7.3 Port P2 (P22 to P20)
TMP86FH47BUG
Port P2
is a 3-bit input/output port.
It is also used as an external interrupt, a STOP mode release signal input, and low-frequency crystal oscillator connection pins. When used as an input port or a secondary function pins, respective output latch (P2DR) should be
set to “1”.
During reset, the P2DR is initialized to “1”.
A low-frequency crystal oscillator (32.768 kHz) is connected to pins P21 (XTIN) and P22 (XTOUT) in the dualclock mode. In the single-clock mode, pins P21 and P22 can be used as normal input/output ports.
It is recommended that pin P20 should be used as an external interrupt input, a STOP mode release signal input, or an input port. If it is used as an output port, the interrupt latch is set on the falling edge of the output pulse.
P2 port output latch (P2DR) and P2 port terminal input (P2PRD) are located on their respective address.
When read the output latch data, the P2DR should be read and when read the terminal input data, the P2PRD register should be read. If a read instruction is executed for port P2, read data of bits 7 to 3 are unstable.
P2DR
(0002H)
R/W
P2PRD
(000AH)
Read only
Figure 7-4 Port P2
76543
76543210
P22P21P20
Page 62
210
P22
XTOUT
P21
XTIN
P20
INT5
STOP
(Initial value: **** *111)
7.4 Port P3 (P37 to P30)
Output latch
Data input (P3DR)
Key on wake up
Analog input
Data output (P3DR)
STOP
STOPj
OUTEN
AINDS
SAIN
P3CRi
P3i
Note: i = 7 to 0
j = 5 to 2
Output latch
P3CRi input
DQ
DQ
TMP86FH47BUG
Port P3
is an 8-bit input/output port which can be configured as an input or an output in one-bit unit under software control. Port P3 is also used as an analog input, key on wake up input. Input/output mode is specified by the
corresponding bit in the port P3 input/output control register (P3CR), and ADCCR1<AINDS>. During reset,
P3CR are initialized to “0” and ADCCR1<AINDS> is set to “1”, therefore port P3 is configured as an input.
When used as an analog input, set an analog input channel to ADCCR1<SAIN> and clear ADCCR1<AINDS>
to “0”. When ADCCR1<AINDS> is “0”, the pin which is specified as an analog input is used as analog input independent on the value of P3CR and P3DR.
When used as an input port or key on wake up input, the corresponding bit of P3CR is cleared to “0” without specifying as an analog input.
When the AD converter is enabled (ADCCR1<AINDS> is “0”), the data of port which is selected as an analog
input is read “0”. and the data of port which is not selected as an analog input is read “0” or “1”, depend on the voltage level.
When used as an output port, the corresponding bit of P3CR is set to “1” without specifying as an analog input. Data can be written into the output latch regardless of P3CR contents, therefore initial output data should be written into the output latch before setting P3CR.
The pins not used as analog input can be used as an input/output port. But output instructions should not be executed to keep a precision. In addition, a variable signal should not be input to an adjacent port to the analog input
during AD conversion.
P3DR
(0003H)
R/W
P3CR
(000EH)
Figure 7-5 Port P3
7
P37
AIN7
STOP5
7
(Initial value: 0000 0000)
P3CR
6543210
P36
AIN6
STOP4
6543210
I/O control
(Specified for
P35
AIN5
STOP3
STOP2
each bit)
P34
AIN4
P33
AIN3
0: Input mode
1: Output
P32
AIN2
mode
Page 63
P31
AIN1
P30
(Initial value: 0000 0000)
AIN0
R/W
7. I/O Ports
7.4 Port P3 (P37 to P30)
Note:Ports set to the input mode read the pin states. Ports set to the output mode read the output latch. When in-
put pin
and output pin exist in port P3 together, the contents of the output latch which is specified as an in-
put mode may be rewritten by executing the bit manipulation instructions.
TMP86FH47BUG
Page 64
7.5 Port P4 (P47 to P40)
TMP86FH47BUG
Port P4
is an 8-bit input/output port which can be configured as an input or an output in one-bit unit under software control. Input/output mode is specified by the corresponding bit in the port P4 input/output control register
(P4CR). Port P4 is configured as an input if its corresponding P4CR bit is cleared to “0”, and as an output if its corresponding P4CR bit is set to “1”.
During reset, the P4CR is initialized to “0” and port P4 is input mode. The P4 output latches are also initial-
ized to “0”.
When used as an input port, the corresponding bit of P4CR is cleared to “0”.
When used as an output port, the corresponding bit of P4CR is set to “1”. Data can be written into the output
latch regardless of P4CR contents, therefore initial output data should be written into the output latch before setting P4CR.
Figure 7-6 Port P4
P4DR
(0004H)
R/W
P4CR
(000FH)
Note:Ports set to the input mode read the pin states. Ports set to the output mode read the output latch. When in-
timer register consists of two shift registers. A value set in the timer register becomes valid at the rising edge of
the first source clock pulse that occurs after the upper byte (TC1DRAH and TC1DRBH) is written. Therefore, write
the lower byte and the upper byte in this order (it is recommended to write the register with a 16-bit access instruction). Writing only the lower byte (TC1DRAL and TC1DRBL) does not enable the setting of the timer register.
Page 68
TMP86FH47BUG
Note 3: To set the mode, source clock, PPG output control and timer F/F control, write to TC1CR during TC1S=00. Set the tim-
Note 4: Auto-capture can be used only in the timer, event counter, and window modes.
Note 5: To set the timer registers, the following relationship must be satisfied.
Note 6: Set TFF1 to “0” in the mode except PPG output mode.
Note 7: Set TC1DRB after setting TC1M to the PPG output mode.
Note 8: When the STOP mode is entered, the start control (TC1S) is cleared to “00” automatically, and the timer stops. After
Note 9: Use the auto-capture function in the operative condition of TC1. A captured value may not be fixed if it's read after
Note 10:Since the up-counter value is captured into TC1DRB by the source clock of up-counter after setting
er F/F1
control until the first timer start after setting the PPG mode.
the STOP mode is exited, set the TC1S to use the timer counter again.
the execution of the timer stop or auto-capture disable. Read the capture value in a capture enabled condition.
TC1CR<ACAP1> to "1". Therefore, to read the captured value, wait at least one cycle of the internal source clock before reading TC1DRB for the first time.
Page 69
8. 16-Bit Timer/Counter 1 (TC1)
8.3 Function
8.3 Function
TMP86FH47BUG
TimerCounter 1
has six types of operating modes: timer, external trigger timer, event counter, window, pulse
In the timer mode, the up-counter counts up using the internal clock. When a match between the up-counter and the timer register 1A (TC1DRA) value is detected, an INTTC1 interrupt is generated and the up-counter is cleared. After being cleared, the up-counter restarts counting. Setting TC1CR<ACAP1> to “1” captures
the up-counter value into the timer register 1B (TC1DRB) with the auto-capture function. Use the auto-capture function in the operative condition of TC1. A captured value may not be fixed if it's read after the execution of the timer stop or auto-capture disable. Read the capture value in a capture enabled condition. Since
the up-counter value is captured into TC1DRB by the source clock of up-counter after setting
TC1CR<ACAP1> to "1". Therefore, to read the captured value, wait at least one cycle of the internal source
clock before reading TC1DRB for the first time.
Table 8-1 Internal Source Clock for TimerCounter 1 (Example: fc = 16 MHz, fs = 32.768 kHz)
TC1CK
001288.39244.1416.0244.1416.0
018.00.5248.00.524--
100.532.77 m0.532.77 m--
Resolution
DV7CK = 0DV7CK = 1
Maximum Time Setting
[μs]
NORMAL1/2, IDLE1/2 mode
[s]
Resolution
[μs]
Maximum Time Setting
[s]
SLOW, SLEEP mode
Resolution
[μs]
Maximum
Time
Setting [s]
Example 1 :Setting the timer mode with source clock fc/211 [Hz] and
(fc = 16 MHz, TBTCR<DV7CK> = “0”)
LDW(TC1DRA), 1E84H; Sets the timer register (1 s ÷ 211/fc =
DI; IMF= “0”
SET(EIRL). 7; Enables INTTC1
EI; IMF= “1”
LD(TC1CR), 00000000B; Selects the source clock and mode
LD(TC1CR), 00010000B; Starts TC1
Example 2 :Auto-capture
LD(TC1CR), 01010000B; ACAP1 ← 1
::
LDWA, (TC1DRB); Reads the capture value
Note:Since the up-counter value is captured into TC1DRB by the source clock of up-counter after setting
TC1CR<ACAP1>
source clock before reading TC1DRB for the first time.
"1". Therefore, to read the captured value, wait at least one cycle of the internal
to
generating an interrupt 1 second later
1E84H)
Page 70
Source clock
Counter
0
Timer start
TMP86FH47BUG
n − 1
n
4
12321
63450
7
TC1DRA
?
INTTC1 interruput request
Source clock
Counter
TC1DRB
ACAP1
n
Match detect
Counter clear
(a) Timer mode
m − 2
?
m − 1
m − 1
m
Capture
m
m + 2m + 1
m + 2m + 1n + 1n
n − 1
n − 1
n + 1n
Capture
(b) Auto-capture
Figure 8-2 Timer Mode Timing Chart
Page 71
8. 16-Bit Timer/Counter 1 (TC1)
8.3 Function
8.3.2 External Trigger Timer Mode
In the external trigger timer mode, the up-counter starts counting by the input pulse triggering of the TC1
pin, and counts up at the edge of the internal clock. For the trigger edge used to start counting, either the rising or falling edge is defined in TC1CR<TC1S>.
・
・
TMP86FH47BUG
When TC1CR<METT1> is set to “1” (trigger start and stop)
When a match between the up-counter and the TC1DRA value is detected after the timer starts,
the up-counter is cleared and halted and an INTTC1 interrupt request is generated.
If the edge opposite to trigger edge is detected before detecting a match between the up-counter
and the TC1DRA, the up-counter is cleared and halted without generating an interrupt request. Therefore, this mode can be used to detect exceeding the specified pulse by interrupt.
After being halted, the up-counter restarts counting when the trigger edge is detected.
When TC1CR<METT1> is set to “0” (trigger start)
When a match between the up-counter and the TC1DRA value is detected after the timer starts,
the up-counter is cleared and halted and an INTTC1 interrupt request is generated.
The edge opposite to the trigger edge has no effect in count up. The trigger edge for the next counting is ignored if detecting it before detecting a match between the up-counter and the TC1DRA.
Since the TC1 pin input has the noise rejection, pulses of 4/fc [s] or less are rejected as noise. A pulse
width of 12/fc [s] or more is required to ensure edge detection. The rejection circuit is turned off in the
SLOW1/2 or SLEEP1/2 mode, but a pulse width of one machine cycle or more is required.
Example 1 :Generating an interrupt 1 ms after the rising edge of the input pulse to the TC1 pin
(fc = 16 MHz)
LDW(TC1DRA), 007DH; 1ms ÷ 27/fc =
DI; IMF= “0”
SET(EIRL). 7; Enables INTTC1 interrupt
EI; IMF= “1”
LD(TC1CR), 00000100B; Selects the source clock and mode
In the event counter mode, the up-counter counts up at the edge of the input pulse to the TC1 pin. Either
the rising or falling edge of the input pulse is selected as the count up edge in TC1CR<TC1S>.
When a match between the up-counter and the TC1DRA value is detected, an INTTC1 interrupt is generated and the up-counter is cleared. After being cleared, the up-counter restarts counting at each edge of the input pulse to the TC1 pin. Since a match between the up-counter and the value set to TC1DRA is detected at
the edge opposite to the selected edge, an INTTC1 interrupt request is generated after a match of the value at
the edge opposite to the selected edge.
Two or more machine cycles are required for the low-or high-level pulse input to the TC1 pin.
Setting TC1CR<ACAP1> to “1” captures the up-counter value into TC1DRB with the auto capture function. Use the auto-capture function in the operative condition of TC1. A captured value may not be fixed if
it's read after the execution of the timer stop or auto-capture disable. Read the capture value in a capture enabled condition. Since the up-counter value is captured into TC1DRB by the source clock of up-counter after setting TC1CR<ACAP1> to "1". Therefore, to read the captured value, wait at least one cycle of the internal
source clock before reading TC1DRB for the first time.
TMP86FH47BUG
TC1 pin Input
Up-counter
TC1DRA
INTTC1
interrput request
Timer start
0
?
n
21
n − 1
Match detectCounter clear
Figure 8-4 Event Counter Mode Timing Chart
Table 8-2 Input Pulse Width to TC1 Pin
High-going23/fc23/fs
Low-going23/fc23/fs
NORMAL1/2, IDLE1/2 ModeSLOW1/2, SLEEP1/2 Mode
Minimum Pulse Width [s]
210 n
At the
rising edge
(TC1S = 10)
Page 74
8.3.4 Window Mode
47
31
Count startCount stopCount start
In the window mode, the up-counter counts up at the rising edge of the pulse that is logical ANDed product of the input pulse to the TC1 pin (window pulse) and the internal source clock. Either the positive logic
(count up during high-going pulse) or negative logic (count up during low-going pulse) can be selected.
When a match between the up-counter and the TC1DRA value is detected, an INTTC1 interrupt is generated and the up-counter is cleared.
Define the window pulse to the frequency which is sufficiently lower than the internal source clock programmed with TC1CR<TC1CK>.
Timer start
TC1 pin input
Internal clock
TMP86FH47BUG
Counter
TC1DRA
INTTC1
interrput request
TC1 pin input
Internal clock
Counter
TC1DRA
INTTC1
interrput request
0
Timer start
7
Count startCount stopCount start
9
?
?
21
(a) Positive logic (TC1S = 10)
1
0
(b) Negative logic (TC1S = 11)
3
Figure 8-5 Window Mode Timing Chart
7
546
Match detect
5
0
Counter clear
62
2
8 90
Match detect
3
1
Counter
clear
Page 75
8. 16-Bit Timer/Counter 1 (TC1)
8.3 Function
8.3.5 Pulse Width Measurement Mode
In the pulse width measurement mode, the up-counter starts counting by the input pulse triggering of the
TC1 pin, and counts up at the edge of the internal clock. Either the rising or falling edge of the internal
clock is selected as the trigger edge in TC1CR<TC1S>. Either the single- or double-edge capture is selected
as the trigger edge in TC1CR<MCAP1>.
・
TMP86FH47BUG
When TC1CR<MCAP1> is set to “1” (single-edge capture)
Either high- or low-level input pulse width can be measured. To measure the high-level input
pulse width, set the rising edge to TC1CR<TC1S>. To measure the low-level input pulse width, set
the falling edge to TC1CR<TC1S>.
When detecting the edge opposite to the trigger edge used to start counting after the timer starts,
the up-counter captures the up-counter value into TC1DRB and generates an INTTC1 interrupt request. The up-counter is cleared at this time, and then restarts counting when detecting the trigger
edge used to start counting.
When TC1CR<MCAP1> is set to “0” (double-edge capture)
・
The cycle starting with either the high- or low-going input pulse can be measured. To measure
the cycle starting with the high-going pulse, set the rising edge to TC1CR<TC1S>. To measure the
cycle starting with the low-going pulse, set the falling edge to TC1CR<TC1S>.
When detecting the edge opposite to the trigger edge used to start counting after the timer starts,
the up-counter captures the up-counter value into TC1DRB and generates an INTTC1 interrupt request. The up-counter continues counting up, and captures the up-counter value into TC1DRB and
generates an INTTC1 interrupt request when detecting the trigger edge used to start counting. The
up-counter is cleared at this time, and then continues counting.
Note 1: The captured value must be read from TC1DRB until the next trigger edge is detected. If not read, the cap-
Note 2: For the single-edge capture, the counter after capturing the value stops at “1” until detecting the next
Note 3: The first captured value after the timer starts may be read incorrectively, therefore, ignore the first period
tured value becomes a don’t care. It is recommended to use a 16-bit access instruction to read the captured value from TC1DRB.
edge. Therefore, the second captured value is “1” larger than the captured value immediately after counting starts.
captured values.
Page 76
Example :Duty measurement (resolution fc/27 [Hz])
WIDTH
TMP86FH47BUG
CLR(INTTC1SW). 0
LD(TC1CR), 00000110B; Sets the TC1 mode and source clock
DI; IMF= “0”
SET(EIRL). 7; Enables INTTC1
EI; IMF= “1”
LD(TC1CR), 00100110B; Starts TC1 with an external trigger at MCAP1 = 0
:
PINTTC1:CPL(INTTC1SW). 0; INTTC1 interrupt, inverts and tests INTTC1 service switch
In the programmable pulse generation (PPG) mode, an arbitrary duty pulse is generated by counting performed in the internal clock. To start the timer, TC1CR<TC1S> specifies either the edge of the input pulse
to the TC1 pin or the command start. TC1CR<MPPG1> specifies whether a duty pulse is produced continuously or not (one-shot pulse).
When TC1CR<MPPG1> is set to “0” (Continuous pulse generation)
・
When a match between the up-counter and the TC1DRB value is detected after the timer starts,
the level of the
tinues counting.
el of the
cleared at
PPG pin is inverted and an INTTC1 interrupt request is generated. The up-counter con-
When a match between the up-counter and the TC1DRA value is detected, the lev-
PPG pin is inverted and an INTTC1 interrupt request is generated. The up-counter is
this time, and then continues counting and pulse generation.
TMP86FH47BUG
When TC1S is cleared to “00” during PPG output, the
fore the
When TC1CR<MPPG1> is set to “1” (One-shot pulse generation)
・
counter stops.
PPG pin retains the level immediately be-
When a match between the up-counter and the TC1DRB value is detected after the timer starts,
the level of the
tinues counting.
el of the
cleared to
PPG pin is inverted and an INTTC1 interrupt request is generated. The up-counter con-
When a match between the up-counter and the TC1DRA value is detected, the lev-
PPG pin is inverted and an INTTC1 interrupt request is generated. TC1CR<TC1S> is
“00” automatically at this time, and the timer stops. The pulse generated by PPG retains
the same level as that when the timer stops.
Since the output level of the
ative pulse
can be generated. Since the inverted level of the timer F/F1 output level is output to the
specify TC1CR<TFF1>
pin. Upon
Note 1: To change TC1DRA or TC1DRB during a run of the timer, set a value sufficiently larger than the count val-
Note 2: Do not change TC1CR<TFF1> during a run of the timer. TC1CR<TFF1> can be set correctly only at initi-
Note 3: In the PPG mode, the following relationship must be satisfied.
Note 4: Set TC1DRB after changing the mode of TC1M to the PPG mode.
reset, the timer F/F1 is initialized to “0”.
ue of the counter. Setting a value smaller than the count value of the counter during a run of the timer
may generate a pulse different from that specified.
alization (after reset). When the timer stops during PPG, TC1CR<TFF1> can not be set correctly from
this point onward if the PPG output has the level which is inverted of the level when the timer starts. (Setting TC1CR<TFF1> specifies the timer F/F1 to the level inverted of the programmed value.) Therefore,
the timer F/F1 needs to be initialized to ensure an arbitrary level of the PPG output. To initialize the timer F/F1, change TC1CR<TC1M> to the timer mode (it is not required to start the timer mode), and then
set the PPG mode. Set TC1CR<TFF1> at this time.
TC1DRA > TC1DRB
PPG pin can be set with TC1CR<TFF1> when the timer starts, a positive or neg-
to “0” to set the high level to the
PPG pin, and “1” to set the low level to the PPG
PPG pin,
Example :Generating a pulse which is high-going for 800 μs and low-going for 200 μs
(fc = 16 MHz)
Setting port
LD(TC1CR), 10000111B; Sets the PPG mode, selects the source clock
LDW(TC1DRA), 007DH; Sets the cycle (1 ms ÷ 27/fc μs