● Mitsubishi Electric Corporation puts the maximum effort into making semiconductor
products better and more reliable, but there is always the possibility that trouble
may occur with them. Trouble with semiconductors may lead to personal injury,
fire or property damage. Remember to give due consideration to safety when
making your circuit designs, with appropriate measures such as (i) placement
of substitutive, auxiliary circuits, (ii) use of non-flammable material or (iii) prevention
against any malfunction or mishap.
Notes regarding these materials
● These materials are intended as a reference to assist our customers in the
selection of the Mitsubishi semiconductor product best suited to the customer’s
application; they do not convey any license under any intellectual property rights,
or any other rights, belonging to Mitsubishi Electric Corporation or a third party.
●Mitsubishi Electric Corporation assumes no responsibility for any damage, or
infringement of any third-party’s rights, originating in the use of any product
data, diagrams, charts or circuit application examples contained in these materials.
●All information contained in these materials, including product data, diagrams
and charts, represent information on products at the time of publication of these
materials, and are subject to change by Mitsubishi Electric Corporation without
notice due to product improvements or other reasons. It is therefore recommended
that customers contact Mitsubishi Electric Corporation or an authorized Mitsubishi
Semiconductor product distributor for the latest product information before
purchasing a product listed herein.
● Mitsubishi Electric Corporation semiconductors are not designed or manufactured
for use in a device or system that is used under circumstances in which human
life is potentially at stake. Please contact Mitsubishi Electric Corporation or an
authorized Mitsubishi Semiconductor product distributor when considering the
use of a product contained herein for any specific purposes, such as apparatus
or systems for transportation, vehicular, medical, aerospace, nuclear, or undersea
repeater use.
● The prior written approval of Mitsubishi Electric Corporation is necessary to
reprint or reproduce in whole or in part these materials.
● If these products or technologies are subject to the Japanese export control
restrictions, they must be exported under a license from the Japanese government
and cannot be imported into a country other than the approved destination.
Any diversion or reexport contrary to the export control laws and regulations of
Japan and/or the country of destination is prohibited.
● Please contact Mitsubishi Electric Corporation or an authorized Mitsubishi
Semiconductor product distributor for further details on these materials or the
products contained therein.
Preface
This user’s manual describes Mitsubishi’s CMOS 8bit microcomputers 3802 Group.
After reading this manual, the user should have a
through knowledge of the functions and features of
the 3802 Group, and should be able to fully utilize
the product. The manual starts with specifications
and ends with application examples.
For details of software, refer to the “SERIES MELPS
740 <SOFTWARE> USER’S MANUAL.”
For details of development support tools, refer to the
“DEVELOPMENT SUPPORT TOOLS FOR MICROCOMPUTERS” data book.
BEFORE USING THIS USER’S MANUAL
This user’s manual consists of the following three chapters. Refer to the chapter appropriate to your conditions, such
as hardware design or software development. Chapter 3 also includes necessary information for systems development.
Be sure to refer to this chapter.
1. Organization
● CHAPTER 1 HARDWARE
This chapter describes features of the microcomputer and operation of each peripheral function.
● CHAPTER 2 APPLICATION
This chapter describes usage and application examples of peripheral functions, based mainly on setting examples
of related registers.
● CHAPTER 3 APPENDIX
This chapter includes necessary information for systems development using the microcomputer, electric
characteristics, a list of registers, the masking confirmation (mask ROM version), and mark specifications which
are to be submitted when ordering.
2. Structure of register
The figure of each register structure describes its functions, contents at reset, and attributes as follows :
(Note 1)
(Note 2)
At reset
0
0
0
0
0
1
✻
✻
RWB
✕
✕
Bits
b0b1b2b3b4b5b6b7
0
CPU mode register (CPUM) [Address : 3B16]
0
Processor mode bits
1
2
Stack page selection bit
3
Nothing arranged for these bits. These are write disabled
bits. When these bits are read out, the contents are “0.”
4
5
Fix this bit to “0.”
6
Main clock (X
7
Internal system clock selection bit
: Bit in which nothing is arranged
Note 1. Contents immediately after reset release
0••••••“0” at reset release
1••••••“1” at reset release
Undefined••••••Undefined or reset release
••••••Contents determined by option at reset release
✻
Contents immediately after reset release
NameFunction
IN-XOUT
) stop bit
: Bit that is not used for control of the corresponding function
b1 b0
0 0 : Single-chip mode
0 1 :
1 0 :
1 1 :
0 : 0 page
1 : 1 page
0 : Operating
1 : Stopped
0 : X
1 : X
Not available
IN-XOUT
selected
CIN-XCOUT
Bit attributes
selected
Note 2. Bit attributes••••••The attributes of control register bits are classified into 3 bytes : read-only, write-only
and read and write. In the figure, these attributes are represented as follows :
R••••••Read
••••••Read enabled
✕••••••Read disabled
W••••••Write
••••••Write enabled
✕ ••••••Write disabled
LIST OF GROUPS HAVING THE SIMILAR FUNCTIONS
3802 group, one of the CMOS 8-bit microcomputer 38000 series presented in this user’s manual is provided with
standard functions.
The basic functions of the 3800, 3802, 3806 and 3807 groups having the same functions are shown below. For the
detailed functions of each group, refer to the related data book and user’s manual.
List of groups having the same functions
Group
Function
Pin
(Package type)
Clock generating circuit
Timer
Serial I/O
A-D converter
D-A converter
3800 group
64 pin
• 64P4B
• 64P6N-A
• 64P6D-A
1 circuit
<8-bit>
Prescaler : 3
Timer : 4
UART or
Clock synchronous ✕ 1
<8-bit>
UART or
Clock synchronous ✕ 1
Clock synchronous ✕ 1
8-bit ✕ 8-channel
8-bit ✕ 2-channel
3802 group
64 pin
• 64P4B
• 64P6N-A
1 circuit
Prescaler : 3
Timer : 4
As of September 1995
3806 group3807 group
80 pin
• 80P6N-A
• 80P6S-A
• 80P6D-A
1 circuit
<8-bit>
<8-bit>
Prescaler : 3
Timer : 4
UART or
Clock synchronous ✕ 1
Clock synchronous ✕ 1
8-bit ✕ 8-channel
8-bit ✕ 2-channel
<16-bit>
UART or
Clock synchronous ✕ 1
Clock synchronous ✕ 1
8-bit ✕ 13-channel
8-bit ✕ 4-channel
80 pin
• 80P6N-A
2 circuit
Timer : 3
Timer X/Y : 2
Timer A/B : 2
Memory
Mask
ROM
One Time
PROM
8K
(Note 1)
8K
16K
(Note 1)
16K
(Note 1)
24K
32K
(Note 1)
32K
8K
(Note 1)
16K
(Note 1)
24K
✽
type
EPROM
RAM
16K32K
384 384640
512384
384384640
PWM output
Remarks
Notes 1: Extended operating temperature version available
2: High-speed version available
3: Extended operating temperature version and High-speed version available
✽. ROM expansion
32K
(Note 1)
32K
(Note 1)
32K
1024
12K
(Note 1)
16K
(Note 1)
24K
(Note 3)
24K
(Note 2)
24K
32K
48K
(Note 3)
(Note 3)
48K
(Note 3)
48K
(Note 2)
1024512384 3841024
16K
16K
16K
512
Real time port output
Analog comparator
Watchdog timer
Fig. 2.2.3 Structure of Timer 1.....................................................................................................2-6
Fig. 2.2.4 Structure of Timer 2, Timer X, Timer Y ....................................................................2 -7
Fig. 2.2.5 Structure of Timer XY mode register......................................................................... 2-8
Fig. 2.2.6 Structure of Interrupt request register 1.................................................................... 2-9
Fig. 2.2.7 Structure of Interrupt request register 2.................................................................... 2-9
Fig. 2.2.8 Structure of Interrupt control register 1 .................................................................. 2-10
Fig. 2.2.9 Structure of Interrupt control register 2 .................................................................. 2-10
Fig. 2.2.10 Connection of timers and setting of division ratios [Clock function] ................ 2-12
Fig. 2.2.11 Setting of related registers [Clock function] ......................................................... 2-13
Fig. 2.2.12 Control procedure [Clock function] ........................................................................ 2-14
Fig. 2.2.13 Example of a peripheral circuit ............................................................................... 2-15
Fig. 2.2.14
Fig. 2.2.15 Setting of related registers [Piezoelectric buzzer output] ................................... 2-16
Fig. 2.2.16 Control procedure [Piezoelectric buzzer output] .................................................. 2-16
Fig. 2.2.17 A method for judging if input pulse exists ........................................................... 2-17
Fig. 2.2.18 Setting of related registers [Measurement of frequency] ................................... 2-18
Fig. 2.2.19 Control procedure [Measurement of frequency] ................................................... 2-19
Fig. 2.2.20
Fig. 2.2.21 Setting of related registers [Measurement of pulse width] ................................ 2-21
Fig. 2.2.22 Control procedure [Measurement of pulse width] ................................................ 2-22
Connection of the timer and setting of the division ratio [Piezoelectric buzzer output]
Connection of the timer and setting of the division ratio [Measurement of pulse width] ...........
........... 2-15
2-20
Fig. 2.3.1 Memory map of serial I/O related registers ........................................................... 2-23
Fig. 2.3.2 Structure of Transmit/Receive buffer register ........................................................ 2-24
Fig. 2.3.3 Structure of Serial I/O1 status register ................................................................... 2-24
Fig. 2.3.4 Structure of Serial I/O1 control register .................................................................. 2-25
Fig. 2.3.5 Structure of UART control register ........................................................................... 2-25
Fig. 2.3.6 Structure of Baud rate generator .............................................................................. 2-26
Fig. 2.3.7 Structure of Serial I/O2 control register .................................................................. 2-26
Fig. 2.3.8 Structure of Serial I/O2 register................................................................................2-27
Fig. 2.3.9 Structure of Interrupt edge selection register ........................................................ 2-27
Fig. 2.3.10 Structure of Interrupt request register 1 ............................................................... 2-28
Fig. 2.3.11 Structure of Interrupt request register 2 ............................................................... 2-28
Fig. 2.3.12 Structure of Interrupt control register 1 ................................................................ 2-29
Fig. 2.3.13 Structure of Interrupt control register 2 ................................................................ 2-29
Fig. 2.3.14 Serial I/O connection examples (1) ....................................................................... 2-30
Fig. 2.3.15 Serial I/O connection examples (2) ....................................................................... 2-31
Fig. 2.3.16 Setting of Serial I/O transfer data format ............................................................. 2-32
Fig. 2.3.17 Connection diagram [Communication using a clock synchronous serial I/O] .. 2-33
Fig. 2.3.18 Timing chart [Communication using a clock synchronous serial I/O] ............... 2-33
Fig. 2.3.19 Setting of related registers at a transmitting side
[Communication using a clock synchronous serial I/O] ................................ 2-34
Fig. 2.3.20 Setting of related registers at a receiving side
[Communication using a clock synchronous serial I/O] ................................ 2-35
ii
3802 GROUP USER’S MANUAL
List of figures
Fig. 2.3.21 Control procedure at a transmitting side
[Communication using a clock synchronous serial I/O] .................................. 2-36
Fig. 2.3.22
Fig. 2.3.23 Connection diagram [Output of serial data] ......................................................... 2-38
Fig. 2.3.24 Timing chart [Output of serial data] ...................................................................... 2-38
Fig. 2.3.25 Setting of serial I/O1 related registers [Output of serial data] .......................... 2-39
Fig. 2.3.26 Setting of serial I/O1 transmission data [Output of serial data]........................ 2-39
Fig. 2.3.27 Control procedure of serial I/O1 [Output of serial data] .................................... 2-40
Fig. 2.3.28 Setting of serial I/O2 related registers [Output of serial data] .......................... 2-41
Fig. 2.3.29 Setting of serial I/O2 transmission data [Output of serial data]........................ 2-41
Fig. 2.3.30 Control procedure of serial I/O2 [Output of serial data] .................................... 2-42
Fig. 2.3.31 Connection diagram
[Cyclic transmission or reception of block data between microcomputers]..2-43
Fig. 2.3.32
Fig. 2.3.33 Setting of related registers
[Cyclic transmission or reception of block data between microcomputers]..2-44
Fig. 2.3.34 Control in the master unit ....................................................................................... 2-45
Fig. 2.3.35 Control in the slave unit .......................................................................................... 2-46
Fig. 2.3.36 Connection diagram [Communication using UART] ............................................ 2-47
Fig. 2.3.37 Timing chart [Communication using UART] ......................................................... 2-47
Fig. 2.3.38
Fig. 2.3.39
Fig. 2.3.40 Control procedure at a transmitting side [Communication using UART] .......... 2-51
Fig. 2.3.41 Control procedure at a receiving side [Communication using UART] ............. 2-52
Control procedure at a receiving side[Communication using a clock synchronous serial I/O]
Timing chart [Cyclic transmission or reception of block data between microcomputers] ..........
Setting of related registers at a transmitting side [Communication using UART] ........................
Setting of related registers at a receiving side [Communication using UART] ............................
..2-37
2-44
2-49
2-50
Fig. 2.4.1 Memory map of PWM related registers .................................................................. 2-53
Fig. 2.4.2 Structure of PWM control register ............................................................................2-54
Fig. 2.4.3 Structure of PWM prescaler...................................................................................... 2-54
Fig. 2.4.4 Structure of PWM register......................................................................................... 2-55
Fig. 2.6.6 Write-cycle (W control, SRAM).................................................................................2-67
Fig. 2.6.7 Application example of the ONW function ............................................................. 2-68
3802 GROUP USER’S MANUAL
iii
List of figures
Fig. 2.7.1 Example of Poweron reset circuit ........................................................................... 2-69
Fig. 2.7.2 RAM back-up system ................................................................................................. 2-69
CHAPTER 3 APPENDIX
Fig. 3.1.1 Circuit for measuring output switching characteristics ......................................... 3-13
Fig. 3.1.2 Timing diagram (in single-chip mode) ..................................................................... 3-14
Fig. 3.1.3 Timing diagram (in memory expansion mode and microprocessor mode) (1) .. 3-15
Fig. 3.1.4 Timing diagram (in memory expansion mode and microprocessor mode) (2) .. 3-16
Fig. 3.2.1 Power source current characteristic example ....................................................... 3-17
Fig. 3.2.2 Power source current characteristic example (in wait mode) ............................. 3-17
Fig. 3.2.3 Standard characteristic example of CMOS output port at P-channel drive(1) . 3-18
Fig. 3.2.4 Standard characteristic example of CMOS output port at P-channel drive(2) . 3-18
Fig. 3.2.5 Standard characteristic example of CMOS output port at N-channel drive(1) . 3-19
Fig. 3.2.6 Standard characteristic example of CMOS output port at N-channel drive(2) . 3-19
Fig. 3.2.7 A-D conversion standard characteristics ................................................................ 3-20
Fig. 3.2.8 D-A conversion standard characteristics ................................................................ 3-21
Fig. 3.3.1 Structure of interrupt control register 2 ................................................................. 3-22
Fig. 3.4.1 Wiring for the RESET pin ......................................................................................... 3-28
Fig. 3.4.2 Wiring for clock I/O pins ........................................................................................... 3-29
Fig. 3.4.3 Wiring for the VPP pin of the One Time PROM and the EPROM version ....... 3-29
Fig. 3.4.4 Bypass capacitor across the VSS line and the VCC line..................................... 3-29
Fig. 3.4.5 Analog signal line and a resistor and a capacitor ............................................... 3-30
Fig. 3.4.6 Wiring for a large current signal line ..................................................................... 3-30
Fig. 3.4.7 Wiring to a signal line where potential levels change frequently ...................... 3-30
Fig. 3.4.8 Stepup for I/O ports ................................................................................................... 3-31
Fig. 3.4.9 Watchdog timer by software ..................................................................................... 3-31
Fig. 3.5.1 Structure of Port Pi (i=0, 1, 2, 3, 4, 5, 6)............................................................. 3-33
Fig. 3.5.2 Structure of Port Pi direction register (i=0, 1, 2, 3, 4, 5, 6) .............................. 3-33
Fig. 3.5.3 Structure of Transmit/Receive buffer register ....................................................... 3-34
Fig. 3.5.4 Structure of Serial I/O1 status register .................................................................. 3-34
Fig. 3.5.5 Structure of Serial I/O1 control register ................................................................. 3-35
Fig. 3.5.6 Structure of UART control register ......................................................................... 3-35
Fig. 3.5.7 Structure of Baud rate generator ............................................................................ 3-36
Fig. 3.5.8 Structure of Serial I/O2 control register ................................................................. 3-36
Fig. 3.5.9 Structure of Serial I/O2 register .............................................................................. 3-37
Fig. 3.5.10 Structure of Prescaler 12, Prescaler X, Prescaler Y ......................................... 3-37
Fig. 3.5.11 Structure of Timer 1 ................................................................................................ 3-38
Fig. 3.5.12 Structure of Timer 2, Timer X, Timer Y .............................................................. 3-38
Fig. 3.5.13 Structure of Timer XY mode register ................................................................... 3-39
Fig. 3.5.14 Structure of PWM control register ........................................................................ 3-40
Fig. 3.5.15 Structure of PWM prescaler ................................................................................... 3-40
Fig. 3.5.16 Structure of PWM register ....................................................................................... 3-41
Fig. 3.5.17 Structure of AD/DA control register ...................................................................... 3-42
Fig. 3.5.18 Structure of A-D conversion register ..................................................................... 3-42
Table 3.3.2 Setting of programming adapter switch .............................................................. 3-26
Table 3.3.3 Setting of PROM programmer address ............................................................... 3-27
Table 3.5.1 Function of CNTR0/CNTR1 edge switch bit ....................................................... 3-39
ii
3802 GROUP USER’S MANUAL
CHAPTER 1CHAPTER1
HARDWARE
DESCRIPTION
FEATURES
APPLICATIONS
PIN CONFIGURATION
FUNCTIONAL BLOCK
PIN DESCRIPTION
PART NUMBERING
GROUP EXPANSION
FUNCTIONAL DESCRIPTION
NOTES ON PROGRAMMING
DATA REQUIRED FOR
MASK ORDERS
ROM PROGRAMMING METHOD
FUNCTIONAL DESCRIPTION
SUPPLEMENT
The 3802 group is the 8-bit microcomputer based on the 740 family core technology.
The 3802 group is designed for controlling systems that require
analog signal processing and include two serial I/O functions, A-D
converters, and D-A converters.
The various microcomputers in the 3802 group include variations
of internal memory size and packaging. For details, refer to the
section on part numbering.
For details on availability of microcomputers in the 3802 group, refer to the section on group expansion.
Mask ROM version
Mask ROM version
Mask ROM version
Mask ROM version
Mask ROM version
Mask ROM version
Mask ROM version
One Time PROM version
One Time PROM version (blank)
Mask ROM version
One Time PROM version
One Time PROM version (blank)
EPROM version
EPROM version
3802 GROUP USER'S MANUAL
1-7
HARDWARE
GROUP EXPANSION
GROUP EXPANSION
(Extended operating temperature version)
Mitsubishi plans to expand the 3802 group (extended operating
temperature version) as follows:
(1) Support for mask ROM One Time PROM, and EPROM ver-
sions
ROM/PROM capacity................................... 8 K to 32 K bytes
RAM capacity .............................................. 384 to 1024 bytes
Remarks
Mask ROM version
Mask ROM version
Mask ROM version
Mask ROM version
Mask ROM version
One Time PROM version
One Time PROM version (blank)
Mask ROM version
One Time PROM version
One Time PROM version (blank)
1-8
3802 GROUP USER’S MANUAL
HARDWARE
FUNCTIONAL DESCRIPTION
FUNCTIONAL DESCRIPTION
Central Processing Unit (CPU)
The 3802 group uses the standard 740 family instruction set. Refer
to the table of 740 family addressing modes and machine instructions or the SERIES 740 <Software> User´s Manual for details on
the instruction set.
Machine-resident 740 family instructions are as follows:
The FST and SLW instructions cannot be used.
The MUL, DIV, WIT and STP instruction can be used.
The central processing unit (CPU) has the six registers.
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), Index register Y (Y)
Both index register X and index register Y are 8-bit registers. In the
index addressing modes, the value of the OPERAND is added to the
contents of register X or register Y and specifies the real address.
When the T flag in the processor status register is set to “1”, the
value contained in index register X becomes the address for the second OPERAND.
Stack pointer (S)
The stack pointer is an 8-bit register used during sub-routine calls
and interrupts. The stack is used to store the current address data
and processor status when branching to subroutines or interrupt routines.
The lower eight bits of the stack address are determined by the contents of the stack pointer. The upper eight bits of the stack address
are determined by the Stack Page Selection Bit. If the Stack Page
Selection Bit is “0”, then the RAM in the zero page is used as the
stack area. If the Stack Page Selection Bit is “1”, then RAM in page
1 is used as the stack area.
The Stack Page Selection Bit is located in the SFR area in the zero
page. Note that the initial value of the Stack Page Selection Bit varies with each microcomputer type. Also some microcomputer types
have no Stack Page Selection Bit and the upper eight bits of the
stack address are fixed. The operations of pushing register contents
onto the stack and popping them from the stack are shown in Fig.7.
Program counter (PC)
The program counter is a 16-bit counter consisting of two 8-bit registers
PC
H and PCL. It is used to indicate the address of the next instruction to
be executed.
b15
PC
b7
A
b7
X
b7
Y
b7
S
b7
H
b7
PC
b0
Accumulator
b0
Index Register X
b0
Index Register Y
b0
Stack Pointer
b0
L
Program Counter
b0
Processor Status Register (PS)
CZIDBTVN
Carry Flag
Zero Flag
Interrupt Disable Flag
Decimal Mode Flag
Break Flag
Index X Mode Flag
Fig. 7. 740 Family CPU register structure
Overflow Flag
Negative Flag
3802 GROUP USER’S MANUAL
1-9
HARDWARE
FUNCTIONAL DESCRIPTION
On-going Routine
Store Return Address
on Stack (Note 2)
Restore Return
Address
Interrupt request
M (S)(PCH)
(S)
M (S)(PCL)
(S)
Subroutine
Execute RTS
(S)
(PCL)M (S)
(S)
(PCH) M (S)
(S – 1)
(S – 1)
(S + 1)
(S + 1)
(Note 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)
(PCL)M (S)
(S)
(S + 1)
Store Return Address
on Stack (Note 2)
Store Contents of Processor
Status Register on Stack
I Flag “0” to “1”
Fetch the Jump Vector
Restore Contents of
Processor Status Register
Restore Return
Address
Note 1 : The condition to enable the interrupt Interrupt enable bit is “1”
2 : When an interrupt occurs, the address of the next instruction to be executed is stored in
the stack area. When a subroutine is called, the address one before the next instruction
to be executed is stored in the stack area.
Fig. 8. Register push and pop at interrupt generation and subroutine call
Table. 4. Push and pop instructions of accumulator or processor status register
Push instruction to stack
Accumulator
Processor status register
PHA
PHP
Interrupt disable flag is “0”
(PCH) M (S)
Pop instruction from stack
PLA
PLP
1-10
3802 GROUP USER’S MANUAL
HARDWARE
FUNCTIONAL DESCRIPTION
Processor status register (PS)
The processor status register is an 8-bit register consisting of flags
which indicate the status of the processor after an arithmetic 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.
After reset, the Interrupt disable (I) flag is set to “1”, but all other flags
are undefined. Since the Index X mode (T) and Decimal mode (D)
flags directly affect arithmetic operations, they should be initialized in
the beginning of a program.
(1) 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 shift or rotate instruction.
(2) 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”.
(3) 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”.
When an interrupt occurs, this flag is automatically set to “1” to
prevent other interrupts from interfering until the current interrupt
is serviced.
(4) 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 be used for decimal arithmetic.
(5) 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”. The saved processor
status is the only place where the break flag is ever set.
(6) Index X mode flag (T)
When the T flag is “0”, arithmetic operations are performed
between accumulator and memory, e.g. the results of an
operation between two memory locations is stored in the
accumulator. When the T flag is “1”, direct arithmetic operations
and direct data transfers are enabled between memory locations,
i.e. between memory and memory, memory and I/O, and I/O and
I/O. In this case, the result of an arithmetic operation performed
on data in memory location 1 and memory location 2 is stored in
memory location 1. The address of memory location 1 is
specified by index register X, and the address of memory
location 2 is specified by normal addressing modes.
(7) 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.
(8) 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. 5. Set and clear instructions of each bit of processor status register
C flagZ flagI flagD flagB flagT flagV flagN flag
Set instruction
Clear instruction
SEC
CLC
_
_
SEI
CLI
SED
CLD
_
_
SET
CLTCLV
_
_
_
3802 GROUP USER’S MANUAL
1-11
HARDWARE
FUNCTIONAL DESCRIPTION
CPU Mode Register
The CPU mode register is allocated at address 003B16. The CPU mode
register contains the stack page selection bit.
The Special Function Register area in the zero page contains control registers such as I/O ports and timers.
RAM
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 user area for storing programs.
Interrupt vector area
The interrupt vector area contains reset and interrupt vectors.
RAM area
RAM capacity
(bytes)
192
256
384
512
640
768
896
1024
Address
XXXX
00FF
013F
01BF
023F
02BF
033F
03BF
043F
16
16
16
16
16
16
16
16
16
Zero page
The 256 bytes from addresses 000016 to 00FF16 are called the
zero page area. The internal RAM and the special function registers (SFR) are allocated to this area.
The zero page addressing mode can be used to specify memory
and register addresses in the zero page area. Access to this area
with only 2 bytes is possible in the zero page addressing mode.
Special page
The 256 bytes from addresses FF0016 to FFFF16 are called the
special page area. The special page addressing mode can be
used to specify memory addresses in the special page area. Access to this area with only 2 bytes is possible in the special page
addressing mode.
0000
RAM
0040
0100
XXXX
16
16
16
16
SFR area
Zero page
Reserved area
ROM area
ROM capacity
(bytes)
4096
8192
12288
16384
20480
24576
28672
32768
Fig. 10 Memory map diagram
Address
YYYY
F000
E000
D000
C000
B000
A000
9000
8000
0440
16
Not used
16
16
16
16
16
16
16
16
16
Address
ZZZZ
F080
E080
D080
C080
B080
A080
9080
8080
16
16
16
16
16
16
16
16
16
ROM
YYYY
ZZZZ
FF00
FFDC
FFFE
FFFF
16
Reserved ROM area
(128 bytes)
16
16
16
Interrupt vector area
16
Reserved ROM area
16
Special page
3802 GROUP USER’S MANUAL
1-13
HARDWARE
FUNCTIONAL DESCRIPTION
Port P0 (P0)
0000
16
Port P0 direction register (P0D)
0001
16
Port P1 (P1)
0002
16
Port P1 direction register (P1D)
0003
16
Port P2 (P2)
0004
16
Port P2 direction register (P2D)
0005
16
Port P3 (P3)
0006
16
Port P3 direction register (P3D)
0007
16
Port P4 (P4)
0008
16
Port P4 direction register (P4D)
0009
16
Port P5 (P5)
000A
16
Port P5 direction register (P5D)
000B
16
Port P6 (P6)
000C
16
Port P6 direction register (P6D)
000D
16
000E
16
000F
16
0010
16
0011
16
0012
16
0013
16
0014
16
0015
16
0016
16
0017
16
Transmit/Receive buffer register (TB/RB)
0018
16
Serial I/O1 status register (SIO1STS)
0019
16
Serial I/O1 control register (SIO1CON)
001A
16
UART control register (UARTCON)
001B
16
Baud rate generator (BRG)
001C
16
Serial I/O2 control register (SIO2CON)
001D
16
001E
16
Serial I/O2 register (SIO2)
001F
16
Prescaler 12 (PRE12)
0020
16
Timer 1 (T1)
0021
16
Timer 2 (T2)
0022
16
Timer XY mode register (TM)
0023
16
Prescaler X (PREX)
0024
16
Timer X (TX)
0025
16
Prescaler Y (PREY)
0026
16
Timer Y (TY)
0027
16
0028
16
0029
16
002A
16
PWM control register (PWMCON)
002B
16
PMW prescaler (PREPWM)
002C
16
002D
16
PWM register (PWM)
002E
16
002F
16
0030
16
0031
16
0032
16
0033
16
AD/DA control register (ADCON)
0034
16
A-D conversion register (AD)
0035
16
D-A1 conversion register (DA1)
0036
16
D-A2 conversion register (DA2)
0037
16
0038
16
0039
16
Interrupt edge selection register
003A
16
CPU mode register (CPUM)
003B
16
Interrupt request register 1(IREQ1)
003C
16
Interrupt request register 2(IREQ2)
003D
16
Interrupt control register 1(ICON1)
003E
16
Interrupt control register 2(ICON2)
003F
16
(INTEDGE)
Fig. 11 Memory map of special function register (SFR)
1-14
3802 GROUP USER’S MANUAL
HARDWARE
FUNCTIONAL DESCRIPTION
I/O Ports
Direction registers
The 3802 group has 56 programmable I/O pins arranged in seven
I/O ports (ports P0 to P6). 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, 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 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
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.
Non-Port Function
Address low-order byte
output
Address high-order
byte output
Data bus I/O
D-A conversion output
Control signal I/O
External interrupt input
Serial I/O1 function I/O
Serial I/O2 function I/O
Timer X and Timer Y
function I/O
PWM output
External interrupt input
A-D conversion input
Related SFRs
CPU mode register
CPU mode register
CPU mode register
AD/DA control register
CPU mode register
CPU mode register
Interrupt edge selection
register
Serial I/O1 control
register
UART control register
Serial I/O2 control
register
Timer XY mode register
PWM control register
Interrupt edge selection register
Ref.No.
(1)
(2)
(1)
(3)
(4)
(5)
(6)
(7)
(8)
(9)
(10)
(11)
(12)
(13)
(3)
(14)
3802 GROUP USER’S MANUAL
1-15
Loading...
+ 177 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.