Semiconductor Group of Hyundai Electronics Industrial Co., Ltd.
MicroElectronics
Page 2
Version 1.04
Published by
MCU Application Team
1999 HYUNDAI Micro Electronics All right reserved.
Additional information of this manual may be served by HYUNDAI Micro Electronics offices in Korea or Distributors and
Representatives listed at address directory.
HYUNDAI Micro Electronics 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 co rrect and reliable; ho wever, HYUNDAI Micro Electronics 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 ....................................................x
D. MASK ORDER SHEET......................xvi
DEC. 1999 Ver 1.04
Page 4
HYUNDAI MicroElectronicsGMS81508B/16B/24B
GMS81508B/16B/24B
CMOS SINGLE-CHIP 8-BIT MICROCONTROLLER
WITH A/D CONVERTER
1. OVERVIEW
1.1 Description
The GMS81508B/16B/24B are advanced CMOS 8-bi t microcon trollers with 8K/16K/24K byt es of ROM. The device is on e
of GMS800 family. This device using the GMS800 family CPU includes several peripheral functions such as Timer, A/D
converter, Programmable buzzer driver, Serial I/O communication, Pulse Width Mod ulation function, etc. The RAM, ROM,
and I/O are placed on the same memory map in addition to simple instruction set.
The GMS815xxB is functi onall y 10 0% com pati ble wit h earie r GMS81508/16 or GMS81508A/16A, h owever bet t er characteristics have such as strong EMS, wide operating voltage, temperature, frequency and fast programming time for the OTP.
• 448 Bytes of On-chip Data RAM
(Included stack memory)
• Minimum Instruction Execution Time
0.5
s at 8MHz
µµµµ
• One 8-bit Basic Interval Timer
• Four 8-bit Timer/Event counter
or Two 16-bit Timer/Event counter
• One 6-bit Watchdog timer
• Eight channel 8-bit A/D converter
• Two channel 8-bit PWM
• One 8-bit Serial Communication Interface
• Four External Interrupt input ports
• Buzzer Driving port
- 500Hz ~ 250kHz@8MHz
• 52 I/O Ports, 4 Input Ports
• Twelve Interrupt sources
- Basic Interval Timer: 1
- External input: 4
- Timer/Event counter: 4
- ADC: 1
- Serial Interface: 1
- WDT: 1
• Built in Noise Immunity Circuit
- Noise filter
- Power fail processor
• Power Down Mode
- STOP mode
• 2.2V to 5.5V Wide Operating Range
• 1~10MHz Wide Operating Frequency
• 64SDIP, 64MQFP, 64LQFP package types
• Available 16K, 24K bytes OTP version
DEC. 1999 Ver 1.041
Page 5
GMS81508B/16B/24BHYUNDAI MicroElectronics
1.3 Development Tools
The GMS815xxB are supported by a full-featured macro
assembler, an in-circuit emulator CHOICE-Jr.
TM
and OTP
programmers. There are third different type programmers
such as emulator add-on board type, single type, gang
type. For mode detail, Refer to “22. OTP PROGRAMMING” on page 73. Macro assembler operates under the
MS-Windows 95/98
TM
.
Please contact sales part of Hyundai MicroElectronics.
1.4 Ordering Information
Device nameROM SizeRAM sizePackage
Mask version
OTP version
GMS81508B K
GMS81508B Q
GMS81508B LQ
GMS81516B K
GMS81516B Q
GMS81516B LQ
GMS81524B K
GMS81524B Q
GMS81524B LQ
GMS81516BT K
GMS81516BT Q
GMS81516BT LQ
GMS81524BT K
GMS81524BT Q
GMS81524BT LQ
Supply voltage.............................................-0.3 to +7.0 V
Storage Temperature ..................................-40 to +125 °C
Voltage on any pin with respect to Ground (V
................................ ..................................-0.3 to V
Maximum current out of V
Maximum current into V
Maximum current sunk by (I
Maximum output current sourced by (I
pin..........................150 mA
SS
pin ..............................80 mA
DD
per I/O Pin) ..........20 mA
OL
OH
)
SS
DD
per I/O Pin)
+0.3
...................................................................................8 mA
7.2 Recommended Operating Conditions
ParameterSymbolCondition
f
=1 ~ 10 MHz
XIN
f
Supply Voltage
Operating Frequency
V
f
DD
XIN
=1 ~ 8 MHz
XIN
f
=1 ~ 4 MHz
XIN
VDD=4.5~5.5V
VDD=2.7~5.5V
VDD=2.2~5.5V
Maximum current (ΣI
Maximum current (ΣI
)......................................100 mA
OL
)........................................50 mA
OH
Note: Stresses above those listed under “Absolute Maximum 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 pecificatio n i s no t i mp l ie d .
Exposure to absolute maximum rating conditions for extended periods may affect device reliability.
Specifications
Unit
Min.Max.
4.5
2.7
2.2
1
1
1
5.5
5.5
5.5
10
8
4
V
MHz
Operating Temperature
T
OPR
7.3 A/D Converter Characteristics
(TA=25°C, VSS=0V, VDD=5.12V@f
ParameterSymbol
Analog Input Voltage Range
Non-linearity Error
Differential Non-linearity Error
Zero Offset Error
Full Scale Error
Gain Error
Overall Accuracy
AV
Input CurrentI
DD
Conversion Time
=8MHz, VDD=3.072V@f
XIN
Normal Version
Temperature Extention Version
=4MHz)
XIN
Min.
V
N
N
N
N
N
N
T
CONV
AIN
NLE
DNLE
ZOE
FSE
GE
ACC
REF
V
SS
-
-
-
-
-
-
-0.51.01.0 mA
--4020
-20
-40
85
85
Specifications
1
Typ.
f
XIN
-
1.0±1.5±1.5LSB
±
1.0±1.5±1.5LSB
±
0.5±1.5±1.5LSB
±
0.35±0.5±0.5LSB
±
1.0±1.5±1.5LSB
±
1.0±1.5±1.5LSB
±
Max.
=4MHzf
AV
DD
XIN
AV
=8MHz
DD
C
°
Unit
V
s
µ
12DEC. 1999 Ver 1.04
Page 16
HYUNDAI MicroElectronicsGMS81508B/16B/24B
Specifications
ParameterSymbol
Min.
Analog Power Supply Input Range
1. Data in “Typ” column is at 25°C unless otherwise stated. These parameters are for design guidance only and are not tested.
AV
DD
0.9V
DD
Typ.
V
DD
1
f
XIN
Max.
=4MHzf
1.1V
XIN
DD
Unit
=8MHz
V
7.4 DC Electrical Characteristics
(TA=-20~85°C, VDD=2.7~5.5V, Ta= -20~85°C, f
=8MHz, VSS=0V)
XIN
ParameterSymbolCondition
, RESET,
X
IN
R4, R5, R6
R0, R1, R2, R3
, RESET,
X
IN
R4, R5, R6
R0, R1, R2, R3-
R0,R1,R2,R3,R4,R5
R6
R0,R1,R2,R3,R4,R5
R6
@ T
=25°C0.9V
A
All input pins-5.0-5.0
All input pins-5.0-5.0
RESET, EC0, EC2,
SIN, SCLK, INT0~INT3
SS
Input High Voltage
Input Low Voltage
Output High Voltage
Output Low Voltage
Power Fail Detect
Voltage
Input High
Leakage Current
Input Low
Leakage Current
Hysteresis
V
IH1
V
IH2
V
IL1
V
IL2
V
OH
V
OL
V
PFD
I
IH1
I
IL
, V
V
T+
T-
I
DD1fXIN
VDD=4.5
VDD=2.7
VDD=4.5
V
=2.7
DD
VDD=4.5
VDD=2.7
I
=-2mA
OH1
VDD=4.5
VDD=2.7
I
=5mA
OL1
V
=3.0V
PFD
V
=2.4V
PFD
VIN=V
DD
VIN=V
SS
= 8 MHzA ll inp ut = V
C ry s ta l Oscilla tor ,
Power Current
1. Data in “Typ.” column is at 4.5V, 25°C unless otherwise stated. These parameters are for design guidance only and are not tested.
Serial Input Clock Pulse
Serial Input Clock Pulse Width
Serial Input Clock Pulse Transition
Time
SIN Input Pulse Transition Time
SIN Input Setup Time (External SCLK)
SIN Input Setup Time (Internal SCLK)
SIN Input Hold Time
Serial Output Clock Cycle Time
Serial Output Clock Pulse Width
Serial Output Clock Pulse Transition
Time
Serial Output Delay Time
XIN
t
SCYC
t
SCKW
t
FSCK
t
RSCK
t
FSIN
t
RSIN
t
SUS
t
SUS
t
HS
t
SCYC
t
SCKW
t
FSCK
t
RSCK
s
OUT
=8MHz)
Specifications
Unit
Min.Typ.Max.
SCLK
SCLK
2t
SYS
+70
t
SYS
-8ns
-8ns
+200
SCLK--30ns
SIN--30n s
SIN100--ns
SIN200-ns
SIN
SCLK
SCLK
t
SYS
t
SYS
4t
SYS
-30
-ns
-
16t
SYS
ns
ns
+70
SCLK30ns
SOUT100ns
SCLK
SIN
SOUT
t
0.8V
0.2V
FSCK
t
SCYC
t
RSCK
SUS
DD
DD
t
SCKW
t
t
FSIN
t
DS
0.8V
DD
0.2V
DD
Figure 7-2 Serial I/O Timing Chart
t
SCKW
t
HS
0.8V
DD
0.2V
DD
t
RSIN
DEC. 1999 Ver 1.0415
Page 19
GMS81508B/16B/24BHYUNDAI MicroElectronics
7.7 Typical Characteristic Curves
This graphs and tables provided in this section are for design guidance only and are not tested or guaranteed.
In some graphs or tables the data presented are outside specified operating range (e.g. outside specified
VDD range). This is for information only and devices
are guaranteed to operate properly only within the
specified range.
I
OH
(mA)
-12
-9
-6
-3
I
OH
VDD=4.5V
Ta=25°C
0
V
−
OH
0.30.6
R0~R6 pins
0.9 1.2
1.5
VDD-V
(V)
OH
I
OH
(mA)
-12
-9
-6
-3
I
0
V
−
OH
VDD=3.0V
Ta=25°C
0.3 0.6
OH
The data presented in this s ection is a statistical s ummary
of data collected on units from different lots over a period
of time. “Typical” represents the mean of the distribution
while “max” or “min” represents (mean + 3σ) and (mean
3σ) respectively where σ is standard deviation
R0~R6 pins
(V)
0.9 1.2
1.5
VDD-V
OH
−
V
I
OL
(mA)
20
15
10
IH1
(V)
0
I
5
0
V
4
3
2
1
V
−
OL
VDD=4.5V
Ta=25°C
0.2 0.4
V
−
DD
f
=8MHz
XIN
Ta=25°C
23
OL1
IH1
R0~R6 pins
0.6 0.8
XIN, RESET,
R4, R5, R6 pins
45
1.0
I
V
−
OL
VDD=3.0V
Ta=25°C
0.2 0.4
V
DD
f
=8MHz
XIN
Ta=25°C
1
OL2
V
−
IH2
23
I
OL
(mA)
20
15
10
5
V
OL
(V)
V
DD
(V)
6
0
V
IH2
(V)
4
3
2
1
0
R0~R6 pins
0.6 0.8
R0, R1, R2, R3 pins
45
1.0
6
V
V
(V)
(V)
OL
DD
16DEC. 1999 Ver 1.04
Page 20
HYUNDAI MicroElectronicsGMS81508B/16B/24B
V
IL2
(V)
I
DD
(mA)
4
3
2
1
0
20
15
10
5
0
V
DD
f
XIN
Ta=25°C
I
−
DD
Ta=25°C
f
V
−
IL1
=8MHz
23
V
DD
= 8MHz
XIN
23
XIN, RESET
R4, R5, R6 pins
45
Normal Operation
4MHz
45
,
V
DD
(V)
6
V
DD
(V)
6
V
I
DD
(µA)
IL2
(V)
0.4
0.3
0.2
0.1
4
3
2
1
0
0
V
DD
f
XIN
Ta=25°C
1
I
STOP
V
−
IL2
=8MHz
23
V
−
DD
23
R0, R1, R2, R3 pins
45
Stop Mode
45
6
6
V
DD
(V)
85°C
25°C
-20°C
V
DD
(V)
Operating Area
f
XIN
(MHz)
Ta= -20~85°C
10
8
6
4
2
0
23
45
V
DD
(V)
6
DEC. 1999 Ver 1.0417
Page 21
GMS81508B/16B/24BHYUNDAI MicroElectronics
SP
01
H
Stack Address (100H ~ 1FEH)
Bit 15Bit 087
Hardware fixed
00H~FE
H
8. MEMORY ORGANIZATION
The GMS81508B/16B/24B has separate address spaces
for Program memory and Data Memory. Pro gram memory
can only be read, not written to. It can be up to 24K bytes
8.1 Registers
This device has six registers that are the Program Counter
(PC), a 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
PCH
Figure 8-1 Configuration of Registers
Accumulator:
PCL
PSW
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.
Y
A
Two 8-bit Registers can be used as a “YA” 16-bit Register
Figure 8-2 Configuration of YA 16-bit Register
X, Y Registers
: In the addressing mode which uses these
index registers, the register conten ts a re added to the specified address, which becomes the actual address. These
modes are extremely effective for referencing subroutine
tables and memory tables . The index regi sters also h ave increment, decrement, comparison and data transfer functions, and they can be used as simple accumulators.
Stack Pointer
: The Stack Pointer is an 8-bit register used
for occurrence interrupts and calling out subroutines. Stack
Pointer identifies the location in the stack to be accessed
(save or restore).
Generally, SP is au to mat ic ally upda t ed wh e n a s ubr outin e
ACCUMULATOR
X REGISTER
Y REGISTER
STACK POINTER
PROGRAM COUNTER
PROGRAM STATUS
WORD
YA
of Program memory. Data memory can be read and written
to up to 448 bytes including the stack area.
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 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 “F E
” is
H
used.
Note: The Stack Pointer must be initialized by software because its value is undefined after RESET.
Example: To initialize the SP
LDX#0FEH
TXSP; SP ← FEH
Address 01FFH can not be used as stack. Don not use
1FFH, or malfunction would be occurred.
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
Program Status Word
:0FFH, PCL:0FEH).
H
: The Program Status Word (PSW)
contains several bits that reflect the current state of the
CPU. The PSW is described in Figure 8-3. 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.
18DEC. 1999 Ver 1.04
Page 22
HYUNDAI MicroElectronicsGMS81508B/16B/24B
[Zero flag Z]
This flag is set when the result of an arithmetic operat ion
MSBLSB
N
V G B H I Z C
NEGATIVE FLAG
OVERFLOW FLAG
when G=1, page is selected to “page 1”
SELECT DIRECT PAGE
BRK FLAG
PSW
Figure 8-3 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.
or data transfer is “0” and is cleared by any other result.
RESET VALUE: 00
CARRY FLAG RECEIVES
CARRY OUT
ZERO FLAG
INTERRUPT ENABLE FLAG
HALF CARRY FLAG RECEIVES
CARRY OUT FROM BIT 1 OF
ADDITION OPERLANDS
H
This flag assigns RAM page for direct addressing mode. In
the direct addressing mode, addressing area is from zero
page 00
addressing area is assigned 100
to 0FFH when this flag is "0". If it is set to "1",
H
to 1FFH. It is set by
H
SETG instruction and cleared by CLRG.
[Overflow flag V]
[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]
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 re-
sult of a data or arithmetic operation. When the BIT instruction is executed, bit 7 of memory is copied to this flag.
DEC. 1999 Ver 1.0419
Page 23
GMS81508B/16B/24BHYUNDAI MicroElectronics
At execution of
a CALL/TCALL/PCALL
01FE
01FD
01FC
01FB
SP before
execution
SP after
execution
PCH
PCL
01FE
01FC
Push
down
SP before
execution
SP after
execution
01FE
01FD
01FC
01FB
At execution
of PUSH instruction
PUSH A (X,Y,PSW)
01FE
01FD
01FC
01FB
A
01FE
01FD
At acceptance
of interrupt
PCH
PCL
PSW
01FE
01FB
Push
down
Push
down
01FE
01FD
01FC
01FB
At execution
of RET instruction
01FE
01FD
01FC
01FB
At execution
of POP instruction
POP A (X,Y,PSW)
PCH
PCL
01FC
01FE
A
01FD
01FE
Pop
up
Pop
up
At execution
of RET instruction
01FE
01FD
01FC
01FB
0100H
01FEH
PCH
PCL
PSW
01FB
01FE
Stack
depth
Pop
up
Figure 8-4 Stack Operation
20DEC. 1999 Ver 1.04
Page 24
HYUNDAI MicroElectronicsGMS81508B/16B/24B
0FFE0H
E2
AddressVector Area Memory
E4
E6
E8
EA
EC
EE
F0
F2
F4
F6
F8
FA
FC
FE
-
-
Serial Communication Interface
Basic Interval Timer
-
-
-
External Interrupt 2
Timer/Counter 1 Interrupt
External Interrupt 0
-
RESET Vector Area
External Interrupt 1
Watchdog Timer Interrupt
“-” means reserved area.
NOTE:
Timer/Counter 2 Interrupt
External Interrupt 3
Timer/Counter 0 Interrupt
Timer/Counter 3 Interrupt
A/D Converter
8.2 Program Memory
A 16-bit program counter is capable of addressing up to
64K bytes, but this device has 2 4K bytes program memory
space only physically implemented. Accessing a location
above FFFF
will cause a wrap-around to 0000H.
H
Figure 8-5, shows a map of Pr ogram 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 fix ed location in Program Memory. Program Memory area contains
the user program.
A000
H
C000
H
E000
H
FEFF
H
FF00
FFC0
FFDF
FFE0
FFFF
H
H
H
H
H
TCALL area
Interrupt
Vector Area
PCALL area
GMS81508B, 8K ROM
GMS815024B, 24K ROM
GMS815016B, 16K ROM
it is more useful to save program byte length.
Table Call (TC ALL) causes the CP U 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
for TCALL15, 0FFC2H for
H
TCALL14, etc., as shown in Figure 8-7.
Example: Usage of TCALL
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,
and 0FFFBH for External Interrupt 0, etc.
H
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,
DEC. 1999 Ver 1.0421
Figure 8-6 Interrupt Vector Area
Page 25
GMS81508B/16B/24BHYUNDAI MicroElectronics
11111111 11010110
01001010
PC:
FH FH DH 6H
4A
~
~
~
~
25
0FFD6
H
0FF00
H
0FFFF
H
D1
NEXT
0FFD7
H
➊
➋
➌
0D125
H
Reverse
Address
0FF00
0FFFF
PCALL Area Memory
H
PCALL Area
(256 Bytes)
H
AddressP ro gra m Mem o r y
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.
;ORG0C000H; 16K ROM Start address
;ORG0E000H; 8K ROM Start address
;*******************************************
; MAIN PROGRAM *
;*******************************************
;
RESET:DI;Disable All Interrupts
RAM_CLR: LDA#0;RAM Clear(!0000H->!00BFH)
;
;
ORG0A000H; 24K ROM Start address
CLRG
LDX#0
STA{X}+
CMPX#0C0H
BNERAM_CLR
LDX#0FEH;Stack Pointer Initialize
TXSP
LDMR0, #0;Normal Port 0
LDMR0DD,#82H;Normal Port Direction
:
:
:
LDMTDR0,#250;8us x 250 = 2000us
LDMTM0,#1FH;Start Timer0, 8us at 8MHz
LDMIRQH,#0
LDMIRQL,#0
LDMIENH,#0C8H ;Enable Timer0, INT0, INT1
LDMIENL,#0
LDMIEDS,#55H;Select falling edge detect on INT pin
LDMPMR4,#3H;Set external interrupt pin(INT0, INT1)
EI;Enable master interrupt
:
:
:
:
NOT_USED:NOP
:
RETI
DEC. 1999 Ver 1.0423
Page 27
GMS81508B/16B/24BHYUNDAI MicroElectronics
8.3 Data Memory
Figure 8-8 shows the internal Data Memory space available. Data Memory is divided in to four groups, a user RAM,
control registers, Stack, and LCD memory.
0000
H
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.
User Memory
00BF
00C0
00FF
0100
01FF
H
H
H
H
H
Control
Registers
User Memory
or Stack Area
PAGE0
PAGE1
When “G-flag=0”,
this page is selected
When “G-flag=1”
Figure 8-8 Data Memory Map
User Memory
The GMS815xxB has 448 × 8 bits for th e user me mory
(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, for example “LDM”.
Example; To write at CKCTLR
LDMCLCTLR,#09H
;Divide ratio(÷32)
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 the next save. Refer to Figure 8-4 on page 20.
24DEC. 1999 Ver 1.04
Page 28
HYUNDAI MicroElectronicsGMS81508B/16B/24B
AddressRegister NameSymbolR/W
Initial Value
76543210
Page
00C0R0 port data registerR0R/WUndefinedpage 31
00C1R0 port I/O direction reg isterR0DDW0 0 0 0 0 0 0 0page 31
00C2R1 port data registerR1R/WUndefinedpage 31
00C3R1 port I/O direction reg isterR1DDW0 0 0 0 0 0 0 0page 31
00C4R2 port data registerR2R/WUndefinedpage 31
00C5R2 port I/O direction reg isterR2DDW0 0 0 0 0 0 0 0page 31
00C6R3 port data registerR3R/WUndefinedpage 32
00C7R3 port I/O direction reg isterR3DDW0 0 0 0 0 0 0 0page 32
00C8R4 port data registerR4R/WUndefinedpage 32
00C9R4 port I/O direction reg isterR4DDW0 0 0 0 0 0 0 0page 32
00CAR5 port data registerR5R/WUndefinedpage 33
00CBR5 port I/O direction registerR5DDW0 0 0 0 0 0 0 0page 33
00CCR 6 port data registerR6R/WUndefinedpage 33
00CDR6 port I/O direction registerR6DDW0 0 0 0 - - - -page 33
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.
26DEC. 1999 Ver 1.04
Page 30
HYUNDAI MicroElectronicsGMS81508B/16B/24B
8.4 Addressing Mode
The GMS800 series MCU 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
MEMORY
Example: G=1
E45535LDM35H,#55H
0135H
➊
0F100H
0F101H
0F102H
(3) Direct Page Addressing
data
~
~
~
~
data ¨ 55H
➋
E4
55
35
dp
→
→
→ →
In this mode, a address is specified within direct page.
Example; G=0
C535LDA35H;A ←RAM[35H]
04
35
A+35H+C → A
When G-flag is 1, then RAM address is defined by 16-bit
address which is composed of 8-bit RAM paging register
(RPR) and 8-bit immediate data.
35H
0E550H
0E551H
data
➋
~
~
C5
35
~
~
data → A
➊
DEC. 1999 Ver 1.0427
Page 31
GMS81508B/16B/24BHYUNDAI MicroElectronics
(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
0F100H
0F101H
0F102H
~
~
0FA55H
H
D5
00
FA
data
➊
0FA00H+55H=0FA55H
~
~
➋
data → A
➌
Example; G=0
3F35JMP[35H]
35H
36H
~
~
0E30AH
~
~
0FA00H
X indexed indirect
0A
E3
NEXT
3F
35
[dp+X]
→
→
→ →
~
~
~
~
➋
➊
jump to
address 0E30AH
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.
Y indexed indirect
Processes memory data as Data, assigned by the data
[dp+1][dp] of 16-bit pair 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]
PROGRAM MEMORY
➊
0E025H
0E026H
0E725H
0FA00H
~
~
~
~
25
E7
NEXT
1F
25
E0
~
~
~
~
➋
jump to
address 0E30AH
30DEC. 1999 Ver 1.04
Page 34
HYUNDAI MicroElectronicsGMS81508B/16B/24B
R1 Data Register
R1
ADDRESS: 0C2
H
RESET VALUE: Undefined
R17
R16 R15 R14 R13
R12 R11 R10
Port Direction
R1 Direction Register
R1DD
ADDRESS: 0C3
H
RESET VALUE: 00
H
0: Input
1: Output
Input / Output data
R2 Data Register
R2
ADDRESS: 0C4
H
RESET VALUE: Undefined
R27 R26 R25 R24 R23 R22 R21 R20
Port Direction
R2 Direction Register
R2DD
ADDRESS: 0C5
H
RESET VALUE: 00
H
0: Input
1: Output
Input / Output data
9. I/O PORTS
The GMS815xxB has seve n ports (R0, R1, R2, R4, R5, and
R6).These ports pins may be multiplexed with an alternate
function for the peripheral features on the device.
All pins have data direction registers which can define
these ports as output or input. A “1” in the port direction
register configure the corresponding port pin as output.
Conversely, write “0” to the corresponding bit to specif y it
as input pin. For example, to use the even numbered bit of
R0 as output ports and the odd numbe red bits as input
ports, write “55
” to address 0C1H (R0 port direction reg-
H
ister) during initial setting as shown in Figure 9-1.
All the port direction registers in the GMS815xxB have 0
written to them by reset function. On the other hand, its initial status is input.
0C0
0C1
0C2
0C3
WRITE “55
H
R0 direction
H
H
R1 direction
H
R0 data
R1 data
” TO PORT R0 DIRECTION REGISTER
H
0 1 0 1 0 1 0 1
76543210
I O I O I O I O
76543210
I: INPUT PORT
O: OUTPUT PORT
BIT
PORT
R1 and R1DD register:
al I/O port (address 0C2
R1 is an 8-bit CMOS bidirection-
). Each I/O pin can independently
H
used as an input or an output through the R1DD register
(address 0C3
R2 and R2DD register:
al I/O port (address 0C4
).
H
R2 is an 8-bit CMOS bidirection-
). Each I/O pin can independently
H
used as an input or an output through the R2DD register
(address 0C5
).
H
Figure 9-1 Example of port I/O assignment
R0 and R0DD register:
al I/O port (address 0C0
used as an input or an output through the R0DD register
(address 0C1
al I/O port (address 0C6
used as an input or an output through the R0DD register
(address 0C7
R3 Data Register
R3
R3 Direction Register
R3DD
R4 and R4DD register:
al I/O port (address 0C8
used as an input or an output through the R4DD register
(address 0C9
In addition, Port R4 is multiplexed with va rious special
features. The control register PMR4 (address 0D0
trols the selection of alternate function. After reset, this
value is “0”, port may be used as normal I/O port.
To use alternate function such as external interrupt, external counter input or timer clock out, write “1” in the corresponding bit of PMR4.
Port PinAlternate Function
R3 is an 8-bit CMOS bidirection-
). Each I/O pin can independently
H
).
H
ADDRESS: 0C6
RESET VALUE: Undefined
R37 R36 R35 R34 R33 R32 R31 R3 0
Input / Output data
ADDRESS: 0C7
RESET VALUE: 00
Port Direction
0: Input
1: Output
R4 is an 8-bit CMOS bidirection-
). Each I/O pin can independently
H
).
H
Regardless of the direction register R4DD, PMR4 is selected to use as alternate functions, port pin can be used as a
corresponding alternate features.
ly used as an input or an outp ut thro ugh th e R5DD register
(address 0CB
Port Pin
R54
R55
The control register PMR5 (address D1
).
H
Alternate Function
WDTO (Watchdog timer output)
BUZ (Square-wave output for buzzer)
) controls the se-
H
lection alternate function. After reset, this value is “0”, port
may be used as general I/O ports. To use buzzer function,
write “1” to the PMR5 and the pi n R 55 mus t be defined as
output mode (the bit 5 of R5DD=1)
R5 Data Register
R5
R57 R56 R55 R54 R53
R5 Direction Register
R5DD
ADDRESS: 0CA
RESET VALUE: Undefined
R52 R51
Input / Output data
ADDRESS: 0CB
RESET VALUE: 00
Port Direction
0: Input
1: Output
R50
H
H
H
R6 and R6DD register:
al I/O port (address 0CC
R6 is an 8-bit CMOS bidirection-
). Each I/O pin can independent-
H
ly used as an input or an output throu gh the R6DD regis ter
(address 0CD
even when they are being used as analog inputs. The user
must make sure to keep the p ins conf igured as inputs when
using them as analog inputs.
Note: On the initial RESET, R60 can not be used di gital in put port, because this port is selected as an analog input
port by ADCM register. To use this port as a digital I/O port,
change the value of lower 4 bits of ADCM (address 0E8
H
On the other hand, R6 port, all eight pins can not be used
as digital I/O port simultaneously. At least one pin is used
as an analog input.
).
R5 Port Mode Register
PMR5
DEC. 1999 Ver 1.0433
BUZ
WDTO
--
R54/WDTO Selection
0: R54
1: WDTO (Output)
R55/BUZ Selection
0: R55
1: BUZ (Output)
ADDRESS: 0D1
RESET VALUE: --00----
H
----
B
Page 37
GMS81508B/16B/24BHYUNDAI MicroElectronics
10. BASIC INTERVAL TIMER
The GMS815xxB has one 8-bit Basic Interval Timer that
is free-run and can not stop. Bloc k diagram is shown in
Figure 10-1.
In addition, the Basic Interval Timer generates the time
base for watchdog timer counting. It also provides a Basic
interval timer interrupt (BITIF). As the count overflow
from FF
to 00H, this overflow causes th e interrupt to be
H
16
÷
32
÷
64
÷
128
PIN
X
IN
÷
256
÷
512
÷
Prescaler
1024
÷
2048
÷
Select Input clock
]
[0D3
H
Basic Interval Timer
clock control register
MUX
source
clock
3
BTS[2:0]
CKCTLR
[0F9
8-bit up-counter
BITR
]
H
clear
BTCL
Internal bus line
generated. The Basic Interval T imer is controlled by the
clock control register (CKCTLR) shown in Figure 10-2.
Source clock can be selected by lower 3 bits of CKCTLR.
BITR and CKCTLR are located at same address, and ad-
dress 0F9
overflow
Read
is read as a BITR, and written to CKCTLR.
H
BITIF
Basic Interval Timer Interrupt
To Watchdog timer (WDTCK)
CKCTLR
[2:0]
000
001
010
011
100
101
110
111
Figure 10-1 Block Diagram of Basic Interval Timer
Source clock
16
f
÷
XIN
f
32
÷
XIN
f
64
÷
XIN
f
128
÷
XIN
f
256
÷
XIN
f
512
÷
XIN
f
1024
÷
XIN
f
2048
÷
XIN
Interrupt (overflow) Period (ms)
= 8MHz
@ f
XIN
0.512
1.024
2.048
4.096
8.192
16.384
32.768
65.536
Table 10-1 Basic Interval Timer Interrupt Time
34DEC. 1999 Ver 1.04
Page 38
HYUNDAI MicroElectronicsGMS81508B/16B/24B
76543210
CKCTLR
--
Caution:
Both register are in same address,
when write, to be a CKCTLR,
when read, to be a BITR.
76543210
BITR
8-BIT FREE-RUN BINARY COUNTER
WDTON
ENPCK
BTCL
BTCL
BTCL
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”. This bit becomes 0 automatically
Enable Peripheral clock
If this bit is 0, all peripherals are disabled such as Timer, ADC, PWM, etc.
0: Operate as a 6-bit general timer
1: Enable Watchdog Timer ope rat ion
See the section “Watchdog Timer”.
Example 1:
Interrupt request flag is generated every 8.19 2ms at 4MHz.
ADDRESS: 0D3
INITIAL VALUE: --01 0111
÷ 16
XIN
÷ 32
XIN
÷ 64
XIN
÷ 128
XIN
÷ 256
XIN
÷ 512
XIN
÷ 1024
XIN
÷ 2048
XIN
after one machine cycle, and starts counting.
ADDRESS: 0D3
INITIAL VALUE: Undefined
H
B
H
:
LDMCKCTLR,#1BH
SET1BITE
EI
:
Example 2:
Interrupt request flag is generated every 8.19 2ms at 8MHz.
:
LDMCKCTLR,#1CH
SET1BITE
EI
:
DEC. 1999 Ver 1.0435
Page 39
GMS81508B/16B/24BHYUNDAI MicroElectronics
11. TIMER/EVENT COUNTER
The GMS815xxB has four Timer/Counter registers. Each
module can generate an interrupt to indicate that an event
has occurred (i.e. timer match).
Timer 0 and Timer 1 are can be used either two 8-bit Timer/Counter or one 16-bit Timer/Counter with combine
them. Also Timer 2 and Timer 3 are same.
In the “timer” function, the register is increased every internal clock input. Thus , one can th ink of it as count ing in ternal clock input. Since a least clock consists of 4 and
most clock consists of 64 oscillator periods, the count rate
is 1/4 to 1/64 of the oscillator frequency.
In the “counter” function, the register is incremented in response to a 1-to-0 (falling edge) transition at its corre-
TM0
CAP
T1ST
0
0X
0XXX008-bit Event counter8-bit Timer
1XXX01 or 10 or 118-bit Capture (internal clock)8-bit Timer
1XXX008-bit Capture (external clock) 8-bit Timer
0X
0XXX0016-bit Event counter
1XXX01 or 10 or 1116-bit Capture (internal clock)
1XXX0016-bit Capture (external clock)
T1SL
[1:0]
01 or
10 or
11
00
T0ST T0CNT0SL[1:0]
XX01 or 10 or 118-bit Timer8-bit Timer
XX01 or 10 or 1116-bit Timer
sponding external input pin, EC0
In addition the “capture” function, the register is incre-
mented in response external or internal clock sources same
with timer or counter function. When external clock edge
input, the count register is captured into Timer data register
correspondingly.
It has four oper ating modes: “8-bit timer/counter”, “16-bit
timer/counter”, “8-bit capture”, “16-bit capture” which are
selected by bit in Timer mode register TM0 and TM2 as
shown in Table 11-1.
In operation of Timer 2, Timer 3, their operations are same
with Timer 0, Timer 1, respectively as shown in Table 11-
2.
TIMER 0TIMER 1
or EC2.
Table 11-1 TM0 Timer Mode Register
TM2
CAP
T3ST
2
0X
0XXX008-bit Event counter8-bit Timer
1XXX01 or 10 or 118-bit Capture (internal clock)8-bit Timer
1XXX008-bit Capture (external clock) 8-bit Timer
0X
0XXX0016-bit Event counter
1XXX01 or 10 or 1116-bit Capture (internal clock)
1XXX0016-bit Capture (external clock)
T3SL
[1:0]
01 or
10 or
11
00
T2ST T2CNT2SL[1:0]
XX01 or 10 or 118-bit Timer8-bit Timer
XX01 or 10 or 1116-bit Timer
Table 11-2 TM2 Timer Mode Register
TIMER 2TIMER 3
36DEC. 1999 Ver 1.04
Page 40
HYUNDAI MicroElectronicsGMS81508B/16B/24B
R/W R/WR/W R/W R/W R/W R/WR/W
TM0
TIMER 1
TIMER 0
76543210
T1STCAP 0T0SL1
BTCL
T0SL0T0CNT0STT1SL1 T1SL0
Bit NameBit PositionDescription
CAP0TM0.70: Timer/Counter mode
1: Capture mode selection flag
T1STTM0.60: When cleared, stop the counting.
1: When set, Timer 1 count register is cleared and start again.
T1SL1
T1SL0
TM0.5
TM0.4
00: 16-bit mode (Clock source is sel ected by T0SL1, T0SL0)
01: 8-bit mode, Clock source is f
10: 8-bit mode, Clock source is f
11: 8-bit mode, Clock source is f
T0STTM0.30: When cleared, stop the counting.
1: When set, Timer 0 Count Register is cleared and start again.
T0CNTM0.20: Stop the timer
1: A logic 1 starts the timer.
T0SL1
T0SL0
TM0.1
TM0.0
00: EC0 (External clock)
01: 8-bit Timer, Clock source is f
10: 8-bit Timer, Clock source is f
11: 8-bit Timer, Clock source is f
ADDRESS: 0E2
INITIAL VALUE: 00
÷ 4
XIN
÷ 16
XIN
÷ 64
XIN
÷ 4
XIN
÷ 16
XIN
÷ 64
XIN
H
H
TM2
TIMER 3
TIMER 2
TDR0~TDR3
R/W R/WR/W R/WR/W R/W R/WR/W
76543210
T3STCAP2T2SL1
Bit NameBit Posi-
tion
BTCL
Description
T2SL0T2CNT2STT3SL1 T3SL0
CAP2TM2.70: Timer/Coun ter mode
1: Capture mode selection flag
T3STTM2.60: When cleared, stop the counting.
1: When set, Timer 3 count register is cleared and start again.
T3SL1
T3SL0
TM2.5
TM2.4
00: 16-bit mode (Clock source is selected by T2SL1, T2SL0)
01: 8-bit mode, Clock source is f
10: 8-bit mode, Clock source is f
11: 8-bit mode, Clock source is f
XIN
XIN
XIN
T2STTM2.30: When cleared, stop the counting.
1: When set, Timer 2 Count Register is cleared and start again.
T2CNTM2.20: Stop the timer
1: A logic 1 starts the timer.
T2SL1
T2SL0
TM2.1
TM2.0
00: EC0 (External clock)
01: 8-bit T imer, Clock source is f
10: 8-bit T imer, Clock source is f
11: 8-bit T imer, Clock source is f
R/W R/W R/W R/W R/W R/W R/W R/W
76543210
XIN
XIN
XIN
ADDRESS: 0E4
INITIAL VALUE: Undefined
ADDRESS: 0E3
INITIAL VALUE: 00
÷ 4
÷ 16
÷ 64
÷ 4
÷ 16
÷ 64
H
~ 0E7
H
H
H
Read: Count value read
Write: Compare data write
Figure 11-1 TM0, TM2 Registers
DEC. 1999 Ver 1.0437
Page 41
GMS81508B/16B/24BHYUNDAI MicroElectronics
11.1 8-bit Timer / Counter Mode
The GMS815xxB has four 8-bit Timer/Counters, Timer 0,
Timer 1, Timer 2, Timer 3. The Timer 0, Timer 1 are
shown in Figure .
The “timer” or “counter” function is selected by control
registers TM0, TM2 as shown in Table 11-1 and Table 11 -
2. To use as an 8-bit timer/counter mode, bit CAP0 of TM0
is cleared to “0” and bits T1SL1, T1SL0 of TM0 or bits
76543210
EC0 PIN
XIN PIN
TM0
T1STCAP0T0SL1
0XXXXX
T0SL[1:0]
00
4
÷
#
01
16
÷
#
10
64
÷
#
Prescaler
11
MUX
BTCL
01 or 10 or 11
T0CN
TIMER 0
T3SL1, T3SL0 of TM2 shoul d not set to zero. Thes e timers
have each 8-bit count register and data register. The count
register is increased by every internal or external clock input. The internal clock has a prescaler divide ratio option
of 4, 16, 64 (selected by control bits TxSL1, TxSL0 of register TMx).
T0SL0T0CNT0STT1SL1 T1SL0
X means don’t care
T0ST
0: Stop
1: Clear and start
T0 (8-bit)
TDR0 (8-bit)
ADDRESS: 0E2
INITIAL VALUE: 00
clear
Comparator
T0IF
H
H
TIMER 0
INTERRUPT
T1SL[1:0]
4
÷
#
01
16
÷
#
10
64
÷
#
11
MUX
Example 1:
Timer0 = 4ms 8-bit timer mode at 4M Hz
Timer1 = 1ms 8-bit timer mode at 4M Hz
LDMTDR0,#250
LDMTDR1,#250
LDMTM0,#0110_1111B
SET1T0E
SET1T1E
EI
LDMTDR0,#250
LDMTDR1,#250
LDMTM0,#0110_1100B
SET1T0E
SET1T1E
EI
T1IF
F/F
TIMER 1
INTERRUPT
T1O PIN
38DEC. 1999 Ver 1.04
Page 42
HYUNDAI MicroElectronicsGMS81508B/16B/24B
Note: The contents of Timer data regist er TDRx shoul d be
initialized 1
~FFH, not 0H, because it is undefined after re-
H
set.
In the Timer 0, timer register T0 increments from 00H until
it matches TDR0 and then reset to 00H. The match output
of Timer 0 generates Timer 0 inter rupt (latched in T0IF bit)
As TDRx and Tx register are in same address, when read-
76543210
EC2 PIN
XIN PIN
TM2
Edge Detector
Prescaler
T3STCAP2T2SL1
0XXXXX
T2SL[1:0]
00
4
÷
#
01
16
÷
#
10
64
÷
#
11
MUX
BTCL
01 or 10 or 11
T2CN
ing it as a Tx, written to TDRx.
In counter function, the counter is increased every 1-to-0
(falling edge) transition of EC0
or EC2 pin. In order to use
counter function, the bit 4, bit 5 of the Port mode register
PMR4 are set to “1”. The Timer 0 can be used as a counter
by pin EC0
Similarly, Timer 2 can be used b y pin EC2
input, but Timer 1 can input by internal clock.
input but Timer
3 can not.
T2SL0T2CNT2STT3SL1 T3SL0
X means don’t care
T2ST
0: Stop
1: Clear and start
T2 (8-bit)
Comparator
ADDRESS: 0E3
INITIAL VALUE: 00
clear
T2IF
H
H
TIMER 2
INTERRUPT
TIMER 2
T3SL[1:0]
4
÷
#
01
16
÷
#
10
64
÷
#
11
MUX
TIMER 3
Figure 11-3 8-bit Timer/Counter 2, 3
Example 3:
Timer2 = 8-bit timer mode, 2ms interval at 8MHz
Timer3 = 8-bit timer mode, 500us interval at 8MHz
LDMTDR2,#250
LDMTDR3,#250
LDMTM2,#0110_1111B
SET1T2E
SET1T3E
EI
LDMTDR2,#250
LDMTDR3,#250
LDMTM2,#0110_1100B
SET1T2E
SET1T3E
EI
T3O PIN
DEC. 1999 Ver 1.0439
Page 43
GMS81508B/16B/24BHYUNDAI MicroElectronics
8-bit Timer Mode
In the timer mode, the internal clock is used for counting
up. Thus, you can think of it as counting internal clock input. The contents of TDRn are compared with the contents
of up-counter, Tn. If match is found, a timer 1 interrupt
(T1IF) is generated and the up-counter is cleared to 0.
Counting up is resumed after the up-counter is cleared.
As the value of TDRn is changeable by software, time interval is set as you want
Source clock
Up-counter
TDR1
T1IF interrupt
Start count
0
n
23
1
Figure 11-4 Timer Mode Timing Chart
Value of
TM[1:0]
00
01
10
11
Clock
Source
f
EC1
f
÷
XIN
f
÷
XIN
f
÷
XIN
4
16
64
Resolution
(At
=8 MHz)
f
XIN
1/f
EC1
0.5
2
8
Maximum Time
1/f
sec
us
us
us
Setting
(At
f
EC1
XIN
× 256
2048
=8 MH z)
128
512
sec
us
us
us
Table 11-1 Timer Source clock Interrupt Time
~
~
~
~
n-2
~
~
~
~
~
~
n-1
Match
Detect
n
0
Counter
Clear
2
14
3
Example:
When
INTERRUPT PERIOD =
TDR1
7D
0
Timer 1 (T1IF)
Interrupt
Make 1msinterrupt using by Timer0 at 8MHz
LDMTM0,#1FH; divide by 64
LDMTDR0,#125; 8us x 125= 1ms
SET1T0E; Enable Timer 0 Interrupt
EI; Enable Master Interrupt
TM0 = 0001 1111
TDR0 = 125
f
= 8 MHz
XIN
~
~
(8-bit Timer mode, Prescaler divide ratio = 64)
B
= 7D
D
H
1
8 × 106 Hz
1
0
Occur interruptOccur interruptOccur interrupt
×
MATCH
(TDR0 = T0)
cou
p-
u
4
3
2
Interrupt period
= 8 µs x 125
64 × 125 = 1 ms
7B
7A
nt
~
~
6
5
7C
7D
Count Pulse
Period
8 µs
~
~
TIME
Figure 11-5 Timer Count Example
40DEC. 1999 Ver 1.04
Page 44
HYUNDAI MicroElectronicsGMS81508B/16B/24B
8-bit Event Counter Mode
In this mode, counting up is started by an external trigger.
This trigger means falling edge of the EC0 or EC1 pin input. Source clock is used as an internal clock selected with
timer mode register TM0 or TM2. The contents of timer
data register TDRn (n = 0,1,2,3) are compared with the
contents of the up-counter Tn. If a match is found, an timer
interrupt request flag TnIF is generated, and the counter is
cleared to “0”. The counter is restart and count up continuously by every falling edge of the EC
The maximum frequency applied to the EC
n
pin input.
n
pin is f
XIN
/2
[Hz].
Start count
ECn pin input
Up-counter
TDR1
T1IF interrupt
0
1
n
2
Figure 11-6 Event Counter Mode Timing Chart
In order to use event counter function, the bit 4, 5 of the
Port Mode Register PMR4(add ress 0D0
) is required to be
H
set to “1”.
After reset, the value of timer data register TDRn is unde-
fined, it should b e initialized to between 1
H
"0"The interval period of Timer is calculated as below
equation.
1
---------- -
Period (sec)
~
~
~
~
~
~
~
~
~
~
~
~
n-1
=
0n
2 Divide Ratio TDRn
f
XIN
1
2
×××
~FF
H
not to
TDR1
Timer 1 (T1IF)
Interrupt
T1ST
Start & St op
T1CN
Control count
disable
clear & start
stop
~
~
Occur interruptOccur interrupt
T1ST = 1
T1ST = 0
enable
~
~
up-count
T1CN = 1
T1CN = 0
Figure 11-7 Count Operation of Timer / Event counter
TIME
DEC. 1999 Ver 1.0441
Page 45
GMS81508B/16B/24BHYUNDAI MicroElectronics
11.2 16-bit Timer / Counter Mode
The Timer register is being run with all 16 bits . A 16-bit
timer/counter register T0, T1 are incremented from 0000
until it matches TDR0, TDR1 and then resets to 0000H.
The match output generates Timer 0 interrupt.
The clock source of the Timer 0 is selected either internal
or external clock by bit T0SL1, T0SL0.
76543210
TM0
EDGE DETECTOR
EC0 PIN
÷
XIN PIN
TIMER 0 + TIMER 1 → TIMER 0 (16-bit)
÷
÷
Prescaler
T1STCAP0T0SL1
0XXXXX00
T0SL[1:0]
“00”
4
“01”
16
“10”
64
“11”
MUX
T0CN
T0STT1SL1 T1SL0
BTCL
X means don’t care
0
1
Higher byte
Even if the Timer 0 (including the Timer 1) is used as a 16-
H
bit timer, the Timer 2 and Timer 3 can still be used as either
two 8-bit timer or one 16-bit timer by setting the TM2. Reversely, even if the Timer 2 (including the Timer 3) is used
as a 16-bit timer, the Timer 0 and Timer 1 can still be used
as 8-bit timer independently.
T0ST
0: Stop
1: Clear and start
TDR1 + TDR0
(16-bit)
TDR1 + TDR0
(16-bit)
Lower byte
COMPARE DATA
T0SL0T0CN
clear
Comparator
ADDRESS: 0E2
INITIAL VALUE: 00
H
T0IF
H
TIMER 0
INTERRUPT
(Not Timer 1 interrupt)
76543210
TM2
EDGE DETECTOR
EC2 PIN
÷
XIN PIN
TIMER 2 + TIMER 3 → TIMER 2 (16-bit)
÷
÷
Prescaler
T3STCAP2T2SL1
0XXXXX00
T2SL[1:0]
“00”
4
“01”
16
“10”
64
“11”
MUX
T2CN
T2STT3SL1 T3SL0
BTCL
X means don’t care
0
1
Higher byte
T2ST
TDR3 + TDR2
(16-bit)
TDR3 + TDR2
(16-bit)
COMPARE DATA
T2SL0T2CN
0: Stop
1: Clear and start
clear
Comparator
Lower byte
Figure 11-8 16-bit Timer/Counter
ADDRESS: 0E3
INITIAL VALUE: 00
H
T2IF
H
TIMER 2
INTERRUPT
(Not Timer 3 interrupt)
42DEC. 1999 Ver 1.04
Page 46
HYUNDAI MicroElectronicsGMS81508B/16B/24B
11.3 8-bit Capture Mode
The Timer 0 capture mode is set by bit CAP0 of timer
mode register TM0 (bi t CAP2 of tim er mode reg ister TM2
for Timer 2) as shown in Figure 21. In this mode, Timer 1
still operates as an 8-bit timer/counter.
As mentioned above, not on ly Timer 0 but Timer 2 can also
be used as a capture mode.
In 8-bit capture mode, Timer 1 and Timer 3 are can not be
used as a capture mode.
The Timer/Counter register is incremented in response internal or external input. This counting function is same
with normal timer mode, but Timer interrupt is not g ene rated. Timer/Counter still does the above, but with the added feature that a edge transition at external input INTn pin
76543210
EC0 PIN
XIN PIN
INT0 PIN
TM0
Edge Detector
Prescaler
IEDS[1:0]
“01”
“10”
“11”
T1STCAP0T0SL1
1XXXXX
01 or 10 or 11
T0CN
TIMER 0
÷
÷
÷
4
16
64
T0SL[1:0]
“00”
“01”
“10”
“11”
MUX
To TIMER1
causes the current value in the Timer counter register
(T0,T2), to be captured into registers CDRn (CDR0,
CDR2), respectively. After captured, Timer counter register is cleared and restarts by hardware.
Note: The CDRn and TDRn are in same address.In the
capture mode, reading operation is read the CDRn, not
TDRn because path is opened to the CDRn.
It has three transition modes: "falling edge", "rising edge",
"both edge" which are selected by interrupt edge selection
register IEDS. Refer to “16.4 External Interrupt” on page
61. In addition, the transition at INTn pin generate an inte rrupt.
BTCL
T0STT1SL1 T1SL0
Capture
This figure is a example of using the Timer0.
In the Time r2, operation is same like Timer0, each register s and
flags may be changed with for Timer2.
T0SL0T0CN
X means don’t care
T0ST
0: Stop
1: Clear and start
T0 (8-bit)
CDR0 (8-bit)
ADDRESS: 0E2
INITIAL VALUE: 00
INT0IF
H
H
INT0
INTERRUPT
Figure 11-9 8-bit Capture Mode
DEC. 1999 Ver 1.0443
Page 47
GMS81508B/16B/24BHYUNDAI MicroElectronics
11.4 16-bit Capture Mode
16-bit capture mode is the same as 8-bit capture, except
that the Timer register is being run will 16 bits.
TM0
Edge Detector
EC0 PIN
XIN PIN
Prescaler
IEDS[1:0]
“01”
INT0 PIN
TIMER 0 + TIMER 1 → TIMER 0 (16-bit)
“10”
“11”
76543210
00
T0CN
BTCL
T0STT1SL1 T1SL0
X means don’t care
T0ST
TDR1 + TDR0
(16-bit)
Capture
TDR1 + TDR0
(16-bit)
Higher byte
CAPTURE DATA
This figure is a example of using the Timer0, 1.
In the Timer2, 3, operation is same like Timer0,1, each registers and
flags may be changed with for Timer2,3.
T1STCAP0T0SL1
1XXXXX
T0SL[1:0]
“00”
4
÷
“01”
16
÷
“10”
64
÷
“11”
MUX
Figure 11-10 16-bit Capture Mode
T0SL0T0CN
0: Stop
1: Clear and start
Lower byte
ADDRESS: 0E2
INITIAL VALUE: 00
INT0IF
H
H
INT0
INTERRUPT
44DEC. 1999 Ver 1.04
Page 48
HYUNDAI MicroElectronicsGMS81508B/16B/24B
Example 1:
Timer0 = 16-bit timer mode, 0.5s at 8MHz
Timer2 = 2ms 8-bit timer mode at 8M Hz
Timer3 = 250us 8-bit timer mode at 8MHz
The analog-to-digital converter (A/D) allows conversion
of an analog input signal to a corresponding 8-bit digital
value. The A/D module has eight analog inputs, which are
multiplexed into one sample and hold. The output of the
sample and hold is the input into the converter, which generates the result via successive approximation. The analog
supply voltage is connected to AV
of ladder resistance
DD
of A/D module.
The A/D module has two registers which are the control
register ADCM and A/D result register ADR. The register
ADCM, shown in Figure 12-2, controls the operation of
the A/D converter module. The port pins can be configured
as analog inputs or digital I/O. To use anal og input s, I/O is
selected input mode by R6DD direction register.
The processing of conversion is start when the start bit
ADST is set to “1”. After one cycle, it is cleared by hardware. The register ADR contains the results of the A/D
conversion. When the conversion is completed, the result
is loaded into the ADR, the A/D conversion status bit
ADSF is set to “1”, and the A/D interrup t flag AIF is set.
The block di agram of the A /D mo dule is shown in Figu re
12-1. The A/D status bit ADSF is set automatically when
A/D conversion is completed, cleared when A/D conversion is in process. The conversion time takes maximum 20
uS (at f
=8 MHz).
XIN
SUCCESSIVE
APPROXIMATION
CIRCUIT
ADR
A/D result register
ADIF
ADDRESS: E9
RESET VALUE: Undefined
H
A/D
INTERRUPT
Figure 12-1 A/D Block Diagram
Note: On the initial RESET, R60 port is selected as an an-
alog input by ADCM register. So it can not be used digital
input port. To use this port as a digital I/O port, change to
except “0” the value of ADCM. Finally all eight ports can not
be used as digita l I/O p ort simul tan eousl y. At le ast one po rt
must be in analog port.
46DEC. 1999 Ver 1.04
Page 50
HYUNDAI MicroElectronicsGMS81508B/16B/24B
ADCM
ADR
76543210
R
76543210
R/W R/W R/W R/W R/W R
--
RRRRRR
BTCL
BTCL
ADS1 ADS0ADEN ADS2
R
ADST
ADSF
ADDRESS: 0E9
INITIAL VALUE: Undefined
ADDRESS: 0E8
INITIAL VALUE: --00 0001
A/D status bit
0: A/D conversion is in progress
1: A/D conversion is completed
A/D start bit
Setting this bit starts an A/D conversion.
After one cycle, bit is cleared to “0” by hardware.
A/D converter Enable bit
0: A/D converter module turn off and
current is not flow.
1: Enable A/D converter
H
H
B
A/D Conversion Data
Figure 12-2 A/D Converter Control Register
DEC. 1999 Ver 1.0447
Page 51
GMS81508B/16B/24BHYUNDAI MicroElectronics
13. SERIAL COMMUNICATION
The serial iterface is used to transmit/receive 8-bit data serially. This consists of seri al I/O data register, seria l I/O
mode register, clock selection circuit octal counter and
control circuit as illustrated in Figure 13-1.Pin R50/SIN,
R51/SOUT, R52/SCLK and R53/SRDY pins ar e con-
SIOST
SCK[1:0]
Start
8
÷
00
16
Prescaler
SCK[1:0]
SRDY Out
÷
32
÷
“11”
not “11”
01
10
11
MUX
RSQ
CONTROL CIRCUIT
Clock
SRDY In
XIN PIN
SCLK PIN
SRDY PIN
trolled by the Serial Mode Register. The contents of the Serial I/O data register can be written into or re ad out by
software. The data in the Serial Data Register can be shifted synchronously with the transfer clock signal.
SIOSF
Complete
Clock
Complete
overflow
Octal
Counter
SIOIF
Serial communication
Interrupt
SOUT PIN
Input shift register
SIOR
Internal bus line
Figure 13-1 SCI Block Diagram
Shift
[0EB
SIN PIN
]
H
48DEC. 1999 Ver 1.04
Page 52
HYUNDAI MicroElectronicsGMS81508B/16B/24B
Serial I/O Mode Register(SIOM) controls serial I/O function. According to SCK1 and SCK0, the internal clock or
external clock can be selected.
R/W R/W R/W R/W R/W R
R/W
76543210
SIOM
-
SRDY
BTCL
SCK1 SCK0SM1 SM0
SIOST
Serial I/O Data Regist er(SIOR) is an 8-bit shift re gister.
First LSB is send or is received.
SIOSF
ADDRESS: 0EA
INITIAL VALUE: -000 0001
Serial transmission status bit
0: Serial transmission is in progress
1: Serial transmission is completed
Serial transmission start bit
Setting this bit starts an Serial transmission.
After one cycle, bit is cleared to “0” by hardware.
Serial transmission Clock selection
00: f
01: f
10: f
11: External Clock
Serial transmission Operation Mode
00: Normal Port(R52,R51,R50)
01: Sending Mode(SCLK,SOUT,R50)
10: Receiving Mode(SCLK,R51,SIN)
11: Sending & Receiving Mode(SCLK,SOUT,SIN)
4
÷
XIN
16
÷
XIN
32
÷
XIN
R53/SRDY Selection
0: R53
1: SRDY
H
B
SIOR
R/W R/W R/W R/WR/W R/W
R/W
76543210
Sending Data at Sending Mode
Receiving Data at Receiving Mode
R/W
BTCL
Figure 13-2 SCI Control Register
ADDRESS: 0EB
INITIAL VALUE: Undefined
H
DEC. 1999 Ver 1.0449
Page 53
GMS81508B/16B/24BHYUNDAI MicroElectronics
13.1 Transmission/Receiving Timing
The serial transmission is started by setting SIOST(bit1 of
SIOM) to “1”. After one cycle of SCK, SIOST is cleared
automatically to “0”. The serial output data from 8-bit shift
register is output at falling edge of SCLK. And input data
Input Clock
SCLK PIN
SIOST FLAG
Output
D2
Latch
D1D0
D2
D1D0
SOUT PIN
SIN PIN
SIOIF
INTERRUPT SIGNAL
Figure 13-3 Timing Diagram of Serial I/O
is latched at rising edge of SCLK pin. When transmis sion
clock is counted 8 times, serial I/O counter is cleared as
‘0”. Transmission clock is halted in “H” state and serial I/
O interrupt(IFSIO) occurred.
D5
D5
D6
D7
D7D6
D4D3
D4D3
13.2 The Serial I/O operation by SRDY pin
Transmission clock = external clock
The SRDY
tells to the external system that this device is ready for se-
Transmission clock = internal clock
The I/O of SRDY
system is ready for serial transmission, The “L” level is in-
pin becomes “L” by SIOST = “1”. This signal
SIOST
SRDY(Output)
pin is input mode. When the external
SIOST
SRDY(Input)
rial transmission. The external system detects the “L” signal and starts transmission. The SRDY
pin becomes “H” at
the first rising edge of transmission clock.
putted at this pin. At this time this device starts serial transmission.
50DEC. 1999 Ver 1.04
Page 54
HYUNDAI MicroElectronicsGMS81508B/16B/24B
13.3 The method of Serial I/O
1. Select transmission/receiving mode.
2. In case of sending mode, wri te d at a t o be s e nd t o SIOR .
3. Set SIOST to “1” to start serial tran smission.
4. The SIO interrupt is generated at the completion of SIO
and SIOSF is set to “1”. In SIO interrupt service routine,
correct transmission should be tested .
5. In case of receiving mode, the received data is acquired
by reading the SIOR.
13.4 The Method to Test Correct Transmission
Serial I/O Interrupt
Service Routine
SIOSF
1
SE = 0
Write SIOM
Note: When external clock is used, the frequency should
be less than 1MHz and recommended duty is 50%. If both
transmission mode is sel ected and transmission is performed simultaneously it would be made error.
0
Abnormal
SR
Normal Operation
- SE: Interrupt Enable Register Low IENL(Bit3)
- SR: Interrupt Request Flag Register Low IRQL(Bit3)
0
1
Overrun Error
Figure 13-4 Serial Method to Test Transmission
DEC. 1999 Ver 1.0451
Page 55
GMS81508B/16B/24BHYUNDAI MicroElectronics
14. PWM OUTPUT
The GMS815xxB have two channels of built-in pulse
width modulation outputs. PWM outputs data are multiplex to the R56 and R57 port. Bit 6 and bit 7 of R5DD
should be set to “1” when PWM is used as an output port.
P0CK[1:0]
EN0
EN1
1
0
1
0
8-bit Counter
PWMR0
8-bit Coun ter
PWMR1
f
f
f
f
f
f
f
f
XIN
XIN
XIN
XIN
XIN
XIN
XIN
XIN
÷ 256
÷ 512
÷ 1024
÷ 2048
÷ 256
÷ 512
÷ 1024
÷ 2048
00
01
10
11
MUX
P1CK[1:0]
00
01
10
11
MUX
The input clock is selected by PWM Control Register
(PWMCR, address F2
) and the width of pulse is deter-
H
mined by the PWM Register (PWMR, address F0
F1
).
H
F/F
Overflow
Comparator
]
[0F0
H
Overflow
Comparator
]
[0F1
H
S
Q
R
POL0
F/F
S
Q
R
POL1
PWM0
PWM1
H
and
Figure 14-1 PWM block diagram
The pulse period according to input clock are shown as below.
Input clockPeriod of PWM
f
256
÷
÷
÷ ÷
f
f
f
XIN
XIN
XIN
XIN
÷
÷
÷ ÷
÷
÷
÷ ÷
÷
÷
÷ ÷
512
1024
2048
8.19 ms
16.38 ms
32.77 ms
65.54 ms
Bit 2 (EN0) and bit 3 (EN1) of PWMCR determine the operation channel of PWM. When EN0=0 and EN1=0, PWM
does not execute
It is a PWM output co ntrolled by PWMCR , PWMR0 a nd
PWMR1.
PWMR 1
+
Duty ratio
--------------------------- -
=
256
×
100%
52DEC. 1999 Ver 1.04
Page 56
HYUNDAI MicroElectronicsGMS81508B/16B/24B
PWMR0
PWMR1
ADDRESS: 0F0
WWWW WWWW
WWWW WWWW
RESET VALUE: Undefined
Duty data
ADDRESS: 0F1
RESET VALUE: Undefined
Duty data
Figure 14-2 PWM Duty Register
WWWWWW
76543210
PWMCR
PWM1 clock selection
÷ 256
00: f
XIN
÷ 512
01: f
XIN
10: f
÷ 1024
XIN
11: f
÷ 2048
XIN
P1CK0P1CK1POL1
H
H
PWM0 clock selection
00: f
01: f
10: f
11: f
BTCL
EN1EN0P0CK1 P0CK0
XIN
XIN
XIN
XIN
÷ 256
÷ 512
÷ 1024
÷ 2048
WW
POL0
ADDRESS: 0F2
INITIAL VALUE: 0000 0000
PWM0 output polarity
0: Active low
1: Active high
PWM1 output polarity
0: Active low
1: Active high
PWM enable flag
00: Disable
01: PWM0
10: PWM1
11: Both (PWM0 and PWM1)
H
B
Figure 14-3 PWM Control Register
Example:
PWM0: Period = 16.384ms, Duty = 20%
PWM1: Period = 8.192ms, Duty = 70%
LDMPWMCR,#0100_1111B
LDMPWMR0,#0B3H
LDMPWMR1,#33H
DEC. 1999 Ver 1.0453
Page 57
GMS81508B/16B/24BHYUNDAI MicroElectronics
3.264ms
PWM1
PWMR1
PWMCR
f
XIN
8MHz 512 256÷÷61.035Hz
16.384ms
×
16.384
33
------------ -
100
H
H
01
fixed
=
3.264ms
=
00
Figure 14-4 Example of Register Setting
enable
111 1
f
XIN
8MHz 256 256÷÷122.07Hz
PWM0
PWMR0
active high
fixed
=
8.192
8.192ms
5.728ms
B3
------------ -
×
100
H
H
5.728ms
=
54DEC. 1999 Ver 1.04
Page 58
HYUNDAI MicroElectronicsGMS81508B/16B/24B
15. BUZZER FUNCTION
The buzzer driver block consists of 6-bit binary counter,
buzzer register, and clock source selector. It generates
square-wave which has very wide range frequency (500Hz
~ 250kHz at f
= 8MHz) by user software.
XIN
A 50% duty pulse can be output to R55 /BUZ pin to use for
piezo-electric buzzer drive
of Buzzer driver by setting the bit 5 of PMR5 (address D1
“1”.
At this time, the pin R55 must be defined as output
. Pin R55 is assigned for output port
) to
H
mode (the bit 5 of R5DD=1).
Example: 2.4kHz output at 8MHz.
LDMR5DD,#XX1X_XXXXB
LDMBUR,#9AH
LDMPMR5,#XX1X_XXXXB
X means don’t care
6-bit binary
6-BIT COUNTER
Compare data
XIN PIN
Prescaler
÷
÷
÷
÷
128
16
00
32
01
64
10
11
MUX
2
The bit 0 to 5 of BUR determines output frequency for
buzzer driving.
Equation of frequency calcu lation is shown below .
f
f
f
: Buzzer frequency
BUZ
: Oscillator frequency
f
XIN
Divide Ratio: Prescaler divide ratio by BUCK[1:0]
BUR: Lower 6-bit value of BUR. Buzzer period value.
The frequency of output signal is controlled by the buzzer
control register BUR.The bit 0 to bit 5 of BUR determine
output frequency for buzzer driving.
R55 port data
0
1
R55/BUZ PIN
Comparator
÷
F/F
2
PMR5
[0EC
]
H
6
BUR
Internal bus line
[0D1
H
PMR5
]
Port selection
Figure 15-1 Block Diagram of Buzzer Driver
ADDRESS: 0D1
RESET VALUE: --00 ----
W
W
--
---
R54/WDTO Selection
0: R54
1: WDTO (Output)
R55/BUZ Selection
0: R55 port (Turn off buzzer)
1: BUZ port (Turn on buzzer)
H
B
-
BUR
WW
BUCK1
BUCK0
WWWWWW
ADDRESS: 0EC
RESET VALUE: Undefined
BUR[5:0]
Buzzer Period Data
Source clock select
00: ÷16
01: ÷ 32
10: ÷ 64
11: ÷128
H
Figure 15-2 PMR5 and Buzzer Register
DEC. 1999 Ver 1.0455
Page 59
GMS81508B/16B/24BHYUNDAI MicroElectronics
Note: BUR is undefined after reset, s o it must be initi alized
to between 1
and 3FH by software.
H
Note that BUR is a write-only register.
BUR
[5:0]
00
01
02
03
04
05
06
07
08
09
0A
0B
0C
0D
0E
0F
10
11
12
13
14
15
16
17
18
19
1A
1B
1C
1D
1E
1F
0001101100011011
-
250.000
125.000
83.333
62.500
50.000
41.667
35.714
31.250
27.778
25.000
22.727
20.833
19.231
17.857
16.667
15.625
14.706
13.889
13.158
12.500
11.905
11.364
10.870
10.417
10.000
9.615
9.259
8.929
8.621
8.333
8.065
BUR[7:6]
125.000
62.500
41.667
31.250
25.000
20.833
17.857
15.625
13.889
12.500
11.364
10.417
9.615
8.929
8.333
7.813
7.353
6.944
6.579
6.250
5.952
5.682
5.435
5.208
5.000
4.808
4.630
4.464
4.310
4.167
4.032
-
62.500
31.250
20.833
15.625
12.500
10.417
8.929
7.813
6.944
6.250
5.682
5.208
4.808
4.464
4.167
3.906
3.676
3.472
3.289
3.125
2.976
2.841
2.717
2.604
2.500
2.404
2.315
2.232
2.155
2.083
2.016
-
31.250
15.625
10.417
7.813
6.250
5.208
4.464
3.906
3.472
3.125
2.841
2.604
2.404
2.232
2.083
1.953
1.838
1.736
1.645
1.563
1.488
1.420
1.359
1.302
1.250
1.202
1.157
1.116
1.078
1.042
1.008
The 6-bit counter is cleared and starts the counting by writing signal at BUR register. It is incremental from 00
it matches 6-bit BUR value.
When main-frequency is 8MHz, buzzer frequency is
shown as below table.
BUR
[5:0]
-
20
21
22
23
24
25
26
27
28
29
2A
2B
2C
2D
2E
2F
30
31
32
33
34
35
36
37
38
39
3A
3B
3C
3D
3E
3F
7.813
7.576
7.353
7.143
6.944
6.757
6.579
6.410
6.250
6.098
5.952
5.814
5.682
5.556
5.435
5.319
5.208
5.102
5.000
4.902
4.808
4.717
4.630
4.545
4.464
4.386
4.310
4.237
4.167
4.098
4.032
3.968
BUR[7:6]
3.906
3.788
3.676
3.571
3.472
3.378
3.289
3.205
3.125
3.049
2.976
2.907
2.841
2.778
2.717
2.660
2.604
2.551
2.500
2.451
2.404
2.358
2.315
2.273
2.232
2.193
2.155
2.119
2.083
2.049
2.016
1.984
1.953
1.894
1.838
1.786
1.736
1.689
1.645
1.603
1.563
1.524
1.488
1.453
1.420
1.389
1.359
1.330
1.302
1.276
1.250
1.225
1.202
1.179
1.157
1.136
1.116
1.096
1.078
1.059
1.042
1.025
1.008
0.992
until
H
0.977
0.947
0.919
0.893
0.868
0.845
0.822
0.801
0.781
0.762
0.744
0.727
0.710
0.694
0.679
0.665
0.651
0.638
0.625
0.613
0.601
0.590
0.579
0.568
0.558
0.548
0.539
0.530
0.521
0.512
0.504
0.496
Table 15-1 Buzzer Frequency
56DEC. 1999 Ver 1.04
Page 60
HYUNDAI MicroElectronicsGMS81508B/16B/24B
16. INTERRUPTS
The GMS815xxB interrup t cir cui ts cons ist of Interr upt enable register (IENH, IENL), Interrupt request flags of
IRQH, IRQL, Priority circuit, and Master enable flag (“I”
flag of PSW). Thirteen interrupt sources are provided. T he
configuration of interrupt circuit is shown in Figure 16-2.
The External Interrupts INT0 ~ INT3 each can be transition-activated (1-to-0 or 0-to -1 transition) by selection
IEDS.
The flags that actu ally generate these in terrupts are bit
INT0F, INT1F, INT2F and INT3F in register IRQH. When
an external interrupt is generated, the flag that generated it
is cleared by the hardware when the service routine is vectored to only if the interrupt was transition-activated.
The Timer 0 ~ Timer 3 Interrupts are generated by TxIF
which is set by a match in their respective timer/counter
register. The Basic Interval Timer Interrupt is generated by
BITIF which is set by an overflow in the timer register.
The AD converter Interrupt is generated by ADIF whi ch is
set by finishing the analog to digital conversion.
The Watchdog timer Interrupt is generated by WDTIF
which set by a match in Watchdog timer register.
The Basic Interval Timer INterrupt is generated by BITIF
which are set by a overflow in the timer counter register.
The interrupts are controlled by the interrupt master enable
flag I-flag (bit 2 of PSW on page 19), the interrupt enable
register (IENH, IENL), and the interrupt request flags (in
IRQH and IRQL) except Power-on reset and software
BRK interrupt. Below table shows the Interrupt priority.
Vector addresses are shown in Figure 8-6 on page 21. Interrupt enable registers are shown in Figure 16-3. These
registers are composed of interrupt enab le flags of each interrupt source and these flags determines whether an interrupt will be accepted or not. When enable flag is “0”, a
corresponding interrupt source is prohibited. Note that
PSW contains also a master enable bit, I-flag, which disables all interrupts at once.
R/W
R/W R/WR/W
INT0IF
IRQH
MSBLSB
IRQL
MSBLSB
INT1IF
R/W R/W
ADIF
WDTIF
R/WR/W
INT2IF
INT3IF
R/W
R/W
SIOIF
BITIF
R/W R/W
T1IF
--
-
-
Figure 16-1 Interrupt Request Flag
T2IF
-
-
T3IFT0IF
-
-
ADDRESS: 0F7
INITIAL VALUE: 0000 0000
Timer/Counter 3 interr up t reque st fla g
Timer/Counter 2 interr up t reque st fla g
Timer/Counter 1 interr up t reque st fla g
Timer/Counter 0 interr up t reque st fla g
External interrupt 3 request flag
External interrupt 3 request flag
External interrupt 3 request flag
External interrupt 3 request flag
ADDRESS: 0F5
INITIAL VALUE: 0000 ----
Serial Communication interrupt request flag
Basic Interval Timer interrupt request flag
Watchdog timer interrupt request flag
A/D Converter interrupt request flag
H
B
H
B
DEC. 1999 Ver 1.0457
Page 61
GMS81508B/16B/24BHYUNDAI MicroElectronics
.
Internal bus line
INT0
INT1
INT2
INT3
Timer 0
Timer 1
Timer 2
Timer 3
A/D Converter
Watchdog Timer
BIT
Communication
Serial
IRQH
[0F7
IRQL
[0F5
]
H
]
H
INT0IF
INT1IF
INT2IF
INT3IF
T0IF
T1IF
T2IF
T3IF
ADIF
WDTIF
BITIF
SIOIF
[0F4
[0F6H]
]
H
IENH
IENL
Internal bus line
Interrupt Enable
Register (Higher byte)
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
To CPU
I-flag
Priority Control
Interrupt Master
Enable Flag
Interrupt
Vector
Address
Generator
Figure 16-2 Block Diagram of Interrupt
R/W
IENH
R/W R/WR/W
INT0E
INT1E
R/WR/W
INT2E
INT3E
R/W R/W
T1E
MSBLSB
R/W
SIOE
--
-
-
IENL
R/W R/W
ADE
WDTE
R/W
BITE
MSBLSB
Figure 16-3 Interrupt Enable Flag
T2E
T3ET0E
ADDRESS: 0F6
INITIAL VALUE: 0000 0000
H
B
Timer/Counter 3 interrupt enable flag
Timer/Counter 2 interrupt enable flag
Timer/Counter 1 interrupt enable flag
Timer/Counter 0 interrupt enable flag
External interrupt 3 enable flag
External interrupt 2 enable flag
External interrupt 1 enable flag
External interrupt 0 enable flag
-
-
-
-
ADDRESS: 0F4
INITIAL VALUE: 0000 ----
H
B
VALUE
0: Disable
1: Enable
Serial Communication interrupt enable flag
Basic Interval Timer interrupt enable flag
Watchdog timer interrupt enable flag
A/D Converter interrupt enable flag
58DEC. 1999 Ver 1.04
Page 62
HYUNDAI MicroElectronicsGMS81508B/16B/24B
16.1 Interrupt Sequence
An interrupt request is held until the interrupt is accepted
or the interrupt latch is cleared to “0” by a reset or an instruction. Interrupt acceptance sequence requires 8
µ
s at f
=4.19MHz) after the completion of the current
MAIN
f
XIN
(2
instruction execution. The interrupt service task is term inated upon execution of an interrupt return instruction
[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.
System clock
Instruction Fetch
Address Bus
PC
SPSP-1
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) ont o 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.
SP-2V.H.New PC
V.L.
Data Bus
Internal Read
Internal Write
V.L. and V.H. are vector addresses.
ADL and ADH are start addresses of interrupt service routine as vector contents.
Not used
PCHPCL
Interrupt Processing StepInterrupt Service Task
Figure 16-4 Timing chart of Interrupt Acceptance and Interrupt Return Instruction
Basic Interval Timer
Vector Table Address
0FFE6
0FFE7
Correspondence between vector table address for BIT interrupt
and the entry address of the interrupt service program.
012
0E3
H
H
H
H
0E312
0E313
Entry Address
0E
2E
H
H
H
H
A interrupt request is not accepted until the I-flag is set to
“1” even if a requested interrupt has higher priority than
that of the current interrupt being serviced.
PSWADLOP codeADH
V.L.
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 interrupt sources are selectively enabled by the individual interrupt enable flags.
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 ar e
not saved itself. These registers are saved by the software
if necessary. Also, when multiple interrupt services are
nested, it is necessary to avoid using the same data memory
DEC. 1999 Ver 1.0459
Page 63
GMS81508B/16B/24BHYUNDAI MicroElectronics
B-FLAG
BRK
INTERRUPT
ROUTINE
RETI
TCALL0
ROUTINE
RET
BRK or
TCALL0
=0
=1
area for saving registers.
The following method is used to save/restore the general-
purpose registers.
Example: Register save using push and pop instructions
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;
main task
acceptance of
interrupt
interrupt
service task
saving
registers
16.2 BRK Interrupt
Software interrupt can be invoked by BRK instruction,
which 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 16-5.
interrupt return
restoring
registers
Figure 16-5 Execution of BRK/TCALL0
60DEC. 1999 Ver 1.04
Page 64
HYUNDAI MicroElectronicsGMS81508B/16B/24B
16.3 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 internal polling sequence determines by hardware which request is serviced.
Main Program
service
Occur
TIMER1 interrupt
Occur
INT0
TIMER 1
service
enable INT0
disable other
EI
enable INT0
enable other
INT0
service
However, multiple processing through software for special
features is possible. Generally when an interrupt is accepted, the I-flag is cleared to disable any further interru pt. But
as user sets I-flag in interrupt routine, some further interrupt can be serviced even if certain interrupt is in progress.
Example:
During Timer1 interrupt is in progress, INT0 in-
terrupt serviced without any suspen d.
TIMER1: PUSHA
PUSHX
PUSHY
LDMIENH,#80H;
LDMIENL,#0;
EI;
:
:
:
:
:
:
LDMIENH,#0FFH ;
LDMIENL,#0F0H
POPY
POPX
POPA
RETI
Enable INT0 only
Disable other
Enable Interrupt
Enable all interrupts
In this example, the INT0 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.
Figure 16-6 Execution of Multi Interrupt
16.4 External Interrupt
The external interrupt on INT0, INT1, INT2 and INT3 pins
are edge triggered depending on the edge selecti on register
IEDS (address 0F8
) as shown in Figure 16-7.
H
The edge detection of external interrupt has three transition
DEC. 1999 Ver 1.0461
Page 65
GMS81508B/16B/24BHYUNDAI MicroElectronics
activated mode: rising edge, falling edge, and both edge.
INT0 pin
INT1 pin
INT2 pin
INT3 pin
22 22
IEDS
[0F8H]
Figure 16-7 External Interrupt Block Diagram
INT0IF
INT0 INTERRUPT
INT1IF
INT1 INTERRUPT
INT2IF
INT2 INTERRUPT
INT3IF
INT3 INTERRUPT
Edge selection
Register
INT0 ~ INT3 are multiplexed with general I/O ports
(R40~R43). To use as an external interrupt pin, the bit of
R4 port mode register PMR4 should be set to “1” corre -
spondingly.
Example:
**** Set port as an input port R40,R42
;
**** Set port as an external interrupt port
;
**** Set Falling-edge Detection
;
To use as an INT0 and INT2
:
:
LDMR4DD,#1111_1010B
;
LDMPMR4,#05H
;
LDMIEDS,#0001_0001B
:
:
:
Response Time
The INT0 ~ INT3 edge are latched into INT1IF ~ INT3IF
at every machine cycle. The values are not actually polled
by the circuitry until the next machine cycle. If a request is
active and conditions are right for it to be acknowledged, a
hardware subroutine call to the requested service routine
will be the next instruction to be executed. The DIV itself
takes twelve cycles. Thus, a minimum of twelve complete
machine cycles elapse between activation of an external
interrupt request and the begi nning of executio n of the first
instruction of the service routine.
The watchdog timer rapidly detects the CPU malfunction
such as endless looping caused by noise or the like, and resumes the CPU to the normal state.
The watchdog timer signal for detecting malfunction can
be selected either a reset CPU or a interrupt request.
BASIC INTERVAL TIMER
OVERFLOW
WDTCL
Count source
[0E0
H
Watchdog
Counter (8-bit)
6-bit compare data
WDTR
]
Internal bus line
clear
6
When the watchdog tim er is not being us ed for malfunction detection, it can be used as a tim er to generate an interrupt at fixed intervals.
clear
comparato r
Watchdog Timer
Register
“0”
“1”
enable
WDTON in CKCTLR [0D3
WDTIF
to reset CPU
]
H
Watchdog Timer interrupt
Figure 17-1 Block Diagram of Watchdog Timer
Watchdog Timer Control
Figure 17-2 shows the watchdog timer control register.
The watchdog timer is automatically disab led aft e r reset.
The CPU malfunction is detected during setting of the detection time, selecting of output, and clearing of the binary
counter. Clearing the binary counter is repeated within the
detection time.
If the malfunction occurs for any cause, the watchdog tim-
WWWW
WDTR
WWWW
76543210
WDTCL-
Clear count flag
0: Free-run count
1: When the WDTCL is set to “1”, binary counter
is cleared to “0”. And the WDTCL becomes “0” automatically
after one machine cycle. Counter count up again.
er output will become active at the rising overflow from
the binary counters unless the binary counter is cleared. At
this time, when WDTON=1, a reset is generated, which
drives the RESET
pin to low to reset the internal hardware.
When WDTON=0, a watchdog timer interrupt (WDTIF) is
generated.
The watchdog timer temporarily stops counting in the
STOP mode, and when the STOP mode is released, it automatically restarts (continues counting).
ADDRESS: 0E0
INITIAL VALUE: -011_1111
6-bit compare data
H
NOTE:
The WDTON bit is in register CKCTLR.
B
Figure 17-2 WDTR: Watchdog Timer Data Register
64DEC. 1999 Ver 1.04
Page 68
HYUNDAI MicroElectronicsGMS81508B/16B/24B
Example: Sets the watchdog timer detection time to 0.5 sec at 4.19MHz
LDMCKCTLR,#3FH;
LDMWDTR,#04FH
LDMWDTR,#04FH;
:
Within WDT
detection time
:
:
:
LDMWDTR,#04FH;
:
Within WDT
detection time
:
:
:
LDMWDTR,#04FH;
Enable and Disable Watchdog
Watchdog timer is enabled by setting WDTON (bit 5 in
CKCTLR) to “1”. WDTON is initialized to “0” during reset and it should be set to “1” to operate after reset is released.
The watchdog timer can be also used as a simple 6-bit timer by clearin g bit5 of CKCTLR to “0”. The in terval of
watchdog timer interrupt is decided by Basic Interval Timer. Interval equation is shown as below.
TWDTR Interval of BIT
=
×
The stack pointer (SP) should be initialized before using
the watchdog timer output as an interrupt source.
The watchdog timer is disabled by clearing bit 5 (WDTON) of CKCTLR. The watchdog timer is halted in STOP
mode and restarts automatically after STOP mode is released.
Source clock
BIT overflow
Binary-counter
WDTR
WDTIF interrupt
WDT resetreset
1
2
n
3
Figure 17-3 Watchdog timer Timing
If the watchdog timer output becomes active, a reset is generated, which drives the RESET
pin low to reset the inter-
nal hardware.
Example: 6-bit timer interrupt set up.
10
3
WDTR ← “0100_0011
The main clock oscillator also turns on wh en a watchdog
timer reset is generated in sub clock mode.
LDMCKCTLR,#xx0xxxxxB;
LDMWDTR,#7FH;
WDTCL
:
2
”
B
30
Counter
Clear
Match
Detect
WDTON
←1
←0
DEC. 1999 Ver 1.0465
Page 69
GMS81508B/16B/24BHYUNDAI MicroElectronics
18. POWER DOWN OPERATION
GMS815xxB has a power-down mode. In power-down
mode, power consumption is reduced considerably that in
battery operation. Battery life can be extended a lot.
18.1 STOP Mode
For applications where power consumption is a critical
factor, device provides reduced power of STOP.
Start The Stop Operation
An instruction that STOP causes to be the last instruct ion
is executed before going into the STOP m ode. In the Stop
mode, the on-chip main-frequency oscillator is stopped.
With the clock frozen, all functions are stopped, but the onchip RAM and Control registers are held. The port pins
output the values held by their res pective port data registe r,
the port direction regis ters. The status of p eripherals during
Stop mode is shown below.
PeripheralSTOP Mode
CPUAll CPU operations are disabled
RAMRetain
PIN
X
IN
X
PIN
OUT
OscillationStop
I/O portsRetain
Control RegistersRetain
Release methodby RESET, by External interrupt
Low
High
STOP Mode is entered by STOP instruction.
Note: Sinc e the XIN pin is conn ecte d inte rnally to G ND to
avoid current leakage due to the crystal oscillator in STOP
mode, do not use STO P ins t ruc ti on w hen an e xte rnal c lo ck
is used as the main system clock.
In the Stop mode of operation, VDD can be reduced to minimize power consumption. Be careful, however, that V
DD
is not reduced before the Stop mode is invoked, and that
V
is restored to its normal operating level before the
DD
Stop mode is terminated.
The reset should not be activated before V
is restored to
DD
its normal operating level, and must be held active long
enough to allow the oscillator to restart and stabilize.
And after STOP instruction, at least two or more NOP in struction should be written as show n in example below.
Example:
LDMCKCTLR,#0000_1110B
STOP
NOP
NOP
:
The Interval Timer Register CKCTLR should be initialized (0F
or 0EH) by software in order that oscillation sta-
H
bilization time should be longer than 20ms before STOP
mode.
~
Oscillator
pin)
(X
IN
Internal Clock
External Interrupt
BIT Counter
~
~
~
~
~
~
STOP Instruction
Executed
n
n+1 n+2n+3
Normal OperationStop OperationNormal Operation
Figure 18-1 STOP Mode Release Timing by External Interrupt
~
~
~
~
Before executing Stop instruction, Basic Interval Timer must be set
properly by software to get stabilization time which is longer than 20ms.
0
Clear
~
~
~
~
~
~
~
~
~
1
~
~
tST > 20ms
by software
FE
FF
0
12
66DEC. 1999 Ver 1.04
Page 70
HYUNDAI MicroElectronicsGMS81508B/16B/24B
Release the STOP mode
The exit from STOP mode is using hardware reset or external interrupt.
To release STOP mode, corresponding interrupt should be
enabled before STOP mode.
the on-chip RAM. External interrupts allow both on-chip
RAM and Control registers to retain their values.
Start-up is performed to acquire the time for stabilizing oscillation. During the start-up, the internal operations are all
stopped.
Reset redefines all t he control regist ers but does not chan ge
The Stop mode is designed to reduce power consumption.
To minimize current drawn during Stop mode, the user
should turn-off output drivers that are sourcing or sinking
current, if it is practical.
Note: In the STOP operation, the power dissipation associated with the os cillato r and th e inter nal hard ware is lowered; however, the power dissipation associated with the
pin interface (depending on the external circuitry and program) is not directly determined by the hardware operation
of the STOP feature. T his point shou ld be little c urrent flows
when the input level is stable at the power voltage level
(V
than the power voltage level (by approximately 0.3V), a cu rrent begins to flow. Therefore, if cutting off the output transistor at an I/O port puts the pin signal into the highimpedance state, a curr ent flow across th e ports input transistor, requiring it to fix the level by pull-up or other means.
); however, when the input level becomes higher
DD/VSS
It should be set prop erl y in order that current flo w t hro ugh
port doesn't exist.
First conseider the setting to input mode. Be sure that there
is no current flow after considering its relationship with
external circuit. In inpu t mode, the pin impeda nce viewing
from external MCU is very high that the current doesn’t
flow.
But input voltage lev el shou ld be V
or VDD. Be careful
SS
that if unspecified voltage, i.e. if unfirmed voltage level
(not V
or VDD) is applied to input pin, there can be little
SS
current (max. 1mA at around 2V) flow.
If it is not appropriate to set as an input m ode, then set to
output mode considering th ere is no current flow. Settin g
to High or Low is decided considering its relationship with
external circuit. For example, if there is external pull-u p resistor then it is set to output mode, i.e. to High, and if there
on
on
DEC. 1999 Ver 1.0467
Page 71
GMS81508B/16B/24BHYUNDAI MicroElectronics
is external pull-down register, it is set to low.
V
DD
O
GND
O
INPUT PIN
V
DD
i
GND
X
Weak pull-up current flows
INPUT PIN
i
Very weak current flows
internal
pull-up
V
DD
V
DD
O
V
DD
X
OPEN
O
Figure 18-2 Application Example of Unused Input Port
When port is configure as an input, input level should
be closed to 0V or 5V to avoid power consumption.
i=0
OPEN
i=0
OUTPUT PIN
ON
ON
OFF
i
GND
X
In the left case, much current flows from port to GND.
OFF
ON
OFF
Figure 18-3 Application Example of Unused Output Port
O
O
OPEN
V
DD
OUTPUT PIN
V
DD
ON
OFF
i
X
In the left case, Tr. base current flows from port to GND.
To avoid power consumpt ion, there s hould be low output
to the port.
L
OFF
ON
GND
O
i=0
GND
V
DD
L
68DEC. 1999 Ver 1.04
Page 72
HYUNDAI MicroElectronicsGMS81508B/16B/24B
X
OUT
X
IN
19. OSCILLATOR CIRCUIT
The GMS815xxB has two oscillation circuits internally.
X
and X
IN
are input and output for frequency, respec-
OUT
C1
C2
Recommend
Crystal Oscillator
8MHz
X
OUT
X
IN
V
SS
C1,C2 = 30pF±10pF
Crystal or Ceramic Oscillator
Figure 19-1 Oscillation Circuit
Oscillation circuit is designed to be used 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.
tively, inverting amplifier which can be configured for being used as an on-chip oscillator, as shown in Figure 19-1.
Open
External Clock
External Oscillator
X
OUT
X
IN
Oscillation circuit is designed to be used 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 19-2 for the layout of the crystal.
Note: Minimize the wiring length. Do not allow the wiring to
intersect with other signa l cond uctors . Do not all ow the wiring to come near changing high current. Set the potential of
the grounding position of the oscillator capacitor to that of
SS
. Do not ground it to any g round pattern where high cur-
V
rent is present. Do not fetch signals from the oscillator.
Figure 19-2 Layout of Oscillator PCB circuit
DEC. 1999 Ver 1.0469
Page 73
GMS81508B/16B/24BHYUNDAI MicroElectronics
7036P
V
CC
10uF
+
10k
Ω
to the RESET pin
20. RESET
The GMS815xxB have two types of reset generation procedures; one is an external reset input, the other is a watch-
dog timer reset. Table 20-1 shows on-chip hardwar e initialization by reset action.
On-chip HardwareInitial ValueOn-chip HardwareInitial Value
Program counter(PC)
(FFFF
H
Watchdog timerDisable
) - (FFFEH)
G-flag(G)0Control registersRefer to Table 8-1 on page 25
Peripheral clockOffPower fail detectorDisable
Table 20-1 Initializing Internal Status by Reset Action
20.1 External Reset Input
The reset input is the RESET pin, which is the input to a
Schmitt Trigger. A reset in accomplished by holding the
RESET pin low for at least 8 oscillator periods, within the
operating voltage range and oscillation stable, it is applied,
and the internal state is initialized. A fter reset, 64ms (at 4
MHz) add with 7 oscillator periods are required to start execution as shown in Figure 20-2.
Internal RAM is not affected by reset. When V
is turned
DD
on, the RAM content is indeterminate. Therefore, this
RAM should be initialized before read or tested it.
When the RESET pin input goes to high, the reset operation is released and the program execution starts at the vector address stored at addresses FFFE
- FFFFH.
H
A connection for simple p ower-on-reset is shown in Figure
20-1.
Figure 20-1 Simple Power-on-Reset Circuit
1234567
??
?
??
RESET Process Step
t
ST
1
= x 256
÷1024
f
MAIN
FFFE FFFF
FE?ADL
ADH
Start
OP
MAIN PROGRAM
Oscillator
pin)
(X
IN
RESET
ADDRESS
BUS
DATA
BUS
~
~
~
~
~
~
?
?
Stabilization Time
t
ST
~
~
~
~
~
~
= 62.5mS at 4.19MHz
Figure 20-2 Timing Diagram after RESET
20.2 Watchdog Timer Reset
Refer to “17. WATCHDOG TIMER” on page 64.
70DEC. 1999 Ver 1.04
Page 74
HYUNDAI MicroElectronicsGMS81508B/16B/24B
21. POWER FAIL PROCESSOR
The GMS815xxB has an on-chip power fail detection circuitry to immunize against power noise. A configuration
register, PFDR, can enable or disable the po wer fail detect
circuitry. Whenever V
falls close to or below power fail
DD
voltage for 100ns, the power fail situation may reset or
freeze MCU according to PFR bit of PFDR. Refer to “7.4
DC Electrical Characteri sti cs ” on page 13.
In the in-circuit emulator, power fail function is not implemented and user can not experiment with it. Theref ore, af ter final development of user program, this function may
be experimented or evaluated.
Note: User can select power fail voltag e leve l acco rding t o
PFV bit of PFDR at the OTP(GMS815xxBT) but must select
the power f ail vol tage le vel to de fine PF D optio n of “M ask
Order & Verification Sheet” at the mas k chip(GMS815 xxB).
Because the power fail voltage level of mask chip
(GMS815xxB ) is de termine d accor ding to mask op tion re gardless of PFV bit of PFDR
76543210
PFDR
R/W
PFV
Note: If power fail voltage is selected to 3.0V on 3V operation, MCU is freezed at all the times.
Power FailFunctionOTPMASK
Enable/Disable by PFD flagby PFD flag
Level Selectionby PFV flagby mask option
Table 21-1 Power fail processor
R/W R/W R/W
PFD
PFR
PFS
ADDRESS: 0 F9
INITIAL VALUE: ---- 1100
H
B
Power Fail Status
0: Normal operate
1: Set to “1” if power fail is detected
Operation Mode
0: Normal operation regardless of power fail
1: MCU will be reset by power fail detection
Disable Flag
0: Power fail detection enable
1: Power fail detection disable
Power Fail Voltage Selection Flag
0: 2.4V
1: 3.0V
Figure 21-1 Power Fail Voltage Detector Register
DEC. 1999 Ver 1.0471
Page 75
GMS81508B/16B/24BHYUNDAI MicroElectronics
RESET VECTOR
V
DD
Internal
RESET
PFS =1
NO
RAM CLEAR
INITIALIZE RAM DATA
INITIALIZE ALL PORTS
INITIALIZE REGISTERS
FUNTION
EXECUTION
YES
PFS = 0
initial routine
Figure 21-2 Example S/W of RESET flow by Power fail
64mS
Skip the
V
MAX
PFD
V
MIN
PFD
When PFR = 1
V
DD
Internal
RESET
V
DD
Internal
RESET
t <64mS
64mS
64mS
Figure 21-3 Power Fail Processor Situations
MAX
V
PFD
V
MIN
PFD
MAX
V
PFD
V
MIN
PFD
72DEC. 1999 Ver 1.04
Page 76
HYUNDAI MicroElectronicsGMS81508B/16B/24B
22. OTP PROGRAMMING
The GMS81516BT/24BT are OTP (One Time Programmable) microcontrollers. Its internal user memory is constructed with EPROM (Electrically Programmable Read
Only Memory).
The OTP micorcontroller is generally used for chip evaluation, first produ ctio n, small amo unt pr odu ction, fas t mass
production, etc.
Blank OTP’s internal EPROM is filled by 00
Note: In any case, you have to use *.OTP file, not *.HEX
file. After assemble, both OTP and HEX file are generated
by automatically. The HEX file is used during porgram emulation on emulator.
, not FFH.
H
22.1 How to Program
To program the OTP devices, user can use HME own programmer or third party universal programmer shown as
listed below.
The Choice-Dr Writer is single writer and physically addon adapter board type, it should be used with Choice-Dr
emulator. However, the Choice-Sigma is stand alone HME
universal single programmer for any HME OTP devices,
also the Choice-Gang4 can program four OTPs at once.
Ask to HME sales part which is listed on appen dix o f thi s
manual.
Third party programmer list
Manufacturer: Hi-Lo Systems
Programmer:
Website : http: //www.hilosystems.com.tw
Choice-Dr Writer
Choice-Sigma, Choice-Gang4
ALL-11, ALL-07
posed of Motorola-S1 format.
3. Set the programming address range as below table.
GMS81516BT
AddressSet Value
Bufferstart address4000H
Buffer end address7FFFH
Device start addressC000H
GMS81524BT
AddressSet Value
Bufferstart address2000H
Buffer end address7FFFH
Device start addressA000H
4. Mount the socket adapter on the programmer.
5. Start program/verify.
22.2 Pin Function
VPP (Program Voltage)
V
is the input for the program voltage for programming
PP
the EPROM.
(Chip Enable)
CE
CE is the input for programming and verifying internal
EPROM.
(Output Enable)
OE
OE is the input of data output control signal for verify.
A0~A15 (Address Bus)
A0~A15 are address input pins for internal EPROM.
O0~O7 (EPROM Data Bus)
These are data bus for internal EPROM.
Socket adapters are supported by third party pro grammer’s
manufacturer. The other third party will be registered and
being under development.
Programming Procedure
1. Select device GMS81516BT or GMS81524BT.
2. Load the *.OTP file to the programmer. The file is com-
Do not care anyChanging state
change permittedunknown
Does not applyCenter line is
Will be steady
high impedance “Off” state
V
IH
Addresses
V
IL
V
IH
Addresses Valid
See note (2)
OE
V
IL
V
IH
Output
V
IL
1. The input timing reference level is 1.0V for a VIL and 4.0V for a VIH at VDD=5.0V.
2. To read the output data, transition requires on the OE
t
AS
High-Z
t
OE
Valid Output
form the high to the low after address setup time tAS.
t
DH
DEC. 1999 Ver 1.0477
Page 81
GMS81508B/16B/24BHYUNDAI MicroElectronics
PROGRAMMING ALGORITHM WAVEFORMS
Addresses
Data In/Out
V
PP
V
DD
CE
OE
V
IH
V
IL
V
IH
V
IL
12.75V
V
DD
6.25V
5.0V
V
IH
V
IL
V
IH
V
IL
t
t
t
DS
VPS
VDS
t
AS
Program
Data in Stable
t
PW
Addresses Valid
t
DH
High-Z
t
OES
Program
t
OE
Verify
Data out valid
t
AH
t
DFP
1. The input timing reference level is 1.0V for a VIL and 4.0V for a VIH at VDD=5.0V.
78DEC. 1999 Ver 1.04
Page 82
AC READING CHARACTERISTICS
=0V, TA = 25°C ± 5°C)
(V
SS
SymbolItemMinTypMaxUnitTest condition
t
AS
t
OE
t
DH
Note: VDD must be applied simultaneously or before VPP and removed simultaneously or after VPP.
Address setup time2
µ
Quick Pulse Programming200ns
VPP supply current
050ns
s
AC PROGRAMMING CHARACTERISTICS
=0V, TA = 25°C ± 5°C)
(V
SS
SymbolItemMinTypMaxUnitTest condition*
t
t
OES
t
t
t
t
DFP
t
VPS
t
VDS
t
t
AS
DS
AH
DH
PW
OE
Address setup time2
OE setup time2
Data setup time2
Address hold time0
Data hold time2
µ
µ
µ
µ
µ
Output delay disable time0130ns
VPP setup time
VDD setup time
Program pulse width95100105
2
2
µ
µ
µ
Data output delay time150ns
s
s
s
s
s
s
s
s
* AC CONDITION OF TEST
Input Rise and Fall Times (10% to 90%)...........................20ns
Input Pulse Levels.............................................................0.45V to 4.55V
Input Timing Reference Level............................................1.0V to 4.0V
Output Timing Reference Level......................................... 1.0V to 4.0V
must be applied simultaneously or before VPP and removed simultaneously or after VPP.
V
DD
Page 83
GMS81508B/16B/24BHYUNDAI MicroElectronics
START
ADDRESS=FIRST LOCATION
VCC=6.0V
=11.75
V
PP
X=0
PROGRAM ON E 100µs PULSE
INCREMENT X
INCREMENT
ADDRESS
NO
PASS
YES
PASS
YES
FAIL
VERIFY
BYTE
FAIL
NO
X=25?
VERIFY
ONE BYTE
LAST
ADDRESS?
VCC=VPP=5.0V
COMPARE
ALL BYTES TO
ORIGINAL
DATA
DEVICE
PASSED
Table 22-1 Programming Algorithm
PASS
FAIL
DEVICE
FAILED
80DEC. 1999 Ver 1.04
Page 84
APPENDIX
Page 85
HYUNDAI Micro ElectronicsGMS800 Series
A. CONTROL REGISTER LIST
AddressRegister NameSymbolR/W
00C0R0 port data registerR0R/WUndefined31
00C1R0 port I/O direction registerR0DDW0 0 0 0 0 0 0 031
00C2R1 port data registerR1R/WUndefined31
00C3R1 port I/O direction registerR1DDW0 0 0 0 0 0 0 031
00C4R2 port data registerR2R/WUndefined31
00C5R2 port I/O direction registerR2DDW0 0 0 0 0 0 0 031
00C6R3 port data registerR3R/WUndefined32
00C7R3 port I/O direction registerR3DDW0 0 0 0 0 0 0 032
00C8R4 port data registerR4R/WUndefined32
00C9R4 port I/O direction registerR4DDW0 0 0 0 0 0 0 032
00CAR5 port data registerR5R/WUndefined33
00CBR5 port I/O direction registerR5DDW0 0 0 0 0 0 0 033
00CCR 6 port data registerR6R/WUndefined33
00CDR6 port I/O direction registerR6DDW0 0 0 0 - - - -33
LDM STROBE,#0000_1011B
LDM TDR0,#250 ;8us x 250 = 2000us
LDM TM0,#0001_1111B ;Timer0(8bit),8us,Start Count-up
LDM IRQH,#0 ;Clear All Interrupts Requeat Flags
LDM IRQL,#0
LDM IENH,#1100_1000B ;EnableT0,Int0,Int1,Interrupt
LDM IENL,#00H
LDM IEDS,#0101_0101B ;External Int. Falling edge select
LDM PMR4,#03H ;General port OR Int?
SET1 UP_F
EI ;Enable Interrupts
DEC. 1999v
Page 90
GMS800 SeriesHYUNDAI Micro Electronics
;
Loop: nop
IF F_500ms == 1
clr1 F_500ms
call INC_DEC
ENDIF
jmp Loop
;
;***********************************************
; Subject: Inc. or Dec. two digits *
;***********************************************
; Entry: UP_F *
; Return: UP_F=1, Increment two digits *
; UP_F=0, Decrement two digits *
;***********************************************
;
INC_DEC: BBC UP_F,DOWN ;Check Down mode or Up mode
;
;**************************
;* Up Count *
;**************************
;
SETC
LDA #0 ; DIGIT1 <- DIGIT1 + 1
ADC DIGIT1
IF A == #0AH
setc
lda #0
ENDIF
STA DIGIT1 ; Store result into DIGIT1
;
LDA #0 ; When Overflow is set,
ADC DIGIT10 ; DIGIT10 <- DIGIT10 + 1
IF A == #10
lda #0
ENDIF
STA DIGIT10
RET
;
;**************************
;* Down Count *
;**************************
;
DOWN: clrc
lda DIGIT1 ; DIGIT1 <- DIGIT1 - 1
sbc #0
IF A == #0FFH
lda #9
clrc
ELSE
setc
ENDIF
sta DIGIT1 ; Store result into DIGIT1
;
lda DIGIT10 ; When Overflow is set,
sbc #0 ; DIGIT10 <- DIGIT10 - 1
IF A == #0FFH
lda #9
ENDIF
STA DIGIT10
RET
;
;**************************************************************************
; TIMER0,INTERRUPT ROUTINE(2ms)& INT0,INT1 *
;**************************************************************************
;
TMR0_INT:
REG_SAVE ;Save Registers to Stacks
CALL DSPLY ;Segments Data Port Output
CALL Make_500msFalg ;250ms mesurement
REG_RESTORE ;Restore Registers from Stacks
RETI
;
;**************************************************************************
; EXTERNAL INTERRUPT 0 (UP/DOWN KEY) *
;**************************************************************************
;
INT_0: NOT1 UP_F ;INT0 Service routine
RETI ;Toggle the Up/Down mode
;
viDEC. 1999
Page 91
HYUNDAI Micro ElectronicsGMS800 Series
;**************************************************************************
; EXTERNAL INTERRUPT 1 (CLEAR KEY) *
;**************************************************************************
;
INT_1: LDM DIGIT1,#0 ;INT1 Service routine
LDM DIGIT10,#0
LDM TMR_500MS,#0 ;0.5Sec Restart
RETI
;
;***********************************************************************
; Subject: Seven Segment Display (DSPLY) *
;***********************************************************************
; Entry: DIGIT10 or DIGIT1 *
; Return: Output SEG_PORT (R00~R07), *
; Strobe_port (R22,R23) *
; Scratch: STROBE *
;***********************************************************************
; Description: After read internal RAM data, output data to the port *
;***********************************************************************
;
DSPLY: LDM STROBE_PORT,#03H ;Segment All Turn Off
NOT1 STROBE.2 ;Toggle strobe0
NOT1 STROBE.3 ;Toggle strobe1
IF STROBE.3 = 1 ;Test if R23 is high.
ldy DIGIT1
ELSE
ldy DIGIT10
ENDIF
LDA !FONT+Y
STA SEG_PORT ;Segment Data output
LDA STROBE
STA STROBE_PORT ;Current Digit Turn On
RET ;Quit
;
;***********************************************
; Subject: Set falg at every 500ms *
;***********************************************
; Entry: None *
; Return: 500ms flag (F_500ms) *
;***********************************************
;
Make_500msFalg:
INC TMR_500MS ;count up every 2ms
LDA TMR_500MS
IF A == #250 ;Compare 0.5S
ldm TMR_500MS,#0 ;clear 0.5sec. counter
set1 F_500ms ;set 0.5sec. flag
ENDIF
RET
;
;**************************************************************************
; 7-SEGMENT PATTERN DATA *
; _a_ *
; f | g |b *
; |---| *
; e |___|c *
; d .h *
;**************************************************************************
; Segment: hgfe dcba To be displayed Digit Number
FONT DB 0011_1111B ; 0
DB 0000_0110B ; 1
DB 0101_1011B ; 2
DB 0100_1111B ; 3
DB 0110_0110B ; 4
DB 0110_1101B ; 5
DB 0111_1100B ; 6
DB 0000_0111B ; 7
DB 0111_1111B ; 8
DB 0110_0111B ; 9
;
;**************************************************************************
;
NOT_USED: nop ;Discard Unexpected Interrupts
reti
;
END ;Notice Program End
DEC. 1999vii
Page 92
GMS800 SeriesHYUNDAI Micro Electronics
C. INSTRUCTION
C.1 Terminology List
TerminologyDescription
AAccumulator
XX - register
YY - register
PSWProgram Status Word
#imm8-bit Immediate data
dpDirect Page Offset Address
!absAbsolute Address
[ ]Indirect expression
{ }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
Bit Position of Memory Data (000
relRelative Addressing Data
upage
U-page (0FF00H~0FFFFH) Offset Address
nTable CALL Number (0~15)
+Addition
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
87S BC { X }3413
88TST dp4C23
89X CNCE15
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
→→→→→→→→
DEC. 1999xi
Page 96
GMS800 SeriesHYUNDAI Micro Electronics
Register / Memory Operation
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
19S TA dpE 524Store accumulator contents in memory
20S TA dp + XE625 ( M ) ← A
21STA !absE735
22STA !abs + YF536
23S TA [ dp + X ]F627
24STA [ dp ] + YF727
25STA { X }F414
26S TA { X }+FB14X- register auto-increment : ( M ) ← A, X ← X + 1
27S TX dpEC24Store X-register contents in memory
28S TX dp + YED25 ( M ) ← X
29STX !absFC35
30S TY dpE 924Store Y-register contents in memory
31S TY dp + XF925 ( M ) ← Y
32STY !absF835
33T AXE812Transf er accum ulator contents to X-register : X ← A
34T AY9F12Transfer accumulator contents to Y-register : Y ← A
35TSP XAE12Transfer stack-pointer contents to X-register : X ← sp
36TXAC812Transfer X-register contents to accumulator: A ← X
37T XSP8E12Transfer X-register contents to stack-pointer: sp ← X
38TYABF12Transfer Y-register contents to accumulator: A ← Y
39X AXEE14Exchange X-register contents with accumulator :X ↔ A
40X AYDE14Exchange Y-register contents with accumulator :Y ↔ A
41X MA dpBC25Exchange memory contents with accumulator
42X MA dp+ XAD26 ( M ) ↔ A
43X MA {X}BB15
44X YXFE14Exchange X-register contents with Y-reg ister : X ↔ Y
Op
Code
ByteNoCycle
No
Operation
Flag
NVGBHIZC
N-----Z-
--------
N-----Z-
N-----Z-
--------
--------
--------
N-----ZN-----ZN-----ZN-----ZN-----ZN-----Z-
--------
--------
N-----Z-
--------
xiiDEC. 1999
Page 97
HYUNDAI Micro ElectronicsGMS800 Series
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.Mnem onic
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 )
17S ET1 dp.bitx124Set bit : ( M.bit ) ← “1”
18S ETA1 A.bit0B22Set A bit : ( A.bit ) ← “1”
19SETCA012Set C-flag : C ← “1”
20SETGC012Set G-flag : G ← “1”
21S TC M.bitEB36Store C-flag : ( M .bit ) ← C
22TCLR1 !abs5C36
23TSET1 !abs3C36
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-
DEC. 1999xiii
Page 98
GMS800 SeriesHYUNDAI Micro Electronics
Branch / Jump Operation
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 minus
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
14CA LL !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 :
17CB NE dp+X,rel8D36/8 if ( A ) ≠ ( M ) , then pc ← ( pc ) + rel.
18DBNE dp,relAC35/7Decrement and branch if not equal :
19DB NE Y,rel7B24/6 if ( M ) ≠ 0 , then pc ← ( pc ) + rel.
20JMP !abs1B33Unconditional jump
21JM P [!abs]1F35 pc ← jump address
22JM P [dp]3F24