2001 Hynix Semiconductor, Inc. All right reserved.
Additional information of this manual may be served by Hynix Semiconductor offices in Korea or Distributors and Representatives listed at address directory.
Hynix Semiconductor reserves the right to make changes to any information here in at any time without notice.
The information, diagrams and other data in this manual are correct and reliable; however, Hynix Semiconductor is in no
way responsible for any violations of patents or other rights of the third party generated by the use of this manual.
Instruction Set ..................................................iv
JUNE 2001 Ver 1.00
Page 4
HMS81004E/08E/16E/24E/32E
HMS81004E/08E/16E/24E/32E
CMOS SINGLE- CHIP 8-BIT MICROCONTROLLER
FOR UNIVERSAL REMOTE CONTROLLER
1. OVERVIEW
1.1 Description
The HMS81004E/08E/16E/24E/32E is an advanced CMOS 8-bit microcontroller with 4/8/16/24/32K bytes of ROM. The
device is one of GMS800 family. The HYNIX HMS81004 E/08E/16E/24E/32E is a powerfu l microcontroller which provides
a highly flexible and cost effective solution to many UR applications.The HMS81004E/0 8E/16E/24E/32E provides the following standard features: 4/8/16/24/32K bytes of ROM, 448 bytes of RAM, 8-bit timer/counter, on-chip oscillator and clock
circuitry. In addition, the HMS81004E/08E/16E/24E/32E supports power saving modes to reduce power consumption.
• Watch Dog Timer Auto Start (During 1second
after Power on Reset)
20 SOP/PDIP
24 SOP/Skinny DIP
28 SOP/Skinny DIP
JUNE 2001 Ver 1.001
Page 5
HMS81004E/08E/16E/24E/32E
1.3 Development Tools
The HMS81004E/08E/16E/24E/32E are supported by a full-featured macro assembler, an in-circuit emulator CHOICE-Dr.
and OTP programmers. Macro assembler operates under the MSWindows 95/98
pins 1 or 0 written to the Port Direction Register can be
used as outputs or inputs .
8JUNE 2001 Ver 1.00
Page 12
HMS81004E/08E/16E/24E/32E
PIN NAME
R00I/O
R01I/O
R02I/O
R03I/O
R04I/O
R05I/O
R06I/O
R07I/O
R10I/O
R11/INT1I/O
R12/INT2I/O
R13I/O
R14/EC
R15/T2I/O
R16/T1I/O
R17/T0I/O
R20I/O- Each bit of the port can be individually configured as
R21I/O
R22I/O
R23I/O
R24I/O
XINI Oscillator inputLow
XOUTOOscillator outputHigh
REMOUTOHigh current output‘L’ output‘L’ output
RESET
TEST
VDDPPositive power supply
VSSPGroud
INPUT/
OUTPUT
- Each bit of the port can be individually configured as
an input or an output by user software
- Push-pull output
- CMOS input with pull-up resister (option)
- Can be programmable as key scan input
- Pull-up resisters are automatically disabled at output
mode
- Each bit of the port can be individually configured as
an input or an output by user software
Storage Temperature ......................................-65~150°C
Power Dissipation................................................700 mA
7.2 Recommended Operating Conditions
ParameterSymbolCondition
Supply Voltage
Operating Frequency
Operating Temperature
V
T
DD
f
XIN
OPR
f
XIN
VDD=2.0~3.6V
7.3 DC Electrical Characteristics
(TA=-0~70°C, VDD=2.0~3.6V, GND=0V)
ParameterSymbolCondition
Note: Stresses above those listed under “Absolute Maxi-
mum Ratings” may cause per manent damage to the d evice. This is a stress ra ting only and functional ope r ati on of
the device at any oth er c ond iti ons ab ov e tho se ind ic ated in
the oper ati o na l se c ti ons of this s pe c ifi ca t io n i s no t i m pl ie d .
Exposure to absolute maximum rating conditions for extended periods may affect device reliability.
Operating current ,fxin=4Mhz, VDD=2.0V-2.46mA
Operating current ,fxin=4Mhz, VDD=3.6V-410mA
Sleep mode current ,fxin=4Mhz,
VDD=2.0V
Sleep mode current ,fxin=4Mhz,
VDD=3.6V
Stop mode current ,Oscillator Stop
VDD=2.0V
Stop mode current ,Oscillator Stop
VDD=3.6V
OL
Specifications
Unit
Min.Typ.Max.
=2V-30
OH
=1V
0.5-3mA
-12-5mA
µ
A
-12mA
-23mA
-28µA
-310µA
-0.7--V
7.4 REMOUT Port Ioh Characteristics Graph
(typical process & room temperature)
.
Ioh(mA)
0
-5
-10
-15
-20
-25
-30
0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0
Voh (
Vdd 2V
Vdd 3V
Vdd 4V
V)
Figure 7-1 Ioh vs Voh
JUNE 2001 Ver 1.0013
Page 17
HMS81004E/08E/16E/24E/32E
7.5 REMOUT Port Iol Characteristics Graph
(typical process & room temperature)
.
Iol(mA)
5
4
3
2
1
0
-1
0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0
7.6 AC Characteristics
(TA=0~+70°°°°C, VDD=2.0~3.6V, VSS=0V)
ParameterSymbolPins
Vdd 2V
Vol (
V)
Figure 7-2 Iol vs Vol
Vdd 4V
Vdd 3V
Specifications
Unit
Min.Typ.Max.
External clock input cycle time
System clock cycle time
External clock pulse width High
External clock pulse width Low
External clock rising time
External clock falling time
Interrupt pulse width High
Interrupt pulse width Low
RESET Input pulse width low
Event counter input pulse width high
Event counter input pulse width low
Event counter input pulse rising time
Event counter input pu lse fa lling time
t
CP
t
SYS
t
CPH
t
CPL
t
RCP
t
FCP
t
t
t
RSTL
t
ECH
t
ECL
t
REC
t
FEC
IH
IL
X
IN
2505001000ns
50010002000
X
IN
X
IN
X
IN
X
IN
40--ns
40--ns
--40ns
--40nS
INT1, INT22-INT1, INT22--
RESET8--
EC2-EC2-EC--40
EC--40
t
SYS
t
SYS
t
SYS
t
SYS
t
SYS
ns
ns
ns
14JUNE 2001 Ver 1.00
Page 18
HMS81004E/08E/16E/24E/32E
X
IN
INT1
INT2
RESET
EC
t
CP
t
RCP
t
IH
0.8V
DD
t
RSTL
t
ECH
Figure 7-3 Timing Diagram
t
CPH
t
ECL
t
CPL
-0.5V
V
DD
0.5V
t
FCP
t
IL
0.2V
DD
0.2V
DD
0.8V
DD
0.2V
DD
JUNE 2001 Ver 1.0015
Page 19
HMS81004E/08E/16E/24E/32E
8. MEMORY ORGANIZATION
The HMS81004E/08E/16E/24E/32E has separate address
spaces for Program memory and Data Memory. Program
memory can only be read, not written to. It can be up to
8.1 Registers
This device has six registers that are the Program Counter
(PC), an Accumulator (A), two index registers (X, Y), the
Stack Pointer (SP), and the Program Status Word (PSW).
The Program Counter consists of 16-bit register.
A
X
Y
SP
PCLPCH
PSW
Figure 8-1 Configuration of Registers
Accumulator:
The Accumulator is the 8-bit general purpose register, used
for data operation such as transfer, temporary saving, and
conditional judgement, etc. The Accumulator can be used
as a 16-bit register with Y Register as shown below.
In the case of multiplication instruction, execute as a multiplier register. After multiplication operation, the lower 8bit of the result enters. (Y*A => YA). In the case of division instruction, ex ecute as the lo wer 8-bit of di vidend. After division operation, quotient enters.
Y
A
Two 8-bit Registers can be used as a "YA" 16-bit Register
ACCUMULATOR
X REGISTER
Y REGISTER
STACK POINTER
PROGRAM COUNTER
PROGRAM STATUS
WORD
YA
32K bytes of Program memory. Data memory can be read
and written to up to 448 bytes including the stack area.
X, Y Registers:
In the addressing mode which uses these index registers,
the register contents are added to the specified address,
which becomes the actual address. These modes are extremely effective for referencing subroutine tables and
memory tables. The index registers also have increment,
decrement, comparison and data transfer functions, and
they can be used as simple accumulators.
• X Regist er
In the case of division instruction, execute as register.
• Y Regist er
In the case of 16-bit operation instruction, execute as the
upper 8-bit of YA. (16-bit accumulator). In the case of
multiplication instruction, execute as a multiplicand register. After multiplication operation, the upper 8-bit of the
result enters. In the case of division instruction, execute as
the upper 8-bit of dividend. After division operation, remains enters. Y register can be used as loop counter of
conditional branch command. (e.g.DBNE Y, rel)
Stack Pointer:
The Stack Pointer is an 8-bit register used for occurrence
interrupts, calling out subroutines and P USH, POP, RETI,
RET instruction. Stack Pointer identifies the location in the
stack to be accessed (save or restore).
Generally, SP is automatically updated when a subrout ine
call is executed or an interrupt is accepted. However, if it
is used in excess of the stack area permitted by the data
memory allocating configuration, the user-processed data
may be lost. The SP is post-decremented when a subroutine call or a push instruction is executed, or when an interrupt is accepted. The SP is pre-incremented when a return
or a pop instruction is executed.
Figure 8-2 Configuration of YA 16-bit Register
The stack can be located at any position within 100
1FF
of the internal data memory. The SP is not initialized
H
to
H
by hardware, requiring to write the initial v alue (the lo cation with which the use of the stack starts) by using the initialization routine. Normally, the initial value of "FF
H
" is
16JUNE 2001 Ver 1.00
Page 20
HMS81004E/08E/16E/24E/32E
used.
Stack Address ( 100H ~ 1FFH )
15087
01
H
Hardware fixed
At execution of
a CALL/TCALL/PCALL
01FC
01FD
01FE
01FF
SP before
execution
SP after
execution
PCL
PCH
01FF
01FD
Push
down
SP
01FC
01FD
01FE
01FF
At acceptance
of interrupt
PSW
PCL
PCH
01FF
01FC
Push
down
Caution:
The Stack Pointer must be initialized by software be-
cause its value is undefined after RESET.
Example: To initialize the SP
LDX#0FFH
TXSP; SP ← FFH
At execution
of RET instruction
01FC
01FD
01FE
01FF
PCL
PCH
01FD
01FF
Pop
up
At execution
of RETI instruction
01FC
01FD
01FE
01FF
PSW
PCL
PCH
01FC
01FF
Pop
up
At execution
of PUSH instruction
PUSH A (X,Y,PSW)
01FC
01FD
SP before
execution
SP after
execution
01FE
01FF
01FF
01FE
Push
A
down
Figure 8-3 Stack Operation
Program Counter:
The Program Counter is a 16-bit wide which consists of
two 8-bit registers, PCH and PCL. This counter indicates
the address of the next instruction to be executed. In reset
state, the program counter has reset routine address
(PC
:0FFH, PCL:0FEH).
H
Program Status Word:
The Program Status Word (PSW) contains several bits that
At execution
of POP instruction
POP A (X,Y,PSW)
01FC
01FD
01FE
01FF
A
01FE
01FF
Pop
up
0100H
01FFH
Stack
depth
reflect the current state of the CPU. The PSW is described
in Figure 8-4 . It contains the Negative flag, the Overflow
flag, the Break flag the Half Carry (for BCD operation),
the Interrupt enable flag, the Zero flag, and the Carry flag.
[Carry flag C]
This flag stores any carry or borrow from the ALU of CPU
after an arithmetic operation and is also changed by the
Shift Instruction or Rotate Instruction.
JUNE 2001 Ver 1.0017
Page 21
HMS81004E/08E/16E/24E/32E
[Zero flag Z]
This flag is set when the result of an arithmetic operat ion
or data transfer is "0" and is cleared by any other result.
MSBLSB
N
PSW
VGBHIZC
RESET VALUE : 00
H
NEGATIVE FLAG
OVERFLOW FLAG
SELECT DIRECT PAGE
when g=1, page is addressed by RPR
BRK FLAG
Figure 8-4 PSW (Program Status Word) Register
[Interrupt disable flag I]
This flag enables/disables all interrupts except interrupt
caused by Reset or software BRK instruction. All interrupts are disabled when cleared to "0". This flag immediately becomes "0" when an interrupt is served. It is set by
the EI instruction and cleared by the DI instruction.
[Half carry flag H]
After operation, this is set when there is a carry from bit 3
of ALU or there is no borrow from bit 4 of ALU. This bit
can not be set or cleared except CLRV instruction with
Overflow flag (V).
[Break flag B]
This flag is set by software BRK instruction to distinguish
BRK from TCALL instruction with the same vector address.
[Direct page flag G]
CARRY FLAG RECEIVES
CARRY OUT
ZERO FLAG
INTERRUPT ENABLE FLAG
HALF CARRY FLAG RECEIVES
CARRY OUT FROM BIT 1 OF
ADDITION OPERLANDS
the direct addressing mode, addressing area is from zero
page 00
to 0FFH when this flag is "0". If it is set to "1",
H
addressing area is 1 Page. It is set by SETG instruction and
cleared by CLRG.
[Overflow flag V]
This flag is set to "1" when an overflow occurs as the result
of an arithmetic operation involving signs. An overflow
occurs when the result of an addition or subtraction exceeds +127(7F
) or -128(80H). The CLRV instruction
H
clears the overflow flag. There is no set instruction. When
the BIT instruction is executed, bit 6 of memory is copied
to this flag.
[Negative flag N]
This flag is set to match the sign bit (bit 7) status of the result of a data or arithmetic operation. When the BIT instruction is executed, bit 7 of memory is copied to this flag.
This flag assigns RAM page for di rect addressing mode. I n
18JUNE 2001 Ver 1.00
Page 22
8.2 Program Memory
E0
E2
Address
Vector Area Memory
E4
E6
E8
EA
EC
EE
F0
F2
F4
F6
F8
FA
FC
FE
-
-
-
Basic Interval Timer Interrupt Vector Area
-
-
Timer2 Interrupt Vector Area
Timer0 Interrupt Vector Area
-
External Interrupt 2 Vector Area
Key Scan Interrupt Vector Area
RESET Vector Area
External Interrupt 1 Vector Area
Timer1 Interrupt Vector Area
Watch Dog Timer Interrupt Vector Area
"-" means reserved area.
NOTE:
-
0FFDE
H
S/W Interrupt Vector Area
HMS81004E/08E/16E/24E/32E
A 16-bit program counter is capable of addressing up to
64K bytes, but this device has 4/8/16/24/32K bytes program memory space only physically implemented. Accessing a location above FFFF
to 0000
.
H
will cause a wrap-around
H
Figure 8-5 , shows a map of Progr am Memory. After reset,
the CPU begins execution from reset vector which is stored
in address FFFE
and FFFFH as shown in Figure 8-6 .
H
As shown in Figure 8-5 , each area is assigned a fixed location in Program M emory. Program Memory area contains the user program.
8000
H
A000
H
C000
H
32KROM
E000
F000
FF00
FFC0
FFE0
FFFF
H
H
H
H
H
INTERRUPT
VECTOR AREA
H
PCALL
AREA
TCALL
AREA
8KROM
4KROM
HMS81008E
HMS81004E
KROM
HMS81016E 16
24KROM
HMS81032E
HMS81024E
Example: Usage of TCALL
LDA#5
TCALL 0FH;
:;
:;
;
;TABLE CALL ROUTINE
;
FUNC_A: LDALRG0
RET
;
FUNC_B: LDALRG1
RET
;
;TABLE CALL ADD. AREA
;
ORG0FFC0H;
DWFUNC_A
DWFUNC_B
1BYTE INSTRUCTION
IN STEAD OF 2 BYTES
NORMAL CALL
1
2
TCALL ADDRESS AREA
The interrupt causes the CPU to jum p to specific location,
where it commences the execution of the service routine.
The External interrupt 0, for example, is assigned to location 0FFFA
interval: 0FFF8
0FFFA
Any area from 0FF00
. The interrupt service locations spaces 2-byte
H
and 0FFF9H for External Interru pt 1,
H
and 0FFFBH for External Interrupt 0, etc.
H
to 0FFFFH, if it is not going to be
H
used, its service location is available as general purpose
Program Memory.
Figure 8-5 Program Memory Map
Page Call (PCALL) area contains subroutine program to
reduce program byte length by using 2 bytes PCALL instead of 3 bytes CALL instruction. If it is frequently
called, it is more useful to save program byte length.
Table Call (TCALL) c auses the CPU to jump to each
TCALL address, where it commences the execution of the
service routine. The Table Call service area spaces 2-byte
for every TCALL: 0FFC0
TCALL14, etc., as shown in Figure 8-7 .
JUNE 2001 Ver 1.0019
for TCALL15, 0FFC2H for
H
Figure 8-6 Interrupt Vector Area
Page 23
HMS81004E/08E/16E/24E/32E
11111111
11010110
01001010
PC:
FHFHDH6
H
4A
~
~
~
~
25
0FFD6H
0FF00H
0FFFFH
D1
NEXT
0FFD7H
➊
➋
➌
0D125H
Reverse
AddressPCALL Area Memory
0FF00
H
PCALL Area
(192 Bytes)
0FFBF
H
AddressPro gram Memory
0FFC0
H
C1
C2
C3
C4
C5
C6
C7
C8
C9
CA
CB
CC
CD
CE
CF
D0
D1
D2
D3
D4
D5
D6
D7
D8
D9
DA
DB
DC
DD
DE
DF
NOTE:
* means that the BRK software interrupt is using
same address with TCALL0.
TCALL 15
TCALL 14
TCALL 13
TCALL 12
TCALL 11
TCALL 10
TCALL 9
TCALL 8
TCALL 7
TCALL 6
TCALL 5
TCALL 4
TCALL 3
TCALL 2
TCALL 1
TCALL 0 / BRK *
Figure 8-7 PCALL and TCALL Memory Area
PCALL
4F35PCALL 35H
20JUNE 2001 Ver 1.00
→
→
→ →
rel
0FF00H
0FF35H
0FFFFH
TCALL
→
→
→ →
n
4ATCALL 4
4F
35
~
~
NEXT
~
~
Page 24
HMS81004E/08E/16E/24E/32E
Example: The usage software example of Vector address and the initialize part.
;********************************************
; MAIN PROGRAM *
;********************************************
;
RESET:NOP
RAM_CLR:LDA#0;RAM Clear(!0000H->!00BFH)
CLRG
DI;Disable All Interrupts
LDX#0
STA{X}+
CMPX#0C0H
BNERAM_CLR;
LDX#0FFH;Stack Pointer Initialize
TXSP
LDMR0, #0;Normal Port 0
LDMR0DD,#1000_0010B;Normal Port Direction
LDMP0PC,#1000_0010B;Pull Up Selection Set
LDMPMR1,#0000_0010B;R1 port / int
:
:
LDMCKCTLR,#0011_1101B;WDT ON , 16mS Time delay after stop mode release
:
:
JUNE 2001 Ver 1.0021
Page 25
HMS81004E/08E/16E/24E/32E
8.3 Data Memory
Figure 8-8 shows the internal Data Memory space available. Data Memory is divided into 3 groups, a user RAM,
control registers, Stack.
0000H
Note that unoccupied addresses may not be implemented
on the chip. Read accesses to these addresses will in general return random data, and write accesses will have an indeterminate effect.
More detailed informations of each register are explained
in each peripheral section.
RAM
(192 Bytes)
00BFH
00C0H
00FFH
0100H
01FFH
Figure 8-8 Data Memory Map
CONTROL
REGISTERS
RAM (STACK)
(256 Bytes)
PAGE0
PAGE1
User Memory
The HMS81004E/08E/16E/24E/32E has 448 × 8 bits for
the user memory (RAM).
Control Registers
The control registers are used by the CPU and Peripheral
function blocks for controlling the desired operation of the
device. Therefore these registers contain control and status
bits for the interrupt system, the timer/ counters, analog to
digital converters and I/O ports. The control registers are in
address range of 0C0
to 0FFH.
H
Note: Write only registers can not be accessed by bit manipulation instruction. Do not use read-modify-write instruction. Use byte manipulation instruction.
Example; To write at CKCTLR
LDMCLCTLR,#09H ;Divide ratio
÷16
Stack Area
The stack provides the area where the return address is
saved before a jump is performed during the processing
routine at the execution of a subroutine call instruction or
the acceptance of an interrupt.
When returning from the processing routine, execu ting the
subroutine return instruction [RET] restores the contents of
the program counter from the stack; ex ecuting the interrupt
return instruction [RETI] restores the contents of the program counter and flags.
The save/restore locations in the stack are determined by
the stack pointed (SP). The SP is automatically decreased
after the saving, and increased before the restoring. This
means the value of the SP indicates the stack location
number for t he next save. Refer to Figure 8-3 on page 17.
22JUNE 2001 Ver 1.00
Page 26
List for Control Registers
8.4
HMS81004E/08E/16E/24E/32E
AddressFunction RegisterSymbol
00C0hPORT R0 DATA REG.R0R/Wundefined
00C1hPORT R0 DATA DIRECTION REG.R0DDW00000000b
00C2hPORT R1 DATA REG.R1R/Wundefined
00C3hPORT R1 DATA DIRECTION REG.R1DDW00000000b
00C4hPORT R2 DATA REG.R2R/Wundefined
00C5hPORT R2 DATA DIRECTION REG.R2DDW00000000b
00C6hreserved
Registers are controlled by byte manipulation instruction such as LDM etc., do not use bit manipulation
instruction such as SET1, CLR1 etc. If bit manipulation instruction is used on these registers,
content of other seven bits are may varied to unwanted value.
Registers are controlled by both bit and byte manipulation instruction.
24JUNE 2001 Ver 1.00
Page 28
8.5 Addressing Mode
E4
0F100
H
data
←
55H
~
~
~
~
data
0C35
H
➊
35
0F102
H
55
0F101
H
➋
data
35
35
H
0E551
H
data → A
➋
➊
~
~
~
~
C5
0E550
H
HMS81004E/08E/16E/24E/32E
The HMS81004E/08E /16E/24E/32E uses six addressing
modes;
• Register addressing
• Immediate addressing
• Direct page addressing
• Absolute addressing
• Indexed addressing
• Register-indirect addressing
(1) Register Addressing
Register addressing accesses the A, X, Y, C and PSW.
(2) Immediate Addressing
→
→
→ →
#imm
In this mode, second byte (operand) is accessed as a data
immediate ly.
Example:
0435ADC#35H
E45535LDM35H,#55H
(3) Direct Page Addressing
→
→
→ →
dp
In this mode, a address is specified within direct page.
Example; G=0
C535LDA35H;A ←RAM[35H]
MEMORY
04
35
A+35H+C → A
When G-flag is 1, then RAM address is difined by 16-bit
address which is composed of 8-bit RAM paging register
(RPR) and 8-bit immediate data.
Example: G=1, RPR=0CH
(4) Absolute Addressing
→
→
→ →
!abs
Absolute addressing sets corresponding memory data to
Data , i.e. second byte(Operand I) of command becomes
lower level address and third byte (Operand II) becomes
upper level address.
With 3 bytes command, it is possible to access to whole
memory area.
This address value is the second byte (Operand) of command plus the data of Y- register, whic h assigns Memory in
Direct page.
This is same with above (2). Use Y register instead of X.
Y indexed absolute
!abs+Y
→
→
→ →
Sets the value of 16-bit absolute address plus Y-register
data as Memory. This addressing mode can specify memory in whole area.
Example; Y=55
D500FALDA!0FA00H+Y
0F100
0F101
0F102
0FA55
H
H
H
H
~
~
H
D5
00
FA
data
➊
0FA00H+55H=0FA55H
~
~
➋
data → A
➌
3F35JMP[35H]
X indexed indirect
→
→
→ →
[dp+X]
Processes memory data as Data, assigned by 16-bit pair
memory which is determined by pair data
[dp+X+1][dp+X] Operand plusX-register data in Direct
page.
Assigns data address to use for accomplishing command
which sets memory data(or pair memory) by Operand.
Also index can be used with Index register X,Y.
JMP, CALL
Example; G=0
28JUNE 2001 Ver 1.00
Page 32
HMS81004E/08E/16E/24E/32E
25
0E025
H
jump to
~
~
~
~
E0
0FA00
H
E7
0E026
H
➋
25
0E725
H
NEXT
~
~
~
~
1F
PROGRAM MEMORY
➊
address 0E30A
H
Y indexed indirect
→
→
→ →
[dp]+Y
Processes momory data as Data, assigned by the data
[dp+1][dp] of 16-bit p air memory paired by Operan d in Direct pageplus Y-register data.
The program jumps to address specified by 16-bit absolute
address.
JMP
Example; G=0
1F25E0JMP[!0C025H]
JUNE 2001 Ver 1.0029
Page 33
HMS81004E/08E/16E/24E/32E
9. I/O PORTS
The HMS81004E/08E/16E/24E/32E has 24 I/O ports
which are PORT0(8 I/O), PORT1 (8 I/O), PORT2 (8 I/O).
Pull-up resistor of each port can be selectable by program.
Each port contains data d irect ion re gister which con trols I/
O and data register which stores port data.
9.1 R0 Ports
R0 is an 8-bit CMOS bidirectional I/O port (address
0C0
). Each I/O pin can indepe ndently used as an in put or
H
an output through the R0DD register (address 0C1
R0 has internal pull-ups that is independently connected or
disconnected by R0PC. The control registers for R0 are
shown below.
R0 Data Register (R/W)
R0
R0 Direction Register (W)
R0DD
R0 Pull-up Control Register (W)
R0PC
R07 R06 R05 R04 R03
ADDRESS : 0C0
RESET VALUE : Undefined
R02 R01
ADDRESS : 0C1
RESET VALUE : 00
ADDRESS :0F8
RESET VALUE : 00
R00
Port Direction
0: Input
1: Output
Pull-up select
1: Without pull-up
0: With pull-up
).
H
H
H
H
H
H
(1) R0 I/O Data Direction Register (R0DD)
R0 I/O Data Direction Register (R0DD) is 8-bit register,
and can assign input state or output state to each bit. If
R0DD is “1”, port R0 is in the output state, and if “0”, it is
in the input state. R0DD is write-only register. Since
R0DD is initialized as “00h” in reset state, the whole port
R0 becomes input state.
(2) R0 Data Register (R0)
R0 data register (R0) is 8-bit register to store data of port
R0. When set as the output state by R0DD, and data is written in R0, data is outputted into R0 pin. When set as the input state, input state of pin is read. The initial value of R0
is unknown in reset state.
(3) R0 Open drain Assign Register (R0ODC)
R0 Open Drain Assign Register (R0ODC) is 8bit register,
and can assign R0 port as open drain output port each bit,
if corresponding port is selected as output. If R0ODC is
selected as “1”, port R0 is open drain output, and if selected as, “0” it is push-pull output. R0ODC is write-only register and initialized as “00h” in reset state.
(4) R0 Pull-up Control Register (R0PC)
R0 Pull-up Control Register (R0PC) is 8-bit register and
can control pull-up on or off each bit, if corresponding port
is selected as input. If R0PC is selected as “1”, pull-up ia
disabled and if selected as “0”, it is enabled. R0PC is writeonly register and initiali zed as “00h” in reset state. The
pull-up is automatically disabl ed, if corresponding port is
selected as output.
R0 Open drain Assign Register (W)
R0ODC
ADDRESS :0E4
RESET VALUE : 00
H
H
Open drain select
0: Push-pull
1: Open drain
9.2 R1 Ports
R1 is an 8-bi t CMOS bidirectional I/ O port (address
0C2
). Each I/O pin can independently used as an input or
H
an output through the R1DD register (address 0C3
).
H
R1 has internal pull -ups that i s independ ently conne cted or
disconnected by register R1PC. The control registers for
R1 are shown below.
30JUNE 2001 Ver 1.00
Page 34
R1 Data Register (R/W)
R1
R1 Direction Register (W)
R1DD
R1 Pull-up Control Register (W)
R1PC
R17 R16 R15 R14 R13 R12 R11 R10
ADDRESS : 0C2
RESET VALUE : Undefined
ADDRESS : 0C3
RESET VALUE : 00
ADDRESS : 0F9
RESET VALUE : 00
H
H
H
Port Direction
0: Input
1: Output
H
H
Pull-up select
1: Without pull-up
0: With pull-up
HMS81004E/08E/16E/24E/32E
and can assign R1 port as open drain output port each bit,
if corresponding port is selected as output. If R1ODC is
selected as “1”, port R1 is open drain output, and if selected as “0”, it is push-pull output. R1ODC is write-only register and initialized as “00h” in reset state.
(4) R1 Port Mode Register (PMR1)
R1 Port Mode Register (PMR1) is 8-bit register, and can
assign the selection mode for each bit. When set as “0”,
corresponding bit of PMR1 acts as port R1 selection mode,
and when set as “1”, it becomes function selection mode.
PMR1 is write-only register and initialized as “00h” in reset state. Therefore, becomes P ort selection mode. Port
R1 can be I/O port by manipulating each R1DD bit, if corresponding PMR1 bit is selected as “0”.
R1 Open drain Assign Register (W)
P1ODC
R1 Port Mode Register (W)
PMR1
ADDRESS : 0DE
RESET VALUE : 00
ADDRESS : 0C9
RESET VALUE : 00
H
H
Open drain select
0: Push-pull
1: Open drain
H
H
Mode select
0: Port R1 selection
1: Function selection
(1) R1 I/O Data Direction Register (R1DD)
R1 I/O Data Direction Register (R1DD) is 8-bit register,
and can assign input state or output state to eac h bit. If
R1DD is “1”, port R1 is in the output state, and if “0”, it is
in the input state. R1DD is write-only register. Since
R1DD is initialized as “00h” in reset state, the whole port
R1 becomes input state.
Pin NamePMR1
T0S
0R17 (I/O)1T0 (O)Timer0
0R16 (I/O)-
T1S
1T1 (O)Timer1
0R15 (I/O)-
T2S
ECS
1T2 (O)Timer2
0R14 (I/O)1EC
0R12 (I/O)
INT2S
1INT2 (I)
0R11 (I/O)
INT1S
1INT1 (I)
Selection
Mode
(I)Timer0 Event
Timer0 Input Cap-
Remarks
ture
(2) R1 Data Register (R1)
Table 9-1 Selection mode of PMR1
R1 data register (R1) is 8-bit register to store data of port
R1. When set as the output state by R1DD, and data is
written in R1, data is outputted into R1 pin. When set as
the input state, input state of pin is read. The initial va lue
of R1 is unknown in reset state.
(5) R1 Pull-up Control Register (R1PC)
R1 Pull-up Control Register (R1PC) is 8-bit register and
can control pull-up on or off each bit, if corresponding port
is selected as input. If R1PC is selected as “1”, pull-up ia
(3) R1 Open drain Assign Register (R1ODC)
R1 Open Drain Assign Register (R1ODC) is 8bit register,
disabled and if selected as “0”, it is enabled. R1PC is writeonly register and initiali zed as “00h” in reset state. The
JUNE 2001 Ver 1.0031
Page 35
HMS81004E/08E/16E/24E/32E
pull-up is automatically disabled, if corresponding port is
selected as output.
9.3 R2 Port
R2 is an 8-bit CMOS bidirectional I/O port (address
0C4
). Each I/O pin can indepe ndently used as an in put or
H
an output through the R2DD register (address 0C5
R2 has internal pujll-ups that is independently connected
or disconnected by R2PC (ad dress 0FA
). The control reg-
H
isters for R2 are shown as below.
R2 Data Register (R/W)
--
R2
R2 Direction Register (W)
R2DD
R2 Pull-up Control Register (W)
R2PC
R2 Open drain Assign Register (W)
R2ODC
-
ADDRESS : 0C4
RESET VALUE : Undefined
R23 R22 R21 R20
R24
ADDRESS : 0C5
RESET VALUE : 00
ADDRESS :0FA
RESET VALUE : 00
ADDRESS :0DF
RESET VALUE : 00
Port Direction
0: Input
1: Output
Pull-up select
1: Without pull-up
0: With pull-up
Open drain select
0: Push-pull
1: Open drain
).
H
H
H
H
H
H
H
H
(1) R2 I/O Data Direction Register (R2DD)
R2 I/O Data Direction Register (R2DD) is 8-bit register,
and can assign input state or output state to each bit. If
R2DD is “1”, port R2 is in the output state, and if “0”, it is
in the input state. R2DD is write-only register. Since
R2DD is initialized as “00h” in reset state, the whole port
R2 becomes input state.
(2) R2 Data Register (R2)
R2 data register (R2) is 8-bit register to store data of port
R2. When set as the output state by R2DD, and data is written in R2, data is outputted into R2 pin. When set as the input state, input state of pin is read. The initial value of R2
is unknown in reset state.
(3) R2 Open drain Assign Register (R2ODC)
R2 Open Drain Assign Register (R2ODC) is 8bit register,
and can assign R2 port as open drain output port each bit,
if corresponding port is selected as output. If R2ODC is
selected as “1”, port R2 is open drain output, and if selected as “0”, it is push-pull output. R2ODC is write-only register and initialized as “00h” in reset state.
(4) R2 Pull-up Control Register (R2PC)
R2 Pull-up Control Register (R2PC) is 8-bit register and
can control pull-up on or off each bit, if corresponding port
is selected as input. If R2PC is selected as “1”, pull-up ia
disabled and if selected as ”0”, it is enabled. R2PC is writeonly register and initiali zed as “00h” in reset state. The
pull-up is automatically disabl ed, if corresponding port is
selected as output.
32JUNE 2001 Ver 1.00
Page 36
10. CLOCK GENERATOR
Clock Control Register (W)
CKCTLR
ADDRESS : 0C7
H
INITIAL VALUE : --110111b
0
123
4567
ENPCK 0: Stopped
1: Provided
HMS81004E/08E/16E/24E/32E
Clock generating circuit con sists of Clo ck Pulse Generato r
(C.P.G), Prescaler, Basic Interval Timer (B.I.T) and Watch
Dog Timer. The clock applied to the Xin pin divided by
two is used as the internal system clock.
Prescaler consist of 12-bit binary counter. The clock supplied from oscillation circuit is input to prescaler(fex)
The divided output from each bit of prescaler is provided
to periphera hardwarel
Clock to pe ripheral hardware can be stopped by bit4 (ENPCK) of CKCTLR Register. ENPCK is set to “1” in reset
OSC
CIRCUIT
fex
PS0PS1PS2PS3PS4PS5PS6PS7PS8PS9PS10
CLOCK PULSE
GENERATOR
state.
PRESCALER
Internal system clock (CPU clock)
PS11
PS12
fEX(MHz)
Frequency
4
period
1
2
÷
÷
PS0PS3PS2PS4PS1PS10PS9PS5PS6PS7
4M1M500K250K2M125K62.5K
250n500n1u2u4u8u16u32u64u256u128u
4
÷
÷8÷
16
32÷64
÷
Peripheral clock
128÷256÷512÷1024
÷
PS8
Figure 10-1 Block diagram of Clock Generator
2048÷4096
÷
3.906K7.183K15.63K31.25K
PS11PS12
1.953K
0.976K
1024u
512u
JUNE 2001 Ver 1.0033
Page 37
HMS81004E/08E/16E/24E/32E
X
OUT
X
IN
10.1 Oscillation Circuit
Oscillation circuit is designed to be used either with a ceramic resonator or crystal oscillator. Figure 10-2 shows
circuit diagrams using a crystal (or ceramic) oscillator. As
shown in the diagram, oscillation circuits can be constructed by connecting a oscillator between Xout and Xin. Colck
from oscillation circuit makesCPU clock via clock pulse
generator, and then enters prescaler to make per ipheral
hardware clock. Alternately, the oscillator may b e driven
from an esternal source as Figure 10-3 . In the ST OP
mode,oscillation stop, Xout state goes to “HIGH” , Xin
state goes to “LOW” , and built-in feed back resistor is disabled.
Oscillation circuit is design ed to be u sed either with a ceramic resonator or crystal oscillator. Since each crystal and
ceramic resonator have their own characteristics, the user
should consult the crystal manufacturer for appropriate
values of external components. In addition, see Figure 104 for the layout of the crystal.
Note: Minimize the wiring length. Do not allo w the wiring to
intersect with other signal co ndu ctors. Do not allo w the wi ring to come near changi ng high cu rrent. Set t he potentia l of
the grounding position of the oscillator capacitor to that of
VSS. Do not ground it to any groun d pattern w here high current is present. Do not fetch signals from the oscillator.
The HMS81004E/08E/16E/24E/32E has one 8-bit Basic
Interval Timer that is free-run and can n ot stop. Blo ck d iagram is shown in Figure 11-1 .
The Basic Interval Timer generates the time base for
Standby release time, watchdog ti m er coun ti n g, and et c. It
also provides a Basic interval timer interrupt (IFBIT). As
the count overflow from FF
to 00H, this overflow causes
H
the interrupt to be generated.
-8bit binary up-counter
-Use the bit output of prescaler as input to secure the oscillation stabilization time after power-on
-Secures the oscillation stabilization time in standby mode
(stop mode) release
-Contents of B.I.T can be read
-Provides the clock for watch dog timer
8
÷
16
÷
32
÷
64
÷
128
÷
256
÷
Prescaler
512
÷
1024
÷
MUX
source
clock
The Basic Interval Timer is controlled by th e clock control
register (CKCTLR) shown in Figure 11-2 . If bit3(BTCL)
of CKCTLR is set to “1”, B.I.T is cleared, and then, after
one machine cycle, BTCL be comes “0”, and B.I.T starts
counting. BTCL is set to ``0`` in reset state.
The input clock of B.I.T can be selected from th e prescaler
within a range of 2us to 256us by clock i nput selecti on bits
(BTS2~BTS0). (at fex = 4MHz). In reset state, or power
on reset, BTS2=“1”, BTS1= “1”, BTS0= “1” to secure the
longest oscillation stabilization time. B.I.T can generate
the wide range of basic interval time interrupt reques t (IF BIT) by selecting prescaler output.
By reading of the Basic Interval Timer Register (BITR),
we can read counter value of B.I.T. Because B.I.T can be
cleared or read, the spending time up to maximum 65.5ms
can be available. B.I.T is read-only register. If B.I.T register is written, then CKCTLR register with same address
is written.
Basic Interval Timer
8-bit up-counter
clear
overflow
IFBIT
Basic Interval Timer Interrupt
To Watchdog timer (WDTR)
Select Input clock
[0C7
clock control register
3
BTS[2:0]
CKCTLR
]
H
BTCL
BITR
Read
Internal bus line
Figure 11-1 Block diagram of Basic Interval Timer
36JUNE 2001 Ver 1.00
Page 40
CKCTLR
76543210
Caution:
Both register are in same address,
when write, to be a CKCTLR,
when read, to be a BITR.
--
W
WDTON
WWWWW
BTCL
ENPCK
BTCL
HMS81004E/08E/16E/24E/32E
BTS1
BTS0BTS2
Basic Interval Timer source clock select
000: f
001: f
010: f
011: f
100: f
101: f
110: f
111: f
Clear bit
0: Normal operation, free-run
1: Clear 8-bit counter (BITR) to “0” and count up again.
Periphral clock
0:stopped
1:provided
Watch Dog Timer function control
0:6bit timer
1:Watch Do g Timer
ADDRESS: 0C7
INITAIL VALUE: --110111
÷ 8
XIN
÷ 16
XIN
÷ 32
XIN
÷ 64
XIN
÷ 128
XIN
÷ 256
XIN
÷ 512
XIN
÷ 1024
XIN
This bit becomes to “0” automatically after one machine cycle.
H
B
BITR
RRRRRRR
76543210
R
BTCL
8-BIT FREE-RUN BINARY COUNTER
Figure 11-2 CKCTLR AND BITR
BTS[2:0]CPU Source clock
000
001
010
011
100
101
110
111
÷
÷
16
÷
32
÷
64
÷
128
÷
256
÷
512
÷
1024
8
ADDRESS: 0C7
INITIAL VALUE: Undefined
H
B.I.T. Input
clock@4Mhz(us)
16
32
64
128
256
Standby release
2
4
8
time(ms)
0.512
1.024
2.048
4.096
8.192
16.384
32.768
65.536
JUNE 2001 Ver 1.0037
Page 41
HMS81004E/08E/16E/24E/32E
12. WATCH DOG TIMER
Watch Dog Timer (WDT) consists of 6- bit bi nary coun ter,
6-bit comparator, and Watch Dog Timer Register
(WDTR).Watch Dog Timer can be used 6-bit genera l Timer or specific Watch dog timer by setting bit5 (WDTON)
of Clock Control Register (CKCTLR).By assigning
bit6(WDTCL) of WDTR, 6-bit counter can be cleared.
WDT Interrupt (IFWDT) interval is determined by the interrupt IFBIT interval of Basic Interval Timer and the value of WDT Register.
-Interval of IFWDT = (IFBIT interval) * (WDTR value)
76543210
WDTR
WDTCL
-
WDTR5 WDTR4 WDTR3
Watch Dog Timer Operation
0:Free-run
1:Automatically cleared, after one machine cycle
BTCL
As IFBIT (Basic Interval Timer Interrupt Request) is used
for input clock of WDT, Input clock cycle is possible from
512 us to 65,536 us by BTS. (at fex = 4MHz)
*At Hardware reset time,WDT starts automatically.
Therefore the user must select the CKCTLR and WD TR
before WDT overflow.
-Reset WDTR value = 0F
,=15
h
-Interval of WDT = 65,536 * 15 = 983040 us
(about 1second )
WDTR2
WDTR1 WDTR0
ADDRESS: 0C8
INITIAL VALUE: -0001111
H
b
WDTON
IFBIT
Clear
Figure 12-1 Block diagram of Watch Dog Timer
Note: When WDTR Register value is 63 (3Fh)
(Caution) : Do not use “0” f or WDTR Register value.
6
[0C8H]
WDT (6-bit)
Comparator
WDTR (6-bit)
IFWDT
WDT
Device come into the reset state by WDT
To Reset circuit
WDT
INTERRUPT
38JUNE 2001 Ver 1.00
Page 42
13. Timer0, Timer1, Timer2
HMS81004E/08E/16E/24E/32E
(1) Timer Operation Mode
Timer consists of 16bit binary counter Timer0 (T0), 8bit
binary Timer1 (T1), Timer2 (T2), Timer Data Register,
Timer Mode Register (TM01, TM0, TM1 , TM2) an d con trol circuit. Timer Data Register Consists of Timer0 HighMSB Data Register (T0HMD), Timer0 High-LS B Data
Register (T0HLD), Timer0 Low-MSB Data Register
(T0LMD), Timer0 Low-LSB Data Register (T0LLD),
Timer1 High Data Register (T1HD), Timer1 Low Data
- 16-bit Interval Timer
- 16-bit Event Counter
Timer0
Timer1
Timer2
16bit Timer (T0)8bit Timer (T1)8bit Timer (T2)
- 16-bit Input Capture
- 16-bit rectangular-wave output
- 8-bit Interval Timer
- 8-bit rectangular-wave output
- 8-bit Interval Timer
- 8-bit rectangular-wave output
- Modulo-N Mode
Table 13-1 Timer Operation
Register (T1LD), Timer2 Data Register (T2DR). Any of
the PS0 ~ PS5, PS11 and external event input EC
can be
selected as clock source for T0. Any of the PS0 ~ PS3, PS7
~ PS10 can be selected as clock T1. Any of the PS5 ~ PS12
can be selected as clock source for T2.
* Relevant Port Mode Re gister (PMR1 : 00C9h) v alue
should be assigned for event counter.
- Single/Modulo-N Mode
- Timer Output Initial Value Setting
- Timer0~Timer1 combination Logic Output
- One Interrupt Generating Every 2nd
Counter Overflow
TIMER0 and TIMER1 have an up-counter. When val ue of
the up-counter reaches the content of Timer Data Register
T0 Data
Register
Value
T0 Value
0
Timer 0 (IFT0)
Interrupt
~
~
0
Occur interruptOccur interruptOccur interrupt
MATCH
(TDR = T0)
up-count
3
2
1
~
~
6
5
4
Interrupt period
Figure 13-5 Operation of Timer0
For Timer0, the internal clock (PS) and the external clock
) can be selected as counter clock. But Timer 1 and
(EC
Timer2 use only internal clock. As internal clock. Timer0
can be used as internal-timer which period is determined
by Timer Data Re gister (TDR). Chosen as e xternal
clock, Timer0 executes as event-counter. The counter execution of Timer0 and Timer1 is controlled by T0CN,
T0ST, CAP0, T1CN, T1ST, of Timer Mode Regi ster TM0
and TM1. T0CN, T1CN are used to stop and start Timer0
and Timer1 without clearing the counter. T0ST, T1ST is
used to clear the counter. For cleari ng and starting the
counter, T0ST or T1ST should be temporarily set to “0 ”
and then set to “1”. T0CN, T1CN, T0ST and T1ST should
be set “1”, w hen Timer coun ting-up. Contr olling of
CAP0 enables Timer0 as input capture. By programming
of CAP0 to “1”, the period of signal from INT2 can be
measured and then, event counter value for INT2 can be
read. During counting-up, value of counter can be readTimer execution is stopped by the reset signal(RE-
(TDR), the up-counter is clear ed to “00h”, and interrupt
(IFT0, IFT1) is occured at the next clock.
~
~
TIME
SET=”L”)
Note: In the process of reading 16-bit Timer Data, first
read the upper 8-bit data. Then read the lower 8-bit data,
and read the upper 8-bit data again. If the earlier read upper 8-bit data are matched with the later read upper 8-bit
data, read 16-bit data are correct. If not, caution should be
taken in the selection of upper 8-bit data.
Timer0 (Timer1) can sel ect initial (T0INIT, T 1INIT of
TM01) output level of Timer Output port. If initial level is
“L”, Low-Data R egister value of T imer Data Re gister is
transferred to comparator an d T0OUT (T1OUT) is to be
“Low”, if initial level is High? High -Data Register is
transferred and to be “High”. Single Mode can be set by
Mode Select bit (T0MOD, T1MOD) of Timer Mode Register (TM0, TM1) to “1” When used as Single Mode, Timer counts up and compares with value of Data Register. If
the result is same, Time Out interrupt occurs and leve l
of Timer Output port togg le, then counter stops a s reset
state. When used as Modulo-N Mode, T0MOD (T1MOD)
[ Single Mode ]
8bit/16bit
counting
Timer Enable initial
value toggle
should be set “0”. Counter counts up until the value of
Data Register and occurs Time-out interrupt. The level of
Timer Output port toggle and repeats process of
counting the value which is selected in Data Register.
During Modulo-N Mode, If interrupt select bit (T0IFS,
T1IFS) of Mode Register is “0”, Interrupt occurs on every
Time-out. If it is “1”, Interrupt occurs every second timeout.
Note: Timer Output is toggled whenever time out happen
[ Module-N Mode ]
8bit/16bit
counting
Timer Enable initial
value toggle
Figure 13-8 Operation Diagram for Single/Modulo-N Mode
(4) Timer 2
Timer2 operates as a up-counter. The content of T2DR are
compared with the contents of up-counter. If a match is
found. Timer2 interrupt (IFT2) is generated and the upcounter is cleared to “00h”. Therefore, Timer2 executes
as a interval timer. Interrupt period is determined by the
count source clock for the Timer2 and content of T2DR.
Timer-output toggle
Int occurs (IFS=1) Each 2nd time out
Int occurs (IFS=0) when Time out
When T2ST is set to “1”, count value of Timer 2 is cleared
and starts counting-up. For clearing and starting the
Timer2. T2ST have to set to “1” after set to “0”. In order to
write a value directly into the T2DR, T2ST sh ould be set
to “0”. Count value of Timer2 can be read at any time.
46JUNE 2001 Ver 1.00
Page 50
14. INTERRUPTS
HMS81004E/08E/16E/24E/32E
The HMS81004E/08E/16E/24E/32E interrupt circuits
consist of Interrupt Mode Register (M OD), Interrupt enable register (IENH, IENL), Interrupt request flags of
IRQH, IRQL, Priority circuit and Master enable flag ("I"
flag of PSW). 8 interrupt sources are provided. The config uration of interrupt circuit is shown in Figure 14-1 .
The HMS81004E/08E/16E/24E/3 2E contains 8 interrupt
sources; 3 externals and 5 internals. Nested interrupt services with priority control is also possible. Software interrupt is non-maskable interrupt, the others are all maskable
interrupts.
- Programmable interrupt mode
(Hardware and software interrupt accept mode)
- Read and write of interrupt request flag are possible.
- In interrupt accept, request flag is automatically cleared.
Interrupt Enable
Register (Lower byte)
I-flag is in PSW, it is cleared by “DI”, set by
“EI” instruction. When it goes interrupt service,
I-flag is cleared by hardware, thus any other
interrupt are inhibited. When interrupt service is
completed by “RETI” instruction, I-flag is set to
“1” by hardware.
Release STOP
Key Scan
INT1
INT2
Timer 0
Timer 1
Timer 2
IRQH
KSCNR
INT1R
INT2R
T0R
T1R
T2R
IENH
Internal bus line
Priority Control
Interrupt Enable
Register (Higher byte)
Interrupt Master
Enable Flag
Figure 14-1 Block Diagram of Interrupt
To CPU
I-flag
Interrupt
Vector
Address
Generator
JUNE 2001 Ver 1.0047
Page 51
HMS81004E/08E/16E/24E/32E
14.1 Interrupt priority and sources
Each interrupt vector is independent and has its own priority. Software interrupt (BRK) is also availabl e. Interrupt
14.2 Interrupt control register
I flag of PSW is a interrupt mask enable flag. When I flag
= “0”, all interrupts become disable. When I flag = “1”, interrupts can be selectively enabled and disabled by contents of corresponding Interrupt Enable Register. When
interrupt is occured, interrupt request flag is set, and Interrupt request is detected at the edge of interrupt sig nal . The
accepted interru pt request flag is automatic ally cleared
during interrupt cycle process. The interrupt request flag
maintains “1” until the interrupt is accepted or is cleared in
program. In reset sta te, interrupt request flag regist er
(IRQH, IRQL) is cleared to “0”. It is possible to read the
state of interrupt register and to mainpulate the contents of
register and to generate interrupt. (Refer to software interrupt)
The interrupt priority order is determined by bit (IM1,
IM0) of IMOD register. The condition allow for accepting
interrupt is set state of the interrupt mask enable flag and
R/W R/WR/WR/W
ADDRESS: 0CF
INITIAL VALUE: 000- 000-
Timer2
Timer1
Timer0
H
B
the interrupt enable bit must be “1”. In Reset state, these
IP3 - IP0 registers become all “0”.
JUNE 2001 Ver 1.0049
Page 53
HMS81004E/08E/16E/24E/32E
l
Interrupt mode register
IMOD
76543210
IM0
BTCL
IP 2IP3
IP1IP0
--
IM1
ADDRESS: 0CA
INITIAL VALUE: --00_0000
R/W R/WR/W R/W R/WR/W
R/WR/W
H
B
Priority
00: Fixed by hardware
01: Changeable by IP3~IP0
1x: Interrupt is inhibited
Figure 14-3 Interrupt Accept Mode & Selection by IP3~IP0
14.4 Interrupt Sequence
An interrupt request is held until the interrupt is accepted or the
interrupt latch is cleared to “0” by a rese t or an instruc tio n. Interrupt acceptance sequ enc e re quire s 8
the current instruction exec ution. The in terrupt service task is terminated upon executio n of an interrup t return instr uction [RETI].
Interrupt acceptance
1. The interrupt master enable flag (I-flag) is cleared to
“0” to temporarily disable the acceptance of any following maskable interrupts. When a non-maskable interrupt is accepted, the acceptance of any following
interrupts is temporarily disabled.
2. Interrupt request flag for the interrupt source accepted is
cleared to “0”.
3. The contents of the program counter (return address)
and the program status word are saved (pushed) onto the
stack area. The stack pointer decreases 3 times.
4. The entry address of the interrupt service program is
read from the vector table address and the entry address
is loaded to the program counter.
5. The instruction stored at the entry address of the interrupt service program is executed.
50JUNE 2001 Ver 1.00
Page 54
System clock
main task
interrupt
service task
saving
registers
restoring
registers
acceptance of
interrupt
interrupt return
Instruction Fetch
HMS81004E/08E/16E/24E/32E
Address Bus
Data Bus
PC
Not used
SPSP-1
PCHPCL
Internal Read
Internal Write
Interrupt Processing StepInterrupt Service Task
V.L. and V.H. are vector addresses.
ADL and ADH are start addresses of interrupt service routi ne as vector contents.
Figure 14-4 Timing chart of Interrupt Acceptance and Interrupt Return Instruction
External Interrupt1
Vector Table Address
012
0FFF8
H
0FFF9
H
Correspondence between vector table address for Exteranl Interrupt1
and the entry address of the interrupt service program.
0E3
H
H
0E312
0E313
Entry Address
0E
H
2E
H
H
H
A interrupt request is not accepted until t he I-flag is set to “1”
even if a requested interrupt has higher priority than that of the
current interrupt being serviced.
When nested interrupt service is required, the I-flag should be set
to “1” by “EI” instruction in the interrupt service program. In this
case, acceptable in terrupt sources are select ively enabled by the
individual interrupt enable flags.
SP-2V.H.New PC
PSWADLOP codeADH
V.L.
V.L.
registers.
Example: Registe r sa v e us in g pu s h an d po p ins t ru c tions
INTxx:PUSHA
PUSHX
PUSHY
interrupt processing
POPY
POPX
POPA
RETI
;SAVE ACC.
;SAVE X REG.
;SAVE Y REG.
;RESTORE Y REG.
;RESTORE X REG.
;RESTORE ACC.
;RETURN
General-purpose register save/restore using push and pop instructions;
Saving/Restoring General-purpose Register
During interrupt acceptance processing, the program counter and
the program status word are automatically saved on the stack, but
accumulator and other registers are not saved itsel f. These re gisters are saved by the software if necessary. Also, when multiple
interrupt services are nested, it is necessary to avoid using the
same data memory area for saving registers.
The following method is used to sav e/restore th e general-p urpose
JUNE 2001 Ver 1.0051
Page 55
HMS81004E/08E/16E/24E/32E
enable INT1
TIMER 1
service
INT1
service
Main Program
service
Occur
TIMER1 interrupt
Occur
INT1
EI
disable other
enable INT1
enable other
In this example, the INT1 interrupt can be serviced without any
pending, even TIMER1 is in progress.
Because of re-setting the interrupt enable registers IENH,IENL
and master enable “EI” in the TIMER1 routine.
14.5 BRK Interrupt
Software interrupt can be invoked by BRK instru ction, whic h has
the lowest priority order.
Interrupt vector address of BRK is shared with the vector of
TCALL 0 (Refer to Program Memory Section). When BRK interrupt is generated, B-flag of PSW is set to distinguish BRK from
TCALL 0.
Each processing step is determined by B-flag as shown in Figure
14-5
=0
=1
TCALL0
ROUTINE
RET
BRK or
TCALL0
B-FLAG
BRK
INTERRUPT
ROUTINE
RETI
Example:
During Timer1 interrupt is in progress, INT1 inte rrupt
serviced without any suspend.
TIMER1: PUSHA
PUSHX
PUSHY
LDMIENH,#40H;
LDMIENL,#00H;
EI;
:
:
:
:
LDMIENH,#0FFH ;
LDMIENL,#0FFH
POPY
POPX
POPA
RETI
Enable INT1 only
Disable other
Enable Interrupt
Enable all interrupts
Figure 14-5 Execution of BRK/TCALL0
14.6 Multi Interrupt
If two requests of different priority levels are received simultaneously, the request of higher priority level is serviced. If requests of the interrupt are received at the same time
simultaneously, an int ernal p olling sequ ence de termin es by hardware which request is serviced.
However, multiple processing through software for special features is possible. Generally when an interrupt is accepted, the Iflag is cleared to disable any further interrupt. But as user sets Iflag in interrupt routine, some further interrupt can be serviced
even if certain interrupt is in progress.
14.7 External Interrupt
) as
H
The external interrupt on INT1 and INT2 pins are edge triggere d
depending on the edge selection register IEDS (address 0D8
The INT1 ~ INT2 edge are latched into IFINT1 ~ IFINT2 at every
machine cycle. The v alues are no t actu ally po lled by th e circuitry
until the next machine cycle. If a request is active and conditions
are right for it to be acknowledg e d, a hard ware sub r o uti ne call to
the requested service routine will be the next instructio n to be executed. The DIV itself takes twel ve cycles. T hus, a mini mum of
twelve complete machine cycles elapse between activation o f an
external interrupt request and the beginning of execution of the
first instruction of the service routine.
Figure 14-8 shows interrupt response timings.
14.8 Key Scan Input Processing
Key Scan Interrupt is generated by detectin g low or high
Input from each Input pin (R0, R1) is one of the sources
which release standby (SLEEP, STOP) mode. Key Scan
ports are all 16bit which are controlled by Standby Mode
Release Register (SMRR0, SMRR1). Key Input is considered as Interrupt, therefore, KSCNE bit of IEHN should be
Figure 14-8 Interrupt Response Timing Diagram
set for correct interrupt executing, SLEEP mode and STOP
mode, the rest of executing is the same as that of external
Interrupt. Each SMRR Register bit is allowed for each port
(for Bit= “0”, no Key Input, for Bit= “1”, Key Input available). At reset, SMRR becomes “00h”. So, there is no Key
Input source.
JUNE 2001 Ver 1.0053
Page 57
HMS81004E/08E/16E/24E/32E
Standby release level control register (SRLC) can select
the key scan input level “L” or “H” fo r stan dby release b y
each bit pin (R0, R1). Standby release level control register
SMRR0SRLC0
R00
R01
R02
R03
R04
R05
R06
R07
R10
R11
R12
R13
R14
R15
R16
R17
R0 PORT LOGIC
R1 PORT LOGIC
SMRR1SRLC1
(SRLC) is write-only register and initialized as “00h” in reset state.
Internal
Key Scan
Input
SMRR0
SMRR1
SRLC0
SRLC1
WW
76543210
KR07
KR06KR05KR04 KR03 KR02
KR0*
1: Select
0: No Select
WW
76543210
KR17
KR16KR15KR14 KR13 KR12
KR1*
1: Select
0: No Select
WW
76543210
KLR07
KLR06 KLR05 KLR04 KLR03 K LR02
KLR0*
1: High
0: Low
WW
76543210
KLR17
KLR16 KLR15 KLR14 KLR13 K LR12
KLR1*
1: High
0: Low
BTCL
BTCL
BTCL
BTCL
KLR11 KLR10
W
WWWWW
KR01 KR00
W
WWWWW
KR11 KR10
W
WWWWW
KLR0 1 KLR 00
W
WWWWW
ADDRESS: 0DC
INITIAL VALUE: 00
ADDRESS: 0DD
INITIAL VALUE: 00
ADDRESS: 0F6
INITIAL VALUE: 00
ADDRESS: 0 F7
INITIAL VALUE: 00
H
H
H
H
H
H
H
H
Figure 14-9 Block Diagram of Key Scan Block
54JUNE 2001 Ver 1.00
Page 58
15. STANDBY FUNCTION
Sleep Mode Control Register (W)
SLPM
ADDRESS : 0F0
H
INITIAL VALUE : -------0b
-
SLPM0
1: sleep mode
Clock Control Register (W)
CKCTLR
ADDRESS : 0C7
H
INITIAL VALUE : --110111b
0
123
4567
ENPCK 0: Stopped
1: Provided
---- --
0: Sleep mode release
0
15.1 Sleep Mode
HMS81004E/08E/16E/24E/32E
SLEEP mode can be entered by setting the bit of SLEEP
mode register (SLPM). In the mode, CPU clock stops but
oscillator keeps running. B.I.T and a part of peripheral
hardware execute, but prescalerís output which provide
clock to peripherals can be stopped by program. (Except,
PS10 can’t stopped.) In SLEEP mode, more consuming
power can be saved by not using other peripheral hard ware
except for B.I.T. By setting ENPCK (peripheral clock control bit) of CKCTLR (clock control register) to “0”, peripheral hardware halted, and SLEEP mode is entered. To
release SLEEP mode by BITR (basic interval timer interrupt), bit10 of prescaler should be selected as B.I.T input
clock before entering SLEEP mode. “NOP” instruction
should be follows setting of SLEEP mode for risi ng pr echarge time of data bus line.
(ex) setting of SLEEP mode : set the bit of SLEEP
; mode register (SLPM)
NOP : NOP instruction
15.2 STOP MODE
STOP mode can be en tered by STOP instruction dur ing
program. In STOP mode, oscillator is stopped to make all
clocks stop, which leads to less power consumption. All
registers and RAM data are preserved. “NOP” instruction
should be follows STOP instruction for rising precharge
time of Data Bus line.
(ex) STOP : STOP instruction execution
NOP : NOP instruction
JUNE 2001 Ver 1.0055
Page 59
HMS81004E/08E/16E/24E/32E
STOP
OSC
Circuit
S
R
Clock Pulse
Generator
MUX
Basic
CPU Clock
Interval
Timer
Prescaler
Clear
Clear
bit7
Control Signal
Q
S
Q
Overflow Detection
R
Release Signal from Interrupt
RESETB
Figure 15-1 Block Diagram of Standby Circuit
15.3 STANDBY MODE RELEASE
Release of STANDBY mode is executed by RESET input
and Interrupt signal. Regist er value is defin ed when Reset.
When there is a release signal of STOP mode (Interrupt,
Release SignalSLEEPSTOP
RESET input), the instruction execution starts after stabilization oscillation time is set by value of BTS2 ~ BTS0
and set ENPCK to “1”.
RESETBOO
KSCN(Key Input)OO
INT1,INT2OO
B.I.T.O
Table 15-1 Release Signal of Standby Mode
56JUNE 2001 Ver 1.00
Page 60
HMS81004E/08E/16E/24E/32E
Release FactorRelease Method
RESETBBy RESETB Pin=Low level, Standby mode is releas and system is initialized
Standby mode is released by low input of selected pin by key scan Input(SMRR0,SMRR1).
KSCN(Key Input)
INT1,INT2
Basic Interval
Timer(IFBIT)
In case of interrupt mask enable flag= “0”, program executes just after standby instruction,
if flag= “1” enters each interrupt service routine.
When external interrupt (INT1,INT2)enable flag is “1”, standby mode is released at the
rising edge of each terminal. When standby mode is released at interrupt. Mask Enable
flag= “0”, program executes from the next instruction of standby instruction. When “1”,
enters each interrupt service routine.
When B.I.T. is executed only by bit10 of prescaler(PS10), SLEEP mode can be released.
Interrupt release SLEEP mode , when BIT inte rrupt ena ble flag is “1”. Wh en stand by mode
is released at interrupt. Mask enable flag= “0”, program executes from the next instruction
of SLEEP instruction. When “1”, enters each interrupt service routine.
Table 15-2
[SLEEP MODE]
release by interrupt
[STOP MODE]
release by interrupt
Xin
RESET
Xin
RESET
SLEEP command
SLEEP mode
STOP mode
Longer than 2 machine cycle
Stable OSC.time
Program setting time by CKCTLR
Longer than stabe OSC. Time
Figure 15-2 Block Diagram of Standby Circuit
JUNE 2001 Ver 1.0057
Page 61
HMS81004E/08E/16E/24E/32E
15.4 RELEASE OPERA TION OF STANDBY MODE
After standby mode is released, the operation be gins according to content of related interrupt register just before
STOP Command
Standby Mode
Interrupt Request GEN.
Int. enable reg.
1
Standby Mode Release
PSW
I Flag
1
Interrupt Service Routine
standby mode start (Figure 15-3).
0
0
Standby Next Command
Execution
.
Figure 15-3 Standby Mode Release Flow
(1) Interrupt Enable Flag(I) of PSW = “0”
Release by only interrupt which interrupt enable flag =
“1”, and starts to execute from next to standby instruction
(SLEEP or STOP).
(2) Interrupt Enable Flag(I) of PSW = “1”
Released by only interrupt which each interrupt enable flag
= “1”, and jump to the relevant interrupt service routine.
Note: When STOP instruction is used, B.I.T should guarantee the stabilizati on oscillati on time. Thus, jus t before en-
tering STOP mode, clock of bit10 (PS10 ) of prescale r is
selected or peripheral hardware clock control bit (ENPCK)
to “1”, Therefore the clock necessary for stabilization oscillation time should be input into B.I.T. otherwise, standby
mode is released by reset signal. In case of interrupt request flag and interrupt enable flag are both “1”, standby
mode is not entered.
58JUNE 2001 Ver 1.00
Page 62
HMS81004E/08E/16E/24E/32E
Internal circuitSLEEP modeSTOP mode
OscillatorActiveStop
Internal CPUStopStop
RegisterRetainedRetained
RAMRetainedRetained
I/O portRetainedRe tai ned
PrescalerActiveRetained
Basic Interval Timer
Watch-dog TimerStopStop
TimerStopStop
Address Bus,Data BusRetainedRetained
Table 15-3 Operation State in Standby Mode
PS10 select ed:Active
Others: Stop
Stop
JUNE 2001 Ver 1.0059
Page 63
HMS81004E/08E/16E/24E/32E
16. RESET FUNCTION
16.1 EXTERNAL RESET
The RESET pin should be held at low for at least 2mach ine
cycles with the power supply voltage within th e operat ing
voltage range and must be connected 0.1uF capacitor for
RESET
Figure 16-1 RESET Pin connection
16.2 POWER ON RESET
Power On Reset circuit automatically detects the rise of
power voltage (the rising time s hould be with in 50ms ) the
power voltage reaches a certain level, RESET terminal is
maintained at “L” Level until a crystal ceramic oscillator
oscillates stably. After power applies and starting of oscillation, this reset state is maintained for about oscillation
cycle of 219 (about 65.5ms : at 4MHz).The execution of
built-in Power On Reset circuit is as follows :
(1) Latch the pulse f rom Power On Detection Pu lse Generator circuit, and reset Prescaler, B.I.T and B.I.T Overflow
stable system initialization. The RESET pin contains a
Schmitt trigger with an internal pull-up resistor.
0.1uF capacito r
GND
detection circuit.
(2) Once B.I.T Overflow detection circuit is reset. Then,
Prescaler starts to count.
(3) Prescaler output is inputted into B.I.T and PS10 of
Prescaler output is automatically selected. If overflow of
B.I.T is detected, Overflow detection circuit is set.
4) Reset circuit generates maximum period of reset pulse
from Prescaler and B.I.T
60JUNE 2001 Ver 1.00
Page 64
HMS81004E/08E/16E/24E/32E
VDD
RESET
0.1uF
GND
GND
Clear
OSC
Circuit
Prescaler
Figure 16-2 Block Diagram of Power On Reset Circuit
Note: When Power On Reset, oscillator stabilization time
doesn`t include OSC. Start time.
VDD
Prescaler Count Start
PS10
Internal Reset
Power on
Detect Pulse
Generator
Clear
Basic
Interval
Timer
MSB
Clear
B.I.T.
Overflow
Detction
Circuit
OSC. Start Time
Figure 16-3 Oscillator stabiliaztion diagram
JUNE 2001 Ver 1.0061
Page 65
HMS81004E/08E/16E/24E/32E
Oscillator
(X
pin)
IN
RESET
ADDRESS
BUS
DATA
BUS
ADL and ADH are start addresses of interrupt service routine as vector contents.
?
?
Stabilization Time
Figure 16-4 Timing Diagram of Reset
16.3 Low Voltage Detection Mode
(1) Low voltage detection condition
An on board voltage comparator checks that VDD is at the
required level to ensure correct operation of the device. If
VDD is below a certain level, Low voltage detector forces
the device into low voltage detection mode.
~
~
~
~
~
~
~
~
~
~
~
~
1234567
?
??
??
RESET Process Step
FFFE FFFF
FE?ADL
ADH
Start
OP
MAIN PROGRAM
all port can be selected with Pull-up resistor by Mask option. If there is no information on the Mask option sheet
,the default pull up option (all port connect to pull-up resistor ) is selected.
(3) Release of Low Voltage Detection Mode
(2) Low Voltage Detection Mode
There is no power consumption except stop current, stop
mode release function is disabled. All I/O port is configured as input mode and Data memory is retained until voltage through external capacitor is worn out. In this mode,
Reset signal result from new battery(normally 3V) wakes
the low voltage detection mode and come into normal reset
state. It depends on user whether to execute RAM clear
routine or not
C)
°
62JUNE 2001 Ver 1.00
Page 66
(4) SRAM BACK-UP after Low Voltage Detection.
about hours depend on Vdd-GND Capacito r
VDD
3V
SRAM Dat a Backup
HMS81004E/08E/16E/24E/32E
2V(Min.)
1.7V(typ.20 °
0.7V(Vret)
C
)
0V
User removes
batteries
Low Voltage detetion point
Power on Reset
(SRAM retention)
Power on Reset
(SRAM unstable)
Time
User replac es
batteries
Figure 16-6 Oscillator stabiliaztion diagram
Interruptdisable
Stop releasedisable
All I/O portinput Mode
Remout portLow Level
OSCSTOP
All I/O port pull-up onMask Option
SRAM Dataretention until Vret
Table 16-1 The operation after Low Voltage detection
JUNE 2001 Ver 1.0063
Page 67
HMS81004E/08E/16E/24E/32E
(5) S/W flow chart example after Reset using SRAM Back-up
RESET
Stack Pointer initialize
Check the SRAM value
(RAM Pattern, Checksum)
SRAM DATA
VALID?
Y
Use Saved SRAM value
Main routine
N
Clear all Ram area
Figure 16-7 S/W flow chart example after Reset using SRAM Back-up
64JUNE 2001 Ver 1.00
Page 68
APPENDIX
Page 69
A. MASK ORDER SHEET
MASK ORDER & VERIFICATION SHEET
HMS810
E -UE
Customer should write inside thick line box.
1. Customer Information
Company Name
Application
Order Date
Tel:
Name&Signature:
YYYYMMDD
Fax:
2. Device Information
20SOP
Package
Mask DataFile Name: ( .OTP)
Check Sum ( @27c256)
24SOP
28SOP
28PIN DIE
3. Inclusion of pull-up resistor in Low Volatage Detection mode
*1
Port R00 R01 R02 R03 R04
Y/N
*1 : is not avilable for 20PIN. So default option is pull-up on.
*2 : is not avilable for 20PIN & 24PIN. So default option is pull-up on.
R05 R06
R07
R10 R11 R12 R13 R14
*1*1*1
R15 R16
R17
*2
R20 R21 R22 R23 R24
4. Marking Specification
(Please check mark into )
20PDIP
24SKDIP
28SKDIP
*2
*2*2
04/08/16/24/32
Customer’s logo
HMS810
E -UE
Hynix ROM Code
Number
HMS810
YYWW
If the customer logo must be used in the special mark, please submit a clean original of the logo.
Customer’s part number
KOREA
Lot Number
YYWW
Customer logo is not required.
5. Delivery Schedule
Customer Sample
Risk Order
YYYYMMDD
YYYYMMDD
6. ROM Code Verification
Verifica tio n D a te :
Please confirm our verification data.
Check Sum:
Tel:Fax:
Name &
Signature:
YYYYMMDD
Date
Quantity
pcs
pcs
This box is written after “6.Verification”.
Approval Date:
I agree with your verification data and confirm
yo u to m a k e ma sk se t.
Tel:
Name &
Signature:
E -UE
KOREA
Hynix Confirmation
YYYYMMDD
Fax:
JUNE 2001
Page 70
B. INSTRUCTION
B.1 Terminology List
TerminologyDescription
AAccumulator
XX - register
YY - register
PSWProgram Status Word
#imm8-bit Immediate data
dpDirect Page Offset Address
!absAbsolute Address
[ ]Indirect expr ession
{ }Register Indirect expression
{ }+Register Indirect expression, after that, Register auto-increment
.bitBit Position
A.bitBit Position of Accumulator
dp.bitBit Position of Direct Page Memory
M.bit
relRelative Addressing Data
upage
nTable CALL Number (0~15)
+Addition
x
y
−
×
/Division
( )Contents Expression
∧
∨
⊕
~NOT
←
→
↔
=Equal
≠
Bit Position of Memory Data (000
~0FFFH)
H
U-page (0FF00H~0FFFFH) Offset Address
0
Bit Position
1
Bit Position
Upper Nibble Expression in Opcode
Upper Nibble Expression in Opcode
Subtraction
Multiplication
AND
OR
Exclusive OR
Assignment / Transfer / Shift Left
Shift Right
Exchange
78ROR dp + X7925
79ROR !abs7835
80SBC #imm2422Subtract with Carry
81SBC dp2523 A ← ( A ) - ( M ) - ~( C )
82SBC dp + X2624
83SBC !abs2734
84SBC !abs + Y3535
85SBC [ dp + X ]3626
86SBC [ dp ] + Y3726
87SBC { X }3413
88TST dp4C23
89XCNCE15
Test memory contents for negative or zero, ( dp ) - 00
Exchange nibbles within the accumulator
↔ A3~A
A
7~A4
0
Flag
NVGBHIZC
NV--H-Z-
N-----Z-
N-----ZC
N-----ZN-----ZN-----ZN-----ZN-----Z-
H
N-----ZC
N-----Z-
N-----Z-
N-----ZC
N-----ZC
NV--HZC
N-----Z-
N-----Z-
C
→→→→→→→→
→
←←←←←←←←
C
→→→→→→→→
lxxivJUNE 2001 Ver 1.00
Page 74
Register / Memory Operation
APPENDIX
No.Mnemonic
1LDA #immC422Load accumulator
2LDA dpC523 A ← ( M )
3LDA dp + XC624
4LDA !absC734
5LDA !abs + YD535
6LDA [ dp + X ]D626
7LDA [ dp ] + YD726
8LDA { X }D413
9LDA { X }+DB14X- register auto-increment : A ← ( M ) , X ← X + 1
10LDM dp,#immE435Load memory with immediate data : ( M ) ← imm
11LDX #imm1E22Load X-register
12LDX dpCC23 X ← ( M )
13LDX dp + YCD24
14LDX !absDC34
15LDY #imm3E22Load Y-register
16LDY dpC923 Y ← ( M )
17LDY dp + XD924
18LDY !absD834
19STA dpE524Store acc umulator contents in memory
20S TA dp + XE 625 ( M ) ← A
21STA !absE735
22STA !abs + YF536
23STA [ dp + X ]F627
24STA [ dp ] + YF727
25STA { X }F414
26STA { X }+FB14X- register auto-increment : ( M ) ← A, X ← X + 1
27STX dpEC24Store X-register contents in memory
28S TX dp + YED25 ( M ) ← X
29STX !absFC35
30STY dpE 924Store Y-register contents in memory
31S TY dp + XF925 ( M ) ← Y
32STY !absF835
33TAXE812Transfer accumulator contents to X-register : X ← A
34TAY9F12Transfer accumulator contents to Y-register : Y ← A
35TSPXAE12Transfer stack-pointer contents to X-register : X ← sp
36TXAC812Transfer X-register contents to accumulator: A ← X
37TXS P8E12Transfer X-re gister content s to stack-pointer: sp ← X
38TYABF12Transfer Y-register contents to accumulator: A ← Y
39XAXEE14Exchange X-register contents with accumulator :X ↔ A
40XAYDE14Exchange Y-register contents with accumulator :Y ↔ A
41XMA dpBC25Exchange memory contents with accumulator
42X MA dp+XAD26 ( M ) ↔ A
43X MA {X}BB15
44XYXFE14Exchange X-register contents with Y-register : X ↔ Y
Op
Code
ByteNoCycle
No
Operation
Flag
NVGBHIZC
N-----Z-
--------
N-----Z-
N-----Z-
--------
--------
--------
N-----ZN-----ZN-----ZN-----ZN-----ZN-----Z-
--------
--------
N-----Z-
--------
JUNE 2001 Ver 1.00lxxv
Page 75
APPENDIX
16-BIT operation
No.Mnemonic
1ADDW dp1D25
2CMPW dp5D24
3DECW dpBD26
4INCW dp9D26
5LDYA dp7D25
6STYA dpDD25
7SUBW dp3D25
Op
Code
ByteNoCycle
No
Operation
16-Bits add without Carry
YA ← ( YA ) ( dp +1 ) ( dp )
Compare YA contents with memory pair contents :
(YA) − (dp+1)(dp)
16-Bits subtract without carry
YA ← ( YA ) - ( dp +1) ( dp)
Bit Manipulation
No.Mnemonic
1AND1 M.bit8B34Bit AND C-flag : C ← ( C ) ∧ ( M .bit )
2AND1B M.bit8B34Bit AND C-flag and NOT : C ← ( C ) ∧ ~( M .bit )
3BIT dp0C24Bit test A with memory :
4BIT !abs1C35
5CLR1 dp.bity124Clear bit : ( M.bit ) ← “0”
6CLRA1 A.bit2B22Clear A bit : ( A.bit ) ← “0”
7CLRC2012Clear C-flag : C ← “0”
8CLRG4012Clear G-flag : G ← “0”
9CLRV8012Clear V-flag : V ← “0”
10EOR1 M.bitAB35Bit exclusive-OR C-flag : C ← ( C ) ⊕ ( M .bit )
11EOR1B M.bitAB35Bit exclusive-OR C-flag and NOT : C ← ( C ) ⊕ ~(M .bit)
12LDC M.bitCB34Load C-flag : C ← ( M .bit )
13LDCB M.bitCB34Load C-flag with NOT : C ← ~( M .bit )
14NOT1 M.bit4B35Bit complement : ( M .bit ) ← ~( M .bit )
15OR1 M.bit6B35Bit OR C-flag : C ← ( C ) ∨ ( M .bit )
16OR1B M.bit6B35Bit OR C-flag and NOT : C ← ( C ) ∨ ~( M .bit )
17SET1 dp.bitx124Set bit : ( M.bit ) ← “1”
18SETA1 A.bit0B22Set A bit : ( A.bit ) ← “1”
19SETCA012Set C-flag : C ← “1”
20SETGC012Set G-flag : G ← “1”
21STC M.bitEB36Store C-flag : ( M .bit ) ← C
22TCLR1 !abs5C36
23TSET1 !abs3 C36
Op
Code
ByteNoCycle
No
Operation
Z ← ( A ) ∧ ( M ) , N ← ( M
Test and clear bits with A :
A - ( M ) , ( M ) ← ( M ) ∧ ~( A )
Test and set bits with A :
A - ( M ) , ( M ) ← ( M ) ∨ ( A )
) , V ← ( M6 )
7
Flag
NVGBHIZC
NV--H-ZC
N-----ZC
N-----Z-
N-----Z-
N-----Z-
--------
NV--H-ZC
Flag
NVGBHIZC
-------C
-------C
MM----Z-
--------
--------
-------0
--0-----
-0--0---
-------C
-------C
-------C
-------C
--------
-------C
-------C
--------
--------
-------1
--1-----
--------
N-----Z-
N-----Z-
lxxviJUNE 2001 Ver 1.00
Page 76
Branch / Jump Operation
APPENDIX
No.Mnemonic
Op
Code
ByteNoCycle
No
Operation
1BBC A.bit,rely224/6Branch if bit clear :
2BBC dp.bit,rely335/7if ( bit ) = 0 , then pc ← ( pc ) + rel
3BBS A.bit,relx224/6Branch if bit set :
4BBS dp.bit,relx335/7if ( bit ) = 1 , then pc ← ( pc ) + rel
5BCC rel5022/4
6BCS relD022/4
7BEQ relF022/4
8BMI rel9022/4
9BNE rel7022/4
10BPL rel1022/4
11BRA rel2F24
12BVC rel3022/4
13BVS relB022/4
Branch if carry bit clear
if ( C ) = 0 , then pc ← ( pc ) + rel
Branch if carry bit set
if ( C ) = 1 , then pc ← ( pc ) + rel
Branch if equal
if ( Z ) = 1 , then pc ← ( pc ) + rel
Branch if minus
if ( N ) = 1 , then pc ← ( pc ) + rel
Branch if not equal
if ( Z ) = 0 , then pc ← ( pc ) + rel
Branch if plus
if ( N ) = 0 , then pc ← ( pc ) + rel
Branch always
pc ← ( pc ) + rel
Branch if overflow bit clear
if (V) = 0 , then pc ← ( pc) + rel
Branch if overflow bit set
if (V) = 1 , then pc ← ( pc ) + rel
14CALL !abs3B38Subroutine call
15CALL [dp]5F28
M( sp)←( pc
if !abs, pc← abs ; if [dp], pc
), sp←sp - 1, M(sp)← (pcL), sp ←sp - 1,
H
( dp ), pc
←
L
16CBNE dp,relFD35/7Compare and branch if not equal :
17CBNE dp+X,rel8 D36/8 if ( A ) ≠ ( M ) , then pc ← ( pc ) + rel.
18DBNE dp,relAC35/7Decrement and branch if not equal :
19DBNE Y,rel7B24/6 if ( M ) ≠ 0 , then pc ← ( pc ) + rel.
20JMP !abs1B33Unconditional jump
21JMP [!abs]1F35 pc ← jump address
22JMP [dp]3F24