The 3803 group (Spec.L) is the 8-bit microcomputer based on the
740 family core technology.
The 3803 group (Spec.L) is designed for household products,
office automation equipment, and controlling systems that
require analog signal processing, including the A/D converter
and D/A converters.
ParameterFunction
Number of basic instructions71
Minimum instruction execution time0.24 µs (Oscillation frequency 16.8 MHz)
Oscillation frequencyOscillation frequency 16.8 MHz(Maximum)
Memory
Package code
SP : PRDP0064BA-A (64P4B)
HP : PLQP0064KB-A (64P6Q-A)
KP : PLQP0064GA-A (64P6U-A)
WG : PTLG0064JA-A (64F0G)
ROM number
Omitted in the flash memory version.
−: standard
Omitted in the flash memory version.
−: Minner spec. change product
L
ROM/Flash memory size
1: 4096 bytes
2: 8192 bytes
3: 12288 bytes
4: 16384 bytes
5: 20480 bytes
6: 24576 bytes
7: 28672 bytes
8: 32768 bytes
The first 128 bytes and the last 2 bytes of ROM are reserved areas ; they
cannot be used as a user’s ROM area.
However, they can be programmed or erased in the flash memory version,
so that the users can use them.
FUNCTIONAL DESCRIPTION
CENTRAL PROCESSING UNIT (CPU)
The 3803 group (Spec.L) uses the standard 740 Family
instruction set. Refer to the table of 740 Family addressing
modes and machine instructions or the 740 Family Software
Manual for details on the instruction set.
Machine-resident 740 Family instructions are as follows:
The FST and SLW instructions cannot be used.
The STP, WIT, MUL, and DIV instructions can be used.
[Accumulator (A)]
The accumulator is an 8-bit register. Data operations such as data
transfer, etc. are executed mainly through the accumulator.
[Index Register X (X)]
The index register X is an 8-bit register. In the index addressing
modes, the value of the OPERAND is added to the contents of
register X and specifies the real address.
[Index Register Y (Y)]
The index register Y is an 8-bit register. In partial instruction, the
value of the OPERAND is added to the contents of register Y
and specifies the real address.
b7 b0
A
b7 b0
X
b7 b0
Y
b7 b0
S
[Stack Pointer (S)]
The stack pointer is an 8-bit register used during subroutine calls
and interrupts. This register indicates start address of stored area
(stack) for storing registers during subroutine calls and
interrupts.
The low-order 8 bits of the stack address are determined by the
contents of the stack pointer. The high-order 8 bits of the stack
address are determined by the stack page selection bit. If the
stack page selection bit is “0”, the high-order 8 bits becomes
“00
16”. If the stack page selection bit is “1”, the high-order 8 bits
becomes “01
The operations of pushing register contents onto the stack and
popping them from the stack are shown in Figure 8.
Store registers other than those described in Fi gure 7 with
program when the user needs them during interrupts or
subroutine calls (see Table 4).
[Program Counter (PC)]
The program counter is a 16-bit counter consisting of two 8-bit
registers PC
next instruction to be executed.
16”.
H and PCL. It is used to indicate the address of the
Accumulator
Index Register X
Index Register Y
Stack Pointer
b15
b7 b0
b7 b0
Fig 7.740 Family CPU register structure
PC
LPCH
Program Counter
CZIDBTVN
Processor Status Register (PS)
Carry Flag
Zero Flag
Interrupt Disable Flag
Decimal Mode Flag
Break Flag
Index X Mode Flag
Overflow Flag
Negative Flag
Rev.1.00Apr 2, 2007Page 9 of 117
REJ03B0212-0100
3803 Group (Spec.L)
On-going Routine
Push Return
Address
on Stack
POP Return
Address from
Stack
Interrupt request
M(S)←(PCH)
(S)←(S) − 1
M(S)←(PCL)
(S)←(S) −1
Subroutine
.....
Execute RTS
(S)←(S) + 1
(PCL)←M(S)
(1)
Execute JSR
M(S)←(PCH)
(S)←(S) − 1
M(S)←(PCL)
(S)←(S) − 1
M(S)←(PS)
(S)←(S) − 1
Interrupt
Service Routine
.....
Execute RTI
(S)←(S) + 1
(PS)←M(S)
(S)←(S) + 1
Push Return Address
on Stack
Push Contents of
Processor
Status Register on Stack
I Flag is Set from
“0” to “1”
Fetch the Jump
Vector
POP Contents of
Processor Status Register
from Stack
(S)←(S) + 1
(PCH)←M(S)
Note 1 : Condition for acceptance of an interrupt → Interrupt enable flag is “1”
Interrupt disable flag is “0”
(PCL)←M(S)
(S)←(S) + 1
(PCH)←M(S)
POP Return
Address from Stack
Fig 8.Register push and pop at interrupt generatio n and subroutine call
Table 4Push and pop instructions of accumulator or processor status register
Push instruction to stackPop instruction from stack
AccumulatorPHAPLA
Processor status registerPHPPLP
Rev.1.00Apr 2, 2007Page 10 of 117
REJ03B0212-0100
3803 Group (Spec.L)
[Processor status register (PS)]
The processor status register is an 8-bit register consisting of 5
flags which indicate the status of the processor after an
arithmetic operation and 3 flags which decide MCU operation.
Branch operations can be performed by testing the Carry (C)
flag, Zero (Z) flag, Overflow (V) flag, or the Negative (N) flag.
In decimal mode, the Z, V, N flags are not valid.
Bit 0: Carry flag (C)
The C flag contains a carry or borrow generated by the
arithmetic logic unit (ALU) immediately after an arithmetic
operation. It can also be changed by a sh ift or rotate
instruction.
Bit 1: Zero flag (Z)
The Z flag is set if the result of an immediate arithmetic
operation or a data transfer is “0”, and cleared if the result is
anything other than “0”.
Bit 2: Interrupt disable flag (I)
The I flag disables all interrupts except for the interrupt
generated by the BRK instruction.
Interrupts are disabled when the I flag is “1”.
Bit 3: Decimal mode flag (D)
The D flag determines whether additions and subtractions are
executed in binary or decimal. Binary arithmetic is executed
when this flag is “0”; decimal arithmetic is executed when it
is “1”.
Decimal correction is automatic in decimal mode. Only the
ADC and SBC instructions can execute decimal arithmetic.
Bit 4: Break flag (B)
The B flag is used to indicate that the current interrupt was
generated by the BRK instruction. The BRK flag in the
processor status register is always “0”. When the BRK
instruction is used to generate an interrupt, the processor
status register is pushed onto the stack with the break flag set
to “1”.
Bit 5: Index X mode flag (T)
When the T flag is “0”, arithmetic operations are performed
between accumulator and memory. When the T flag is “1”,
direct arithmetic operations and direct data transfers are
enabled between memory locations.
Bit 6: Overflow flag (V)
The V flag is used during the addition or subtraction of one
byte of signed data. It is set if the result exceeds +127 to −
128. When the BIT instruction is executed, bit 6 of the
memory location operated on by the BIT instruction is stored
in the overflow flag.
Bit 7: Negative flag (N)
The N flag is set if the result of an arithmetic operation or
data transfer is negative. When the BIT instruction is
executed, bit 7 of the memory location operated on by the
BIT instruction is stored in the negative flag.
Table 5Set and clear instructions of each bit of processor status register
C flagZ flagI flagD flagB flagT flagV flagN flag
Set instructionSEC
Clear instructionCLC−CLICLD−CLTCLV−
−SEISED−SET−−
Rev.1.00Apr 2, 2007Page 11 of 117
REJ03B0212-0100
3803 Group (Spec.L)
[CPU Mode Register (CPUM)] 003B16
The CPU mode register contains the stack page selection bit, the
internal system clock control bits, etc.
The CPU mode register is allocated at address 003B16.
b7b0
1
CPU mode register
(CPUM: address 003B
Processor mode bits
b1 b0
00 : Single-chip mode
01:
10 :Not available
11:
Stack page selection bit
0 : 0 page
1 : 1 page
Fix this bit to “1”.
Port XC switch bit
0 : I/O port function (stop oscillating)
CIN-XCOUT oscillating function
1:X
Main clock (X
0 : Oscillating
1 : Stopped
Main clock division ratio selection bits
b7 b6
00:φ = f(X
01:φ = f(X
10:φ = f(X
11 : Not available
When the MCU stops the clock oscillation by the STP instruction
and the STP instruction has been released by an external
interrupt source, usually, the fixed values of Timer 1 and
Prescaler 12 (Timer 1 = 0116, Prescaler 12 = FF16) are
automatically reloaded in order for the oscillation to stabilize.
The user can inhibit the automatic setting by setting “1” to bit 0
of MISRG (address 0010
16).
However, by setting this bit to “1”, the previous values, set just
before the STP instruction was executed, will remain in Timer 1
and Prescaler 12. Therefore, you will need to set an appropriate
value to each register, in accordance with the oscillation
stabilizing time, before executing the STP instruction.
Figure 10 shows the structure of MISRG.
(2) Bits 1, 2, 3 of address 0010
16: Middle-speed Mode
Automatic Switch Function
In order to switch the clock mode of an MCU which has a subclock, the following procedure is necessary:
set CPU mode register (003B
16) --> start main clock oscillation
--> wait for oscillation stabilization --> switch to middle-speed
mode (or high-speed mode).
However, the 3803 group (Spec.L) has the built-in function
which automatically switches from low to middle-spee d mode by
program.
• Middle-speed mode automatic switch by program
The middle-speed mode can also be automatically switche d by
program while operating in low-speed mode. By setting the
middle-speed automatic switch start bit (bit 3) of MISRG
(address 0010
16) to “1” in the condition that the middle-speed
mode automatic switch set bit is “1” while operating in lowspeed mode, the MCU will automatically switch to middle-speed
mode. In this case, the oscillation stabilizing time of the main
clock can be selected by the middle-speed automatic switch wait
time set bit (bit 2) of MISRG (address 0010
16).
b7b0
Note 1 : When automatic switch to middle-speed mode from low-speed mode occurs,
the values of CPU mode register (3B
MISRG
(MISRG: address 0010
Oscillation stabilizing time set after STP instruction
released bit
0 : Automatically set “01
Prescaler 12
1 : Automatically set disabled
Middle-speed mode automatic switch set bit
0 : Not set automatically
1 : Au tomatic switching enabled
Middle-speed mode automatic switch wait time set bit
0 : 4.5 to 5.5 machine cycles
1 : 6.5 to 7.5 machine cycles
Middle-speed mode automatic switch start bit
(Depending on program)
0 : Invalid
1 : Automatic switch start
Not used (return “0” when read)
(Do not write “1” to this bit)
16) change.
16)
16” to Timer 1, “FF16” to
(1)
(1)
Fig 10. Structure of MISRG
Rev.1.00Apr 2, 2007Page 13 of 117
REJ03B0212-0100
3803 Group (Spec.L)
MEMORY
• Special Function Register (SFR) Area
The Special Function Register area in the zero page contains
control registers such as I/O ports and timers.
• RAM
The RAM is used for data storage and for stack area of
subroutine calls and interrupts.
•ROM
The first 128 bytes and the last 2 bytes of ROM are reserved for
device testing and the rest is a user area for storing programs.
The reserved ROM area can program/erase in the flash memory
version.
Port P0 (P0)
Port P0 direction register (P0D)
Port P1 (P1)
Port P1 direction register (P1D)
Port P2 (P2)
Port P2 direction register (P2D)
Port P3 (P3)
Port P3 direction register (P3D)
Port P4 (P4)
Port P4 direction register (P4D)
Port P5 (P5)
Port P5 direction register (P5D)
Port P6 (P6)
Port P6 direction register (P6D)
Timer 12, X count source selection register (T12XCSS)
Timer Y, Z count source selection register (TYZCSS)
MISRG
Reserved (Note 1)
Reserved (Note 1)
Reserved (Note 1)
Reserved (Note 1)
Reserved (Note 1)
Reserved (Note 1)
Reserved (Note 1)
Transmit/Receive buffer register 1 (TB1/RB1)
Serial I/O1 status register (SIO1 STS)
Serial I/O1 control register (SIO1CON)
UART1 control register (UART1CON)
Baud rate generator (BRG1)
Serial I/O2 control register (SIO2CON)
Watchdog timer control register (WDTCON)
Serial I/O2 register (SIO2)
Fig 12. Memory map of special function register (SFR)
Rev.1.00Apr 2, 2007Page 15 of 117
REJ03B0212-0100
0FF016
0FF116
0FF216
0FF316
0FF416
0FF516
0FF616
Notes1: Do not write any data to these addresses, because these are
Port P0 pull-up control register (PULL0)
Port P1 pull-up control register (PULL1)
Port P2 pull-up control register (PULL2)
Port P3 pull-up control register (PULL3)
Port P4 pull-up control register (PULL4)
Port P5 pull-up control register (PULL5)
Port P6 pull-up control register (PULL6)
reserved area.
2: Do not access to the SFR area including nothing.
3803 Group (Spec.L)
I/O PORTS
The I/O ports have direction registers which determine the
input/output direction of each individual pin. Each bit in a
direction register corresponds to one pin, and each pin can be set
to be input port or output port.
When “0” is written to the bit corresponding to a pin, that pin
input are floating. If a pin set to input is written to, only the port
output latch is written to and the pin remains floating.
By setting the port P0 pull-up control register (address 0FF016)
to the port P6 pull-up control register (address 0FF6
16) ports can
control pull-up with a program. However, the contents of these
registers do not affect ports programmed as the output ports.
becomes an input pin. When “1” is written to that bit, that pin
becomes an output pin.
If data is read from a pin which is set to output, the value of the
port output latch is read, not the value of the pin itself. Pins set to
Table 6 I /O po rt function
PinNameInput/
Output
0/AN8−P07/AN15Port P0 Input/output,
P0
P10/INT
41
P11/INT
01
2−P17(3)
P1
0(LED0)−
P2
7(LED7)
P2
0/DA1
P3
Port P1External interrupt input Interrupt edge selection register(2)
Port P2
Port P3D/A converter outputAD/DA control register(4)
individual
bits
P31/DA2
2, P33CMOS compatible
P3
P3
4/RXD3
P35/TXD3
P36/SCLK3
P37/SRDY3
P4
0/INT40/XCOUT
Port P4External interrupt input
P41/INT00/XCIN
2/INT1
P4
P43/INT2
4/RXD1
P4
P45/TXD1
P46/SCLK1
P4
7/SRDY1/CNTR2
P5
0/SIN2
Port P5Serial I/O2 function I/OSerial I/O2 control register(13)
P51/SOUT2
P52/SCLK2
P53/SRDY2
Serial I/O1 function I/OSerial I/O1 control register
UART1 control register
Serial I/O1 function I/O
Timer Z function I/O
Serial I/O1 control register
Timer Z mode register
Timer X, Y function I/OTimer XY mode register(17)
NOTES:
1. Refer to the applicable sections how to use double-function ports as function I/O ports.
2. Make sure that the input level at each pin is either 0 V or VCC during execution of the STP instruction.
When an input level is at an intermediate potential, a current will flow from V
CC to VSS through the input-stage gate.
No.
(5)
(6)
(7)
(8)
(9)
(10)
(11)
(6)
(7)
(8)
(12)
(14)
(15)
(16)
Rev.1.00Apr 2, 2007Page 16 of 117
REJ03B0212-0100
3803 Group (Spec.L)
(1) Ports P0, P6
Data bus
(3) Ports P12 to P17, P2
Data bus
Pull-up control bit
Direction
register
Port latch
A/D converter input
Pull-up control bit
Direction
register
Port latch
Analog input pin
selection bit
(2) Ports P10, P11, P42, P43, P57
Pull-up control bit
Direction
register
Data bus
Port latch
(4) Ports P30, P31
Pull-up control bit
Direction
register
Data bus
Port latch
D/A converter output
Interrupt input
DA1 output enable bit (P30)
2 output enable bit (P31)
DA
(5) Ports P32, P33
Data bus
(7) Ports P35, P45
Serial I/O enable bit
Transmit enable bit
Direction
register
Data bus
Port latch
Serial I/O output
Direction
register
Port latch
Pull-up control bit
P-channel
output
disable bit
(6) Ports P34, P44
Serial I/O enable bit
Receive enable bit
Data bus
(8) Ports P36, P46
Serial I/O synchronous clock
Serial I/O mode selection bit
selection bit
Serial I/O enable bit
Serial I/O enable bit
Data bus
Serial I/O clock output
Pull-up control bit
Direction
register
Port latch
Direction
register
Port latch
Serial I/O external clock input
Serial I/O input
Pull-up control bit
Fig 13. Port block diagram (1)
Rev.1.00Apr 2, 2007Page 17 of 117
REJ03B0212-0100
3803 Group (Spec.L)
(9) Port P37
Serial I/O3 mode selection bit
Serial I/O3 enable bit
SRDY3 output enable bit
Direction
register
Data bus
Serial I/O3 ready output
Port latch
(11) Port P41
Port XC switch bit
Direction
register
Data bus
Port latch
Sub-clock generating circuit input
Pull-up control bit
Pull-up control bit
INT00 Interrupt input
Port XC
switch bit
(10) Port P40
Port XC switch bit
Direction
register
Data bus
Port latch
(12) Port P47
Timer Z operating
mode bits
Bit 2
Bit 1
Bit 0
Serial I/O1 mode selection bit
Serial I/O1 enable bit
SRDY1 output enable bit
Direction
register
Data bus
Port latch
Pull-up control bit
INT40 Interrupt input
Pull-up control bit
Port XC
switch bit
(13) Port P50
Pull-up control bit
Direction
register
Data bus
Port latch
Fig 14. Port block diagram (2)
Serial I/O2 input
Timer output
Serial I/O1 ready output
(14) Port P51
Serial I/O2 transmit completion signal
Serial I/O2 port selection bit
Direction
register
Data bus
Port latch
Serial I/O2 output
2 interrupt input
CNTR
Pull-up control bit
P-channel
output
disable bit
Rev.1.00Apr 2, 2007Page 18 of 117
REJ03B0212-0100
3803 Group (Spec.L)
(15) Port P52
Serial I/O2 synchronous clock
Data bus
selection bit
Serial I/O2 port selection bit
Direction
register
Port latch
Serial I/O2 clock output
(17) Ports P54, P55
Direction
register
Data bus
Port latch
Pulse output mode
Timer output
Pull-up control bit
Serial I/O2 external clock input
Pull-up control bit
CNTR Interrupt input
(16) Port P53
SRDY2 output enable bit
Data bus
(18) Port P56
PWM function enable bit
Data bus
Direction
register
Port latch
Serial I/O2 ready output
Direction
register
Port latch
PWM output
Pull-up control bit
Pull-up control bit
Fig 15. Port block diagram (3)
Rev.1.00Apr 2, 2007Page 19 of 117
REJ03B0212-0100
3803 Group (Spec.L)
b7b0
Port P0 pull-up control register
(PULL0: address 0FF0
0 pull-up control bit
P0
16)
0: No pull-up
1: Pull-up
P0
1 pull-up control bit
0: No pull-up
1: Pull-up
2 pull-up control bit
P0
0: No pull-up
1: Pull-up
P0
3 pull-up control bit
0: No pull-up
1: Pull-up
4 pull-up control bit
P0
0: No pull-up
1: Pull-up
P0
5 pull-up control bit
0: No pull-up
1: Pull-up
6 pull-up control bit
P0
0: No pull-up
1: Pull-up
7 pull-up control bit
P0
0: No pull-up
1: Pull-up
Note: Pull-up control is valid when the corresponding
bit of the port direction register is “0” (input).
When that bit is “1” (output), pull-up cannot be
set to the port of which pull-up is selected.
b7b0
Port P1 pull-up control register
(PULL1: address 0FF1
0 pull-up control bit
P1
16)
0: No pull-up
1: Pull-up
P1
1 pull-up control bit
0: No pull-up
1: Pull-up
2 pull-up control bit
P1
0: No pull-up
1: Pull-up
P1
3 pull-up control bit
0: No pull-up
1: Pull-up
4 pull-up control bit
P1
0: No pull-up
1: Pull-up
P1
5 pull-up control bit
0: No pull-up
1: Pull-up
P1
6 pull-up control bit
0: No pull-up
1: Pull-up
7 pull-up control bit
P1
0: No pull-up
1: Pull-up
Note: Pull-up control is valid when the corresponding
bit of the port direction register is “0” (input).
When that bit is “1” (output), pull-up cann ot be
set to the port of which pull-up is selected.
Fig 16. Structure of port pull-up control register (1)
Rev.1.00Apr 2, 2007Page 20 of 117
REJ03B0212-0100
3803 Group (Spec.L)
b7b0
Port P2 pull-up control register
(PULL2: address 0FF2
0 pull-up control bit
P2
16)
0: No pull-up
1: Pull-up
1 pull-up control bit
P2
0: No pull-up
1: Pull-up
P2
2 pull-up control bit
0: No pull-up
1: Pull-up
P2
3 pull-up control bit
0: No pull-up
1: Pull-up
4 pull-up control bit
P2
0: No pull-up
1: Pull-up
P2
5 pull-up control bit
0: No pull-up
1: Pull-up
6 pull-up control bit
P2
0: No pull-up
1: Pull-up
P2
7 pull-up control bit
0: No pull-up
1: Pull-up
Note: Pull-up control is valid when the corresponding
bit of the port direction register is “0” (input).
When that bit is “1” (output), pull-up cannot be
set to the port of which pull-up is selected.
b7b0
Port P3 pull-up control register
(PULL3: address 0FF3
0 pull-up control bit
P3
16)
0: No pull-up
1: Pull-up
1 pull-up control bit
P3
0: No pull-up
1: Pull-up
Not used
(return “0” when read)
P3
4 pull-up control bit
0: No pull-up
1: Pull-up
5 pull-up control bit
P3
0: No pull-up
1: Pull-up
P3
6 pull-up control bit
0: No pull-up
1: Pull-up
7 pull-up control bit
P3
0: No pull-up
1: Pull-up
Note: Pull-up control is valid when the corresponding
bit of the port direction register is “0” (input).
When that bit is “1” (output), pull-up cann ot be
set to the port of which pull-up is selected.
Fig 17. Structure of port pull-up control register (2)
Rev.1.00Apr 2, 2007Page 21 of 117
REJ03B0212-0100
3803 Group (Spec.L)
b7b0
Port P4 pull-up control register
(PULL4: address 0FF4
0 pull-up control bit
P4
16)
0: No pull-up
1: Pull-up
P4
1 pull-up control bit
0: No pull-up
1: Pull-up
2 pull-up control bit
P4
0: No pull-up
1: Pull-up
P4
3 pull-up control bit
0: No pull-up
1: Pull-up
4 pull-up control bit
P4
0: No pull-up
1: Pull-up
P4
5 pull-up control bit
0: No pull-up
1: Pull-up
6 pull-up control bit
P4
0: No pull-up
1: Pull-up
7 pull-up control bit
P4
0: No pull-up
1: Pull-up
Note: Pull-up control is valid when the corresponding
bit of the port direction register is “0” (input).
When that bit is “1” (output), pull-up cannot be
set to the port of which pull-up is selected.
b7b0
Port P5 pull-up control register
(PULL5: address 0FF5
0 pull-up control bit
P5
16)
0: No pull-up
1: Pull-up
P5
1 pull-up control bit
0: No pull-up
1: Pull-up
2 pull-up control bit
P5
0: No pull-up
1: Pull-up
P5
3 pull-up control bit
0: No pull-up
1: Pull-up
4 pull-up control bit
P5
0: No pull-up
1: Pull-up
P5
5 pull-up control bit
0: No pull-up
1: Pull-up
P5
6 pull-up control bit
0: No pull-up
1: Pull-up
7 pull-up control bit
P5
0: No pull-up
1: Pull-up
Note: Pull-up control is valid when the corresponding
bit of the port direction register is “0” (input).
When that bit is “1” (output), pull-up cann ot be
set to the port of which pull-up is selected.
Fig 18. Structure of port pull-up control register (3)
Rev.1.00Apr 2, 2007Page 22 of 117
REJ03B0212-0100
3803 Group (Spec.L)
b7b0
Port P6 pull-up control register
(PULL6: address 0FF6
0 pull-up control bit
P6
16)
0: No pull-up
1: Pull-up
1 pull-up control bit
P6
0: No pull-up
1: Pull-up
2 pull-up control bit
P6
0: No pull-up
1: Pull-up
P6
3 pull-up control bit
0: No pull-up
1: Pull-up
P6
4 pull-up control bit
0: No pull-up
1: Pull-up
5 pull-up control bit
P6
0: No pull-up
1: Pull-up
6 pull-up control bit
P6
0: No pull-up
1: Pull-up
7 pull-up control bit
P6
0: No pull-up
1: Pull-up
Note: Pull-up control is valid when the corresponding
bit of the port direction register is “0” (input).
When that bit is “1” (output), pull-up cannot be
set to the port of which pull-up is selected.
Fig 19. Structure of port pull-up control register (4)
Rev.1.00Apr 2, 2007Page 23 of 117
REJ03B0212-0100
3803 Group (Spec.L)
Termination of unused pins
• Termination of common pins
I/O ports:Select an input port or an output port and follow
each processing method.
In addition, it is recommended that related
registers be overwritten periodically to prevent
malfunctions, etc.
Output ports: Open.
Input ports: If the input level become unstable, through current
flow to an input circuit, and the power supply
current may increase.
Table 7Termination of unused pins
PinsTermination
P0, P1, P2, P3, P4, P5, P6• Set to the input mode and connect each to V
REFConnect to VCC or VSS (GND).
V
SSConnect to VCC or VSS (GND).
AV
OUTOpen (only when using external clock)
X
• Set to the output mode and open at “L” or “H” output state.
Especially, when expecting low consumption
current (at STP or WIT instruction execution etc.),
pull-up or pull-down input ports to prevent
through current (builtin resistor can be used).
We recommend processing unused pins through a
resistor which can secure I
OH(avg) or IOL(avg).
Because, when an I/O port or a pin which have an
output function is selected as an input port, it may
operate as an output port by incorrect operation
etc.
CC or VSS through a resistor of 1 kΩ to 10 kΩ.
Rev.1.00Apr 2, 2007Page 24 of 117
REJ03B0212-0100
3803 Group (Spec.L)
INTERRUPTS
The 3803 group (Spec.L) interrupts are vector interrupts with a
fixed priority scheme, and generated by 16 sources among 21
sources: 8 external, 12 internal, and 1 software.
(1)
The interrupt sources, vector addresses
, and interrupt priority
are shown in Table 8.
An interrupt requests is accepted when all of the following
conditions are satisfied:
• Interrupt disable flag ................................ .“0”
Though the interrupt priority is determined by hardware, priority
processing can be performed by software using the above bits
Each interrupt except the BRK instruction interrupt has the
and flag.
interrupt request bit and the interrupt enable bit. These bits and
the interrupt disable flag (I flag) control the acceptance of
interrupt requests. Figure 20 shows an interrupt control diagram.
Table 8Interrupt vector addresses and priority
Vector
Interrupt SourcePriority
Addresses
(1)
HighLow
(2)
Reset
INT
02FFFB16FFFA16 At detection of either rising or falling
1FFFD16FFFC16 At resetNon-maskable
Timer ZAt timer Z underflow
13FFF916FFF816 At detection of either rising or falling
2. Reset function in the same way as an interrupt with the highest priority.
16 FFDC16 At BRK instruction executionNon-maskable software interrupt
Interrupt Request Generating
Conditions
edge of INT
edge of INT
0 input
1 input
reception
transmission shift or when
transmission buffer is empty
edge of CNTR
edge of CNTR
0 input
1 input
reception
transmission or reception
edge of INT
edge of INT
edge of INT
edge of CNTR
2 input
3 input
4 input
2 input
At completion of serial I/O3
transmission shift or when
transmission buffer is empty
Remarks
External interrupt
(active edge selectable)
External interrupt
(active edge selectable)
Valid when serial I/O1 is selected
Valid when serial I/O1 is selected
External interrupt
(active edge selectable)
External interrupt
(active edge selectable)
Valid when serial I/O3 is selected
Valid when serial I/O2 is selected
External interrupt
(active edge selectable)
External interrupt
(active edge selectable)
External interrupt
(active edge selectable)
External interrupt
(active edge selectable)
Valid when serial I/O3 is selected
Rev.1.00Apr 2, 2007Page 25 of 117
REJ03B0212-0100
3803 Group (Spec.L)
Interrupt request bit
Interrupt enable bit
Interrupt disable flag (I)
BRK instruction
Fig 20. Interrupt control diagram
• Interrupt Disable Flag
The interrupt disable flag is assigned to bit 2 of the processor
status register. This flag controls the acceptance of all interrupt
requests except for the BRK instruction. When this flag is set to
“1”, the acceptance of interrupt requests is disabled. When it is
set to “0”, acceptance of interrupt requests is enabled. This flag is
set to “1” with the SET instruction and set to “0” with the CLI
instruction.
When an interrupt request is accepted, the contents of the
processor status register are pushed onto the stack while the
interrupt disable flag remaines set to “0”. Subsequently, this flag
is automatically set to “1” and multiple interrupts are disabled.
To use multiple interrupts, set this flag to “0” with the CLI
instruction within the interrupt processing routine.
The contents of the processor status register are popped off the
stack with the RTI instruction.
• Interrupt Request Bits
Once an interrupt request is generated, the corresponding
interrupt request bit is set to “1” and remaines “1” until the
request is accepted. When the request is accepted, this bit is
automatically set to “0”.
Each interrupt request bit can be set to “0”, but cannot be set to
“1”, by software.
Reset
Interrupt request
• Interrupt Source Selection
Any of the following combinations can be selected by the
interrupt source selection register (0039
1. INT
0 or timer Z
16).
2. CNTR1 or Serial I/O3 reception
3. Serial I/O2 or timer Z
4 or CNTR2
4. INT
5. A/D conversion or serial I/O3 transmission
• External Interrupt Pin Selection
For external interrupts INT
0 and INT4, the INT0, INT4 interrupt
switch bit in the interrupt edge selection register (bit 6 of address
003A16) can be used to select INT00 and INT40 pin input or
INT
01 and INT41 pin input.
• Interrupt Enable Bits
The interrupt enable bits control the acceptance of t he
corresponding interrupt requests. When an interrupt enable bit is
set to “0”, the acceptance of the corresponding interrupt request
is disabled. If an interrupt request occurs in this condition, the
corresponding interrupt request bit is set to “1”, but the interrupt
request is not accepted. When an interrupt enable bit is set to “1”,
acceptance of the corresponding interrupt request is enabled.
Each interrupt enable bit can be set to “0” or “1” by software.
The interrupt enable bit for an unused interrupt should be set to
“0”.
request bit
Serial I/O2/Timer Z interrupt request bit
INT
2 interrupt request bit
INT
3 interrupt request bit
4/CNTR2 interrupt request bit
INT
AD converter/Serial I/O3 transmit
interrupt request bit
Not used (returns “0” when read)
Interrupt control register 2
(ICON2 : address 003F
16)
0 : Interrupts disabled
1 : Interrupts enabled
b7b0
INT
0/Timer Z interrupt enable bit
1 interrupt enable bit
INT
Serial I/O1 receive interrupt enable bit
Serial I/O1 transmit interrupt enable bit
Timer X interrupt enable bit
Timer Y interrupt enable bit
Timer 1 interrupt enable bit
Timer 2 interrupt enable bit
Interrupt source selection register
(INTSEL : address 0039
0/Timer Z interrupt source selection bit
INT
0 interrupt
0 : INT
1 : Timer Z interrupt
Serial I/O2/Timer Z interrupt source selection bit
16)
(Do not write “1” to these bits simultaneously.)
0 : Serial I/O2 interrupt
1 : Timer Z interrupt
Not used (Do not write “1”.)
INT
4/CNTR2 interrupt source selection bit
0 : INT
4 interrupt
1 : CNTR
2 interrupt
Not used (Do not write “1”.)
1/Serial I/O3 receive interrupt source selection bit
CNTR
0 : CNTR
1 interrupt
1 : Serial I/O3 receive interrupt
AD converter/Serial I/O3 transmit interrupt source selection bit
0 : A/D converter interrupt
1 : Serial I/O3 transmit interrupt
CNTR0 interrupt enable bit
CNTR
enable bit
Serial I/O2/Timer Z interrupt enable bit
INT
2 interrupt enable bit
INT
3 interrupt enable bit
4/CNTR2 interrupt enable bit
INT
AD converter/Serial I/O3 transmit
interrupt enable bit
Not used (returns “0” when read)
(Do not write “1”.)
0 : Interrupts disabled
1 : Interrupts enabled
1/Serial I/O3 receive interrupt
Fig 21. Structure of interrupt-related registers
Rev.1.00Apr 2, 2007Page 27 of 117
REJ03B0212-0100
3803 Group (Spec.L)
• Interrupt Request Generation, Acceptance, and Handling
Interrupts have the following three phases.
(i) Interrupt Request Generation
An interrupt request is generated by an interrupt source
(external interrupt signal input, timer underflow, etc.) and
the corresponding request bit is set to “1”.
(ii) Interrupt Request Acceptance
Based on the interrupt acceptance timing in each instruction
cycle, the interrupt control circuit determines acceptance
conditions (interrupt request bit, interrupt enable bit, and
interrupt disable flag) and interrupt priority levels for
accepting interrupt requests. When two or more interrupt
requests are generated simultaneo usly, the highest priority
interrupt is accepted. The value of interrupt request bit for
an unaccepted interrupt remains the same and acceptance is
determined at the next interrupt acceptance timing point.
(iii) Handling of Accepted Interrupt Request
The accepted interrupt request is processed.
Figure 22 shows the time up to execution in the interrupt
processing routine, and Figure 23 shows the interrupt sequence.
Figure 24 shows the timing of interrupt request generation,
interrupt request bit, and interrupt request acceptance.
• Interrupt Handling Execution
When interrupt handling is executed, the following operations
are performed automatically.
(1) Once the currently executing instruction is completed, an
interrupt request is accepted.
(2) The contents of the program counters and the processor
status register at this point are pushed onto the stack area in
order from 1 to 3.
1. High-order bits of program counter (PCH)
2. Low-order bits of program counter (PCL)
3. Processor status register (PS)
(3) Concurrently with the push operation, the jump address of
the corresponding interrupt (the start address of the interrupt
processing routine) is transferred from the interrupt vector to
the program counter.
(4) The interrupt request bit for the corresponding interrupt is
set to “0”. Also, the interrupt disable flag is set to “1” and
multiple interrupts are disabled.
(5) The interrupt routine is executed.
(6) When the RTI instruction is executed, the contents of the
registers pushed onto the stack area are popped off in the
order from 3 to 1. Then, the routine that was before running
interrupt processing resumes.
As described above, it is necessary to set the stack pointer and
the jump address in the vector area corresponding to each
interrupt to execute the interrupt processing routine.
<Notes>
The interrupt request bit may be set to “1” in the following cases.
• When setting the external interrupt active edge
Related registers:Interrupt edge selection register
• When switching the interrupt sources of an interrupt vector
address where two or more interrupt sources are assigned
Related registers:Interrupt source selection register
(address 0039
16)
If it is not necessary to generate an interrupt synchronized with
these settings, take the following sequence.
(1) Set the corresponding enable bit to “0” (disabled).
(2) Set the interrupt edge selection bit (the active edge switch
bit) or the interrupt source bit.
(3) Set the corresponding interrupt request bit to “0” after one
or more instructions have been executed.
(4) Set the corresponding interrupt enable bit to “1” (enabled).
Interrupt request
generated
Main routine
* When executing DIV instruction
*
0 to 16 cycles
Interrupt request
acceptance
7 to 23 cycles
Interrupt sequence
Stack push and
Vector fetch
7 cycles
Interrupt routine
starts
Interrupt handling
routine
Fig 22. Time up to execution in interrupt routine
Push onto stack
Vector fetch
φ
SYNC
RD
WR
Address bus
Data bus
SYNC : CPU operation code fetch cycle
(This is an internal signal that cannot be observed from the external unit.)
BL, BH: Vector address of each interrupt
AL, AH: Jump destination address of each interrupt
16” or “0116”
SPS : “00
([SPS] is a page selected by the stack page selection bit of CPU mode register.)
S,SPS S-1,SPS S-2,SPS
PC
Not usedPCHPCLPSALAH
BLBHAL,AH
Execute interrupt
routine
Rev.1.00Apr 2, 2007Page 28 of 117
REJ03B0212-0100
Fig 23. Interrupt sequence
3803 Group (Spec.L)
Push onto stack
Vector fetch
Instruction cycle
IR2T3
Internal clock φ
SYNC
Instruction cycle
12
T1
T1 T2 T3 : Interrupt acceptance timing points
IR1 IR2 : Timings points at which the interrupt request bit is set to “1”.
Note : Period 2 indicates the last φ cycle during one instruction cycle.
(1) The interrupt request bit for an interrupt request generated during period 1 is set to “1” at timing point IR1.
(2) The interrupt request bit for an interrupt request generated during period 2 is set to “1” at timing point IR1 or IR2.
The timing point at which the bit is set to “1” varies depending on conditions. When two or more interrupt
requests are generated during the period 2, each request bit may be set to “1” at timing point IR1 or IR2
separately.
IR1T2
Fig 24. Timing of interrupt request generation, interrupt request bit, and interrupt acceptance
Rev.1.00Apr 2, 2007Page 29 of 117
REJ03B0212-0100
3803 Group (Spec.L)
TIMERS
•8-bit Timers
The 3803 group (Spec.L) has four 8-bit timers: timer 1, timer 2 ,
timer X, and timer Y.
The timer 1 and timer 2 use one prescaler in common, and the
timer X and timer Y use each prescaler. Those are 8-bit
prescalers. Each of the timers and prescalers has a timer latch or
a prescaler latch.
The division ratio of each timer or prescaler is given by 1/(n + 1),
where n is the value in the corresponding timer or prescaler latch.
All timers are down-counters. When the timer reaches “00
16”, an
underflow occurs at the next count pulse and the contents of the
corresponding timer latch are reloaded into the timer and the
count is continued. When the timer underflows, the interrupt
request bit corresponding to that timer is set to “1”.
• Timer divider
The divider count source is switched by the main clock division
ratio selection bits of CPU mode register (bits 7 and 6 at address
003B
16). When these bits are “00” (high-speed mode) or “01”
(middle-speed mode), X
(low-speed mode), X
IN is selected. When these bits are “10”
CIN is selected.
• Prescaler 12
The prescaler 12 counts the output of the timer divider. The
count source is selected by the timer 12, X count source selection
register among 1/2, 1/4, 1/8, 1/16, 1/32, 1/64, 1/128, 1/256,
1/512, 1/1024 of f(XIN) or f(XCIN).
• Timer 1 and Timer 2
The timer 1 and timer 2 counts the output of prescaler 12 and
periodically set the interrupt request bit.
• Prescaler X and prescaler Y
The prescaler X and prescaler Y count the output of the timer
divider or f(X
X count source selection register (address 000E
Y, Z count source selection register (address 000F
CIN). The count source is selected by the timer 12,
16) and the timer
16) among 1/2,
1/4, 1/8, 1/16, 1/32, 1/64, 1/128, 1/256, 1/512, and 1/1024 of
f(XIN) or f(XCIN); and f(XCIN).
(1) Timer mode
• Mode selection
This mode can be selected by setting “00” to the timer X
operating mode bits (bits 1 and 0) and the timer Y operating
mode bits (bits 5 and 4) of the t imer XY mode re gister (add ress
0023
16).
• Explanation of operation
The timer count operation is started by setting “0” to the timer X
count stop bit (bit 3) and the timer Y count stop bit (bit 7) of the
timer XY mode register (address 0023
When the timer reaches “00
16”, an underflow occurs at the next
16).
count pulse and the contents of timer latch are reloaded into the
timer and the count is continued.
(2) Pulse Output Mode
• Mode selection
This mode can be selected by setting “01” to the timer X
operating mode bits (bits 1 and 0) and the timer Y operating
mode bits (bits 5 and 4) of the t imer XY mode re gister (add ress
16).
0023
• Explanation of operation
The operation is the same as the timer mode’s. Moreover the
pulse which is inverted each time the timer underflows is output
from CNTR
not the output of CNTR
0/CNTR1 pin. Regardless of the timer counting or
0/CNTR1 pin is initialized to the level of
specified by their active edge switch bits when writing to the
timer. When the CNTR0 active edge switch bit (bit 2) and the
CNTR
1 active edge switch bit (bit 6) of the timer XY mode
register (address 0023
16) is “0”, the output starts with “H” level.
When it is “1”, the output starts with “L” level.
Switching the CNTR
reverse the output level of the corresponding CNTR
0 or CNTR1 active edge switch bit will
0 or CNTR1
pin.
• Precautions
Set the double-function port of CNTR
4/P55 to output in this mode.
P5
0/CNTR1 pin and port
• Timer X and Timer Y
The timer X and timer Y can each select one of four operating
modes by setting the timer XY mode register (address 0023
16).
(3) Event Counter Mode
• Mode selection
This mode can be selected by setting “10” to the timer X
operating mode bits (bits 1 and 0) and the timer Y operating
mode bits (bits 5 and 4) of the t imer XY mode re gister (add ress
0023
16).
• Explanation of operation
The operation is the same as the timer mode’s except that the
timer counts signals input from the CNTR
valid edge for the count operation depends on the CNTR
edge switch bit (bit 2) or the CNTR
of the timer XY mode register (address 0023
0 or CNTR1 pin. The
0 active
1 active edge switch bit (bit 6)
16). When it is “0”,
the rising edge is valid. When it is “1”, the falling edge is valid.
• Precautions
Set the double-function port of CNTR
P5
4/P55 to input in this mode.
0/CNTR1 pin and port
Rev.1.00Apr 2, 2007Page 30 of 117
REJ03B0212-0100
Loading...
+ 89 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.