Operating Voltage, 2.7~5.5V is extended with 2.4~5.5V.
Operating Temperature, -20~80°C is extended wi t h -20~85°C.
Add the "Typical Characteristics" on page 16, 17.
Add the unused port guidance on page 48.
Revision the information for the OTP programming guidance, recommand using "Intelligent Mode" on page 49.
Add the chapter for OTP programming specification as an appendix.
Rev 1.0 (Nov. 1997)
First Edition
Page 2
Second Edition
Published by
MCU Application Team
1998 LG Semicon Co., Ltd. All right reserved.
Additional information of this manual may be served by LG Semicon offices in Korea or Distributors and
Representatives listed at address directory.
LG Semicon reserves the right to make changes to any information here in at any time without notice.
The information, diagrams and other data in this manual are correct and reliable; however, LG Semicon Co,. Ltd.
is in no way responsible for any violations of patents or other rights of the third party generated by the use of this
manual.
The GMS81604/08 is a high-performance CMOS 8-bit microcontroller with 4K or 8K bytes of ROM. The device
is one of GMS800 family. The LG Semicon GMS81604/08 is a powerful microcontroller which provides a highly
flexible and cost effective solution to many embedded control applications. The GMS81604/08 provides the
following standard features: 8K bytes of ROM, 256 bytes of RAM, 35 I/O lines(33 lines for 40PDIP), 16-bit or
8-bit timer/counter, a precision analog to digital converter, on-chip oscillator and clock circuitry. In addition, the
GMS81604/08 supports power saving modes to reduce power consumption. The Stop Mode saves the RAM
contents but freezes the oscillator disabling all other chip functions until the next hardware reset or external
interrupt.
Features
4K/ 8K On-chip Program Memory
256 Bytes of On-Chip Data RAM
Instruction execution time: 0.5us at 8MHz
2.4V to 5.5V Operating Range
1~8 MHz Operating frequency
Basic Interval Timer
Four 8-Bit Timer/ Counters (can be used
as two 16-bit)
Four external interrupt ports
Two Programmable Clock Out
Memory Proliferation
DeviceROM BytesRAM Bytes
GMS816044K256
GMS816088K256
GMS81608T8K EPROM256
Development Tools
The GMS800 family is supported by a full-featured
macro assembler, an in-circuit emulators CHOICEJr.TM, socket adapters for OTP device.
The availability of OTP devices are especially useful
for customers expecting frequent code changes and
updates. The OTP devices, packaged in plastic pack-
One Buzzer Driving port
31 Programmable I/O, 4 Input pins,
Twelve Interrupt Sources
All LED Direct Drive Output Ports
8-Channel 8-Bit On-Chip Analog to Digital
Converter
Power Fail Processor
(Noise immunity circuit)
Power Down Mode (Stop Mode)
ages permit the user to program them once. In addition
to the program memory, the configuration fuses must
be programmed.
port. As an output port each pin can sink several LS
TTL inputs. R0 pins that have 1 or 0 written to their
Port Direction Mode Register, can be used as outputs
or inputs.
R10~R17: R1 is an 8-bit, CMOS, bidirectional I/O
port. As an output port each pin can sink several LS
TTL inputs. R1 pins that have 1 or 0 written to their
Port Direction Mode Register, can be used as outputs
or inputs.
R40~R47: R4 is an 8-bit, CMOS, bidirectional I/O
port. As an output port each pin can sink several LS
TTL inputs. R4 pins that have 1 or 0 written to their
Port Direction Mode Register, can be used as outputs
or inputs.
In addition, Port 4 serves the functions of the various
following special features.
EC0 (External Count Input to Timer/
Counter 0)
EC2 (External Count Input to Timer/
Counter 2)
T1O (Timer 1 Clock-Out)
T3O (Timer 3 Clock-Out)
R50, R51, R55: R5 is a 3-bit, CMOS, bidirectional I/O
port. As an output port each pin can sink several LS
TTL inputs. R5 pins that have 1 or 0 written to their
Port Direction Mode Register, can be used as outputs
or inputs. R50 and R51 differs in having internal
pull-ups.
Port R55 serves the functions of special features.
Port PinAlternate Function
R55BUZ (Square wave output for Buzzer
driving)
R60~R67: R6 is an 8-bit, CMOS, I/O port. R60~R63
can be used as only input, can not be output, R64~R67
are bidirectional I/O port. As an output port each pin
can sink several LS TTL inputs. R64~R67 pins that
have 1 or 0 written to their Port Direction Mode
Register, can be used as outputs or inputs.
R6 serves the functions of following special features.
INPUT MODE: PULL-UP RESISTOR IS ACTIVATED.
OUTPUT MODE: PULL-UP RESISTOR IS DE-ACTIVATED.
Rd.
R64/AN4, R65/AN5, R66/AN6, R67/AN7
DATA BUS
DATA BUS
DATA BUS
TO A/D Converter
Ch. Select
DATA REG.
DIRECTION REG.
Rd.
10
MUX
0: Output
Rd.
1: Reset, Input, AD ch. select
Page 15
LG SemiconGMS81604/08
RESET
XIN, X
X
IN
X
OUT
OUT
Pull-up Resister
TEST
OTP: No P-Ch diode
STOP
11
Page 16
GMS81604/08LG Semicon
ELECTRICAL CHARACTERISTICS
Absolute Maximum Ratings
Supply Voltage . . . . . . . . . . . . . . . -0.3 to +6.0 V
Storage Temperature . . . . . . . . . . . . -40 to +125 °C
Voltage on any pin with
respect to Ground (VSS) . . . . . . -0.3 to VDD+0.3 V
Maximum current out of VSS pin . . . . . . . . . 150 mA
Maximum current into VDD pin . . . . . . . . . 100 mA
Maximum current sunk by (IOL per I/O Pin) . . . . 20 mA
Maximum output current sourced
by (IOH per I/O Pin) . . . . . . . . . . . . . . . 8 mA
Maximum current (Σ IOL) . . . . . . . . . . . . 120 mA
Maximum current (Σ IOH) . . . . . . . . . . . . . 50 mA
Notice:
Stresses above those listed under "Absolute Maximum Ratings" may cause permanent damage to
the device. This is a stress rating only and functional operation of the device at these of any
other conditions above those indicated in the operational sections of this specification is not implied. Exposure to absolute maximum rating
conditions for extended periods may affect device
reliability.
Recommended Operating Conditions
ParameterSymbolCondition
Supply VoltageV
Operating Frequencyf
Operating TemperatureT
DD
XIN
OPR
f
= 8 MHz
XIN
f
= 4 MHz
XIN
VDD = 4.5~5.5V
VDD = 2.4~5.5V
Specifications
Min.Max.
4.5
2.4
1
1
5.5
5.5
8
4.2
-2085
Unit
V
MHz
°C
12
Page 17
LG SemiconGMS81604/08
DC Characteristics ( 5V )
(VDD = 5.0V± 10%, VSS = 0V, TA = -20 ~ 85 °C, f
ParameterPinSymbol Test Condition
XIN, RESET,
Input High Voltage
R40~R45
R0,R1,R46,R47
R5,R6
X
RESET,
IN,
Input Low Voltage
R40~R45
R0,R1,R46,R47
R5,R6
Output High VoltageR0,R1,R4,R5,R6V
Output Low VoltageR0,R1,R4,R5,R6V
Power Fail Detect
Voltage
Input Leakage
Current
Input Pull-up Current
Power Current
V
DD
RESET, R0, R1,
R4, R5, R6
RESETI
R50, R51I
Operating modeI
STOP modeI
Hysteresis
* : Data in "Typ" column is at 5 V, 25°C unless otherwise stated. These parameters are for design guidance only and are not tested.
RESET,
R40~R45
= 8 MHz)
XIN
V
V
V
V
V
PFD
I
I
P1
P2
DD
STOP
VT+
~VT-
Specifications
Min.Typ.*Max.
IH1
IH2
IL1
IL2
OH
OL
-0.8V
-0.7V
-0-0.2V
-0-0.3V
VDD = 5V
IOH = -2mA
VDD = 5V
IOL = 10mA
VDD -1.0 VDD -0.4-V
-0.61.0V
DD
DD
-V
-V
VDD=3~4V3.0-4.0V
VI = V
IH
IL
DD
VI = 0V-5.0-5.0uA
-5.0-5.0uA
VDD = 5V-180-120-30uA
VDD = 5V-90-60-15uA
f
XIN
f
XIN
=4MHz
=8MHz
4.5
8
VDD = 5V-220uA
VDD = 5V0.50.8-V
15
DD
DD
8
DD
DD
Unit
V
V
V
V
mA
A/D Converter Characteristics ( 5V )
(VDD = 5.0V± 10%, V
ParameterSymbol
Analog Input RangeV
Non-linearity ErrorN
Differential Non-linearity ErrorN
Zero Offset ErrorN
Full Scale ErrorN
AccuracyA
AVDD Input CurrentI
Conversion TimeT
Analog power supply Input
Range
* : Data in "Typ" column is at 5 V, 25°C unless otherwise stated. These parameters are for design guidance only and are not tested.
= 5.0V, VSS = 0V, TA = 25 °C)
AIN
AVDD
V
AIN
LE
DIF
OFF
FS
CC
CONV
AVDD
Specifications
Min.Typ.*Max.
V
SS
-0.7
-0.1
-1.5
-1.0
-2.0
-V
AVDD
± 1.5
± 0.5
± 2.5
± 1.5
± 3.0
-0.51.0mA
--40uS
4.55.05.5
Unit
V
LSB
LSB
LSB
LSB
LSB
V
13
Page 18
GMS81604/08LG Semicon
DC Characteristics ( 3V )
(VDD = 3.0V± 10%, VSS = 0V, TA = -20 ~ 85 °C, f
ParameterPinSymbol Test Condition
XIN, RESET,
Input High Voltage
R40~R45
R0,R1,R46,R47
R5,R6
XIN, RESET,
Input Low Voltage
R40~R45
R0,R1,R46,R47
R5,R6
Output High VoltageR0,R1,R4,R5,R6V
Output Low VoltageR0,R1,R4,R5,R6V
Power Fail Detect
Voltage**
Input Leakage
Current
Input Pull-up
Current
Power Current
Hysteresis
* : Data in "Typ" column is at 3 V, 25°C unless otherwise stated. These parameters are for design guidance only and are not tested.
**: Power Fail Detection function is not available on 3V operation.
Analog Input RangeV
Non-linearity ErrorN
Differential Non-linearity ErrorN
Zero Offset ErrorN
Full Scale ErrorN
AccuracyA
AVDD Input CurrentI
Conversion TimeT
Analog power supply Input
Range
* : Data in "Typ" column is at 3 V, 25°C unless otherwise stated. These parameters are for design guidance only and are not tested.
= 3.0V, VSS = 0V, TA = 25 °C)
AIN
AVDD
V
AIN
LE
DIF
OFF
FS
CC
CONV
AVDD
Specifications
Min.Typ.*Max.
V
SS
-0.2
-0.1
-2.0
-1.0
-2.0
-V
AVDD
± 1.0
± 0.5
± 2.5
± 1.5
± 3.0
-0.30.5mA
--40uS
2.73.03.3
Unit
V
LSB
LSB
LSB
LSB
LSB
V
14
Page 19
LG SemiconGMS81604/08
AC Characteristics
(VDD = 2.7~5.5V, VSS = 0V, TA = -20 ~ 85 °C)
ParameterPinSymbol
Main clock frequencyX
Oscillation stabilization TimeXIN, X
External Clock Pulse WidthX
External Clock Transition TimeX
These parameters are for design guidance only and are not tested.
VDD=5V
I
DD
(mA)
I
OL
(mA)
IDD - V
DD
TA=25°C
8
6
4
2
IOL - V
VDD=5.0V
24
18
12
6
0
f
XIN
f
= 4MHz
XIN
234506 (V)
OL
TA=25°C
1234
= 8MHz
I
STOP
I
STOP
(uA)
TA=25°C
8
6
4
2
V
DD
I
(mA)
V
OL
(V)
234506 (V)
IOH - V
OH
24
18
12
6
0
OH
VDD=5.0V
TA=25°C
1234
VDD-V
(V)
V
DD
OH
16
Operating area
f
XIN
(MHz)
TA = -20~80°C
8
6
4
2
0
1
2345
V
DD
(V)
Page 21
LG SemiconGMS81604/08
VDD=3.0V
I
OL
(mA)
20
IOL - V
VDD=3.0V
TA=25°C
OL
I
OH
(mA)
-8
IOH - V
VDD=3.0V
TA=25°C
OH
15
10
5
0
0.51.01.52.0
-6
-4
-2
VDD-V
V
OL
(V)
0
0.51.01.52.0
OH
(V)
17
Page 22
GMS81604/08LG Semicon
MEMORY ORGANIZATION
The GMS81604 has separate address spaces for Program and Data Memory. Program memory can only be
read, not written to. It can be up to 4K (8K for
GMS81608) bytes of Program Memory. Data memory can be read and written to up to 256 bytes including
the stack area.
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
PCHPCL
PSW
ACCUMULATOR
X REGISTER
Y REGISTER
STACK POINTER
PROGRAM COUNTER
PROGRAM STATUS
WORD
Figure 3. Configuration of Registers
Accumulator: The accumulator is the 8-bit general
purpose register, used for data operation such as transfer, temporary saving and conditional judgment, etc.
The accumulator can be used as a 16-bit register with
Y register as shown below.
Y
YA
A
TWO 8-BIT REGISTERS ONE "YA" 16-BIT REGISTER
Figure 4. Configuration of YA 16-bit register
X register, Y register: In the addressing modes which
use these index registers, the register contents are
added to the specified address and this becomes the
actual address. These modes are extremely effective
for referencing subroutine tables and memory tables.
The index registers also have increment, decrement,
compare 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. The stack can be located at any position within
100H to 13FH of the internal data memory. Data store
and restore sequence to(from) stack area is shown in
Figure 0.
Caution:
The stack pointer must be initialized by software
because its value is undefined after reset.
Ex) LDX#03FH
TXSP ; SP ← 3F
Stack Address (100H~13FH)
158 70
1SP
Hardware fixed.
H
Figure 5. Stack Pointer
Program Counter: The program counter is a 16-bit
wide which consists of two 8-bit registers, PCH, PCL.
This counter indicates the address of the next instruction to be executed. In reset state, the program counter
has reset routine address (PCH: FFH, PCL: FEH). .
Program Status Word : The Program Status Word
(PSW) contains several status bits that reflect the current state of the CPU. The PSW shown in Figure 6. It
contains the Negative flag, the Overflow flag, the
Direct page flag, the Break flag, the Half Carry (for
BCD operations), the Interrupt enable flag, the Zero
flag and the Carry bit.
[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.
[Zero flag Z]
This flag is set when the result of an arithmetic operation or data transfer is "0" and is cleared by any other
result.
[Interrupt disable flag I] This flag enables/disables all
interrupts except interrupt caused by Reset or software
18
Page 23
LG SemiconGMS81604/08
MSBLSB
PSW
NEGATIVE FLAG
OVERFLOW FLAG
N
V G B HIZ C
RESET VALUE: 00H
CARRY FLAG RECEIVES
CARRY OUT
ZERO FLAG
G FLAG TO SELECT DIRECT PAGE
BRK FLAG
Figure 6. PSW (Program Status Word) Register
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, cleared by the DI instruction.
[Half carry flag H]
After operation, set when there is a carry from bit 3 of
ALU or there is not a borrow from bit 4 of ALU. This
bit can not be set or cleared except CLRV instruction,
clearing with Overflow flag (V).
[Break flag B]
This flag set by software BRK instruction to distinguish BRK from TCALL instruction which as the
same vector address.
[Direct page flag G]
This flag assign direct page for direct addressing mode.
In the direct addressing mode, addressing area is
INTERRUPT ENABLE
FLAG
HALF CARRY FLAG RECEIVES
CARRY OUT FROM BIT 1 OF
ADDITION OPERANDS
within zero page 00H to FFH when this flag is "0". If it
is set to "1", addressing area is 100H to 1FFH.
It is set by SETG instruction, and cleared by CLRG.
[Overflow flag V]
This flag is set to "1" when an overflow occurs in the
result of an arithmetic operation involving signs. An
overflow occurs when the result of an addition or
subtraction exceeds +127(7FH) or -128(80H).
The CLRV instruction clears the overflow flag. There
is no set instruction. When the BIT instruction is
executed, for other than the above, bit 6 of memory is
copy to this flag.
[Negative flag N]
This flag is set to match the sign bit (bit 7) status of the
result of a data or arithmetic operation. When the BIT
instruction is executed, bit 7 of memory is copy to this
flag.
1) INTERRUPT
M(SP) ← (PCH)
SP ← SP - 1
M(SP) ← (PCL)
SP ← SP - 1
M(SP) ← (PSW)
SP ← SP - 1(PCH) ← M(SP)
2) RETI
SP ← SP + 1
(PSW) ← M(SP)
SP ← SP + 1
(PCL) ← M(SP)
SP ← SP + 1
3) CALL
M(SP) ← (PCH)
SP ← SP - 1
M(SP) ← (PCL)
SP ← SP - 1
Figure 7. Stack Operation
4) RET
SP ← SP + 1
(PCL) ← M(SP)
SP ← SP + 1
(PCH) ← M(SP)
5) PUSH A (X,Y,PSW)
M(SP) ← ACC.
SP ← SP - 1
6) POP A (X,Y,PSW)
SP ← SP + 1
M(SP) ← (PCH)
19
Page 24
GMS81604/08LG Semicon
Program Memory
A 16-bit program counter is capable of addressing up
to 64K bytes, but this devices have 4K bytes (8K for
GMS81608) program memory space only the physically implemented. Accessing a location above FFFF
will cause a wrap-around to 0000H.
Figure 8, shows a map of the upper part of the Program
Memory. After reset, the CPU begins execution from
reset vector which is stored in address FFFEH, FFFFH.
As shown in Figure 8, each area is assigned a fixed
location in Program Memory. Program Memory area
contains the user program, Page Call (PCALL) area
contains subroutine program, to reduce program byte
length because of using by 2 bytes PCALL instead of
3 bytes CALL instruction. If it is frequently called,
more useful to save program byte length.
E000H
F000H
PROGRAM
MEMORY
FEFFH
FF00H
FFBFH
FFC0H
FFDFH
FFE0H
FFFFH
PCALL
AREA
TCALL
AREA
INTERRUPT
VECTOR
AREA
GMS81608
GMS81604
Figure 8. Program Memory
Table Call (TCALL) causes the CPU to jump to each
TCALL address, where it commences execution of the
service routine. The Table Call service locations are
spaced at 2-byte interval : FFC0H for TCALL15,
FFC2H for TCALL14, etc.
AddressTCALL Name
FFC0H
FFC2H
FFC4H
H
FFC6H
FFC8H
FFCAH
FFCCH
FFCEH
FFD0H
FFD2H
FFD4H
FFD6H
FFD8H
FFDAH
FFDCH
FFDEH
1) The BRK software interrupt is using same address with
TCALL0.
The interrupt causes the CPU to jump to specific
location, where it commences execution of the service
routine. The External interrupt 0, for example, is assigned to location FFFAH. The interrupt service locations are spaced at 2-byte interval : FFF8H for External
Interrupt 1, FFFAH for External Interrupt 0, etc.
Any area from FF00H to FFFFH, if it not going to be
used, its service location is available as general purpose Program Memory.
AddressVector Name
FFE0H
FFE2H
FFE4H
FFE6H
FFE8H
FFEAH
FFECH
FFEEH
FFF0H
FFF2H
FFF4H
FFF6H
FFF8H
FFFAH
FFFCH
FFFEH
-
-
Basic Interval Timer
Watch Dog Timer
Analog to Digital Converter
Timer/ Counter 3
Timer/ Counter 2
Timer/ Counter 1
Timer/ Counter 0
External Interrupt 3
External Interrupt 2
External Interrupt 1
External Interrupt 0
RESET
20
Page 25
LG SemiconGMS81604/08
Data Memory
Figure 9 shows the internal Data Memory space available. Data Memory are divided into three groups, a
user RAM, control registers and Stack.
00
H
DATA
MEMORY
(RAM)
BF
C0
100
13F
FF
H
H
CONTROL
REGISTERS
H
H
STACK
H
AREA
256 BYTES
Figure 9. Data Memory
Internal Data Memory addresses are always one byte
wide, which implies an address space of 256 bytes
including the stack area. To access above FFH, G-flag
should be set to "1" before, because after MCU reset,
G-flag is "0".
The stack pointer should be initialized within 00H to
3FH by software because of implemented area of
internal data memory.
The control registers are used by the CPU and Peripheral functions 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, I/O ports. The control registers
are in address C0H to FFH.
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 detail informations of each register are explained
in each peripheral sections.
Caution:
Write only registers can not be accessed by bit
manipulation instruction.
AddressSymbolR/W
C0
C1
C2
C3
C8
C9
CA
CB
CC
CD
D0
D1
D3
D3
E0
E2
E3
E4
E5
E6
E7
E8
E9
EC
ED
F4
F5
F6
F7
F8
C0
C1
C2
C3
C8
C9
CA
CB
CC
CD
D0
D1
D3
D3
E0
E2
E3
E4
E5
E6
E7
E8
E9
EC
ED
F4
F5
F6
F7
F8
Legend - = Unimplemented locations.
R0R0 port data register
H
R0DDR0 port direction register
H
R1R1 port data register
H
R1DDR1 port direction register
H
R4R4 port data register
H
R4DDR4 port direction register
H
R5R5 port data register
H
R5DDR5 port direction register
H
R6R6 port data register
H
R6DDR6 port direction register
H
PMR4T3ST1SEC2SEC0SINT3SINT2SINT1SINT0S
H
PMR5--BUZS-----
H
1)
BITRBasic Interval Timer data register
H
1)
CKCTLR--WDTON ENPCKBTCLBTS2BTS1BTS0
H
WDTR-WDTCL6-bit Watch Dog Counter register
H
TM0CAP0T1STT1SL1T1SL0T0STT0CNT0SL1T0SL0
H
TM2CAP2T3STT3SL1T3SL0T2STT2CNT2SL1T2SL0
H
T0/ TDR0/ CDR0Timer 0 register/ Timer data register 0/ Capture data register 0
H
T1/ TDR1/ CDR1Timer 1 register/ Timer data register 1/ Capture data register 1
H
T2/ TDR2/ CDR2Timer 2 register/ Timer data register 2/ Capture data register 2
H
T3/ TDR3/ CDR3Timer 3 register/ Timer data register 3/ Capture data register 3
H
ADCM--ADENADS2ADS1ADS0ADSTADSF
H
ADRADC result data register
H
BURBUCK1 BUCK0BU5BU4BU3BU2BU1BU0
H
2)
PFDR-----PFDPFRPFS
H
IENLAEWDTEBITE-----
H
IRQLAIFWDTIFBITIF-----
H
IENHINT0EINT1EINT2EINT3ET0ET1ET2ET3E
H
IRQHINT0IFINT1IFINT2IFINT3IFT0IFT1IFT2IFT3IF
H
IEDSIED3HIED3LIED2HIED2LIED1HIED1LIED0HIED0L
H
NOTES:
1) The register BITR and CKCTLR are located at same address. Address D3H is read as BITR, written to CKCTLR.
2) The register PFDR only be implemented on device, not on In-circuit Emulator.
22
Page 27
LG SemiconGMS81604/08
I/O PORTS
The GMS81604/08 have five ports, R0, R1, R4, R5,
R6. These ports pins may be multiplexed with an
alternate function for the peripheral features on the
device. In general, when a initial reset state, all ports
are used as a general purpose input port.
All pins have data direction registers which can configure these pins as output or input.
A "1" in the port direction register configures the
corresponding port pin as output. Conversely, write
"0" to the corresponding bit to specify as an input pin.
For example, to use the even numbered bit of R1 as
output ports and the odd numbered bits as input ports,
write "55H" to address C1H (R0 direction register)
during initial setting as shown in Figure 10.
WRITE "55H" TO PORT R0 DIRECTION REGISTER
C0H
C1H
C2H
C3H
R0 DATA
R0 DIRECTION
R1 DATA
R1 DIRECTION
0 1 0 1 0 1 0 1
7 6 5 4 3 2 1 0 BIT
II O I O I OO
7 6 5 4 3 2 1 0 PORT
I: INPUT PORT
O: OUTPUT PORT
Figure 10. Example port I/O assignment
Reading data register reads the status of the pins
whereas writing to it will write to the port latch.
R0 and R0DD registers: R0 is a 8-bit bidirectional
I/O port (address C0H). Each pin is individually configurable as input and output through the R0DD register (address C1H).
Port 0 Data Register
R07 R06 R05 R04 R03 R02 R01 R00
R0
Port 0 Direction Register
R07 R06 R05 R04 R03 R02 R01 R00
R0DD
ADDRESS: C0
RESET VALUE: Undefined
Input/ Output data
ADDRESS: C1
RESET VALUE: 00000000
Direction select
0: Input
1: Output
H
H
R1 and R1DD registers: R1 is an 8-bit bidirectional
I/O port (address C2H). Each pin is individually configurable as input and output through the R1DD register (address C3H).
Port 1 Data Register
R17 R16 R15 R14 R13 R12 R11 R10
R1
Port 1 Direction Register
R17 R16 R15 R14 R13 R12 R11 R10
R1DD
ADDRESS: C2
RESET VALUE: Undefined
Input/ Output data
ADDRESS: C3
RESET VALUE: 00000000
Direction select
0: Input
1: Output
H
H
R4 and R4DD registers: R4 is an 8-bit bidirectional
I/O port (address C8H). Each pin is individually configurable as input and output through the R4DD register (address C9H).
In addition, Port R4 is multiplexed with various special
features. The control register PMR4 (address D0H)
controls to select alternate function. After reset, this
value is "0", port may be used as general I/O ports. To
select alternate function such as External interrupt or
External counter or Timer clock out, write "1" to the
corresponding bit of PMR4.
Regardless of the direction register R4DD, PMR4 is
selected to use as alternate functions, port pin can be
used as a corresponding alternate features.
23
Page 28
GMS81604/08LG Semicon
R5 and R5DD registers: R5 is a 3-bit bidirectional
Port 4 Data Register
R47 R46 R45 R44 R43 R42 R41 R40
R4
ADDRESS: C8
RESET VALUE: Undefined
H
I/O port (address CAH). R50, R51 and R55 only are
physically implemented on this device.
R50, R51 have internal pullups which is activated on
input but deactivated on output. As input, these pins
Input/ Output data
that are externally pull low will source current (IP2 on
the DC characteristics) because of the internal pullups.
Caution:
Pins R50, R51 are present on 42SDIP, 44PLCC
package only, but not on 40DIP . Refer to Pin assignment.
Each pin is individually configurable as input and
output through the R5DD register (address CBH).
Port PinAlternate Function
R55BUZ (Square-wave output for
Buzzer driving)
The control register PMR5 (address D1H) controls the
selection 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.
Port 5 Data Register
-- R55 --- R51 R50
R5
Port 5 Direction Register
R5DD
-- R55 --- R51 R50
Port 5 Mode Register
PMR5
-- BUZS -----
ADDRESS: CA
RESET VALUE: Undefined
Input/ Output data
ADDRESS: CB
RESET VALUE: --0---00
Direction select
0: Input
1: Output
ADDRESS: D1
RESET VALUE: --0-----
H
H
H
24
0: R55
1: BUZ (Buzzer Port)
Page 29
LG SemiconGMS81604/08
R6 and R6DD registers: R6 is an 8-bit port (address
CCH). Pins R64~R67 are indiv idual ly confi gurabl e as
input and output th rough the R6DD registe r (address
CDH), but pins R60~R63 are input only.
R6DD (address CDH) controls the direction of the R6
pins, even when they are being used as analog inputs.
The user must make sure to keep the pins configured
as inputs when using them as analog inputs.
On the initial RESET, R60 can not be used digital
input 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
On the other hand, R6 port, all eight pins can not be
used as digital I/O port simultaneousely. At least
one pin is used as an analog input.
).
H
Port 6 Data Register
R67 R66 R65 R64 R63 R62 R61 R60
R6
Port 6 Direction Register
R67 R66 R65 R64 R63 R62 R61 R60
R6DD
ADDRESS: CC
RESET VALUE: Undefined
Input/ Output data
ADDRESS: CD
RESET VALUE: 0000----
H
H
Fixed as Input.
Can not write.
Direction select
0: Input
1: Output
25
Page 30
GMS81604/08LG Semicon
BASIC INTERVAL TIMER
The GMS81604 has one 8-bit Basic Interval Timer that
is free-run, can not stop. Block diagram is shown in
Figure 11.
The 8-bit Basic interval timer register (BITR) is incremented every internal count pulse which is divided by
prescaler. Since prescaler has divided ratio by 16 to
2048, the count rate is 1/16 to 1/2048 of the oscillator
frequency. As the count overflows from FFH to 00H,
this overflow causes to generate the Basic interval
timer interrupt. The BITR is interrupt request flag of
BTS[2:0]
3
8
MUX
XIN PIN
÷16
÷32
÷64
÷128
÷256
÷512
÷1024
÷2048
PRESCALER
Figure 11. Block Diagram of The Basic Interval Timer
CKCTLR
WDTON-ENPCK BTCLBTS1BTS2BTS0-
Basic interval timer.
Caution:
All control bits of Basic interval timer are in
CKCTLR register which is located at same address of BITR (address D3H). Address D3H is
read as BITR, written to CKCTLR.
When write "1" to bit BTCL of CKCTLR, data register
is cleared to "0" and restart to count-up. It becomes "0"
after one machine cycle by hardware.
BTCL
CLEAR
BITR (8 BITS)
BITIF
BASIC INTERVAL TIMER
INTERRUPT
ADDRESS: D3
RESET VALUE: --010111
H
26
SymbolPositionName and Significance
WDTONCKCTLR.5
ENPCKCKCTLR.4Enable Peripheral clock.
BTCLCKCTLR.3
BASIC INTERVAL TIMER CLOCK SELECTION
BTS2BTS1BTS0Prescale value
0
0
0
0
0
1
0
1
1
0
1
0
1
1
1
1
WDTON=1, enables Watch Dog Timer operation,
WDTON=0, operates as a 6-bit timer
BTCL is set to "1", BITR is cleared. BTCL becomes "0" automatically
after one machine cycle, and starts counting.
0
1
0
1
0
1
0
1
16
32
64
128
256
512
1024
2048
Figure 12. CKCTLR: Control Clock Register
Page 31
LG SemiconGMS81604/08
TIMER/COUNTER
The GMS81604 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 the two
8-bit Timer/Counter or one 16-bit Timer/Counter to
combine them. Also Timer 2 and Timer 3 are same.
In the "timer" function, the register is incremented
every internal clock input. Thus, one can think of it as
counting internal 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
corresponding external input pin, EC0 or EC2.
In addition the "capture" function, the register is incremented 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 operating 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 right Table.
In operation of Timer 2, Timer 3, their operations are
same with Timer 0, Timer 1, respectively.
operate as one 16-bit capture timer combine
two 8-bit timers.
When set, Timer 1 count register is cleared
T1STStart/Stop control for Timer 0. A logic 1
and start again.
When cleared, stop the counting.
TIMER 1TIMER 0
T1SL1 T1SL0
0
0
1
1
NOTE:
If this mode selected, the Timer 0 are used as a 16-bit timer mode. The Timer 1 is engaged to the Timer 0.
The source clock is selected by bits T0SL1 and T0SL0.
INPUT CLOCK
0
16-BIT TIMER MODE (NOTE 1)
1
8-BIT TIMER, ÷ 4 ← PRESCALER
0
8-BIT TIMER, ÷ 16
1
8-BIT TIMER, ÷ 64
T1SL1T1STT1SL0 T0STT0SL1T0CNT0SL0CAP0
TIMER 1TIMER 0
When set, The Timer 0 Count Register is
T0ST
cleared and start again.
When cleared, stop the counting.
T0CN
starts the timer.
T0SL1 T0SL0
0
0
0
1
1
0
1
1
INPUT CLOCK
Timer or Counter select
÷ 4 ← PRESCALER
÷ 16
÷ 64
ADDRESS: E2
RESET VALUE: 00H
Figure 13. TM0: Timer 0, Timer 1 Mode Register
H
27
Page 32
GMS81604/08LG Semicon
MSB
TM2
Capture mode selection flag, When set, timer
CAP2
operate as one 16-bit timer combine two 8-bit
timers. See Figure 21 and Figure 22.
When set, Timer 3 count register is cleared
T3STStart/Stop control for Timer 2. A logic 1
and start again.
When cleared, stop the counting.
TIMER 3TIMER 2
T3SL1 T3SL0
0
0
1
1
NOTE:
If this mode selected, the Timer 2 and Timer 3 are used as a 16-bit timer mode. The Timer 3 is engaged to
the Timer 2. The source clock is selected by bits T2SL1 and T2SL0.
INPUT CLOCK
0
16-BIT TIMER MODE (NOTE 1)
1
8-BIT TIMER, ÷ 4 ←PRESCALER
0
8-BIT TIMER, ÷ 16
1
8-BIT TIMER, ÷ 64
T3SL1T3STT3SL0 T2STT2SL1T2CNT2SL0CAP2
TIMER 3TIMER 2
When set, Timer 2 count register is cleared
T2ST
and start again.
When cleared, stop the counting.
T2CN
starts the timer.
T2SL1 T2SL0
0
0
1
1
LSB
INPUT CLOCK
0
Timer or Counter select
1
÷ 4 ← PRESCALER
0
÷ 16
1
÷ 64
ADDRESS: E3
RESET VALUE: 00
Figure 14. TM2: Timer 2, Timer 3 Mode Register
ADDRESS: E4
RESET VALUE: 00
ADDRESS: E5
RESET VALUE: 00
ADDRESS: E6
RESET VALUE: 00
ADDRESS: E7
RESET VALUE: 00
TDR0
TDR1
TDR2
TDR3
MSB
LSB
H
H
H
H
H
H
H
H
H
H
28
Figure 15. TDRx : Timer x Data Register
Page 33
LG SemiconGMS81604/08
8-bit Timer/Counter Mode
The GMS81604 has four 8-bit Timer/Counters, Timer
0, Timer 1, Timer 2, Timer 3. The Timer 0, Timer 1
only as shown in Figure 16. because other timer/counters are same with Timer 0 and Timer 1.
The "timer" or "counter" function is selected by control
registers TM0, TM2 as shown in Figure 13 and Figure
14. 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 T3SL1, T3SL0 of TM2 should not set to
zero (Figure 16).
These timers have each 8-bit count register and data
register. The count register is incremented 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).
In the Timer 0, timer register T0 increments from 00
MSBLSB
CAP0 T1ST T1SL1 T1SL0 T0ST T0CN T0SL1 T0SL0
TM0
0X≠ 0≠ 0XXXX
T0SL[1:0]
EC0 PIN
XIN PIN
EDGE DETECTOR
÷ 4
÷ 16
÷ 64
PRESCALER
MUX
TIMER 0
0
1
T0CN
until it matches TDR0 and then reset to 00H. The match
output of Timer 0 generates Timer 0 interrupt (latched
in T0IF bit)
As TDRx and Tx register are in same address, when
reading it as a Tx, written to TDRx.
Caution:
The contents of Timer data register TDRx should
be initialized 1H~FFH except 0H, because it is undefined after reset.
In counter function, the counter is incremented every
1-to 0 (falling edge) transition of EC0 or EC2 pin. In
order to use counter function, the bit EC0S, EC2S of
the Port mode register PMR4 are set to "1". The Timer
0 can be used as a counter by pin EC0 input, but Timer
1 can not. Similarly, Timer 2 can be used by pin EC2
input but Timer 3 can not.
H
T0ST
0: Stop
1: Clear and Start
T0 (8-BITS)
TDR0 (8-BITS)
CLEAR
COMPARATOR
ADDRESS: E2
RESET VALUE: 00
T0IF
H
TIMER 0
INTERRUPT
H
T1SL[1:0]
MUX
TIMER 1
T1ST
0: Stop
1: Clear and Start
T1 (8-BITS)
TDR1 (8-BITS)
COMPARATOR
Figure 16. 8-bit Timer/Counter Mode
CLEAR
T1IF
F/F
TIMER 1
INTERRUPT
T1O PIN
29
Page 34
GMS81604/08LG Semicon
To pulse out, the timer match can goes to port pin as
shown in Figure 16. Thus, pulse out is generated by
the timer match. These operation is implemented to
pin, T1O and T3O. The pin T1O is output from Timer
1, the T3O is from Timer 3. Operation of T3O is
omitted in this document, but still presents and same
architecture with T1O.
PMR4
T3S0: R47
1: T3O (TIMER 3 OUTPUT)
T1S0: R46
1: T1O (TIMER 1 OUTPUT)
EC2S0: R45
1: EC2 (EXTERNAL INPUT PIN FOR
TIMER 2
EC0S0: R44
1: EC0 (EXTERNAL INPUT PIN FOR
TIMER 0
EC2ST1SEC0S INT3SINT1SINT2SINT0ST3S
Figure 17. PMR4: R4 Port Mode Register
When TM0: 00110111 (PRESCALER= 16)
EX)
TDR0
00
TDR0: F9H = 249
OSCILLATOR FREQ.= 4MHz
INTERRUPT PERIOD =
H
1
MATCH
(TDR0 = T0)
F1
F0
3
2
D
1
4 × 106 Hz
F5
F4
F3
F2
× 16 × (249 + 1) = 1ms
F7
F6
f
TxO
INT3S0: R43
INT2S0: R42
INT1S0: R41
INT0S0: R40
F9
F8
Oscillator Frequency
(Hz)=
2 ⋅Prescaler⋅TDR
LSBMSB
1: INT3 (EXTERNAL INTERRUPT 3)
1: INT2 (EXTERNAL INTERRUPT 2)
1: INT1 (EXTERNAL INTERRUPT 1)
1: INT0 (EXTERNAL INTERRUPT 0)
COUNT PULSE
PERIOD
4 us
CLEAR
ADDRESS: D0
RESET VALUE: 00
H
H
TIMECLEARCLEAR
30
TIMER 0
INTERRUPT
OCCUR INTERRUPT
INTERRUPT
PERIOD
Figure 18. Timer Count Example
OCCUR INTERRUPT
OCCUR INTERRUPT
Page 35
LG SemiconGMS81604/08
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
0000H 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.
MSB
CAP0 T1ST T1SL1 T1SL0 T0ST T0CN T0SL1 T0SL0
TM0
0X00XXXX
T0SL[1:0]
EDGE DETECTOR
EC0 PIN
MUX
XIN PIN
THIS FIGURE IS A EXAMPLE OF THE TIMER 0 AND
TIMER 1.
IN THE TIMER 2, EACH REGISTERS AND FLAGS MAY BE
CHANGED CORRESPONDINGLY.
÷ 4
÷ 16
÷ 64
PRESCALER
DO NOT CARE
0
1
T0CN
TIMER 0
(+TIMER1)
Figure 19. 16-bit Timer/Counter Mode
Even if the Timer 0 (including the Timer 1) is used as
a 16-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
T1
(8-BITS)
TDR1
(8-BITS)
HIGHER LOWER
T0
(8-BITS)
TDR0
(8-BITS)
LSB
CLEAR
COMPARATOR
ADDRESS: E2
RESET VALUE: 00
T0IF
(NOT TIMER 1 INTERRUPT)
H
H
TIMER 0
INTERRUPT
TDR0
00
TIMER
INTERRUPT
TxST
TxCN
MATCH
Clear and Start
Stop
H
HIGH
LOW
HIGH
LOW
Stop
Restart
MATCH
Count Up
TIMECLEARCLEARCLEAR
OCCUR INTERRUPTOCCUR INTERRUPT
Figure 20. Timer Count Operation
31
Page 36
GMS81604/08LG Semicon
8-bit Capture Mode
The Timer 0 capture mode is set by bit CAP0 of timer
mode register TM0 (bit CAP2 of timer mode register
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 only 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 generated. Timer/Counter still does the above, but
with the added feature that a edge transition at external
MSBLSB
CAP0 T1ST T1SL1 T1SL0 T0ST T0CN T0SL1 T0SL0
TM0
1X≠ 0≠ 0XXXX
T0SL[1:0]
EC0 PIN
XIN PIN
EDGE DETECTOR
÷ 4
÷ 16
÷ 64
PRESCALER
IEDS[1:0]
MUX
0
1
T0CN
input INTx pin causes the current value in the Timer x
register (T0,T2), to be captured into registers CDRx
(CDR0, CDR2), respectively. After captured, Timer
x register is cleared and restarts by hardware.
Caution:
The CDRx and TDRx are in same address.
In the capture mode, reading operation is read the
CDRx, not TDRx because path is opened to the
CDRx.
It has three transition modes: "falling edge", "rising
edge", "both edge" which are selected by interrupt
edge selection register IEDS (Refer to External interrupt section). In addition, the transition at INTx pin
generate an interrupt.
T0 (8-BITS)
CAPTURE
CDR0 (8-BITS)
T0ST
0: Stop
1: Clear and Start
ADDRESS: E2
RESET VALUE: 00
THIS FIGURE IS A EXAMPLE OF THE TIMER 0.
IN THE TIMER 2, EACH REGISTERS AND FLAGS
MAY BE CHANGED CORRESPONDINGLY.
H
H
32
INT0 PIN
Figure 21. 8-bit Capture Mode
INT0IF
INT0
INTERRUPT
Page 37
LG SemiconGMS81604/08
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.
EC0 PIN
XIN PIN
INT0 PIN
EDGE DETECTOR
÷ 4
÷ 16
÷ 64
PRESCALER
IEDS[1:0]
MSBLSB
CAP0 T1ST T1SL1 T1SL0 T0ST T0CN T0SL1 T0SL0
TM0
1X00XXXX
T0SL[1:0]
MUX
DO NOT CARE
T0CN
TIMER 0
+
TIMER 1
0
1
T0ST
0: Stop
1: Clear and Start
T1
(8-BITS)
CDR1
(8-BITS)
HIGHER LOWER
T0
(8-BITS)
CDR0
(8-BITS)
THIS FIGURE IS A EXAMPLE OF USING TIMER 0
AND TIMER 1.
IN THE TIMER 2 AND TIMER 3 EACH
REGISTERS AND FLAGS MAY BE CHANGED.
Figure 22. 16-bit Capture Mode
ADDRESS: E2
RESET VALUE: 00
INT0IF
H
INT 0
INTERRUPT
H
33
Page 38
GMS81604/08LG Semicon
ANALOG TO DIGITAL CONVERTER
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 AVDD of ladder resistance 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 24, controls the
operation of the A/D converter module. The port pins
can be configured as analog inputs or digital I/O. To
use analog inputs, I/O is selected input mode by R6DD
ADEN
AVDD PIN
R60/AN0
R61/AN1
R62/AN2
R63/AN3
R64/AN4
R65/AN5
R66/AN6
R67/AN7
"0"
"1"
ADS[2:0]
3
000
001
010
011
100
101
110
111
INPUT CHANNEL SELECTION
V
IN
S/H
SAMPLE & HOLD
LADDER
RESISTOR
DECODER
direction register.
How to Use A/D Converter
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 interrupt flag
AIF is set. The block diagram of the A/D module is
shown in Figure 23. 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 40 uS (at f
SUCCESSIVE
APPROXIMATION
CIRCUIT
ADR
A/D RESULT REGISTER
AIF
ADDRESS: E9
RESET VALUE: Undefined
H
=4 MHz).
XIN
A/D
INTERRUPT
34
Figure 23. A/D Block Diagram
Page 39
LG SemiconGMS81604/08
ADCM
R/WR/WR/WR/WR/WR
LSBMSB
ADEN-ADS2 ADS1ADSTADS0ADSF-
RESERVED
Figure 24. ADCM: A/D Converter Control Register
ADDRESS: E8
RESET VALUE: --00001
A/D status bit
0: A/D conversion is in process.
1: A/D conversion is completed, not in
process.
A/D start bit
1: Setting this bit starts an A/D conversion.
After one cycle, bit is cleared to "0".
0: Bit force to zero.
0: A/D converter module shut off and
consumes no operating current.
1: Enable A/D converter
H
35
Page 40
GMS81604/08LG Semicon
BUZZER FUNCTION
The buzzer driver consists of 6-bit binary counter, the
XIN PIN
÷ 16
÷ 32
÷ 64
÷ 128
PRESCALER
MUX
BUR[7:6]
COUNTER
(6 BIT)
BUR[5:0]
(6 BIT)
BUR REGISTER
F/F
BUZ PIN
buzzer register BUR and the clock selector. It generates square-wave which is very wide range frequency
(250 Hz~125 kHz at f
=4 MHz) by user program-
XIN
mable counter.
Pin R55 is assigned for output port of Buzzer driver by
setting the bit 5 of PMR5 (address D1H) to "1". At this
time, the pin R55 must be defined as output mode (the
bit 5 of R5DD=1)
The bit 0 to 5 of BUR determines output frequency for
buzzer driving.
Frequency calculation is following below.
f
f
f
f
Prescaler: Prescaler divide ratio by BUCK1, BUCK0
BUR:Lower 6-bit of BUR. Buzzer period data value
(Hz)=
BUZ
: Buzzer frequency
BUZ
: Min oscillator frequency
XIN
2⋅ Prescaler ratio ⋅ BUR value
XIN
The bits BUCK1, BUCK0 of BUR selects the source
clock from prescaler output.
The 6-bit buzzer counter is cleared and start the counting by writing signal to the register BUR. It is increment from 00H until it matches 6-bit register BUR.
Caution:
The register BUR contains undefined value after
reset. It must be initialized none 0H(1H~3FH).
LSBMSB
Buzzer Period Data
ADDRESS: EC
RESET VALUE: Undefined
H
36
PMR5
LSBMSB
BUZS-------
R55/ BUZ Port Selection
0: R55
1: BUZ
Figure 27. PMR5: Port 5 Mode Register
ADDRESS: D1
RESET VALUE: --0-----
H
Page 41
LG SemiconGMS81604/08
INTERRUPTS
The GMS81604/08 interrupt circuits consist of Interrupt enable register (IENH, IENL), Interrupt request
flags of IRQH, IRQL, priority circuit and Master enable flag(I flag of PSW). The configuration of interrupt
circuit is shown in Figure 28.
12 interrupt sources are provided including the Reset.
*Vector addresses are shown in Program Memory
section.
INT0
INT1
INT2
INT3
TIMER 0
TIMER 1
TIMER 2
TIMER 3
ADC
WDT
BASIC INTERVAL
TIMER
IRQH
INT0IF
INT1IF
INT2IF
INT3IF
T0IF
T1IF
T2IF
T3IF
IRQL
WDTIF
BITIF
RST
INT0IF
INT1IF
INT2IF
INT3IF
T0IF
T1IF
T2IF
T3IF
AIF
WDTIF
BITIF
AIF
MSB
LSB
BIT 7
BIT 6
BIT 5
IENH
IENL
10
11
12
1
2
3
4
5
6
7
8
9
0
1
The External Interrupts INT0~INT3 can each be transition-activated, depending on interrupt edge selection
register.
The Timer 0~Timer 3 Interrupts are generated by T0IF
~T3IF, which are set by a match in their respective
timer/counter register.
The AD converter Interrupt is generated by AIF which
is set by finishing the analog to digital conversion.
The Watch dog timer Interrupt is generated by WDTIF
which set by a match in Watch dog 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), the interrupt enable
register (IENH, IENL) and the interrupt request flags
(in IRQH, IRQL) except Power-on reset and software
BRK interrupt.
Interrupt enable registers are shown in Figure 29.
These registers are composed of interrupt enable flags
of each interrupt source, these flags determines
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.
BRK (Software Interrupt)
PRIORITY
CONTROL
0
1
I-FLAG
Master Enable Flag
RELEASE THE STOP
(IF IN STOP MODE)
TO CPU
RESET
Figure 28. Block Diagram of Interrupt Function
37
Page 42
GMS81604/08LG Semicon
LSBMSB
IENH
INT2EINT1EINT3E T0ET2ET1ET3EINT0E
ADDRESS: F6
RESET VALUE: 00
H
H
MSBLSB
IENL
BITEWDTE-----AE
Enables or disables the interrupt individually.
If flag is cleared, the interrupt is disabled.
0: Disable
1: Enable
Figure 29. IENH, IENL: Interrupt Enable Registers
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.
When an interrupt is responded to, the I-flag is cleared
to disable any further interrupt, the return address is
pushed into the stack and the PC is vectored to. Once
in the interrupt service routine the source(s) of the
interrupt can be determined by polling the interrupt
flag bits.
The interrupt flag bit(s) must be cleared in software
before reenabling interrupts to avoid recursive interrupts. The Interrupt Request flags are able to be read
and write.
External Interrupt
External interrupt on INT0~INT3 pins are edge triggered depending the edge selection register IEDS.
The edge detection of external interrupt has three
transition activated mode: rising edge, falling edge,
both edge. INT0~INT3 are multiplexed with general
I/O ports (R40~R43). To use external interrupt pin, set
Software interrupt can be invoked by BRK instruction,
which is the lowest priority order.
Interrupt vector address of BRK is shared with the
vector of TCALL0 (Refer to Program Memory Section). When BRK interrupt is generated, B-flag of
PSW is set to distinguish BRK from TCALL0.
Each processing step is determined by B-flag as shown
below.
= 0
B-FLAG
BRK or
TCALL0
= 1
BRK
INTERRUPT
ROUTINE
RETI
TCALL0
ROUTINE
RET
Multiple Interrupt
If two requests of different priority levels are received
simultaneously, the request of higher priority level is
serviced. If requests of the same priority level are
received simultaneously, an internal polling sequence
determines by hardware which request is serviced.
Hardware interrupt priority is shown in Page37.
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 interrupt. But as user set I-flag in interrupt
routine, some further interrupt can be serviced even if
certain interrupt is in progress.
In this example, the INT0 interrupt can be serviced without any
pending, even TIMER 0 is in progress.
Because of re-setting the interrupt enable registers IENH, IENL
and master enable flag "EI" in the Timer/Counter 0 routine.
MAIN
ROUTINE
Occur
TIMER 0 INTERRUPT
TIMER 0
ROUTINE
MOV IENH,#80H
MOV IENL,#00H
EI
INT 0
ROUTINE
INT0
ROUTINE
Figure 33. Execution of BRK/ TCALL0
40
MOV IENH,#FFH
MOV IENL,#FFH
RETI
RETI
Figure 34. Execution of Multi-Interrupt
Page 45
LG SemiconGMS81604/08
WATCHDOG TIMER
The purpose of the watchdog timer is to detect the
malfunction (runaway) of program due to external
noise or other causes and return the operation to the
normal condition.
The watchdog timer consists of 6-bit binary counter,
6-bit comparator and the watchdog timer data register.
When the value of 6-bit binary counter is equal to the
lower 6 bits of WDTR, the match is generated to go to
reset the CPU.
The 6-bit binary counter is cleared by WDTCL=1.
WDTCL
BASIC INTERVAL TIMER
OVERFLOW
COUNT SOURCE
WATCHDOG
COUNTER
(6-BITS)
WDTR[5:0]
(6-BITS)
WATCHDOG TIMER
REGISTER
Caution:
Because the watchdog timer counter is enabled after clearing Basic Interval Timer .
After the bit WDTON set to "1", maximum error of
timer is depend on prescaler ratio of Basic Interval
Timer.
This watchdog timer can also be used as a simple 6-bit
timer by interrupt WDTIF. The interval of watchdog
timer interrupt is decided by Basic Interval Timer.
Interval equation is as below.
T
CLEAR
COMPARATOR
= WDTR ⋅ Interval of BIT
WDT
NOTE:
The bit WDTON is in register CKCTLR. See Figure 12.
"0"
"1"
WDTON
WDTIF
TO RESET CPU
WATCH-DOG TIMER
INTERRUPT
Figure 35. Block Diagram of Watch-dog Timer
WDTR
WDTCL-
Reserved
6-bit Watch-dog count register
WDTCL
0: Free-run Watch-dog Timer
1: WDTCL is set to "1", Counter is cleared. WDTCL becomes "0"
automatically after one machine cycle, and Counter starts counting.
Figure 36. WDTR: Watch-dog Timer Data Register
LSBMSB
ADDRESS: EC
RESET VALUE: Undefined
H
41
Page 46
GMS81604/08LG Semicon
STOP MODE
For applications where power consumption is a critical
factor, device provides reduced power of STOP.
An instruction that STOP causes that to be the last
instruction executed before going into the Stop mode.
In the Stop mode, the on-chip oscillator is stopped.
With the clock frozen, all functions are stopped, but
the on-chip RAM and Control registers are held. The
port pins out the values held by their respective port
data register Rx, port direction register RxDD. The
status of peripherals during Stop mode is shown below.
PeripheralStatus
RAMRetain
Control registersRetain
I/ORetain
OscillationStop
X
IN
X
OUT
In the Stop mode of operation, V
Low
High
can be reduced to
DD
minimize power consumption. Care must be taken,
however, to ensure that VDD is not reduced before the
Stop mode is invoked, and that VDD is restored to its
normal operating level, before the Stop mode is terminated. The reset should not be activated before VDD is
restored to its normal operating level, and must be held
active long enough to allow the oscillator to restart and
stabilize (minimum 20 msec).
Caution:
The NOP instruction have to be written more than
two to next line of the STOP instruction.
Ex)
STOP
NOP
NOP
Release Stop Mode
The exit from Stop mode is hardware reset or external
interrupt. Reset redefines all the Control registers but
does not change the on-chip RAM. External interrupts
allow both on-chip RAM and Control registers to
retain their values.
If I-flag = 1, the normal interrupt response takes place.
If I-flag = 0, the chip will resume execution starting
with the instruction following the STOP instruction. It
will not vector to interrupt service routine.
When exit from Stop mode by external interrupt from
Stop mode, enough oscillation stabilization time is
required to normal operation. Figure 37 shows the
timing diagram. When release the Stop mode, the
OSCILLATOR
INTERNAL
CLOCK
EXTERNAL
INTERRUPT
BASIC INTERVAL
TIMER COUNTER
42
NORMAL OPERATION
N+200 01FE FF00N N+1
STOP INSTRUCTION
EXECUTION
STOP MODE
CLEAR BASIC
INTERVAL TIMER
STABILIZATION
TIME
tST > 20 ms
010203
Figure 37. Timing of Stop Release by External Interrupt
PC: Program Counter contents after the event.
N: Address of STOP instruction.
Chip Status
before event
Chip function after event
PC
Vector
N+1
Oscillator
Circuit
on
on
Basic interval timer is activated on wake-up. It is
incremented from 00H until FFH then 00H. The count
overflow is set to start normal operation. Therefore,
before STOP instruction, user must be set its relevant
prescaler divide ratio to have long enough time (more
than 20msec). This guarantees that crystal oscillator
has started and stabilized.
By reset, exit from Stop mode is shown in Figure 38.
STOP MODE
OSCILLATOR
INTERNAL
CLOCK
RESET
STOP INSTRUCTION
EXECUTION
Minimizing Current Consumption in
Stop Mode
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. Weak pull-ups on
port pins should be turned off, if possible. All inputs
should be either as VSS or at VDD (or as close to rail as
possible). An intermediate voltage on an input pin
causes the input buffer to draw a significant amount of
current.
tST = 64 ms
at 8 MHz
STABILIZATION TIME
Time can not be control by software.
Figure 38. Timing of Stop Mode Release by Reset
43
Page 48
GMS81604/08LG Semicon
RESET
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,
while the oscillator running. After reset, 64ms (at 8
MHz) plus 7 oscillator periods are required to start
execution as shown in Figure 40.
Internal RAM is not affected by reset. When VDD is
turned on, the RAM content is indeterminate. Initial
state of each register is as follow. Therefore, this RAM
should be initialized before reading or testing it.
The GMS81604/08 have on-chip power fail detection
circuitry to immunize against power noise. A configuration register, PFDR, can enable (if clear/programmed) or disable (if set) the Power-fail Detect
circuitry. If VDD falls below 3.0~4.0V range for longer
than 100 ns, the Power fail situation may reset MCU
according to PFR bit of PFDR.
PFDR
MSB
----PFRPFDPFS-
Reserved
Figure 41. PFDR: Power Fail Detector Register
Caution:
Power fail processor function is not available on
3V operation, because this function will detect
power fail all the time.
As below PFDR register is not implemented on the
in-circuit emulator, user can not experiment with it.
Therefore, after final development of user program,
this function may be experimented.
R/W
R/WR/W
ADDRESS: ED
RESET VALUE: -----100
LSB
Power Fail Status
0: Normal operate
1: This bit force to "1" when Power fail was
detected.
Operation Mode
0: Normal operation regardless of power fail.
1: MCU will be reset during power fail.
Disable flag
0: Power fail detection enable
1: Power fail detection disable
H
RESET VECTOR
PFS = 1 ?
NO
RAM CLEAR
INITIALIZE RAM DATA
INITIALIZE ALL PORTS
INITIALIZE REGISTERS
FUNCTION
EXECUTION
YES
PFS = 0
Skip the initial routine.
Figure 42. Example S/W of Reset flow by Power Fail
45
Page 50
GMS81604/08LG Semicon
V
When PFR = 1
DD
Internal
Reset
V
DD
Internal
Reset
V
DD
Internal
Reset
64 mS
t < 64 mS
64 mS
64 mS
PFVDD MAX.
PFVDD MIN.
PFVDD MAX.
PFVDD MIN.
PFVDD MAX.
PFVDD MIN.
Figure 43. Power Fail Processor Situations
46
Page 51
LG SemiconGMS81604/08
OSCILLATOR CIRCUIT
XIN and X
are the input and output, respectively,
OUT
of a inverting amplifier which can be configured for
use as an on-chip oscillator, as shown in Figure 44.
C1
C2
Recommend:
C1,C2 = 30 pF ± 10 pF for Crystals.
X
OUT
X
IN
V
SS
V
SS
X
IN
X
OUT
RESET
R00
R01
Figure 46. Layout of Crystal
Figure 44. Oscillator Connections
Oscillation circuit is designed to be used either with a
To drive the device from an external clock source,
X
should be left unconnected while XIN is driven
OUT
as shown in Figure 45. There are no requirements on
the duty cycle of the external clock signal, since the
input to the internal clocking circuitry is through a
divide-by-two flip-flop, but minimum and maximum
high and low times specified on the data sheet must be
observed.
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 46. for the layout of the crystal.
In all cases, an external clock operation is available.
X
N/C
EXTERNAL
OSCILLATOR
SIGNAL
OUT
X
IN
V
SS
Figure 45. External Clock Drive
Configuration
47
Page 52
GMS81604/08LG Semicon
UNUSED PORTS
All unused ports should be set properly that current
flow through the port does not exist.
First conseider the setting to input mode. Be sure that
there is no current flow after considering its relationship with external circuit. In input mode, the pin impedance viewing from external MCU is very high that
the current does not flow.
But input voltage level should be VSS or VDD. Be
careful that if unspecified voltage, i.e. if unfirmed
voltage level is applied to input pin, there can be little
current ( max. 1mA at around 2V) flow.
If it is not appropriate to set to input mode, then set to
output mode considering there is no current flow.
Setting to High or Low is decided considering its
relationship with external circuit. For example, if there
is external pull-up resistor then it is set to output mode,
i.e. to High, and if there is external pull-down register,
it is set to low.
48
Page 53
LG SemiconGMS81604/08
GMS81608T (OTP) PROGRAMMING
The GMS81608T is one-time PROM (OTP) microcontroller with 8K bytes electrically programmable
read only memory for the GMS81604/08 system
evaluation, first production and fast mass production.
The programming to the OTP device, user can have
two way. One is using the universal programmer which
is support LGS microcontrollers, other is using the
general EPROM programmer.
1. Using the Universal programmer
Third party universal programmer support to program
the GMS81608T microcontrollers and lists are shown
as below.
Manufacturer: Advantech
Web site: http://www.aec.com.tw
Programmer: LabTool-48
Manufacturer: Hi-Lo systems
Web site: http://www.hilosystems.com.tw
Programmer: ALL-11, GANG-08
Socket adapters are supported by third party programmer manufacturer.
2. Using the general EPROM(27C256)
programmer
The programming algorithm is simmilar with the standart EPROM 27C256. It give some convience that user
can use standard EPROM programmer. Make sure
that 1ms programming pulse must be used, it generally called "Intelligent Mode". Do not use 100us
programming pulse mode, "Quick Pulse Mode".
With these socket adapters, the GMS81608T can easy
be programming and verifying using 27C256 EPROM
mode on general-purpose PROM programmer.
In assembler and file type, two files are generated after
compiling. One is "*.HEX", another is "*.OTP". The
"*.HEX" file is used for emulation in circuit emulator
(CHOICE-DrTM or CHOICE-JrTM) and "*.OTP" file
is used for programming to the OTP device.
Programming Procedure
1. Select the EPROM device and manufacturer on
EPROM programmer (Intel 27C256).
2. Select the programming algorithm as an Intelligent
mode (apply 1ms writing pulse), not a Quick pulse
mode.
3. Load the file (*.OTP) to the programmer.
4. Set the programming address range as below table.
AddressSet Value
Buffer start address6000
Buffer end address7FFF
Device start address6000
H
H
H
5. Mount the socket adapter with the GMS81608T on
the PROM programmer.
6. Start the PROM programmer to programming/
verifying.
When user use general EPROM programmer, socket
adaper is essencially required. It convert pin to fit the
pin of general 27C256 EPROM.
Three type socket adapters are provided according to
package variation as below table.
9 R61/AN1 I (1) 10 R60/AN0 I (1) 11 R47/T3O I/O A4 I
12 R46/T1O I/O (1) 13 R45/
14 R44/
EC2 I/OCE I
EC0 I/OOE I
15 R43/INT3 I/O A3 I
16 R42/INT2 I/O A2 I
17 R41/INT1 I/O A1 I
18 R40/INT0 I/O A0 I
19 R55/BUZ I/O (1) 20 V
NOTES:
(1) Pins must be connected to VSS, because these
pins are input ports during programming, program verify
and reading
(2) Pins must be connected to VDD.
(3) X
OUT
DD
pin must be opened during programming.
- V
DD
-
-
Pin No. MCU Mode OTP Mode
21 R17 I/O A12 I
22 R16 I/O A11
23 R15 I/O A10 I
24 R14 I/O A9 I
25 R13 I/O A8 I
26 R12 I/O A7 I
27 R11 I/O A6 I
28 R10 I/O A5 I
29 R07 I/O O7 O
30 R06 I/O O6 O
31 R05 I/O O5 O
32 R04 I/O O4 O
33 R03 I/O O3 O
34 R02 I/O O2 O
35 R01 I/O O1 O
36 R00 I/O O0 O
37
38 X
39 X
40 V
9 R61/AN1 I (1) 10 R60/AN0 I (1) 11 R47/T3O I/O A4 I
12 R46/T1O I/O (1) 13 R45/
14 R44/
EC2 I/OCE I
EC0 I/OOE I
15 R43/INT3 I/O A3 I
16 R42/INT2 I/O A2 I
17 R41/INT1 I/O A1 I
18 R40/INT0 I/O A0 I
19 R55/BUZ I/O (1) 20 V
DD
- V
DD
21 R51 I/O (2) -
NOTES:
(1) Pins must be connected to VSS, because these
pins are input ports during programming, program verify
and reading
(2) Pins must be connected to VDD.
(3) X
pin must be opened during programming.
OUT
-
-
Pin No. MCU Mode OTP Mode
22 R50 I/O (2) 23 R17 I/O A12 I
24 R16 I/O A11
25 R15 I/O A10 I
26 R14 I/O A9 I
27 R13 I/O A8 I
28 R12 I/O A7 I
29 R11 I/O A6 I
30 R10 I/O A5 I
31 R07 I/O O7 O
32 R06 I/O O6 O
33 R05 I/O O5 O
34 R04 I/O O4 O
35 R03 I/O O3 O
36 R02 I/O O2 O
37 R01 I/O O1 O
38 R00 I/O O0 O
39
40 X
41 X
42 V
9 R62/AN2 I (1) 10 R61/AN1 I (1) 11 R60/AN0 I (1) 12 R47/T3O I/O A4 I
13 R46/T1O I/O (1) 14 R45/
15 R44/
EC2 I/OCE I
EC0 I/OOE I
16 R43/INT3 I/O A3 I
17 N.C. - N.C. 18 R42/INT2 I/O A2 I
19 R41/INT1 I/O A1 I
20 R40/INT0 I/O A0 I
21 R55/BUZ I/O (1) 22 V
NOTES:
(1) Pins must be connected to VSS, because these
pins are input ports during programming, program verify
and reading
(2) Pins must be connected to VDD.
(3) X
OUT
DD
pin must be opened during programming.
- V
DD
-
-
Pin No. MCU Mode OTP Mode
23 R51 I/O (2) 24 R50 I/O (2) 25 R17 I/O A12 I
26 R16 I/O A11
27 R15 I/O A10 I
28 R14 I/O A9 I
29 R13 I/O A8 I
30 R12 I/O A7 I
31 R11 I/O A6 I
32 R10 I/O A5 I
33 R07 I/O O7 O
34 R06 I/O O6 O
35 R05 I/O O5 O
36 R04 I/O O4 O
37 R03 I/O O3 O
38 R02 I/O O2 O
39 R01 I/O O1 O
40 R00 I/O O0 O
41
42 X
43 X
44 V
I/O: Input/Output Pin
I: Input Pin
O: Output Pin
RESET I (1) -
OUT
IN
SS
O (3) -
I (1) -
- (1) -
I
55
Page 60
GMS81608T PROGRAMMING SPECIFICATION LG Semicon
PIN FUNCTION (OTP Mode)
VPP (Program Voltage)
VPP is the input for the program voltage for programming the EPROM.
CE ( Chip Enable)
CE is the input for programming and verifying internal EPROM.
OE (Output Enable)
OE is the input of data output control signal for verify.
A0~A12 (Address Bus)
A0~A12 are address input pins for internal EPROM.
O0~O7 (EPROM Data Bus)
These are data bus for internal EPROM.
PROGRAMMING
The GMS81608T has address A0~A12 pins. Therefore, the programmer just program 8K bytes data of addresses
6000
to 7FFFH into the GMS81608T OTP device. During the programming addresses A13, A14, A15 of
H
programmer must be pulled to a logic high.
When the programmer write the data from 6000
addresses E000
to FFFFH of the OTP device.
H
to 7FFFH, consequently, the data actually will be written into
H
Programming Flow
1. The data format to be programmed is made up of Motorola S1 format.
3. Programming the data from address 6000
respectively, and then record the data into the OTP device. When read the data, it also must be turned over.
Ex) 00(00000000)
→FF(11111111), 76(01110110)→89(10001001), FF(11111111)→00(00000000) etc.
4. Of course, the check sum is result of the sum of whole data from address 6000
data of the OTP MCU).
* When GMS81608T shipped, the blank data of GMS81608T is initially 00
to 7FFFH into the OTP MCU, the data must be turned over
1. VDD must be applied simultaneously or before VPP and removed simultaneously or after VPP.
2. The length of the overprogram pulse may vary from 2.85 msec to 78.75 msec as a function of the iteration counter value X
(Intelligent Programming Algorithm).Refer to flow chart of page 13.
Address set-up time 2 us
OE set-up time 2 us
Data setup time 2 us
Address hold time 0 us
Data hold time 1 us
Output disable delay time 0 us
setup time 2 us
setup time 2 us
Program pulse width 0.95 1.0 1.05 ms
CE pulse width when over
programming
2.85 78.75 ms
Data output delay time 200 ns
Condition*
(Note 2)
(Note 1)
61
Page 66
GMS81608T PROGRAMMING SPECIFICATION LG Semicon
Intelligent Programming Algorithm
START
ADDRESS= FIRST LOCATION
VDD = 6.0V
= 12.5V
V
PP
X = 0
PROGRAM ONE 1 ms PULSE
INCREMENT X
INCREMENT
ADDRESS
X = 25 ?
FAIL
NO
VERIFY
ONE BYTE
PASS
PROGRAM ONE PULSE
OF 3X msec DURATION
LAST
ADDRESS ?
VDD = VPP = 5.0V
COMPARE
ALL BYTES TO
ORIGINAL
DATA
DEVICE PASSED
NO
YES
PASS
YES
FAIL
VERIFY
BYTE
FAIL
PASS
DEVICE FAILED
62
Page 67
APPENDIX
Page 68
A. INSTRUCTION
A.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
81SBC dp2523 A ← ( A ) - ( M ) - ~( C )
82SBC dp + X2624
83SBC !abs2734
84SBC !abs + Y3535
85SBC [ dp + X ]3626
86SBC [ dp ] + Y3726
87SBC { X }3413
88TST dp4C23
89XCNCE15
Code
ByteNoCycle
No
Operation
Test memory contents for nega ti ve or zer o, ( dp ) 00
H
Exchange nibbles within the accumulator
↔ A3~A
A
7~A4
0
GMS800 Series
Flag
NVGBHIZC
NV--HZC
N-----Z-
N-----Z-
v
Page 73
GMS800 Series
Register / Memory Operation
Op
No.Mnemonic
1LDA #immC422Load accum u lato r
2LDA dpC523 A ← ( M )
3LDA dp + XC6 2 4
4LDA !absC734
5LDA !abs + YD535
6LDA [ dp + X ]D626
7LDA [ dp ] + YD726
8LDA { X }D4 1 3
9LDA { X }+DB14X- register auto-incre m ent : 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 + XD 924
18LDY !absD834
19STA dpE524Store accumulator contents in memory
20STA dp + XE625 ( M ) ← A
21STA !absE735
22STA !abs + YF536
23STA [ dp + X ]F627
24STA [ dp ] + YF727
25STA { X }F414
26STA { X }+FB14X- register auto-increment : ( M ) ← A, X ← X + 1
27STX dpEC24Store X-register contents in memory
28STX dp + YED25 ( M ) ← X
29STX !absFC35
30STY dpE924Sto re Y-register conten ts in memory
31STY dp + XF925 ( M ) ← Y
32STY !absF835
33TAXE812Transfer accumulator contents to X-register : X ← A
34TAY9F12Transfer accumulator conte nts to Y-r eg ist er : Y ← A
35TSPXAE12Transfer stack-pointer contents to X-register : X ← sp
36TXAC812Transfer X-register contents to accumulator: A ← X
37TXSP8E12Transfer X-register contents to stack-pointer: sp ← X
38TYABF12Transfer Y-register contents to accumulator : A ← Y
39XAXEE14
Code
ByteNoCycle
No
Operation
Exchange X-register contents with accumulator :X ↔
A
Flag
NVGBHIZC
N-----Z-
--------
N-----Z-
N-----Z-
--------
--------
--------
N-----ZN-----ZN-----ZN-----ZN-----ZN-----Z-
--------
vi
Page 74
GMS800 Series
40XAYDE14
41XMA dpBC25Exchange memory contents with accumulator
42XMA dp+XAD26 ( M ) ↔ A
43XMA {X}BB15
44XYXFE14Exchange X-register contents with Y-register : X ↔ Y
Exchange Y-register contents with accumulator :Y ↔
A
16-BIT operation
Op
No.Mnemonic
1ADDW dp1D25
2CMPW dp5D 2 4
3DECW dpBD26
4INCW dp9D26
5LDYA dp7D 2 5
6STYA dpDD25
7SUBW dp3D25
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)
--------
N-----Z-
--------
Flag
NVGBHIZC
NV--H-ZC
N-----ZC
N-----Z-
N-----Z-
N-----Z-
--------
NV--H-ZC
Bit Manipulation
Op
No.Mnemonic
1AND1 M.bit8B34Bit AND C-flag : C ← ( C ) ∧ ( M .bit )
2AND1B M.bit8B34Bit AND C-flag and NOT : C ← ( C ) ∧ ~( M .bit )
3BIT dp0C24Bit test A with memory :
4BIT !abs1C35
5CLR1 dp.bity124Clear bit : ( M.bit ) ← “0”
6CLRA1 A.bit2B22Clear A bit : ( A.bit ) ← “0”
7CLRC2012Clear C-flag : C ← “0”
8CLRG4012Clear G-flag : G ← “0”
9CLRV8012Clear V-flag : V ← “0”
10EOR1 M.bitAB35Bit exclusive-OR C-flag : C ← ( C ) ⊕ ( M .bit )
11EOR1B M.bitAB35
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 )
Code
ByteNoCycle
No
Operation
Z ← ( A ) ∧ ( M ) , N ← ( M
Bit exclusive-OR C-flag and NOT : C ← ( C )
~(M .bit)
) , V ← ( M6 )
7
⊕
Flag
NVGBHIZC
-------C
-------C
MM----Z-
--------
--------
-------0
--0-----
-0--0---
-------C
-------C
-------C
-------C
--------
-------C
-------C
vii
Page 75
GMS800 Series
17SET1 dp.bitx124Set bit : ( M.bit ) ← “1”
18SETA1 A.bit0B22Set A bit : ( A.bit ) ← “1”
19SETCA012Set C-flag : C ← “1”
20SETGC012Set G-flag : G ← “1”
21STC M.bitEB36Store C-flag : ( M .bit ) ← C
22TCLR1 !abs5C36
23TSET1 !abs3C36
Test and clear bits with A :
A - ( M ) , ( M ) ← ( M ) ∧ ~( A )
Test and set bits with A :
A - ( M ) , ( M ) ← ( M ) ∨ ( A )
--------
--------
-------1
--1-----
--------
N-----Z-
N-----Z-
viii
Page 76
Branch / Jump Operation
Op
No.Mnemonic
Code
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 relD0 2 2/4
7BEQ relD022/4
8BMI rel9022/4
9BNE rel70 2 2/4
10BPL rel1022/4
11BRA rel2F24
12BVC rel3022/4
13BVS relB022/4
14CALL !abs3B38Subroutine call
15CALL [dp]5F28
16CBNE dp,relFD35/7Compare and branch if not equal :
17CBNE dp+X,rel8D36/8 if ( A ) ≠ ( M ) , then pc ← ( pc ) + rel.
18DBNE dp,relAC35/7Decrement and branch if not equal :
19DBNE Y,rel7B24/6 if ( M ) ≠ 0 , then pc ← ( pc ) + rel.
20JMP !abs1B33Unconditional jump
21JMP [!abs]1F35 pc ← jump address
22JMP [dp]3F24
23PCALL upage4F26
24TCALL nnA18
ByteNoCycle
No
Operation
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