Copyright 1988, OKI ELECTRIC INDUSTRY COMPANY, LTD.
OKI makes no warranty for the use of its products and assumes no
responsibility for any errors which may appear in this document nor
does it make a commitment to update the information contained
herein.
OKI retains the right to make changes to these specifications at
any time, without notice.
7.2 Description of Instruction Symbols .................................................................232
7.3 List of Instructions...........................................................................................233
7.4 Simplified Description of Instructions..............................................................234
7.5 Detailed Description of MSM80C154S/MSM83C154S Instructions ...............246
1. INTRODUCTION
MSM80C154S/83C154S/85C154HVS
2
INTRODUCTION
1. INTRODUCTION
1.1 MSM80C154S/MSM83C154S/MSM85C154HVS Outline
MSM80C154S/MSM83C154S/MSM85C154HVS are single-chip 8-bit fully static microcontrollers featuring high performance and low power consumption. All MSM80C31F /MSM80C51F
instructions and functions have been retained.
Apart from being without the internal program memory (ROM), MSM80C154S is identical to
MSM83C154S. And the difference between MSM85C154HVS and MSM83C154S is that the
internal program memory (ROM) in MSM83C154S is replaced by an external ROM
connected to MSM85C154HVS by using a piggy-back package.
While the MSM83C154S microcontroller integrates a 16384-word × 8-bit program memory
(ROM) in a single chip, MSM80C154S/MSM83C154S/MSM85C154HVS all feature computer functions including a 256-word × 8-bit data memory (RAM), 32 input/ output ports, three
16-bit timer/counters, six interrupts, serial I/O, an 8-bit parallel processing circuit, and a clock
generator.
The internal operation in these CPUs is based on an instruction code address method for
greater efficiency. In this method, operations are specified in the instruction code (OP)
section, and the objective registers are specified by part of that instruction code and the
second or third byte following the code. A feature of this method is the ability to achieve
several operations by simply changing the manipulation register designation in a single
instruction code.
Inclusion of 8-bit multiplication and division instructions further increases the processing
capacity of these CPUs.
In addition to expansion of the bit processing area, a comprehensive range of bit processing
instructions has also been included. Processing operations include logical processing of the
carry flag and specified bit within each register, transfer between the carry flag and specified
bit in certain registers, transfer of specified bits between different registers, setting, resetting,
and complement of the specified bit in each register, and execution of various bit tests within
a wide area.
To make a relative jump after the execution of a bit test instruction, jumps can be made within
a wide address range between –128 and +127 relative to the address of the instruction and
there is no page field restriction.
The contents of specified registers can be saved in stack by using the PUSH instruction, and
the saved contents can be returned from stack to a specified register by the POP instruction.
Absolute interrupt priority can be allocated to any interrupt when in priority circuit operation
mode. And by controlling only the interrupt enable register (IE) when in priority circuit stop
mode, multi-level interrupt processing can be executed to make interrupt processing much
easier than in conventional CPUs.
Employing the low-power consumption feature of C-MOS devices, these CPUs are designed
to operate in a number of “CPU power down” modes. In idle mode the IDL bit in the power
control register (PCON) is set to “1” to halt CPU operations while the oscillator continues to
run. In soft power down mode the PD bit in the power control register is set to “1” to halt CPU
operations as well as the oscillator. And in hard power down mode where the HPD bit in the
power control register is set in advance to “1”, CPU operations and the oscillator are stopped
if the HPDI pin (P3.5) power failure detect signal level is changed from “1” to “0”. CPU power
down modes can be cancelled by resetting the CPU via reset pin and restarting execution
from address 0, by restarting execution from the relevant interrupt address, or by resuming
3
MSM80C154S/83C154S/85C154HVS
execution from the next address after the stop address where CPU power down mode was
activated.
Each of the quasi-bidirectional ports 1, 2, and 3 can be set independently as high impedance
input ports. And the 10 kW pull-up resistance for these input ports can be isolated from the
power supply (VCC), leaving only the 100 kW pull-up resistance and thereby enabling the
quasi-bidirectional ports to be driven by devices with low drive capacity. Furthermore, the
outputs of ports, 0, 1, 2, and 3 can be switched to floating status during CPU power down
modes (PD, HPD).
Three built-in 16-bit timer/counters capable of operating in a wide range of modes enable the
CPUs to be used in many different ways. And since timer/counters 0 and 1 can be operated
by external clock during CPU power down modes (PD, HPD) where the oscillator is stopped,
these two counters can also be used in cancelling CPU power down modes.
UART based serial communication can be executed at any baud rate by carry signal from
timer/counter 1 or timer/counter 2.
If an overrun or framing error is generated during data reception, the SERR bit in the I/O
control register is set. And by testing this SERR bit, the accuracy of the data can be checked
quite easily to ensure correct serial communication.
As can be seen, these CPUs are equipped with a very comprehensive range of functions. Also
note that EASE80C51mkII is available for use as the program development support system
for these CPUs.
Equipped with the MSM85C154E dedicated evachip, EASE80C51mkII is capable of program area mapping, realtime tracing, generating breaks according to accumulator contents,
and various other functions designed for accurate and efficient support of program development of these CPUs.
With this great line-up of functions and with EASE80C51mkII capable of developing
programs in a very short time, MSM80C154S/MSM83C154S/MSM85C154HVS give a highly
integrated high performance solution.
4
INTRODUCTION
1.2 MSM80C154S/MSM83C154S Features
• Full static circuitry
• Internal program memory (ROM)
16384 words × 8 bits (MSM83C154S)
• External program memory (ROM)
Connectable up to 64K bytes
• Internal data memory (RAM)
256 words × 8 bits
• External data memory (RAM)
Connectable up to 64K bytes
• Four sets of working registers (R0 thru R7 × 4)
• Stack
Free use of 256-word × 8-bit internal data memory area
• Four input/output ports (8-bit × 4)
• Serial ports (UART operation)
• Six types of interrupts
(1) Two external interrupts
(2) Three timer interrupts
(3) One serial port interrupt
• CPU power down function
(1) Idle mode: CPU stopped while oscillation continued.
(Software setting)
(2) PD mode:CPU and oscillation all stopped.
(Software setting)
(Setting I/O ports to floating status possible)
(3) HPD mode: CPU and oscillation all stopped.
(Hardware setting)
(Setting I/O ports to floating status possible)
• CPU power down mode cancellation
(1) Execution commenced from address 0 by CPU resetting.
(IDLE, PD, and HPD mode cancellation)
* RESET pin is used
(2) Execution from interrupt address by interrupt request, or execution resumed from next
address after the stop address. (IDLE and PD mode cancellation)
* External, timer, and serial port interrupts
• I/O control registers (0F8H)
b0: Port 0, 1, 2, and 3 floating setting (PD, HPD)
b1: Port 1 high impedance input port setting
b2: Port 2 high impedance input port setting
b3: Port 3 high impedance input port setting
b4: Port 1, 2, and 3 pull-up resistance switching (10 kW pull-up resistance switch off to
leave only 100 kW)
b5: Serial port reception error detector bit
b6: 32-bit timer mode setting (TL0+TH0+TL1+TH1)
2.2.2 MSM85C154HVS pin layout and external dimensions
M85C154H
2764/27128
Pin 1 for 2764, 27128
* The MSM85C154HVS pin layout of bottom side is the same as the pin layout for
MSM83C154SRS.
OKI
JAPAN XXXX
* The 27C64/128 device should be used for EPROM.
40-Pin Ceramic Piggy Back (ADIP40-C-600-2.54)
Figure 2-4 MSM85C154HVS pin layout and external dimensions
17
MSM80C154S/83C154S/85C154HVS
2.3 MSM80C154S Block Diagram
18
P2.0
PORT 2
P2.7
P0.0
PORT 0
Figure 2-5 MSM80C154S block diagram
P0.7
OSC AND TIMING
XTAL1
PCONIOCON
PCHLPCLL
XTAL2
ALE
PSEN
EA
RESET
T2CONTL2
P1.0
PORT 1
P1.7
P3.0
PORT 3
TH1
P3.7
DPH
CONTROL SIGNALSIGNALR/W
SPECIAL
FUNCTION
DPL
PLA
REGISTER
ADDRESS
DECODER
SP
PCH
PCL
IRAIR
C-ROM
2H
R/W AMP
256WORD
×8bit
ACCTR2TR1
RAMDP
PSW
INTERRUPT
SBUF
(T)
ALU
SBUF
(R)
SERIAL IO
BR
TH2
TIMER/
COUNTER 2
RCAP
RCAP
2L
TL1TH0TL0TMODTCONIEIPSCON
TIMER/COUNTER 0&1
2.4 MSM83C154S Block Diagram
19
P2.0
PORT 2PORT 0PCONIOCON
P2.7
P0.0
Figure 2-6 MSM83C154S block diagram
P0.7
XTAL1
OSC AND TIMING
PCHLPCLL
XTAL2
ALE
PSEN
EA
RESET
T2CONTL2
P1.0
PORT 1PORT 3
P1.7
P3.0
TH1
P3.7
DPH
CONTROL SIGNALSIGNALR/W
SPECIAL
ROM
16KWORD
×8bit
DPL
PLA
FUNCTION
REGISTER
ADDRESS
DECODER
SP
IRAIR
PCH
SENSE AMP
PCL
C-ROM
2H
R/W AMP
256WORD
×8bit
ACCTR2TR1
RAMDP
PSW
INTERRUPT
SBUF
(T)
ALU
SBUF
(R)
SERIAL IO
BR
TH2
TIMER/
COUNTER 2
RCAP
RCAP
2L
TL1TH0TL0TMODTCONIEIPSCON
TIMER/COUNTER 0&1
SYSTEM CONFIGURATION
MSM80C154S/83C154S/85C154HVS
2.5 MSM85C154HVS Block Diagram
20
P2.0
PORT 2PORT 0PCONIOCON
P2.7
P0.0
Figure 2-7 MSM85C154HVS block diagram
P0.7
XTAL1
OSC AND TIMING
PCHLPCLL
XTAL2
ALE
PSEN
EA
RESET
T2CONTL2
P1.0
PORT 1PORT 3
P1.7
P3.0
TH1
TL1TH0TL0TMODTCONIEIPSCON
P3.7
PCH
PCL
TIMER/
COUNTER 2
RCAP
2L
TIMER/COUNTER 0&1
SOCKET
A0
EXTERNAL
A13
16KWORD
×8bit
D0 ... D7
TH2
RCAP
2H
ROM
R/W AMP
256WORD
×8bit
DPH
DPL
SP
RAMDP
INTERRUPT
CONTROL SIGNALSIGNALR/W
SPECIAL
FUNCTION
PLA
REGISTER
ADDRESS
DECODER
IRAIR
ACCTR2TR1
PSW
SBUF
(T)
ALU
SBUF
(R)
SERIAL IO
C-ROM
BR
SYSTEM CONFIGURATION
2.6 Timing and Control
2.6.1 Outline of MSM80C154S/MSM83C154S timing
The MSM80C154S/MSM83C154S devices are both equipped with a built-in oscillation
inverter (see Figure 2-8) for use in the generation of clock pulses by external crystal or ceramic
resonator. These clock pulses are passed to the timing counter and control circuits where the
basic timing and control signals required for internal control purposes are generated.
The basic timing consists of state 1 (S1) thru state 6 (S6) (see Figure 2-9) where each state
cycle is based on two XTAL1·2 fundamental clock pulses. The interval from S1 thru S6 forms
a single machine cycle with a total of 12 fundamental clock pulses. 1-byte 1-machine cycle
and 2-byte 1-machine cycle instructions are fetched into the instruction register during
M1·S1, decoded during M1·S2, and executed during M1·S3 thru M1·S6. The second byte is
fetched during M1·S4. 1-byte 2-machine cycle, 2-byte 2-machine cycle, and 3-byte 2machine cycle instructions are also fetched during M1·S1, decoded during M1·S2, and
executed during M1·S3 thru M2·S6. The second and third bytes are fetched during M1·S4,
M2·S1, or M2·S4. The number of clocks used is 24. 1-byte 4-machine cycle instructions are
involved in multiplication and division operations where 48 clocks are used.
S1S2S3S4S5S6
XTAL2
XTAL1
RESET
INT
DQ
Figure 2-8 Oscillator, timing counter, and control stage block diagram
DQDQDQDQDQ
S I/O & TIMER CONTROL
CPU CONTROL
1/2
1/2
POWER DOWN
IDLE
S I/O
TIMER & INTERRUPT
CPU
PLA
PLA OUT
21
MSM80C154S/83C154S/85C154HVS
M1
Instruction excecution
TM+1
M2
M1
M1
S1 S2 S3 S4 S5 S6
S1 S2 S3 S4 S5 S6
S1 S2 S3 S4 S5 S6
DPL & Rr
PCLPCLPCLPCLPCLPCLACC & RAM
PORT NEW DATA
DATA STABLEDATA STABLE
PORT OLD DATA
Instruction decoding
Instruction decoding
PC+1PC+1
Instruction excecution
PC+1
Instruction excecution
TM+1TM+1
TM+1
CYCLE
S1 S2 S3 S4 S5 S6
STEP
1
XTAL1
PCHPCHPCHPCHDPH & PORT DATAPCHPCHPCH
0
1
0
1
0
1
0
1
0
1
0
1
0
ALE
PSEN
RD/WR
PORT–0
PORT–2
CPU←PORT
Instruction decoding
1
0
PORT←CPU
Figure 2-9 MSM80C154S/MSM83C154S fundamental timing
22
PC+1PC+1
SYSTEM CONFIGURATION
2.6.2 Major synchronizing signals
(1) ALE (Address Latch Enable)
The ALE signal is used as a clock signal where the address signals 0 thru 7 output from
CPU port 0 can be latched externally when external program or external data memory
(RAM) is used.
Although two ALE signal outputs are obtained in a single machine cycle during normal
operations, no output is obtained during output of the RD/WR signal when an external
memory instruction (MOVX...... ) is executed.
(2) PSEN (Program Store Enable)
The PSEN output signal is generated during execution of an external program. The
output is obtained when an instruction or data is fetched.
The PSEN signal is valid when at “0” level, and external program data is enabled when
in this valid state.
Although two PSEN signal outputs are obtained in a single machine cycle during
normal operations, no output is obtained during output of the RD/WR signal when an
external data memory instruction (MOVX...... ) is executed.
(3) WR (Write Strobe)
The WR output signal is obtained when an external data memory instruction (MOVX
@Rr, A or MOVX @ DPTR, A) is executed.
CPU port 0 output data is written in the external RAM when the WR signal is at “0” level.
(4) RD (Read Strobe)
The RD output signal is obtained when an external data memory instruction (MOVX
A, @ Rr or MOVX A, @ DPTR) is executed.
The external RAM is enabled and output data is passed to CPU port 0 when the RD
signal is at “0” level.
23
MSM80C154S/83C154S/85C154HVS
2.6.3 MSM80C154S fundamental operation time charts
(1) External program memory read cycle timing chart
M1 or M2
XTAL1
ALE
PSEN
PORT–0
PORT–2
1
0
1
0
1
0
1
0
1
PCH OUT
0
Figure 2-10 MSM80C154S external program memory read cycle timing chart
2.7 Instruction Register (IR) and Instruction Decoder (PLA)
MSM80C154S/MSM83C154S operations are based on an instruction code address method.
Hence, in addition to the instruction code instruction register (IR) and instruction decoder
(PLA), these devices also include an instruction register (AIR) and register manipulation
decoder (PLA) for data addresses and bit addresses.
Operation codes are passed to the IR, and data and bit addresses are passed to the AIR. CPU
control signals are formed at the respective PLA for each instruction register, thereby
activating the CPU. The block diagram is outlined in Figure 2-21.
Timing
AND
Matrix
AIR
Control signals
Data bus
WAIR
Data bus
WIR
IR
Decoder
Matrix
Decoder
PLA
Timing
AND
Control signals
PLA
Figure 2-21 lR and PLA block diagram
30
SYSTEM CONFIGURATION
2.8 Arithmetic Operation Section
(1) Outline
The MSM80C154S/MSM83C154S arithmetic operation section consists of
(1) an arithmetic operation instruction decoder, and
(2) an arithmetic and logic unit [ALU].
(2) Arithmetic operation instruction decoder:
Arithmetic operation instructions are passed to the instruction register (IR) and then to
the PLA where they are converted into control signals.
The control signals from the PLA are used to control ALU peripheral circuits and ALU
arithmetic operations (ADD, AND, OR, EOR).
(3) Arithmetic and logic unit [ALU]:
Upon reception of 8-bit data from one or two data sources the ALU processes that data
in accordance with control signals from the PLA. The ALU is capable of executing the
following processes:
• Additions and subtractions with and without carry
• Increments (+1) and decrements (–1)
• Bit complements
• Rotations (either direction with and without carry)
• BCD (decimal adjust)
• Carry, auxiliary carry, and overflow signal output
• Multiplications and divisions
• Bit detection
• Exchange of low and high order nibbles
• Logical AND, logical OR, and exclusive OR
If a bit-3 auxiliary carry (AC), a bit-7 carry (CY), or an overflow (OV) is generated as a
result of the arithmetic operation executed by the ALU, that result is set in the program
status word (PSW 0D0H).
PSW(0D0H)
CY
7AC6F05
Figure 2-22 Program status word
RS14RS03OV2F11P
31
0
MSM80C154S/83C154S/85C154HVS
2.9 Program Counter
The MSM80C154S/MSM83C154S program counter has a 16-bit configuration PC0 thru
PC15, as shown in Figure 2-23.
ENABLE ROM
MSM83C154S INTERNAL ROM
16KWORD × 8BIT
CPU INTERNAL
DATA BUS
EXTERNAL
ROM MODE
Q8Q9Q10Q11Q12Q13Q14Q15
D8D9D10D11D12D13D14D15
CPU INTERNAL DATA BUS
Figure 2-23 MSM80C154S/MSM83C154S program ounter
Q0Q1Q2Q3Q4Q5Q6Q7
PC+1
D0D1D2D3D4D5D6D7
This program counter is a binary up-counter which is incremented by 1 each time one byte
of instruction code is fetched. When the program counter is counted by 1 after counter
contents have reached 0FFFFH, the counter is returned to 0000H. MSM83C154S is
automatically switched to external ROM mode when the counter contents exceed 3FFFH.
32
SYSTEM CONFIGURATION
2.10 Program Memory and External Data Memory
2.10.1 MSM80C154S/MSM83C154S program area and external ROM connections
Since MSM80C154S/MSM83C154S are equipped with a 16-bit program counter, these
devices can execute programs of up to 64K bytes (including both internal and external
programs).
Since the MSM80C154S is not equipped with an internal program ROM, however, only
external instructions are executed. MSM83C154S, on the other hand, is equipped with a 16K
byte program ROM which enables it to execute internal instructions from address 0 thru
address 16383. External instructions are executed when the address is greater than 16383.
The program area is outlined in Figure 2-24, and a diagram of ROM connections made when
external instructions are executed is shown in Figure 2-25.
0FFFFH65535
4000H16384
3FFFH16383
MSM80C154S external ROM area
002CH44
002BH43
Timer interrupt 2 start address43 002BH
Serial I/O interrupt start address35 0023H
Timer interrupt 1 start address27 001BH
External interrupt 1 start address19 0013H
Timer interrupt 0 start address11 000BH
External interrupt 0 start address30003H
20002H
MSM83C154S internal ROM areaMSM83C154S external ROM area
0
Figure 2-24 MSM80C154S/MSM83C154S program area
10001H
CPU reset start address00000H76543210
33
Figure 2-25 MSM80C154S/MSM83C154S external ROM connection diagram
MSM80C154S/83C154S/85C154HVS
34
P0.0
P0.1
P0.2
P0.3
P0.4
MSM80C154S/MSM83C154S
P0.5
P0.6
P0.7
ALE
P2.0
P2.1
P2.2
P2.3
P2.4
P2.5
P2.6
P2.7
PSEN
D0
D1
MSM74HC373
D2
D3
D4
D5
D6
D7
LATCH
Q0
Q1
Q2
Q3
Q4
Q5
Q6
Q7
A0
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
A11
A12
A13
A14
A15
CS
OUTPUT ENABLE
ROM
64kW × 8BIT
Q7Q6Q5Q4Q3Q2Q1Q0
SYSTEM CONFIGURATION
2.10.2 Procedures and circuit connections used when external data memory (RAM)
is accessed by data pointer (DPTR)
The MSM80C154S/MSM83C154S can be connected to an external 64K word × 8-bit data
memory (RAM) when accessing the memory by data pointer (DPTR).
The data pointer (DPTR) consists of DPL and DPH registers. The DPL register contents serve
as addresses 0 thru 7 of the external data memory, and the DPH register contents serve as
addresses 8 thru 15.
The MOVX @DPTR, A instruction is used when accumulator contents are transferred to an
external data memory, and the MOVX A, @DPTR instruction is used when external data
memory contents are transferred to the accumulator. The external data memory connection
diagram is shown in Figure 2-26 and the external data memory access time chart is shown
in Figure 2-27.
When the data pointer indirect external memory instruction is executed, the CPU passes the
DPL register contents to port 0, and the port 0 contents are latched externally by ALE signal.
Data stored in the latch serves as the lower order addresses 0 thru 7 of the external data
memory (RAM), and the DPH register contents passed to port 2 serve as the higher order
addresses 8 thru 15 for addressing of the external data memory.
The WR or RD external data memory control signal is subsequently generated by the CPU
to enable transfer of data between port 0 and the external data memory.
35
Figure 2-26 Connection circuit for external data memory addressed by DPTR
MSM80C154S/83C154S/85C154HVS
36
P0.0
P0.1
P0.2
P0.3
P0.4
MSM80C154S/MSM83C154S
P0.5
P0.6
P0.7
ALE
P2.0
P2.1
P2.2
P2.3
P2.4
P2.5
P2.6
P2.7
WR
D0
D1
MSM74HC373
D2
D3
D4
D5
D6
D7
LATCH
Q0
Q1
Q2
Q3
Q4
Q5
Q6
Q7
A0
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
A11
A12
A13
A14
A15
R/W
I/O
76543210
ROM
64kW × 8BIT
RD
CS
SYSTEM CONFIGURATION
M1
M2
M1
S1 S2 S3 S4 S5 S6
S1 S2 S3 S4 S5 S6
S1 S2 S3 S4 S5 S6
M1
S1 S2 S3 S4 S5 S6
M2
S1 S2 S3 S4 S5 S6
MOVX @DPTR, A
M1
S1 S2 S3 S4 S5 S6
RAM DATA IN
MOVX A, @DPTR
M1
S1 S2 S3 S4 S5 S6
S6
M1
PCLPCLPCLPCLPCLPCLACC DATADPL
1
XTAL1
INSTRUCTION IN
PCHPCHPCHPCHDPHPCHPCHPCH
0
1
0
ALE
1
PSEN
0
PCL
1
0
PORT–0
1
0
PORT–2
1
0
WR
S1 S2 S3 S4 S5 S6
S6
1
XTAL1
0
1
ALE
Figure 2-27 DPTR external data memory access timing
37
0
1
PSEN
PCLPCLPCLPCLPCLPCLDPL
INSTRUCTION IN
PCHPCHPCHPCHDPHPCHPCHPCH
PCL
0
1
0
1
PORT–0
PORT–2
1
0
0
RD
MSM80C154S/83C154S/85C154HVS
2.10.3 Procedures and circuit connections used when external data memory (RAM)
is accessed by registers R0 and R1
The MSM80C154S/MSM83C154S can be connected to an external 256 word ¥ 8-bit data
memory (RAM) when addressing the memory according to the contents of registers R0 and
R1 in the internal data memory (RAM).
The MOVX @Rr, A instruction is used when accumulator contents are transferred to an
external data memory, and the MOVX A, @Rr instruction is used when external data memory
contents are transferred to the accumulator. The external data memory connection diagram
is shown in Figure 2-28 and the external data memory access time chart is shown in Figure
2-29.
When the indirect register external memory instruction is executed, the CPU passes the R0
or R1 register contents to port 0, and the port 0 contents are latched externally by the ALE
signal. Data stored in the latch serves as the addresses 0 thru 7 of the external data memory.
The WR or RD external data memory control signal is subsequently generated by the CPU
to enable transfer of data between port 0 and the external data memory.
However, if the port 2 latched data is used in addresses 8 thru 15 of the external data memory,
the circuit connections are the same as when the data pointer (DPTR) is used, thereby
enabling a 64K byte ¥ 8-bit data memory to be accessed.
38
76543210
I/O
A0A1A2A3A4A5A6
ROM
256W × 8BIT
A7
SYSTEM CONFIGURATION
CS
R/W
Q0Q1Q2Q3Q4Q5Q6
MSM74HC373
D0D1D2D3D4D5D6
P0.0
P0.1
P0.2
P0.3
P0.4
P0.5
P0.6
Q7
D7
P0.7
LATCH
ALE
WR
RD
MSM80C154S/MSM83C154S
Figure 2-28 Connection circuit for external data memory addressed by register R0 or R1
39
MSM80C154S/83C154S/85C154HVS
M1
M2
M1
S1 S2 S3 S4 S5 S6
S1 S2 S3 S4 S5 S6
S1 S2 S3 S4 S5 S6
M1
S1 S2 S3 S4 S5 S6
M2
S1 S2 S3 S4 S5 S6
MOVX @Rr, A
M1
S1 S2 S3 S4 S5 S6
RAM DATA IN
MOVX A, @Rr
M1
S1 S2 S3 S4 S5 S6
S6
1
XTAL1
PCLPCLPCLPCLPCLPCLACC DATARr
INSTRUCTION IN
PCHPCHPCHPCHPORT 2 LATCH DATAPCHPCHPCH
0
1
0
ALE
1
0
PSEN
PCL
1
0
PORT–0
1
0
PORT–2
1
WR
M1
S1 S2 S3 S4 S5 S6
S6
0
1
XTAL1
0
1
0
ALE
Figure 2-29 Register R0/R1 external data memory access timing
40
PCLPCLPCLPCLPCLPCLRr
INSTRUCTION IN
PCL
1
0
1
PSEN
PORT–0
0
PCHPCHPCHPCHPORT 2 LATCH DATAPCHPCHPCH
1
0
PORT–2
1
0
RD
3. CONTROL
MSM80C154S/83C154S/85C154HVS
42
CONTROL
3. CONTROL
3.1 Oscillators: XTAL1
XTAL2
An oscillator is formed by connecting a crystal or ceramic resonator between the XTAL1 and
XTAL2 pins of the MSM80C154S/MSM83C154S devices.
If an external clock is applied to XTAL1, the input should be at 50% duty and C-MOS level.
IDLE MODE
PD & HPD MODE
C
*
XTAL
C
*
XTAL1
1MΩ
XTAL2
MSM80C154S/MSM83C154S
CPU CONTROL CLOCK
TIMER, S I/O & INTERRUPT
* The capacity of the compensating capacitor depends on the crystal resonator.
* The XTAL1·2 frequency depends on VCC.
Figure 3-1 Crystal resonator connection diagram
43
MSM80C154S/83C154S/85C154HVS
IDLE MODE
PD & HPD MODE
C
*
C
*
XTAL1
1MΩ
XTAL2
MSM80C154S/MSM83C154S
CPU CONTROL CLOCK
TIMER, S I/O & INTERRUPT
* The capacity of the compensating capacitor depends on the ceramic resonator.
* The XTAL1·2 frequency depends on VCC.
Figure 3-2 Ceramic resonator connection diagram
IDLE MODE
CPU CONTROL CLOCK
PD & HPD MODE
XTAL1
74HC04
*CLOCK
XTAL2
MSM80C154S/MSM83C154S
* Supply of 50% duty clock
Figure 3-3 External clock supply circuit
TIMER, S I/O & INTERRUPT
1MΩ
44
CONTROL
3.2 CPU Resetting
3.2.1 Outline
If a reset signal (kept at “1” level for at least 1µsec) is applied to the RESET pin when the
correct voltage (in respect to the various specifications) is applied to the MSM80C154S/
MSM83C154S VCC pin, a reset signal is stored in the CPU even if the XTAL1·2 oscillators
have been stopped.
The internally stored reset signal is used in direct initialization (setting to “1”) of ports 0, 1, 2,
and 3. All of the special function registers are then initialized (set to “0”) two machine cycles
after the XTAL1·2 oscillator commences regular operation.
When the reset is released, instruction execution is started in the third machine cycle if the
reset signal is changed from “1” level to “0” level before the M1·S1 signal leading edge, and
in the fifth machine cycle if the reset signal is changed from “1” to “0” after the leading edge.
The reset circuit block diagram is shown in Figure 3-4, the reset start time charts in Figures
3-5 and 3-6, and the reset release time charts in Figures 3-7 and 3-8.
Figure 3-5 Reset execution time chart (internal ROM mode)
46
M1
M2
CONTROL
S1 S2 S3 S4 S5 S6
S1 S2 S3 S4 S5 S6
M1
M1 or M2
S1 S2 S3 S4 S5 S6
S1 S2 S3 S4 S5 S6
S6
1
XTAL1
CPU RESET EXCECUTE CYCLE
FLOATING
PORT DATA = 1
PCL
PCHPCH
0
1
0
1
0
1
0
1
0
1
0
1
0
ALE
PSEN
PORT 0
PORT 2
RESET
CPU RESET
CONTROL
1
0
RESET
EXCECUTE
PORT DATA = 1
PORT DATA = 1
PORT DATA
PORT DATA
1
0
1
0
PORT 1
PORT 3
Figure 3-6 Reset execution time chart (external ROM mode)
47
MSM80C154S/83C154S/85C154HVS
M1
M2
M1
M1
S1 S2 S3 S4 S5 S6
S1 S2 S3 S4 S5 S6
FLOATING
PORT DATA = 1
PORT DATA = 1
EXCECUTE CYCLE
PORT DATA = 1
CPU RESET EXCECUTE CYCLE
S1 S2 S3 S4 S5 S6 S1 S2 S3 S4 S5 S6
S6
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
XTAL1
ALE
PSEN
PORT 0
PORT 1
PORT 2
PORT 3
RESET
CPU RESET
CONTROL
RESET
EXCECUTE
Figure 3-7 Reset release time chart (internal ROM mode)
48
M1
CONTROL
PCLPCLPCL
M2
M1
M1
S1 S2 S3 S4 S5 S6
S1 S2 S3 S4 S5 S6
FLOATING
PCHPCHPCH
PORT DATA = 1
EXCECUTE CYCLE
PORT DATA = 1
PORT DATA = 1
CPU RESET EXCECUTE CYCLE
S1 S2 S3 S4 S5 S6 S1 S2 S3 S4 S5 S6
S6
1
0
1
0
1
0
1
XTAL1
ALE
PSEN
0
1
PORT 0
0
PORT 2
1
RESET
0
1
CPU RESET
0
CONTROL
1
0
RESET
EXCECUTE
1
0
PORT 1
1
0
PORT 3
Figure 3-8 Reset release time chart (external ROM mode)
49
MSM80C154S/83C154S/85C154HVS
3.2.2 Reset Schmitt trigger circuit
The Schmitt trigger circuit connected to the RESET pin shown in the MSM80C154S/ MSM83C154S reset circuit block diagram in Figure 3-4 operates in the following way when the VCC
power supply voltage is +5V.
If the voltage of the reset signal applied to the RESET pin exceeds 3V when the level of that
signal is changed from “0” to “1”, the Schmitt trigger output level is changed from “0” to “1”,
and the reset signal is set in the CPU reset control circuit, resulting in the reset operation being
started by the CPU.
The CPU reset state is released when the “1” level on the RESET pin is changed to “0”. An
input signal level below 1.5V is regarded as “0” level, and the Schmitt trigger output level is
changed from “1” to “0”. When the reset signal is changed to “0” level, the CPU reset control
circuit is ready for reset release. The Schmitt trigger circuit operation time chart for changes
in the reset input voltage is outlined in Figure 3-9.
5 [V]
V
CC
0 [V]
RESET
5 [V]
0 [V]
•
VIH = 3.0[V]
•
•
TH = 1.5[V]
V
•
•
V
IL = 1.5[V]
•
Schmitt trigger gate output
Figure 3-9 Reset Schmitt trigger gate detector time chart
5 [V]
0 [V]
CPU reset
control input
50
CONTROL
3.2.3 CPU internal status by reset
When a reset signal is applied to the CPU with normal voltage applied to the MSM80C154S/
MSM83C154S VCC power supply pin, ports 0, 1, 2, and 3 are set to “1” (input mode) even if
XTAL1·2 oscillation has been stopped. The output status of the ALE and PSEN pins also
becomes “1”. The CPU is then reset after normal XTAL1·2 oscillation has resumed. The
internal CPU status when the CPU is reset is shown in Table 3-1.
Table 3-1 MSM80C154S/MSM83C154S reset internal status
Register Name
PC
SP
IP
IE
PCON
PSW, DPH, DPL, A, B
SCON, TCON, TMOD
T2CON, IOCON, TL0
TL1, TL2, TH0, TH1
TH2, RCAP2L, RCAP2H
P1, P2, P3
P0
SBUF
INTERNAL RAM
ALE, PSEN
* Denotes direct resetting even if XTAL1·2 has stopped.
51
MSM80C154S/83C154S/85C154HVS
3.3 EA (CPU Memory Separate)
3.3.1 Outline
The function of the EA pin is to determine whether a CPU internal program memory (ROM)
instruction or an external program instruction is to be executed.
(1) Internal ROM mode
If the EA pin is connected to VCC and a “1” reset signal is applied to the RESET pin to
reset the CPU, an internal program memory (ROM) is executed from address 0.
(MSM83C154S, MSM85C154HVS)
(2) External ROM mode
If the EA pin is connected to VSS and a “1” reset signal is applied to the RESET pin to
reset the CPU, an external program memory is executed from address 0.
52
4. INTERNAL
SPECIFICATIONS
MSM80C154S/83C154S/85C154HVS
54
INTERNAL SPECIFICATIONS
4. INTERNAL SPECIFICATIONS
4.1 Internal Data Memory (RAM) and Special Function Registers
4.1.1 Outline
MSM80C154S/MSM83C154S operation is based on an instruction code address method
where operations are specified in an instruction code (OP) section, and the data memory
(RAM) and special function registers (ACC, B, TCON, P0........ ) are specified directly by part
of the instruction code and the second or third byte of data following that instruction code.
According to this instruction code address method, all eight bits of data in the data memory
and special function register may be specified, or one bit of data memory and one bit of data
in the special function register may be specified. Direct designation of all eight bits of data is
called data addressing, and direct designation of one bit of data is called bit addressing.
Since these CPU devices specify data memory (RAM) and special function register contents
by the above method, specific addresses are assigned to the respective CPU data memory
(RAM) and special function registers (ACC, B, TCON, P0, .... ). Data addresses consist of
eight bits, and range from 00 to 0FFH in binary (which correspond to 0 thru 255 in decimal).
All data memory (RAM) and special function registers (ACC, B, TCON, P0, .... ) exist in these
256 locations.
The data memory contains 256 bytes. The data memory between addresses 00 thru 7FH can
be specified directly by data address, and the data memory from address 80H to 0FFH can
be specified by indirect register instruction where R0 or R1 contents are set to 80H thru 0FFH.
Note that the entire data memory (RAM) from 00 thru 0FFH can be specified by indirect
register instruction.
Special function registers are located between addresses 80H thru 0FFH, and can also be
specified directly by data address. Bit addresses consist of eight bits, the manipulation bits
being specified by the three lower order bits and the data memory (RAM) or special function
register (ACC, B, TCON, P0, .... ) by the five higher order bits. Data memory between
addresses 20 thru 2FH can be specified by bit addressing. Other areas cannot be specified
by bit designation.
The special function registers which can be specified by bit address are P0, P1, P2, P3,
TCON, SCON, IE, IP, T2CON, PSW, ACC, B, and IOCON, a total of 13 registers. The data
memory (RAM) and special function register address space layout is shown in Figure 4-1.
Figure 4-1 Data memory and special function register layout
56
INTERNAL SPECIFICATIONS
4.2 Internal Data Memory (RAM)
4.2.1 Internal data memory (RAM)
The storage capacity of the MSM80C154S/MSM83C154S data memory is 256 words ¥ 8 bits.
The layout diagram is shown in Figure 4-2.
The data memory can be accessed (R/W) in four different ways - direct register designation,
indirect register designation, data addressing, and bit addressing.
Four banks of registers group (R0 thru R7 ¥ 4) exist within the data memory address range
from 00 to 1FH. Banks are specified by RS0 and RS1 data combinations within the PSW.
The data memory address range from 20 to 2FH is an area where bit addressing is possible.
One bit of data can be manipulated directly by bit manipulation instructions.
The data memory address range from 00 to 7FH is an area where data addressing is possible.
8-bit data manipulations can be handled directly by data address manipulation instructions.
The data memory address range from 80H to 0FFH is an area where data addressing is not
possible. To manipulate data in this data memory area, the contents of register R0 or R1 are
set in 80H thru 0FFH, then an indirect register instruction is used. (Indirect register
instructions can be used to specify the entire data memory from address 00 to 0FFH.)
In addition to data storage in the CPU, the data memory is used as the place for saving stack
data. This stack data storage area is addressed by a stack pointer (SP 81H).
Since the stack pointer can be set any desired value by software, the data memory can be
used as stack from any data memory address. Note that 07H data is set automatically in the
stack pointer when the CPU is reset.
Four banks of registers group exist in the data memory (RAM) between memory addresses
00 thru 1FH. Banks are specified by RS0 and RS1 bit combinations within the program status
word (PSW). Note that the register area R0 thru R7 can also be used as normal data memory.
The PSW table is shown in Table 4-1, and the data memory register bank layout in Figure 4-
Figure 4-3 Internal data memory register bank layout
59
MSM80C154S/83C154S/85C154HVS
4.2.3 Stack
The stack data save (storage) area is in the internal data memory (RAM), and is specified by
stack pointer (SP 81H).
Although 07H data is automatically set in the stack pointer when the CPU is reset, any desired
data can be set by software to enable the data memory to be used as stack from any address.
Two bytes of data memory are used when the stack is used by interrupt or CALL instruction,
and a single byte of data memory is used when the PUSH instruction is used. The status
where an interrupt is generated and the program counter contents are saved in the stack
when the stack pointer contents are 7FH, and the status where accumulator contents are
pushed during interrupt routine and are subsequently saved in the stack are shown in Table
4-2. The stack status up to completion of interrupt processing upon execution of POP and
RETI instructions is also included.
Table 4-2 Stack storage layout
Stack processing
Before execution7FHD7D6D5D4D3D2D1D0
Interrupt process80HPC7PC6PC5PC4PC3PC2PC1PC0
(push PC)81HPC15 PC14 PC13 PC12 PC11 PC10 PC9PC8
PUSH process (ACC)82HA7A6A5A4A3A2A1A0
POP process (ACC)82HA7A6A5A4A3A2A1A0
RETI process (pop PC)
After execution7FHD7D6D5D4D3D2D1D0
Stack
pointer
81H
76543210
PC15 PC14 PC13 PC12 PC11 PC10 PC9PC8
PC7PC6PC5PC4PC3PC2PC1PC080H
RAM data bit
60
INTERNAL SPECIFICATIONS
4.3 lnternal Data Memory (RAM) Operating Procedures
4.3.1 Internal data memory indirect addressing
Operation of the internal data memory indirect increment instruction is described here as an
example. This instruction (INC @Rr) is a 1-byte 1-machine cycle instruction (see Figure 4-
4). The indirect address register is specified by instruction code bit 0 data r where r denotes
either register 0 or 1 in the register group specified by PSW RS0 and RS1 bank data. Register
0 is specified when the r data is 0, and register 1 is specified when the data is 1.
When this instruction is executed, register data is read from the specified register 0 or 1, and
the read out register data is written into the data pointer for the data memory.
The data memory contents specified by the data pointer are read by the CPU into a temporary
register. Then a subsequent increment (+1) by the ALU is followed by a return to the data
memory at the address where the data were read out. In this way, the contents of the data
memory at the address specified by the contents of R0 or R1 are incremented.
Instruction (OP)
code portion
INC @Rr:Byte 1
Figure 4-4 INC @Rr bit arrangement
0000011r
76543210
Register
designation portion
61
MSM80C154S/83C154S/85C154HVS
4.3.2 Internal data memory register R0 thru R7 designation
Operation of the internal data memory register decrement instruction is described here as an
example. This instruction (DEC Rr) is a 1-byte 1-machine cycle instruction (see Figure 4-5).
Register R0 thru R7 is specified by r0, r1, and r2 data of instruction code bit 0, 1, and 2. The
r0, r1, and r2 data is represented in binary code, r0 being the LSB, and r2 the MSB. The code
is weighted 1, 2, and 4 from the LSB. Any one of the eight registers can be specified by
combinations of this code. See Table 4-3 for the register designation combinations.
When this instruction is executed, one of the registers R0 thru R7 from the register group
specified by the PSW RS0 and RS1 bank data is specified. The contents of the specified
register is read by the CPU into a temporary register. Then a subsequent decrement (–1) by
the ALU is followed by a return to the register where the data were read out. In this way, the
register contents specified by r0, r1, and r2 are decremented.
In the MSM80C154S/MSM83C154S, 1-bit data manipulations (test, reset, set, complement,
transfer) can be executed directly between internal data memory addresses 20 thru 2FH by
bit manipulation instructions. The operation of a bit reset instruction is described below as an
example.
This instruction (CLR bit address) is a 2-byte 2-machine cycle instruction (see Figure 4-6).
The instruction code is indicated in byte 1, and the data memory address and bit designation
are indicated in byte 2. The manipulation bit is specified by the b0, b1, and b2 data in bits 0,
1, and 2 of byte 2. The b0, b1, and b2 portion is expressed in binary code which is weighted
1, 2, and 4. Combinations of this code enable any one of eight bits to be specified. The bit
designation combinations are listed in able 4-4.
The data memory is addressed by bits b3, b4, b5, b6 and b7 of byte 2 with b7 being “0”. These
bits can be expressed in binary by 0 thru 0FH, and a total of 16 designations of the data
memory are possible.
When data memory addresses are specified, the data memory bit manipulation start address
20H is added to the b3, b4, b5, and b6 binary data to obtain the data memory address.
The data memory contents specified by the above method are read by the CPU into a
temporary register, the specified bit data is reset to “0” by the ALU, and the CPU returns the
result to the data memory where the data were read. One bit of specified data memory is thus
reset to “0”.
4.4 Special Function Registers (TCON, SCON,.... ACC, B)
4.4.1 Outline
As can be seen from the configuration shown in Table 4-6, the MSM80C154S/ MSM83C154S
special function registers consist of 27 8-bit registers.
Special function registers can be accessed (R/W) by either data addressing or bit addressing.
All 27 registers can be specified by data addressing. 13 registers (P0, P1, P2, P3, TCON,
T2CON, SCON, IE, IP, PSW, ACC, B, and IOCON) can be specified by bit addressing.
If a register which does not exist at the data address is accessed when a special function
register is used, the read data becomes 0FFH. And when data is written, none of the registers
in the CPU are effected at all. Note, however, that since a jump is always executed when a
bit test instruction which results in a relative jump at data condition “1” is executed, make sure
that no instruction is executed for a register which does not exist.
Timer/counter 0 count clock designation control bit.
XTAL1·2 divided by 12 clock is the input applied to timer/counter 0
when C/T="0".
The external clock applied to the T0 pin is the input applied to
timer/counter 0 when C/T="1".
When this bit is "0", the TR0 bit of TCON (timer control register) is
used to control the start and stop of timer/counter 0 counting. If
this bit is "1", timer/counter 0 starts counting when both the TR0 bit
of TCON and INT0 pin input signal are "1", and stops counting
when either is changed to "0".
M1
0
0
1
1
Timer/counter 1 count clock designation control bit.
XTAL1·2 divided by 12 clock is the input applied to timer/counter 1
when C/T="0".
The external clock applied to the T1 pin is the input applied to
timer/counter 1 when C/T="1".
When this bit is "0", the TR1 bit of TCON is used to control the
start and stop of timer/counter 1 counting.
If this bit is "1", timer/counter 1 starts counting when both the TR1
bit of TCON and INT1 pin input signal are "1", and stops counting
when either is changed to "0".
Timer/counter 0 mode setting
M0
8-bit timer/counter with 5-bit prescalar
0
16-bit timer/counter
1
8-bit timer/counter with 8-bit auto reloading
0
Timer/counter 0 separated into TL0 (8-bit) timer/counter
1
and TH0 (8-bit) timer/counter. TF0 is set by TL0 carry,
and TF1 is set by TH0 carry.
Timer/counter 1 mode setting
M0
8-bit timer/counter with 5-bit prescalar
0
16-bit timer/counter
1
8-bit timer/counter with 8-bit auto reloading
0
Timer/counter 1 operation stopped
1
67
MSM80C154S/83C154S/85C154HVS
4.4.2.2 Power control register (PCON)
NameAddress
PCON87HSMODHPDRPD—GF1GF0PDIDL
Bit locationFlagFunction
PCON.0
PCON.1
PCON.2
PCON.3
PCON.4
PCON.5
PCON.6
PCON.7
IDL
PD
GF0
GF1
—
RPD
HPD
SMOD
MSBLSB
76543210
IDLE mode set when this bit is set to "1". CPU operations are
stopped when IDLE mode is set, but XTAL1·2, timer/counters 0, 1,
and 2, the interrupt circuits, and serial port remain active. IDLE
mode is cancelled when the CPU is reset or when an interrupt is
generated.
PD mode set when this bit is set to "1". CPU operations and
XTAL1·2 are stopped when PD mode is set. PD mode is cancelled
when the CPU is reset or when an interrupt is generated.
User flag. Testing this flag when IDLE mode is cancelled by an
interrupt shows whether the interrupt is a normal interrupt or an
IDLE mode release interrupt.
User flag. Testing this flag when PD mode is cancelled by an
interrupt shows whether the interrupt is a normal interrupt or a PD
mode release interrupt.
Reserved bit. The output data is "1" if the bit is read.
Bit used to specify cancellation of CPU power down mode (IDLE
or PD) by interrupt signal.
Power down mode cannot be cancelled by interrupt signal if
interrupt is not enabled by IE (interrupt enable register) when this
bit is "0".
If the interrupt flag is set to "1" by an interrupt request signal when
this bit is "1" (even if interrupt is disabled), the program is executed
from the next address of the power down mode setting instruction.
The flag is reset to "0" by software.
The hard power down setting mode is enabled when this bit is set
to "1".
If the level of the power failure detect signal applied to the HPDI
pin (pin 3.5) is changed from "1" to "0" when this bit is "1",
XTAL1·2 oscillation is stopped and the system is put into hard
power down mode.
When the serial port is used in mode 1, 2 or 3, this bit has the
following functions. The serial port operation clock is reduced by
1/2 when the bit is "0" for delayed processing. And when the bit is
"1", the serial port operation clock is normal for faster processing.
68
4.4.2.3 Timer control register (TCON)
INTERNAL SPECIFICATIONS
NameAddress
TCON88HTF1TR1TF0TR0IE1IT1IE0IT0
Bit locationFlagFunction
TCON.0
TCON.1
TCON.2
TCON.3
TCON.4
TCON.5
TCON.6
TCON.7
IT0
IE0
IT1
IE1
TR0
TF0
TR1
TF1
MSBLSB
76543210
External interrupt 0 signal used in level detect mode when this bit
is "0", and in trigger detect mode when "1".
Interrupt request flag for external interrupt 0.
Bit is reset automatically when interrupt is serviced.
Bit can be set and reset by software when IT0="1".
External interrupt 1 signal used in level detect mode when this bit
is "0",and in trigger detect mode when "1".
Interrupt request flag for external interrupt 1 .
Bit is reset automatically when interrupt is serviced.
Bit can be set and reset by software when IT1="1".
Counting start and stop control bit for timer/counter 0.
Timer/counter 0 starts counting when this bit is "1", and stops
counting when "0".
Interrupt request flag for timer interrupt 0.
Bit is reset automatically when interrupt is serviced. Bit is set to "1"
when carry signal is generated from timer/counter 0.
Counting start and stop control bit for timer/counter 1.
Timer/counter 1 starts counting when this bit is "1", and stops
counting when "0".
Interrupt request flag for timer interrupt 1 .
Bit is reset automatically when interrupt is serviced. Bit is set to "1"
when carry signal is generated from timer/counter 1.
69
MSM80C154S/83C154S/85C154HVS
4.4.2.4 Serial port control register (SCON)
NameAddress
SCON98HSM0SM1SM2RENTB8RB8TIRI
Bit locationFlagFunction
SCON.0
SCON.1
SCON.2
SCON.3
SCON.4
SCON.5
SCON.6
SCON.7
RI
TI
RB8
TB8
REN
SM2
SM1
SM0
MSBLSB
76543210
"End of serial port reception" interrupt request flag. This flag must
be reset by software during interrupt service routine.
This flag is set after the eighth bit of data has been received when
in mode 0, or by the STOP bit when in any other mode. In mode 2
or 3, however, RI is not set if the RB8 data is "0" with SM2="1". RI
is set if STOP bit is received when SM2="1" in mode 1.
"End of serial port transmission" interrupt request flag. This flag
must be reset by software during interrupt service routine. This flag
is set after the eighth bit of data has been sent when in mode 0, or
after the last bit of data has been sent when in any other mode.
The ninth bit of data received in mode 2 or 3 is passed to RB8.
The STOP bit is applied to R88 if SM2="0" when in mode 1. RB8
cannot be used in mode 0.
The TB8 data is sent as the ninth data bit when in mode 2 or 3.
Any desired data can be set in TB8 by software.
Reception enable control bit.
No reception when REN="0".
Reception enabled when REN="1".
If the ninth bit of received data is "0" with SM2="1" in mode 2 or 3,
the "end of reception" signal is not set in the RI flag.
Nor is the "end of reception" signal set in the RI flag if the STOP bit
is not "1" when SM2="1" in mode 1.
Interrupt control bit for external interrupt 0.
Interrupt disabled when bit is "0".
Interrupt enabled when bit is "1".
Interrupt control bit for timer interrupt 0.
Interrupt disabled when bit is "0".
Interrupt enabled when bit is "1".
Interrupt control bit for external interrupt 1 .
Interrupt disabled when bit is "0".
Interrupt enabled when bit is "1".
Interrupt control bit for timer interrupt 1 .
Interrupt disabled when bit is "0".
Interrupt enabled when bit is "1".
Interrupt control bit for serial port.
Interrupt disabled when bit is "0".
Interrupt enabled when bit is "1".
Interrupt control bit for timer interrupt 2.
Interrupt disabled when bit is "0".
Interrupt enabled when bit is "1".
Reserved bit. The output data is "1" if the bit is read.
Overall interrupt control bit.
All interrupts are disabled when bit is "0".
All interrupts are enabled/disabled by IE.0 thru IE.5 when bit is "1".
71
MSM80C154S/83C154S/85C154HVS
4.4.2.6 Interrupt priority register (IP)
NameAddress
IP0B8HPCT—PT2PSPT1PX1PT0PX0
Bit locationFlagFunction
IP.0
IP.1
IP.2
IP.3
IP.4
IP.5
IP.6
IP.7
PX0
PT0
PX1
PT1
PS
PT2
—
PCT
MSBLSB
76543210
Interrupt priority bit for external interrupt 0.
Priority is assigned when bit is "1".
Interrupt priority bit for timer interrupt 0.
Priority is assigned when bit is "1".
Interrupt priority bit for external interrupt 1 .
Priority is assigned when bit is " 1 ".
Interrupt priority bit for timer interrupt 1 .
Priority is assigned when bit is "1".
Interrupt priority bit for serial port.
Priority is assigned when bit is "1".
Interrupt priority bit for timer interrupt 2.
Priority is assigned when bit is "1".
Reserved bit. The output data is "1" if the bit is read.
Priority interrupt circuit control bit.
The priority register contents are valid and priority assigned
interrupts can be processed when this bit is "0". When the bit is
"1", the priority interrupt circuit is stopped, and interrupts can only
be controlled by the interrupt enable register (IE).
72
4.4.2.7 Program status word register (PSW)
INTERNAL SPECIFICATIONS
NameAddress
MSBLSB
76543210
PSW0D0HCYACF0RS1RS0OVF1P
Bit locationFlagFunction
PSW.0
P
Accumulator (ACC) parity indicator.
"1" when the "1" bit number in the accumulator is an odd number,
and "0" when an even number.
PSW.1
PSW.2
F1
OV
User flag which may be set to "0" or "1" as desired by the user.
Overflow flag which is set if the carry C6 from bit 6 of the ALU or
CY is "1" as a result of an arithmetic operation. The flag is also set
to "1" if the resultant product of a multiplication instruction (MUL
AB) is greater than 0FFH, but is reset to "0" if the product is less
than or equal to 0FFH.
PSW.3
RS0
RAM register bank switch
RS1RS0BANKRAM ADDRESS
00000H – 07H
PSW.4
RS1
01108H – 0FH
10210H – 17H
11318H – 1FH
PSW.5
PSW.6
F0
AC
User flag which ma be set to "0" or "1" as desired by the user.
Auxiliary carry flag.
This flag is set to "1" if a carry C
3 is generated from bit 3 of the
ALU as a result of executing an arithmetic operation instruction. In
all other cases, the flag is reset to "0".
PSW.7
CY
Main carry flag.
This flag is set to "1" if a carry C
7 is generated from bit 7 of the
ALU as a result of executing an arithmetic operation instruction. In
all other cases, the flag is reset to "0".
73
MSM80C154S/83C154S/85C154HVS
4.4.2.8 I/O control register (IOCON)
NameAddress
IOCON0F8H—T32SERRIZCP3HZP2HZP1HZALF
Bit locationFlagFunction
IOCON.0
IOCON.1
IOCON.2
IOCON.3
IOCON.4
IOCON.5
IOCON.6
IOCON.7
ALF
P1HZ
P2HZ
P3HZ
IZC
SERR
T32
—
MSBLSB
76543210
If CPU power down mode (PD, HPD) is activated with this bit set
to "1", the outputs from ports 0, 1, 2, and 3 are switched to floating
status.
When this bit is "0", ports 0, 1, 2, and 3 are in output mode.
Port 1 becomes a high impedance input port when this bit is "1".
Port 2 becomes a high impedance input port when this bit is "1".
Port 3 becomes a high impedance input port when this bit is "1".
The 10 kohm pull-up resistance for ports 1, 2, and 3 is switched off
when this bit is "1", leaving only the 100 kohm pull-up resistance.
Serial port reception error flag.
This flag is set to "1" if an overrun or framing error is generated
when data is received at a serial port. The flag is reset by software.
Timer/counters 0 and 1 are connected serially to form a 32-bit
timer/counter when this bit is set to "1". TF1 of TCON is set if a
carry is generated in the 32-bit timer/counter.
The output data is "0" if the bit is read.
This bit should not be set to "1".
74
4.4.2.9 Timer 2 control register (T2CON)
INTERNAL SPECIFICATIONS
NameAddress
TMOD0C8HTF2EXF2RCLKTCLK
Bit locationFlagFunction
T2CON.0
T2CON.1
T2CON.2
T2CON.3
T2CON.4
T2CON.5
T2CON.6
T2CON.7
CP/
RL2
C/
T2
TR2
EXEN2
TCLK
RCLK
EXF2
TF2
MSBLSB
76543210
EXEN2
Capture mode is set when TCLK+RCLK="0" and CP/
auto reload mode is set when TCLK+RCLK="0" and CP/
CP/
Timer/counter 2 count clock designation control bit.
The internal clocks (XTAL1·2÷12, XTAL1·2÷2) are used when this
bit is "0", and the external clock applied to the T2 pin is passed to
timer/counter 2 when the bit is "1".
Timer/counter 2 counting start and stop control bit.
Timer/counter 2 commences counting when this bit is "1" and
stops counting when "0".
T2EX timer/counter 2 external control signal control bit. Input of the
T2EX signal is disabled when this bit is "0", and enabled when "1".
Serial port transmit circuit drive clock control bit.
Timer/counter 2 is switched to baud rate generator mode when this
bit is "1", and the timer/counter 2 carry signal becomes the serial
Port transmit clock. Note, however, that the serial ports can only
use the timer/counter 2 carry signal in serial port modes 1 and 3.
Serial port receive circuit drive clock control bit.
Timer/counter 2 is switched to baud rate generator mode when this
bit is "1", and the timer/counter 2 carry signal becomes the serial
Port receive clock. Note, however, that the serial ports can only
use the timer/counter 2 carry signal in serial port modes 1 and 3.
Timer/counter 2 external flag.
This bit is set to "1" when the T2EX timer/counter 2 external
control signal level is changed from "1" to "0" while EXEN2="1".
This flag serves as the timer interrupt 2 request signal. if an
interrupt is generated, it must be reset to "0" by software.
Timer/counter 2 carry flag.
This bit is set to "1" by a carry signal when timer/counter 2 is in 16bit auto reload mode or in capture mode.
This flag serves as the timer interrupt 2 request signal. if an
interrupt is generated, it must be reset to "0" by software.
is ignored when TCLK+RCLK="1".
RL2
TR2C/
RL2
T2
16-bit
RL2
CP/RL2
="0".
75
MSM80C154S/83C154S/85C154HVS
4.5 Timer/Counters 0, 1 and 2
4.5.1 Outline
Timer/counters 0, 1 and 2 are all equipped with 16-bit binary up-counting and Read/Write
functions, and can be operated independently.
All control of timer/counters 0 and 1 is handled by the timer control register (TCON 88H) and
the timer mode register (TMOD 89H). And both timer/counters can be set independently to
modes 0 thru 3 for a diversity of applications.
Timer/counters 0 and 1 can be operated by an external clock applied to the T0 and T1 pins
(if external clock mode has been set) during soft power down mode (PD) and hard power
down mode (HPD) where XTAL1·2 are stopped. Therefore, CPU power down mode can be
cancelled by generating a timer/counter carry signal.
Timer/counter 2 can be fully controlled by timer 2 control register (T2CON 0C8H). There are
three operational modes for a wide range of applications. Note that counting is stopped when
XTAL1·2 are stopped.
4.5.2 Timer/counters 0 and 1
4.5.2.1 Outline
Timer/counters 0 and 1 are both equipped with a 16-bit binary counting function which can
be operated independently.
All control of timer/counters 0 and 1 is handled by the timer control register (TCON) and the
timer mode register (TMOD). And both timer/counters can be set independently to modes 0
thru 3 for a diversity of applications. The overall control circuit for timer/counters 0 and 1 is
outlined in Figure 4-7 (excluding timer mode 3).
4.5.2.2 Timer/counter 0 and 1 counting control
Counting start and stop in timer/counters 0 and 1 is controlled by bit 4, TR0, and bit 6, TR1,
in the timer control register (TCON 88H) as indicated in Table 4-7.
TR0 controls timer/counter 0, and TR1 controls timer/counter 1. Timer/counter operation is
stopped when the bit data is “0”, and enabled when “1”.
Table 4-7 Timer control register (TCON 88H)
Timer 1Timer 0
Bit 76543210
FlagTF1TR1TF0TR0IE1IT1IE0IT0
Set••
76
INTERNAL SPECIFICATIONS
TIMER 1
TIMER 0
TIMER CONTROL REGISTER (TCON)
76543210
TF1 TR1TF0TR0IE1IT1IE0IT0
Q
DATA
LATCHS5
INT0 PIN
(PORT 3.2)
XTAL 1÷12S3
DETECTOR
T1 PIN
(PORT 3.5)
Q
DATA
LATCHS5
INT1 PIN
(PORT 3.3)
DETECTOR
T0 PIN
(PORT 3.4)
Figure 4-7 Overall clock input control circuit for timer/counters 0 and 1
77
TIMER MODE REGISTER (TMOD)
76543210
GATE C/TM1M0 GATE C/TM1M0
MSM80C154S/83C154S/85C154HVS
4.5.2.3 Timer/counter 0 and 1 count clock designation
Designation of count clock inputs to timer/counters 0 and 1 is controlled by bit 2 and 6, C/T,
in the timer mode register (TMOD 89H).
Timer/counter 0 is controlled by bit 2, C/T, and timer/counter 1 is controlled by bit 6, C/T.
The internal clock is passed to the timer/counter when the C/T bit is “0”. This internal clock
is the result of dividing XTAL1·2 by 12. The S3 timing signal (see Figure 2-9) becomes the
clock.
The external clock is applied to the timer/counter when the C/T bit is “1”. The external clock
applied to the T0 pin serves as the timer/counter 0 input, while the external clock applied to
the T1 pin serves as the timer/counter 1 input.
Table 4-8 Timer mode register (TMOD 89H)
Timer 1Timer 0
Bit 76543210
Flag
Set•
GATEC/TM1M0GATEC/TM1M0
•
78
INTERNAL SPECIFICATIONS
4.5.2.3.1 External clock detector circuit for timer/counters 0 and 1
The detector circuit shown in Figure 4-8 is inserted between the timer/counters and the
external clock pin.
This detector circuit operates in the following way. When the external clock applied to the T0
and T1 pins is changed from “1” to “0” level, that clock is fetched by F/Fl, and is then passed
to F/F2 when the S5 timing signal appears. This F/F2 output is subsequently ANDed (logical
product) with the S3 timing signal to form the timer/counter clock signal which then serves as
the F/Fl reset signal. The reset F/Fl then waits for the next external clock. The “0” and “1” signal
cycle widths of the respective external clocks applied to the T0 and T1 pins must have a
minimum of period 12 times (12T) the XTAL1·2 oscillator clock cycle T. However, when the
CPU is in PD mode or HPD mode the external clock applied to the T0 and T1 pins is input
to timer/counters 0 and 1 directly. The operational time chart for this detector circuit is outlined
in Figure 4-9.
1
0
12T 12T
F/F1F/F2
V
CC
T0 or T1
RESET
PD & HPD
Figure 4- 8 T0 and T1 external clock detector circuit
QD
R
S5
QD
L
S3
TIMER 0
or
TIMER 1
79
MSM80C154S/83C154S/85C154HVS
M1 or M2
XTAL1
ALE
T0 or T1
COUNT IN
F/F1Q
F/F2Q
TIMER COUNT
S1 S2 S3 S4 S5 S6M1S1 S2 S3 S4 S5 S6
1
0
1
0
1
0
1
0
1
0
1
0
S1
S2S6
Figure 4-9 Detector circuit operational time chart
4.5.2.4 Counting control of timer/counters 0 and 1 by INT pin
In addition to control by TR0 and TR1 bits of timer control register (TCON), timer/counter 0
and 1 counting start and stop can also be controlled by the signal level applied to the external
interrupt pin in accordance with the GATE data values of bits 3 and 7 in the timer mode register
(TMOD 89H) indicated in Table 4-9.
Timer/counter 0 is controlled by the bit 3, GATE bit. When the GATE bit is “0”, counting is
started and stopped only by TR0.
When the GATE bit is “1”, counting in timer/counter 0 is enabled if the TR0 bit and INT0 pin
input signal are both “1”. Counting is subsequently stopped if either is changed to “0” level.
Timer/counter 1 is controlled by the bit 7, GATE bit, the functional operation being the same
as timer/counter 0. The GATE - INT timer/counter counting control circuit is outlined in Figure
4-10, and the control table is given in Table 4-10.
Bit
Flag
Set
Table 4-9 Timer mode register (TMOD 89H)
Timer 1Timer 0
76543210
GATEC/TM1M0GATEC/TM1M0
••
80
INTERNAL SPECIFICATIONS
GATE
TR0
INT0
RUN
STOP
XTAL 1÷
T0 or T1
INT0 or INT1
✽ GATE
TR0 or TR1
Figure 4-10 INT0 and INT1 timer/counter start/stop control circuit
Table 4-10 GATE·INT·TR timer/counter control tables
0
0
0
1
×
×
•
•
12S3
DETECTOR
C/ T
S5
TIMER 0
1
0
0
•
QD
L
1
1
1
1
0
1
•
•
GATE
TR1
INT1
RUN
STOP
0
0
×
•
TIMER 1
0
1
×
•
1
0
0
•
TIMER 0
or
TIMER 1
CLOCK
1
1
0
•
1
1
1
•
81
MSM80C154S/83C154S/85C154HVS
4.5.2.5 Timer/counters 0/1 timer modes
4.5.2.5.1 Outline
The timer/counter 0 and 1 timer modes are set by combinations of M0 and M1 bit data in the
timer mode register (TMOD 89H) shown in Table 4-11. The timer modes which can be set
are 0, 1, 2, and 3.
Timer/counter 0 modes are specified by M0 and M1 of bits 0 and 1, and timer/counter 1 modes
are specified by M0 and M1 of bits 4 and 5.
Table 4-11 Timer mode register (TMOD 89H)
TIMER COUNTER 1TIMER COUNTER 0
Bit
Flag
Set
76543210
GATEC/TM1M0GATEC/TM1M0
••••
4.5.2.5.2 Mode 0
M1M0
00
In mode 0, timer/counters 0 and 1 both become 13-bit timer/counters by the circuit connection
shown in Figures 4-11 and 4-12. TL0 and TL1 in timer/counters 0 and 1 serve as the counter
for the five lower bits, and TH0 and TH1 serve as the counter for the eight upper bits.
TF0 of TCON is set by the timer/counter 0 carry signal, and TF1 of TCON is set by the timer/
counter 1 carry signal. Note that the timer/counter 1 carry signal can also be used as the serial
port transmission/reception clock.
Although the three upper bits of TL0 and TL1 are operative, they are invalid as signals.
82
INTERNAL SPECIFICATIONS
T0 PIN
(PORT 3.4)
0 PIN
INT
(PORT 3.2)
XTAL 1÷
DETECTOR
T
C/
TR0
GATE
DATA
LATCHS5
XTAL 1÷
12S3
Q
Figure 4-11 Timer/counter 0 mode 0
12S3
DETECTORTF0
Q0------Q4
TL0
(5BITS)
DETECTORTF1
Q0------Q7
(8BITS)
TH0
C
T1 PIN
(PORT 3.5)
1 PIN
INT
(PORT 3.3)
DETECTOR
T
C/
TR1
GATE
DATA
LATCHS5
Q
Figure 4-12 Timer/counter 1 mode 0
Q0------Q4
TL1
(5BITS)
S I/O CLOCK
Q0------Q7
TH1
(8BITS)
C
83
MSM80C154S/83C154S/85C154HVS
4.5.2.5.3 Mode 1
M1M0
01
In mode 1, timer/counters 0 and 1 both become 16-bit timer/counters by the circuit connection
shown in Figures 4-13 and 4-14.
TL0 and TL1 in timer/counters 0 and 1 serve as the counter for the eight lower bits, and TH0
and TH1 serve as the counter for the eight upper bits.
TL0 is set by the timer/counter 0 carry signal, and TF1 is set by the timer/counter 1 carry
signal. Again note that the timer/counter 1 carry signal can also be used as the serial port
transmission/reception clock.
84
INTERNAL SPECIFICATIONS
T0 PIN
(PORT 3.4)
0 PIN
INT
(PORT 3.2)
XTAL 1÷
DETECTOR
T
C/
TR0
GATE
DATA
LATCHS5
XTAL 1÷
12S3
Q
Figure 4-13 Timer/counter 0 model
12S3
DETECTORTF0
Q0------Q7
TL0
(8BITS)
DETECTORTF1
Q0------Q7
(8BITS)
TH0
C
T1 PIN
(PORT 3.5)
1 PIN
INT
(PORT 3.3)
DETECTOR
T
C/
TR1
GATE
DATA
LATCHS5
Q
Figure 4-14 Timer/counter 1 model
Q0------Q7
TL1
(8BITS)
S I/O CLOCK
Q0------Q7
TH1
(8BITS)
C
85
MSM80C154S/83C154S/85C154HVS
4.5.2.5.4 Mode 2
M1M0
10
In mode 2, timer/counters 0 and 1 both become 8-bit timer/counters with 8-bit auto reloader
registers by the circuit connection shown in Figures 4-15 and 4-16. TH0 and TH1 in timer/
counters 0 and 1 serve as the 8-bit auto reloader section, and TL0 and TL1 serve as the timer/
counter section.
If a carry signal is generated by the 8-bit timer/counter TL0 and TL1, the respective auto
reloader register data is preset into the timer/counter, and counting proceeds from the preset
value.
TF0 is set by the timer/counter 0 carry signal, and TF1 is set by the timer/counter 1 carry
signal. Note that the timer/counter 1 carry signal can also be used as the serial port
transmission/reception clock.
86
INTERNAL SPECIFICATIONS
T0 PIN
(PORT 3.4)
0 PIN
INT
(PORT 3.2)
XTAL 1÷
DETECTOR
T
C/
TR0
GATE
DATA
LATCHS5
XTAL 1÷
12S3
Q
Figure 4-15 Timer/counter 0 mode 2
12S3
DETECTORTF0
Q0------Q7
C
TL0
(8BITS)
Q0------Q7
TH0
(8BITS)
S I/O CLOCK
DETECTORTF1
RELOAD
DATA
T1 PIN
(PORT 3.5)
1 PIN
INT
(PORT 3.3)
DETECTOR
T
C/
TR1
GATE
DATA
LATCHS5
Q
Figure 4-16 Timer/counter 1 mode 2
Q0------Q7
TL1
(8BITS)
Q0------Q7
TH1
(8BITS)
C
RELOAD
DATA
87
MSM80C154S/83C154S/85C154HVS
4.5.2.5.5 Mode 3
M1M0
11
In mode 3, timer/counter 0 TL0 and TH0 become independent 8-bit timer/counters by the
circuit connection shown in Figure 4-17. Timer/counter 1 does not operate when mode 3 is
set. The TL0 8-bit timer/counter is controlled in the same way as the regular timer/counter 0,
TF0 being set if a carry signal is generated by TL0.
The TH0 8-bit timer/counter is controlled only by TR1, and the control only covers count
starting and stopping. TF1 is set by a carry signal generated by TH0.
When timer/counter 0 is set to mode 3, timer/counter 1 can operate in modes 0, 1, or 2, and
be used by the serial port clock. Control of timer/counter 1 count starting and stopping in this
case is handled between operating mode and mode 3. If mode 3 is set, the timer/counter 1
counting operation is stopped.
T0 PIN
(PORT 3.4)
0 PIN
INT
(PORT 3.2)
XTAL 1÷
DETECTOR
T
C/
TR0
GATE
DATA
LATCHS5
XTAL 1÷
TR1
12S3
Q
12
DETECTORTF0
Q0------Q7
TL0
(8BITS)
DETECTORTF1
Q0------Q7
TH0
C
(8BITS)
Figure 4-17 Timer/counter 0 mode 3
88
INTERNAL SPECIFICATIONS
4.5.2.5.6 32-bit timer mode
When “1” is set in bit 6 (T32) of the I/O control register (IOCON 0F8H), timer/counters 0 and
1 are connected serially as indicated in Figure 4-18 to become a 32-bit timer/counter.
This 32-bit timer/counter is started by the following procedure. First, “0” is set in TR0, TR1,
TF0, and TF1 of the timer control register (TCON 88H) to stop the timer/counter and reset the
timer flag.
Next timer/counter preset data values are set in timer/counters 0 and 1, and a counter clock
designation is set in bit 2 (C/T) of the timer mode register (TMOD 89H).
If “1” is then set in bit 6 (T32) of the 1/0 control register (IOCON 0F8H) after completing the
above procedure, the 32-bit timer/counter is established and counting is commenced. This
32-bit timer/counter is especially useful in cancelling CPU power down mode. (See power
down mode cancellation.)
T0 PIN
(PORT 3.4)
C/
T
(TMOD bit2)
DETECTOR
XTAL 1÷
IOCON [0F8H]
76543210
TH0
SERR
•
Q0-----Q7
TL1
(8BITS)
12
Q0-----Q7
(8BITS)
Figure 4-18 32-bit timer/counter
—T32
Q0-----Q7
TL0
(8BITS)
IZC
P3HZ P2HZ P1HZ
Q0-----Q7
TH1
(8BITS)
ALF
TF1
89
MSM80C154S/83C154S/85C154HVS
4.5.2.5.7 Caution about use of timer counters 0 and 1
Since the internal clock stops operation during soft power down mode (PD), the auto-reload
operation is not executed if timer/counters 0 and 1 are set to mode 2 or mode 3.
If the power down mode is to be cancelled by the timer, timer/counters 0 and 1 must be set
to mode 0 or mode 1.
When timers 0 and 1 are set to external clock mode, the external clock is taken in as shown
in Figure 4-19 and the power down mode can be cancelled through the overflow of the timer.
If the external interrupt occurs when the T0 or T1 pin goes to “1” level and the soft power down
mode (PD) is cancelled, the gate output (A) changes from “1” level to “0” level and the counter
is incremented by 1.
In addition, “Q” of F/F1 is set on the trailing edge of T0 or T1.
Thus, the counter is incremented by additional 1.
The same event occurs not only by the external interrupt but also by the overflow of the timer.
This is because the overflow signal of the timer is made up of the timer count value “FF” and
the clock input signal “AND”. Therefore, the timer interrupt occurs when the T0 or T1 pin goes
to “1” level, and the power down mode is cancelled and the counter is incremented by
additional 1.
In cancelling the soft power down mode with the external interrupt, if the timer is set to external
clock mode, the T0 or T1 pin must be set to “0” level. If the T0 or T1 pin is at “1” level or if the
power down mode is cancelled by the overflow of the timer, the timer must be reset or the
counter must be decremented by 1.
4.5.2.5.8 Caution about use of timer counters 0 and 1 when setting software power
down mode
When setting sofware power down mode, if the value of a timer counter by which a timer
interrupt is set is immediately before overflow, the software power down mode can not be set.
(Example)
Timer 0 is in mode 1 of external clock.
Content of timer 0 is "FF".
Interrupt by timer 0 is enabled.
TO pin is "1".
If the above conditions all are established, the sofware power down mode cannot be set. This
is because the AND output, shown as (A) of Fig. 4-19, becomes "1" when the software power
down mode is set and timer interrupt is generated.
In this case, set the software power down mode after setting the TO pin to "0".
91
MSM80C154S/83C154S/85C154HVS
4.5.3 Timer/counter 2
4.5.3.1 Outline
Timer/counter 2 is equipped with 16-bit binary counting and Read/Write functions. This timer/
counter is controlled entirely by timer 2 control register (T2CON 0C8H).
The operating modes are 16-bit auto reload mode, capture mode, and baud rate generator
mode. Modes are specified by T2CON RCLK, TCLK, and CP/RL2 bits combinations.
The internal or external clock applied to the timer/counter 2 is specified by the C/T2 bit. And
starting and stopping of timer/counter 2 counting is controlled by the TR2 bit. Note that timer/
counter 2 counting is stopped in CPU power down mode where XTAL1·2 are stopped.
4.5.3.2 Timer 2 control register (T2CON)
The timer 2 control register (T2CON 0C8H) consists of the timer/counter 2 control bits, timer
2 internal flag (TF2), and timer 2 external flag (EXF2). The T2CON contents are outlined in
Table 4-12.
Table 4-12 Timer 2 control register (T2CON 0C8H)
Bit
Flag
76543210
TF2EXF2RCLKTCLKEXEN2TR2C/T2CP/ RL2
CP/RL2 :Capture mode is set when TCLK+RCLK=0 and CP/RL2=1. The timer/counter
2 contents are passed to the capture register (RCAP2L/RCAP2H) when the
level o the signal applied to the T2EX pin (bit 1 of port 1) is changed from “1” to
“0” with EXEN2-1.
16-bit auto reload mode is set when TCLK+RCLK=0 and CP/RL2=0. The CP/
RL2 data is ignored when TCLK+RCLK=1.
C/T2:Timer/counter 2 clock input designation bit.
The internal clock is specified when this bit is “0” and the external clock is
specified
when “1”.
TR2:Timer/counter 2 counting start and stop control bit.
Timer/counter 2 operation is stopped when this bit is “0”, and enabled when “1”
EXEN2 :The T2EX pin control bit. The signal applied to the T2EX pin is invalid when this
bit is “0”, and valid when “1”.
TCLK:Serial port transmit clock control bit. When this bit is set to “1”, timer/counter 2
is set to 16-bit auto reload operation mode, and the timer/counter 2 carry signal
activates the serial port transmit circuit. This clock is only valid when serial port
mode 1 or 3 has been set.
RCLK:Serial port receive clock control bit. When this bit is set to “1”, timer/counter 2
is set to 16-bit auto reload operation mode, and the timer/counter 2 carry signal
activates the serial port receive circuit.
This clock is only valid when serial port mode 1 or 3 has been set.
92
INTERNAL SPECIFICATIONS
EXF2:Timer/counter 2 external flag bit which is set when the T2EX pin level (bit 1 of
port 1) is changed from “1” to “0” at EXEN2=1. This flag serves as the timer
interrupt 2 request signal. When an interrupt is generated, this flag must be reset
to “0” by software.
TF2:Timer/counter 2 internal flag bit which is set when a carry signal is generated by
timer/counter 2 in 16-bit auto reload mode or capture mode. This flag serves as
the timer interrupt 2 request signal. When an interrupt is generated, this flag
must be reset to “0” by software.
4.5.3.3 Timer/counter 2 operation modes
Timer/counter 2 operation modes are set by combinations of the CP/RL2, TCLK, and RCLK
bits in timer 2 control register (T2CON 0C8H) shown in Table 4-13. The timer modes are listed
in Table 4-14.
Table 4-13 Timer 2 control register (T2CON 0C8H)
Bit
Flag
Set
RCLKTCLKCP/RL2TR2
0001
0011
RCLK + TCLK = 1×1
×××0
76543210
TF2EXF2RCLKTCLKEXEN2TR2C/T2CP/RL2
•••
Table 4-14 Timer/counter 2 modes
Mode
16-bit auto reload
16-bit capture
Baud rate generator
All operations stopped
4.5.3.3.1 16-bit auto reload mode
16-bit auto reload mode is set by making the circuit connection shown in Figure 4-20 by setting
RCLK=0, TCLK=0, and CP/RL2=0 as the bit conditions in timer 2 control register (T2CON).
Timer/counter 2 operates in the following way when 16-bit auto reload mode is set. When a
timer/counter 2 carry signal is generated, or when the signal applied to the T2EX pin (bit 1
of port 1) is changed from level “1” to “0”, the reload data in the RCAP2L and RCAP2H
registers is preset in L2 and TH2 of timer/counter 2. The timer/counter thus starts counting
from this preset value.
The timer/counter 2 carry signal is set in internal timer flag 2 (TF2), and the T2EX change is
set in external timer flag 2 (EXF2). The TF2 and EXF2 serve as the timer interrupt 2 request
signals with an interrupt call being made to address 43 (2BH) if the timer interrupt 2 has been
enabled. If an interrupt routine is commenced, the TF2 and EXF2 flags must be reset to “0”
by software.
93
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.