The GMS81C1404 and GMS81C14 08 are an ad vanced C MOS 8 -bi t microcontroller with 4K/8K bytes of ROM. The Hynix
semiconductor’s GMS81C 1404 and GMS81C1408 are a power ful microcont roller which prov ides a highly flexib le and cost
effective solution to many small applications such as controller for battery charger. The GMS81C1404 and GMS81C1408
provide the followi ng st an dard feat ur es: 4 K/8K bytes of ROM, 192 bytes of RAM, 8-bit t i mer /co un ter , 8 -bi t A/D converter,
10-bit high speed PWM output, programmable buzzer driving port, 8-bit serial communication port, on-chip oscillator and
clock circuitry. In addition, the GMS81C1404 and GMS81C1408 supports power saving modes to reduce power consumption.
Device nameROM SizeEPROM SizeRAM Size
GMS81C14044K bytes-192bytes2.2 ~ 5.5V28 SKDIP or SOP
GMS81C14088K bytes-192bytes2.2 ~ 5.5V28 SKDIP or SOP
GMS87C1404-4K bytes192bytes2.5 ~ 5.5V28 SKDIP or SOP
GMS87C1408-8K bytes192bytes2.5 ~ 5.5V28 SKDIP or SOP
1.2 Features
• 4K/8K Bytes On-chip Program Memory
• 192 Bytes of On-chip Data RAM
(Included stack memory)
• Instruction Cycle Time:
- 250nS at 8MHz
• 23 Programmable I/O pins
(LED direct driving can be source and sink)
• 2.2V to 5.5V Wide Operating Range
• One 8-bit A/D Converter
• One 8-bit Basic Interval Timer
• Four 8-bit Timer / Counters
• Two 10-bit High Speed PWM Outputs
• Watchdog timer (can be operate with internal
RC-oscillation)
Operatind
Voltage
• One 8-bit Serial Peripheral Interface
• Twelve Interrupt sources
- External input: 4
- A/D Conversion: 1
- Serial Peripheral Interface: 1
- Timer: 6
• One Programmable Buzzer Driving port
- 500Hz ~ 130kHz
• Oscillator Type
- Crystal
- Ceramic Resonator
• Noise Immunity Circuit
- Power Fail Processor
• Power Down Mode
- STOP mode
- Wake-up Timer mode
Package
June. 2001 Ver 1.2 1
Page 4
GMS81C1404/GMS81C1408
1.3 Development Tools
The GMS81C1404 and GMS81C1408 are supported by a
full-featured macro assembler, an in-circuit emulator
CHOICE-Dr
TM
.
1.4 Ordering Information
ROM SizePackage TypeOrdering Device CodeOperating Temperature
28SKDIPGMS81C1404 SK
4K bytes
8K bytes
4K bytes (OTP)
8K bytes (OTP)
28SOPGMS81C1404 D
28SKDIPGMS81C1404E SK
28SOPGMS81C1404E D
28SKDIPGMS81C1408 SK
28SOPGMS81C1408 D
28SKDIPGMS81C1408E SK
28SOPGMS81C1408E D
28SKDIPGMS87C1404 SK
28SOPGMS87C1404 D
28SKDIPGMS87C1408 SK
28SOPGMS87C1408 D
In Circuit Emulators
Assembler
OTP Writer
OTP Devices
CHOICE-Dr.
HME Macro Assembler
Single Writer : Dr. Writer
4-Gang Writer : Dr.Gang
GMS87C1404 SK (Skinny DIP)
GMS87C1404 D (SOP)
GMS87C1408 SK (Skinny DIP)
GMS87C1408 D (SOP)
: Input to the inverting oscillator amplifier and input to
IN
the internal main clock operating circuit.
X
: Output from the inverting oscillator amplifier.
OUT
RA0~RA7: RA is an 8-bit, CMOS, bidirectional I/O port.
RA pins can be used as outputs or inputs according to “1”
or “0” written the their Port Direction Register(RAIO).
Port pinAlternate function
RA0
RA1
RA2
RA3
RA4
RA5
RA6
RA7
EC0 ( Event Counter Input Source )
AN1 ( Analog Input Port 1 )
AN2 ( Analog Input Port 2 )
AN3 ( Analog Input Port 3 )
AN4 ( Analog Input Port 4 )
AN5 ( Analog Input Port 5 )
AN6 ( Analog Input Port 6 )
AN7 ( Analog Input Port 7 )
Table 5-1 RA Port
In addition, RA serves the functions of the various special
features in Table 5-1 .
RB0~RB7: RB is a 8-bit, CMOS, bidirectional I/O port.
RB pins can be used as outputs or inputs according to “1”
or “0” written the their Port Direction Register(RBIO).
RC3~RC6: RC is a 4-bit, CMOS, bidirectional I/O port.
RC pins can be used as outputs or inputs according to “1”
or “0” written the their Port Direction Register(RCIO).
RC serves the functions of the serial interface following
special features in Table 5-3 .
Port pinAlternate function
RC3
RC4
RC5
RC6
SRDYIN
SRDYOUT
SCKI (SPI CLK Input)
SCKO (SPI CLK Output)
SIN (SPI Serial Data Input)
SOUT (SPI Serial Data Output)
(SPI Ready Input)
(SPI Ready Output)
Table 5-3 RC Port
RD0~RD2: RD is a 3-bit, CMOS, bidirectional I/O port.
RC pins can be used as outputs or inputs according to “1”
or “0” written the their Port Direction Register(RDIO).
RD serves the functions of the external interrupt following
special features in Table 5-4
Port pinAlternate function
RD0
RD1
RD2
INT2 (External Interrupt Input Port 2)
INT3 (External Interrupt Input Port 3)
Table 5-4 RD Port
RB serves the functions of the va rious following special
features
in
Table 5-2
Port pinAlternate function
RB0
RB1
RB2
RB3
RB4
RB5
RB6
RB7
AN0 ( Analog Input Port 0 )
AVref ( External Analog Reference Pin )
BUZ ( Buzzer Driving Output Port )
INT0 ( External Interrupt Input Port 0 )
INT1 ( External Interrupt Input Port 1 )
PWM0 (PWM0 Output)
COMP0 (Timer1 Compare Output)
PWM1 (PWM1 Output)
COMP1 (Timer3 Compare Output)
EC1 (Event Counter Input Source)
TMR2OV (Timer2 Overflow Output)
External Event Counter input 0
Analog Input Port 1
Analog Input Port 2
Analog Input Port 3
Analog Input Port 4
Analog Input Port 5
Analog Input Port 6
Analog Input Port 7
Analog Input Port 0 / Analog Reference
Buzzer Driving Output
External Interrupt Input 0
External Interrupt Input 1
PWM0 Output or Timer1 Compare Output
PWM1 Output or Timer3 Compare Output
External Event Counter input 1
Timer2 Overflow Output
SPI READY Input/Output
SPI CLK Input/Output
SPI DATA Input
SPI DATA Output
External Interrupt Input 2
External Interrupt Input 3
Supply voltage...........................................-0.3 to +6.0 V
Storage Temperature ................................-40 to +125 °C
Voltage on any pin with respect to Ground (V
SS
)
................................ ............................... -0.3 to VDD+0.3
Maximum current out of V
Maximum current into V
Maximum current sunk by (I
Maximum output current sourced by (I
pin........................200 mA
SS
pin ..........................150 mA
DD
per I/O Pin) ........25 mA
OL
per I/O Pin)
OH
...............................................................................15 mA
Maximum current (ΣI
) ....................................150 mA
OL
7.2 Recommended Operating Conditions
Maximum current (ΣI
Stresses above those listed under “Absolute Maxi-
Note:
mum Ratings” may cause perma nent damage to the
device. This is a stress rat ing only and functional op eration of the device at any other conditions above
those indicated in the operational sections of this
specification is not implied. Exposure to absolute
maximum rating cond itions for extended pe riods
may affect device reliability.
)....................................100 mA
OH
ParameterSymbolCondition
Supply Voltage
Operating Frequency
Operating Temperature
V
T
f
XIN
OPR
DD
7.3 A/D Converter Characteristics
(TA=25°C, VSS=0V, VDD=5.12V @
ParameterSymbolCondition
Analog Input Voltage Range
Analog Power Supply Input Voltage Range
Overall Accuracy
Non-Linearity Error
Differential Non-Linearity Error
Zero Offset Error
Full Scale Error
Gain Error
Conversion Time
AV
Input CurrentI
REF
f
=8MHz, VDD=3.072V @
XIN
f
=8MHz
XIN
=4.2MHz
f
XIN
VDD=4.5~5.5V
V
=2.2~5.5V
DD
V
AIN
V
REF
N
ACC
N
NLE
N
DNLE
N
ZOE
N
FSE
N
NLE
T
CONV
REF
Specifications
Unit
Min.Max.
4.55.5V
2.25.5V
18MHz
14.2MHz
-20 (-40 for GMS81C140XE)85
f
=4MHz)
XIN
C
°
Specifications
Unit
Min.Typ.Max.
AVREFS=0
AVREFS=1
VDD=5V
V
=3V
DD
f
=8MHz
XIN
f
=4MHz
XIN
V
SS
V
SS
-
-
3-
2.4-
-
-
-
-
-
-
±
±
±
±
±
±
1.0
1.0
1.0
0.5
0.25
1.0
--10
--20
V
DD
V
REF
V
DD
V
DD
1.5LSB
±
1.5LSB
±
1.5LSB
±
1.5LSB
±
0.5LSB
±
1.5LSB
±
V
V
V
µ
AVREFS=1-0.51.0mA
S
12
June. 2001 Ver 1.2
Page 15
7.4 DC Electrical Characteri stics
GMS81C1404/GMS81C1408
(TA=-20~85°C for GMS81C1404/1408 or TA=-40~85°C for GMS81C1404E/1408E, VDD=2.2~5.5V, VSS=0V)
(TA=-20~85°C for GMS81C1404/1408 or TA=-40~85°C for GMS81C1404E/1408E, VDD=5V±10%, VSS=0V)
ParameterSymbolPins
Operating Frequency
External Clock Pulse Width
External Clock Transition Time
Oscillation Stabilizing Time
External Input Pulse Width
RESET Input Width
X
IN
f
CP
t
CPW
t
RCP,tFCP
t
ST
t
EPW
t
RST
X
IN
X
IN
X
IN
XIN, X
OUT
INT0, INT1, INT2, INT3
EC0, EC1
RESET8--
t
t
1/f
SYS
CP
t
RCP
t
CPW
RST
t
FCP
t
CPW
Specifications
Unit
Min.Typ.Max.
1-8MHz
80--nS
--20nS
--20mS
2--
-0.5V
V
DD
0.5V
t
t
SYS
SYS
RESET
INT0, INT1
INT3
INT2,
EC0,
EC1
t
EPW
t
EPW
Figure 7-1 Timing Chart
0.2V
0.2V
DD
DD
0.8V
DD
14
June. 2001 Ver 1.2
Page 17
7.6 Typical Characteristics
GMS81C1404/GMS81C1408
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.
Operating Area
f
XIN
(MHz)
Ta= 25°C
10
8
6
4
2
0
23
45
V
DD
(V)
6
STOP Mode
I
DD
(µA)
I
0.8
0.6
0.4
STOP
f
= 8MHz
XIN
V
−
DD
-40°C
25°C
85°C
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
Supply voltage...........................................-0.3 to +6.0 V
Storage Temperature ................................-40 to +125 °C
Voltage on any pin with respect to Ground (V
SS
)
................................ ............................... -0.3 to VDD+0.3
Maximum current out of V
Maximum current into V
Maximum current sunk by (I
Maximum output current sourced by (I
pin........................200 mA
SS
pin ..........................150 mA
DD
per I/O Pin) ........25 mA
OL
per I/O Pin)
OH
...............................................................................15 mA
Maximum current (ΣI
) ....................................150 mA
OL
8.2 Recommended Operating Conditions
Maximum current (ΣI
Note: Stresses above those listed under “Absolute Maxi-
mum Ratings” may cause perma nent damage to the
device. This is a stress rat ing only and functional op eration of the device at any other conditions above
those indicated in the operational sections of this
specification is not implied. Exposure to absolute
maximum rating cond itions for extended pe riods
may affect device reliability.
)....................................100 mA
OH
ParameterSymbolCondition
T
V
f
XIN
OPR
DD
Supply Voltage
Operating Frequency
Operating Temperature
8.3 A/D Converter Characteristics
(TA=25°C, VSS=0V, VDD=5.12V @
ParameterSymbolCondition
Analog Input Voltage Range
Analog Power Supply Input Voltage Range
Overall Accuracy
Non-Linearity Error
Differential Non-Linearity Error
Zero Offset Error
Full Scale Error
Gain Error
Operating Frequency
External Clock Pulse Width
External Clock Transition Time
Oscillation Stabilizing Time
External Input Pulse Width
RESET Input Width
X
IN
f
CP
t
CPW
t
RCP,tFCP
t
ST
t
EPW
t
RST
X
IN
X
IN
X
IN
XIN, X
OUT
INT0, INT1, INT2, INT3
EC0, EC1
RESET8--
t
t
1/f
SYS
CP
t
RCP
t
CPW
RST
t
FCP
t
CPW
Specifications
Unit
Min.Typ.Max.
1-8MHz
80--nS
--20nS
--20mS
2--
-0.5V
V
DD
0.5V
t
t
SYS
SYS
RESET
INT0, INT1
INT3
INT2,
EC0,
EC1
t
EPW
t
EPW
Figure 8-1 Timing Chart
0.2V
0.2V
DD
DD
0.8V
DD
June. 2001 Ver 1.2 19
Page 22
GMS81C1404/GMS81C1408
8.6 Typical Characteristics
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.
Operating Area
f
XIN
(MHz)
Ta= 25°C
10
8
6
4
2
0
23
45
V
DD
(V)
6
STOP Mode
I
DD
(µA)
I
0.8
0.6
0.4
STOP
f
= 8MHz
XIN
V
−
DD
-25°C
25°C
85°C
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
Normal Operation
I
V
−
DD
Ta=25°C
23
DD
f
XIN
= 8MHz
4MHz
45
V
DD
(V)
6
I
DD
(mA)
8
6
4
2
0
Wake-up Timer Mode
I
DD
(mA)
2.0
1.5
1.0
I
WKUP
Ta=25°C
V
−
DD
f
= 8MHz
XIN
20
0.2
0
23
RC-WDT in Stop Mode
I
DD
(µA)
20
15
10
5
0
I
RCWDT
Ta=25°C
23
V
−
T
RCWDT
DD
45
= 80uS
45
0.5
V
DD
(V)
6
V
DD
(V)
6
0
23
4MHz
V
DD
(V)
45
6
June. 2001 Ver 1.2
Page 23
GMS81C1404/GMS81C1408
I
OL
I
OL
(mA)
40
30
20
10
0
V
V
−
DD
IH1
V
IH1
f
=4MHz
XIN
(V)
Ta=25°C
4
3
2
, VDD=5V
V
−
OL
12345
XIN, RESET
I
OH
I
OH
-25°C
25°C
85°C
V
OL
(V)
V
V
−
DD
IH2
V
IH2
f
=4kHz
XIN
(V)
Ta=25°C
4
3
2
(mA)
-20
-15
-10
-5
0
Hysteresis input
, VDD=5V
V
−
OH
V
23456
V
V
−
DD
IH3
V
IH3
f
=4kHz
XIN
(V)
Ta=25°C
4
3
2
-25°C
OH
(V)
Normal input
25°C
85°C
V
(V)
IL2
1
0
V
4
3
2
1
0
23
V
−
DD
f
=4kHz
XIN
Ta=25°C
23
45
IL2
Hysteresis input
45
V
DD
(V)
6
V
DD
(V)
6
1
0
1
23
V
V
−
DD
V
IL1
f
=4MHz
XIN
(V)
Ta=25°C
4
3
2
1
0
1
23
45
IL1
XIN, RESET
45
V
DD
(V)
6
V
DD
(V)
6
V
(V)
IL3
1
0
V
4
3
2
1
0
23
V
−
DD
f
=4kHz
XIN
Ta=25°C
23
IL3
Normal input
45
45
V
DD
(V)
6
V
DD
(V)
6
June. 2001 Ver 1.2 21
Page 24
GMS81C1404/GMS81C1408
9. MEMORY ORGANIZATION
The GMS81C1404 and GMS81C1408 have separate address spaces for Program memory and Data Memory. Pro gram memory can only be read, not written to. It can be up
9.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
PCLPCH
PSW
Figure 9-1 Configuration of Registers
Accumulator: The Accumulato r is the 8-bit gen eral 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.
ACCUMULATOR
X REGISTER
Y REGISTER
STACK POINTER
PROGRAM COUNTER
PROGRAM STATUS
WORD
to 4K /8K bytes of Prog ram memor y. Data memory ca n be
read and written to up to 192 bytes including the stack area.
Generally, SP is automatically updated when a subrout ine
call is executed or an interrupt is accepted. However, if it
is used in excess of the stack area permitted by the data
memory allocating configuration, the us er-processed data
may be lost.
The stack can be located at any position within 00
to BF
H
of the internal data memory. The SP is not initialized by
hardware, requiring to write the initial value (the location
with which the use of the stack starts) by using the initialization routine. Normally, the initial value of “BF
H
” is
used.
Stack Address (000
15087
0
Hardware fixed
The Stack Pointer must be initi alized by softwa re be-
Note:
cause its value is undefined after RESET.
Example: To initialize the SP
LDX#0BFH
TXSP; SP ← BFH
~ 0BFH)
H
SP
H
Y
YA
A
Two 8-bit Registers can be used as a “YA” 16-bit Register
Figure 9-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).
22
Program Counter: The Program Counter is a 16-bit wide
which consists of two 8-bit regist ers, PCH and PCL. This
counter indicates the address of the next instruction to be
executed. In reset state, the program counter has reset routine address (PC
:0FFH, PCL:0FEH).
H
Program Status Word: The Program Status Word (PSW)
contains several bits that reflect the current state of the
CPU. The PSW is described in Figure 9-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.
[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.
June. 2001 Ver 1.2
Page 25
PSW
MSBLSB
N
V-BHIZC
RESET VALUE: 00
GMS81C1404/GMS81C1408
H
NEGATIVE FLAG
OVERFLOW FLAG
BRK FLAG
Figure 9-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.
[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 ad-
CARRY FLAG RECEIVES
CARRY OUT
ZERO FLAG
INTERRUPT ENABLE FLAG
HALF CARRY FLAG RECEIVES
CARRY OUT FROM BIT 1 OF
ADDITION OPERLANDS
dress.
[Overflow flag V]
This flag is set to “1” when an overflow occurs as the result
of an arithmetic operation involving signs. An overflow
occurs when the result of an addition or subtraction exceeds +127(7F
) or -128(80H). The CLRV instruction
H
clears the overflow flag. There is no set instruction. When
the BIT instruction is executed, bit 6 of memory is copied
to this flag.
[Negative flag N]
This flag is set to match the sign bit (bit 7) status of the re-
sult of a data or arithmetic operation. When the BIT instruction is executed, bit 7 of memory is copied to this flag.
June. 2001 Ver 1.2 23
Page 26
GMS81C1404/GMS81C1408
9.2 Program Memory
A 16-bit program counter is capable of addressing up to
64K bytes, but these devices have 4K/8K bytes program
memory space only physically implemented. Accessing a
location above FFFF
will cause a wrap-around to 0000H.
H
Figure 9-4 , shows a map of Progr am Memory. After reset ,
the CPU begins execution from reset vector which is stored
in address FFFE
and FFFFH as shown in Figure 9-5 .
H
As shown in Figure 9-4 , each area is assigned a fixed location in Program M emory. Program Memory area contains the user program.
E000H
GMS81C1408
F000H
GMS81C1404
FEFFH
FF00H
FFC0H
FFDFH
FFE0H
FFFFH
TCALL
AREA
INTERRUPT
VECTOR AREA
PROGRAM
MEMORY
PCALL
AREA
Example: Usage of TCALL
LDA#5
TCALL 0FH;
:;
:;
;
;TABLE CALL ROUTINE
;
FUNC_A: LDALRG0
RET
;
FUNC_B: LDALRG1
RET
;
;TABLE CALL ADD. AREA
;
ORG0FFC0H;
DWFUNC_A
DWFUNC_B
1BYTE INSTRUCTION
INSTEAD O F 3 BYTES
NORMAL CALL
1
2
TCALL ADDRESS AREA
The interrupt causes the CPU to jum p to specific location,
where it commences the execution of the service routine.
The External interrupt 0, for example, is assigned to location 0FFFA
interval: 0FFF8
0FFFA
As for the area from 0FF00
. The interrupt service locations spaces 2-byte
H
and 0FFF9H for External Interru pt 1,
H
and 0FFFBH for External Interrupt 0, etc.
H
to 0FFFFH, if any area of
H
them is not going to be used, its s ervice location is available as general purpose Program Memory.
Figure 9-4 Program Memory Map
Page Call (PCALL) area contains subroutine program to
reduce program byte length by using 2 bytes PCALL instead of 3 bytes CALL instruction. If it is frequently called,
it is more useful to save program byte length .
Table Call (TCALL) c auses the CPU to jump to each
TCALL address, where it commences the execution of the
service routine. The Table Call service area spaces 2-byte
for every TCALL: 0FFC0
for TCALL15, 0FFC2H for
H
TCALL14, etc., as shown in Figure 9-6 .
AddressVector Area Memory
0FFE0
H
E2
E4
Serial Peripheral Interface Interrupt Vector Area
E6
E8
EA
EC
EE
F0
F2
F4
F6
F8
FA
FC
FE
NOTE:
“-” means reserved area.
Basic Interval Interrupt Vector Area
Watchdog Timer Interru pt Ve ctor Area
A/D Converter Interrupt Vector Area
Timer/Counter 3 Interrupt Vector Area
Timer/Counter 2 Interrupt Vector Area
External Interrupt 3 Vector Area
External Interrupt 2 Vector Area
Timer/Counter 1 Interrupt Vector Area
Timer/Counter 0 Interrupt Vector Area
External Interrupt 1 Vector Area
External Interrupt 0 Vector Area
RESET Vector Area
-
-
-
Figure 9-5 Interrupt Vector Area
24
June. 2001 Ver 1.2
Page 27
AddressPCALL Area Memory
0FF00
H
PCALL Area
(256 Bytes)
0FFFF
H
GMS81C1404/GMS81C1408
AddressProgram Memory
0FFC0
H
C1
C2
C3
C4
C5
C6
C7
C8
C9
CA
CB
CC
CD
CE
CF
D0
D1
D2
D3
D4
D5
D6
D7
D8
D9
DA
DB
DC
DD
DE
DF
NOTE:
* means that the BRK software interrupt is using
same address with TCALL0.
TCALL 15
TCALL 14
TCALL 13
TCALL 12
TCALL 11
TCALL 10
TCALL 9
TCALL 8
TCALL 7
TCALL 6
TCALL 5
TCALL 4
TCALL 3
TCALL 2
TCALL 1
TCALL 0 / BRK *
Figure 9-6 PCALL and TCALL Memory Area
PCALL→ rel
4F35PCALL 35H
~
~
0FF00H
0FF35H
0FFFFH
4F
35
NEXT
~
~
TCALL→ n
4ATCALL 4
4A
~
~
0F125H
0FF00H
0FFD6H
0FFD7H
0FFFFH
NEXT
25
F1
01001010
~
~
PC:
11111111
FHFHDH6
➌
Reverse
➊
11010110
➋
H
June. 2001 Ver 1.2 25
Page 28
GMS81C1404/GMS81C1408
Example: The usage software example of Vector address and the initialize part.
;********************************************
; MAIN PROGRAM *
;*******************************************
;
RESET:DI;Disable All Interrupts
RAM_CLR: LDA#0;RAM Clear(!0000H->!00BFH)
;
;
;
LDX#0
STA{X}+
CMPX#0C0H
BNERAM_CLR
LDX#0BFH;Stack Pointer Initialize
TXSP
CALLINITIAL;
LDMRA, #0;Normal Port A
LDMRAIO,#1000_0010B;Normal Port Direction
LDMRB, #0;Normal Port B
LDMRBIO,#1000_0010B;Normal Port Direction
:
:
LDMPFDR,#0;Enable Power Fail Detector
:
:
26
June. 2001 Ver 1.2
Page 29
9.3 Data Memory
g
Figure 9-7 shows the internal Data Memory space available. Data Memory is divi d ed i nto two groups, a user RAM
(including Stack) and control registers.
0000H
USER
MEMORY
(including STACK)
00BFH
00C0H
00FFH
Figure 9-7 Data Memory Map
CONTROL
REGISTERS
User Memory
The GMS81C1404 and GMS 81C 140 8 has 1 92 × 8 bits for
the user memory (RAM).
Control Registers
The control registers are used by the CPU and Peripheral
function blocks for controlling the desired operation of the
device. Therefore these registers contain control and status
bits for the interrupt system, the timer/ counters, analog to
digital converters and I/O ports. The control registers are in
address range of 0C0
to 0FFH.
H
Note 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.
Note: Write only registers can not be accessed by bit ma-
nipulation instruction. Do not use read-modify-write
instruction. Use byte manipulation instruction.
byte, bit
byte, bit
byte, bit
byte, bit
byte, bit
byte, bit
byte
byte
byte
byte
byte
byte, bit
1
Table 9-1 Control Registers
June. 2001 Ver 1.2 27
Page 30
GMS81C1404/GMS81C1408
1. “byte, bit” means that register can be addressed by not only bit
but byte manipulation instruction.
2. “byte” means that register can be addressed by only byte
manipulation instruction. On the other hand, do not use any
read-modify-write instruction such as bit manipulation for
clearing bit.
Several names are given at sam e add res s. Refe r to
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.
C0HRARA Port Data Register
C1HRAIORA Port Direction Register
C2HRBRB Port Data Register
C3HRBIORB Port Direction Register
C4HRCRC Port Data Register
C5HRCIORC Port Direction Register
C6HRDRD Port Data Register
C7HRDIORD Port Direction Register
CAHRAFUNCANSEL7ANSEL6ANSEL5ANSEL4ANSEL3ANSEL2ANSEL1ANSEL0
CBHRBFUNCTMR2OVEC1IPWM1OPWM0OINT1IINT0IBUZOAVREFS
CCHPUPSEL----PUPSEL3 PUPSEL2 PUPSEL1 PUPSEL0
CDHRDFUNC------INT3IINT2I
D0HTM0--CAP0T0CK2T0CK1T0CK0T0CNT0ST
D1H
D2HTM1POL16BITPWM0ECAP1T1CK1T1CK0T1CNT1ST
D3H
D4H
D5HPWM0HRPWM0 High Register
D6HTM2--CAP2T2CK2T2CK1T2CK0T2CNT2ST
D7H
D8HTM3POL16BITPWM1ECAP3T3CK1T3CK0T3CNT3ST
D9H
DAH
DBHPWM1HRPWM1 High Register
DEHBURBUCK1BUCK0BUR5BUR4BUR3BUR2BUR1BUR0
E0HSIOMPOLSRDYSM1SM0SCK1SCK0SIOSTSIOSF
E1HSIORSPI DATA REGISTER
E2HIENHINT0EINT1ET0ET1EINT2EINT3ET2ET3E
E3HIENL ADEWDTEBITESPIE----
E4HIRQHINT0IFINT1IFT0IFT1IFINT2IFINT3IFT2IFT3IF
E5HIRQL ADIFWDTIFBITIFSPIF----
E6HIEDSIED3HIED3LIED2HIED2LIED1HIED1LIED0HIED0L
T0/TDR0/
CDR0
TDR1/
T1PPR
T1/CDR1/
T1PDR
T2/TDR2/
CDR2
TDR3/
T3PPR
T3/CDR3/
T3PDR
Timer0 Register / Timer0 Data Register / Capture0 Data Regi ster
Timer1 Data Register / PWM0 Period Register
Timer1 Register / Capture1 Data Register / PWM0 Duty Register
Timer2 Register / Timer2 Data Register / Capture2 Data Register
Timer3 Data Register / PWM1 Period Register
Timer3 Register / Capture3 Data Register / PWM1Duty Register
Table 9-3 Control Registers of GMS81C1404 and GMS81C1408
These registers of shaded area can not be accessed by bit manipulation instruction as “SET1, CLR1”, but should be accessed by
register operation instruction as “LDM dp,#imm”.
June. 2001 Ver 1.2 29
Page 32
GMS81C1404/GMS81C1408
EAHADCM--ADENADS2ADS1ADS0ADSTADSF
EBHADCRADC Result Data Register
ECH
ECH
EDHWDTRWDTCL7-bit Watchdog Counter Register
EFH
These registers of shaded area can not be accessed by bit manipulation instruction as “SET1, CLR1”, but should be accessed by
register operation instruction as “LDM dp,#imm”.
1.The register BITR and CKCTLR are located at same address. Address ECH is read as BITR, written to CKCTLR.
2.The register PFDR only be implemented on devices, not on In-circuit Emulator.
1
BITR
CKCTLR
2
PFDR
Basic Interval Timer Data Register
1
-WAKEUPRCWDTWDTONBTCLBTS2BTS1BTS0
-----PFDISPFDMPFDS
Table 9-3 Control Registers of GMS81C1404 and GMS81C1408
30
June. 2001 Ver 1.2
Page 33
9.4 Addressing Mode
GMS81C1404/GMS81C1408
The GMS81C1404 and GMS81C 140 8 u ses s ix 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
04
35
A+35H+C → A
(3) Direct Page Addressing → dp
In this mode, a address is specified within direct page.
Example;
C535LDA35H;A ←RAM[35H]
0035
H
data
➋
0F550
0F551
~
~
H
H
C5
35
~
~
➊
data → A
(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, which assigns Memory in
Direct page.
This is same with above (2). Use Y register instead of X.
Y indexed absolute →!abs+Y
Sets the value of 16-bit absolute address plus Y-register
data as Memory. This addressing mode can specify memory in whole area.
Example; Y=55
D500FALDA!0FA00H+Y
0F100
0F101
0F102
0FA55
H
H
H
H
~
~
H
D5
00
FA
data
➊
0FA00H+55H=0FA55H
~
~
➋
data → A
➌
3F35JMP[35H]
0E30A
0FA00
35
H
36
H
~
~
H
~
~
H
0A
E3
NEXT
3F
35
jump to address 0E30A
➋
~
~
~
~
➊
H
X indexed indirect → [dp+X]
Processes memory data as Data, assigned by 16-bit pair
memory which is determined by pair data
[dp+X+1][dp+X] Operand plus X-register data in Direct
page.
ADC, AND, CMP, EOR, LDA, OR, SBC, STA
(6) Indirect Addressing
Direct page indirect → [dp]
Assigns data address to use for accomplishing command
which sets memory data(or pair memory) by Operand.
Also index can be used with Index register X,Y.
JMP, CALL
Example;
Example; X=10
H
1625ADC[25H+X]
0E005
0FA00
35
H
36
H
~
~
H
~
~
H
05
E0
data
16
25
0E005
H
➋
~
~
25 + X(10) = 35
➊
~
~
➌
A + data + C → A
H
June. 2001 Ver 1.2 33
Page 36
GMS81C1404/GMS81C1408
Y indexed indirect → [dp]+Y
Processes memory data as Data, assigned by the data
[dp+1][dp] of 16-bit p air memory paired by Operan d in Direct page plus Y-register data.
ADC, AND, CMP, EOR, LDA, OR, SBC, STA
Example; Y=10
1725ADC[25H]+Y
0E015
0FA00
H
25
H
26
H
~
~
H
~
~
H
05
E0
data
17
25
0E005H + Y(10) = 0E015
➋
~
~
H
➊
~
~
A + data + C → A
➌
Absolute indirect → [!abs]
The program jumps to address specified by 16-bit absolute
address.
JMP
Example;
1F25E0JMP[!0C025H]
PROGRAM MEMORY
0E025
H
0E026
H
~
~
0E725
0FA00
H
~
~
H
➊
25
E7
NEXT
1F
25
E0
~
~
~
address 0E30A
H
jump to
➋
~
34
June. 2001 Ver 1.2
Page 37
10. I/O PORTS
GMS81C1404/GMS81C1408
The GMS81C1404 and GMS81C1408 has four ports, RA,
RB, RC and RD. 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 set these
ports as output or i nput. A “1 ” in the p ort di rection regis ter
defines the corresponding port pin as output. Conversely,
write “0” to th e corresponding bit to s pecify as an inp ut
pin. For example, to use the even numbered bit of RA as
output ports and the o dd numbered bit s as input ports, write
“55
” to address C1H (RA direction regist er) duri ng initia l
H
setting as shown in Figure 10-1 .
10.1 RA and RAIO registers
RA is an 8-bit bidirectional I/O port (address C0H). Each
port can be set in dividual ly as inpu t and out put thro ugh the
RAIO register (address C1
RA7~RA1 ports are multiplexed with Analog Input Port
(AN7~AN1) and RA0 port is multiplexed with Event
Counter Input Port (EC0)
RA Data Register
RA
RA Direction Register
RAIO
RA Function Selec tion Register
RAFUNC
ANSEL7ANSEL1ANSEL2ANSEL3ANSEL4ANSEL5ANSEL6
RA7 RA6 RA5 RA4 RA3 RA2 RA1 RA0
0 : RA6
1 : AN6
0 : RA7
1 : AN7
Figure 10-2 Registers of Port RA
The control register RAFUNC (address CAH) controls to
0 : RA4
1 : AN4
0 : RA5
1 : AN5
).
H
.
ADDRESS : C0H
RESET VALUE : Undefined
INPUT / OUTPUT DATA
ADDRESS : C1H
RESET VALUE : 00000000
DIRECTION SELECT
0 : INPUT PO RT
1 : OUTPUT PORT
ADDRESS : CAH
RESET VALUE : 00000000
0 : RA3
1 : AN3
0 : RA2
1 : AN2
ANSEL0
0 : RB0
1 : AN0
0 : RA1
1 : AN1
Reading data register reads the status of the pins whereas
writing to it will write to the port latch.
WRITE “55H” TO PORT RA DIRECTION REGISTER
C0H
C1H
C2H
C3H
RA DATA
RA DIRECTION
RB DATA
RB DIRECTION
0 1 0 1 0 1 0 1
76543210BIT
I O I O I O I O
76543210PORT
I: INPUT PORT
O: OUTPUT PORT
Figure 10-1 Example of port I/O assignment
select alternate function. After reset, this value is “0”, port
may be used as general I/O ports. To select alter nate function such as Analog Input or External Event Counter Input,
write “1” to the corresponding bit of RAFUNC.Regardless
of the direction register RAIO, RAFUNC is selected to use
as alternate functions, port pin can be used as a corresponding alternate features (R A0/EC0 is controlled by RBFUNC)
PORTRAFUNC.7~0Description
RA7/AN7
RA6/AN6
RA5/AN5
RA4/AN4
RA3/AN3
RA2/AN2
RA1/AN1
RA0/EC0
1. This port is not an Analog Input port, but Event Counter clock
source input port. ECO is controlled by setting TOCK2~0 =
111. The bit RAFUNC.0 (ANSEL0) controls the RB0/AN0/AVref
port (Refer to Port RB).
RB is a 5-bit bidirectional I/O port (address C2H). Each
pin can be set individually as input and output through the
RBIO register (address C3
tiplexed with various special features. The control register
RBFUNC (address CB
). In addition, Port RB is mul-
H
) controls to select alternate func-
H
tion. After reset, this value is “0”, port may be used as general I/O ports. To select alternate function such as External
interrupt or Timer compare output, write “1” to the corresponding bit of RBFUNC.
RB Data Register
RB
RB5
RB6RB7
RB Direction Register
RBIO
ADDRESS : C2H
RESET VALUE : Undefined
RB4 RB3 RB2 RB1 RB0
INPUT / OUTPUT DATA
ADDRESS : C3H
RESET VALUE : 00000000
DIRECTION SELECT
0 : INPUT PORT
1 : OUTPUT PORT
RB Function Selection Register
RBFUNC
Pull-up Selection Register
PUPSEL
-
Interrupt Edge Selection Register
IEDS
ADDRESS : CBH
RESET VALUE : 00000000
--
-
RB3 / INT1 Pull-up
0 : No Pull-up
1 : With Pull-up
IED2LIED2HIED3LIED3H
INT2INT3
ADDRESS : CCH
RESET VALUE : ----0000
PUP0
PUP1
PUP2PUP3
RB2 / INT0 Pull-up
0 : No Pull-up
1 : With Pull-up
ADDRESS : E6H
RESET VALUE : 00000000
IED0L
IED0HIED1LIED1H
INT0INT1
External Interrupt Edge Select
00 : Normal I/O port
01 : Falling (1-to-0 transition)
10 : Rising (0-to-1 transition)
11 : Both (Rising & Falling)
0 : RB7
1 : TMR2OV
0 : RB6
1 : EC1
0 : RB5
1 : PWM1 Output or
Compare Output
0 : RB4
1 : PWM0 Output or
Compare Output
TMR2OV
EC1I
PWM1O
Figure 10-3 Registers of Port RB
Regardless of the di rection register R BIO, R BFUNC is s elected to use as alternate functions, port pin can be used as
36
AVREFS
BUZOINT0IINT1IPWM0O
0 : RB0 when ANSEL0 = 0
AN0 when ANSEL0 = 1
1 : AVref
Table 10-1 Serial Communication Functions in RC Port
June. 2001 Ver 1.2
Page 41
10.4 RD and RDIO registers
RD is a 3-bit bidirectional I/O port (address C6H). Each
pin can be set individually as input and output through the
GMS81C1404/GMS81C1408
RDIO register (address C7H).
RD Data Register
RD
RD Direction Register
RDIO
ADDRESS : C6H
RESET VALUE : Undefined
RD2 RD1 RD0
INPUT / OUTPUT DATA
ADDRESS : C7H
RESET VALUE : -----000
DIRECTION SELECT
0 : INPUT PORT
1 : OUTPUT PORT
RD Function Selection Register
RDFUNC
Pull-up Selection Register
PUPSEL
-
RD1 / INT3 Pull-up
0 : No Pull-up
1 : With Pull-up
Interrupt Edge Selection Register
IEDS
ADDRESS : CDH
RESET VALUE : 00000000
INT3I
INT2I
--
-
IED2LIED2HIED3LIED3H
INT2INT3
0 : RD0
1 : INT2
0 : RD1
1 : INT3
ADDRESS : CCH
RESET VALUE : ----0000
PUP0
PUP1
PUP2PUP3
RD0 / INT2 Pull-up
0 : No Pull-up
1 : With Pull-up
ADDRESS : E6H
RESET VALUE : 00000000
IED0L
IED0HIED1LIED1H
INT0INT1
External Interrupt Edge Select
00 : Normal I/O port
01 : Falling (1-to-0 transition)
10 : Rising (0-to-1 transition)
1 1: Both (Rising & Falling)
Figure 10-5 Registers of Port RD
In addition, Port RD is multiplexed with external interrupt
input function. The control register RDFUNC (addre ss
CD
) controls to select alternate function. After reset, this
H
value is “0”, port may be used as general I/O ports. To select alternate function, write “1” to the corresponding bit of
RDFUNC.
Regardless of the direction register RDIO, RDFUNC is se-
lected to use as external interrupt input function, port pin
can be used as a interrupt input feature.
June. 2001 Ver 1.2 39
Page 42
GMS81C1404/GMS81C1408
11. CLOCK GENERATOR
The clock generator produces the basic clock pulses which
provide the system cl ock to be supp lied to the CP U and peripheral hardware.
with a crystal resonator or a ceramic resonato r
STOP
WAKEUP
The main system clock oscillator oscillates
connected to the
OSCILLATION
CIRCUIT
fxin
1
÷
÷2÷4÷8÷
Figure 11-1 Block Diagram of Clock Pulse Generator
11. 1 Oscil lation Circuit
XIN and X
verting amplifier which can be set for use as an on-chip oscillator, as shown in Figure 11-2 .
are the input and output, respectively, a in-
OUT
C1
C2
Xout
R1
Xin
Vss
Xin and Xout pins. External clocks can be input to the main
system clock oscillator. In this case, input a clock signal to
the Xin pin and open the Xout pin.
CLOCK PULSE
GENERATOR
16
÷32÷
Peripheral clock
PRESCALER
128÷256÷512÷1024
64
÷
Internal system clock
2048
÷
should consult the crystal manufacturer for appropriate
values of external components.
Xout
Xin
Vss
External
Clock
Source
OPEN
Recommended: C1, C2 = 30pF±10pF for Crystals
R1 = 1M
Ω
Figure 11-2 Oscillator Connections
To drive the device from an external clock source, Xout
should be left unconnected while Xin is driven as sh own in
Figure 11-3 . There are no requirements on the duty cycle
of the external clock signal, since the input to the internal
clocking circuitry i s through a divide-by-two flip-flop, b ut
minimum and maximum high and low times specified on
the data sheet must be observed.
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
40
Figure 11-3 External Clock Connections
Note: When using a system clock os ci ll ator, c arry ou t wir-
ing in the broken line area in Figure 11-2 to prevent
any effects from wiring capacities.
- Minimize the wiring length.
- Do not allow wiring to inters ect with other signal
conductors.
- Do not al low wiring to come near changing high
current.
- Set the potential of the grounding position of the
SS
oscillator capacitor to that of V
. Do not ground to
any ground pattern where high current is present.
- Do not fetch signals from the oscillator.
June. 2001 Ver 1.2
Page 43
12. Basic Interval Timer
GMS81C1404/GMS81C1408
The GMS81C1404 and GMS81C1408 has one 8-bit Basic
Interval Timer that is free-run, can not stop. Block diagram
is shown in Figure 12-1 .The 8-bit Basic interval timer register (BITR) is increased every internal count pulse which
is divided by prescaler. Since prescaler has divided ratio by
8 to 1024, the count rate is 1/8 to 1/1024 of the oscillator
frequency. As the count ove rflows from FF
to 00H, this
H
overflow causes to generate the Basic interval timer interrupt. The BITF is interrupt request flag of Basic interval
timer.
When write “1” to bit BTCL of CKCTLR, BITR register is
cleared to “0” and restart to count-up. The bit BTCL becomes “0” after one machine cycle by hardware.
If the STOP instructio n executed after writing “1” to bit
WAKEUP of CKCTLR, it goes into the wake-up timer
mode. In this mode, all of the block is halted except the os-
RCWDT
BTS[2:0]
8
fxin
÷
÷
÷
÷
÷
÷
÷
÷
16
32
64
128
256
512
1024
3
8
MUX
0
1
cillator, prescaler (only fxin÷2048) and Timer0.
If the STOP instruction executed after writing “1” to bit
RCWDT of CKCTLR, it goes into the internal RC oscillated watchdog timer mode. In this mode, all of the block is
halted except the internal RC oscillator, Basic Interval
Timer and Watchdog Timer. More detail informations are
explained in Power Saving Function. The bit WDTON decides Watchdog Timer or the normal 7-bit timer
Note: All control bits of Basic interval timer are in CKCTLR
register which is located at same address of BITR
(address EC
). Address ECH is read as BITR, writ-
H
ten to CKCTLR. Therefor e, the CKCTL R can not be
accessed by bit manipulation instru ction.
The GMS81C1404 and GMS81C1408 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 can be used either the two 8-bit Timer/Counter or one 16-bit Timer/Counter by combining
them. Also Timer 2 and Timer 3 are sa me. In this document, explain Timer 0 and Timer 1 because Timer 2 and
Timer3 same with Timer 0 and Timer 1.
In the “timer” function, the register is i ncreased every internal clock input. Thus , one can th ink of it as count ing in ternal clock input. Since a least clock consists of 2 and
most clock consists of 2048 oscillator periods, the count
rate is 1/2 to 1/2048 of the oscillator frequency in Timer0.
And Timer1 can use the same clock source too. In addition,
Timer1 has more fast clock source (1/1 t o 1/8).
In the “counter” function, the register is increased in response to a 0-to-1 (rising edge) transition at its correspond ing external input pin, EC0(Timer 0) or EC1(Timer 2).
Timer 0(2) Mode Register
TM0(2)
--CAPxTxCK2TxCK1TxCK0TxCNTxST
In the external event counter function, the RA0/EC0
Note:
pin has not a schmitt trigger, but a normal input port.
Therefore, it may be count more than input event
signal if the noise interfere in slow transition input
signal .
In addition the “capture” function, the register is increased
in response external interrupt same with timer function.
When external interrupt edge input, the count register is
captured into capture data register CDRx.
Timer1 and Timer 3 are shared with “PWM” function and
“Compare output” function
It has seven operating modes: “8-bit timer/counter”, “16bit timer/counter”, “8-bit capture”, “16-bit capture ”, “8-bit
compare output”, “16-bit compare output” and “10-bit
PWM” which are selected by bit in Timer mode register
TMx as shown in Figure 13-1 and Table 13-1 .
ADDRESS : D0H (D6H for TM2)
RESET VALUE : --000000
1. X: The value “0” or “1” corresponding your operation.
13.1 8-bit Timer/Counter Mode
The GMS81C1404 and GMS81C1408 has four 8-bit Timer/Counters, Timer 0, Timer 1, Tim er 2 and Timer 3, as
shown in Figure 13-2 .
The “timer” or “counter” function is selected by mode reg -
isters TMx as shown in Figure 13-1 and Table 13-1 . To
use as an 8-bit timer/counter mode, bit CAP0 of TM0 is
cleared to “0” and bits 16BIT of TM1 should be cleared to
“0”(Table 13-1 ).
TM0
TM1
EC0
fxin
--
--
POL
Edge Detector
16BITPWMECAP1
X
÷
÷
÷
÷
÷
÷
÷
÷
÷
÷
2
4
8
32
128
512
2048
000
1
2
8
CAP0
0
T0CK[2:0]
MUX
T1CK[1:0]
MUX
T0CK2T0CK1T0CK0T0CNT0ST
XXXXX
T1CK1T1CK0T1CNT1ST
XXXX
X: The value “0” or “1” corresponding your operation.
T0ST
0 : Stop
1
T0CN
1
T1CN
1 : Clear and Start
T0 (8-bit)
TDR0 (8-bit)
T1ST
0 : Stop
1 : Clear and Start
T1 (8-bit)
TDR1 (8-bit)
CLEAR
COMPARATOR
CLEAR
COMPARATOR
ADDRESS : D0H
RESET VALUE : --000000
ADDRESS : D2H
RESET VALUE : 00000000
T0IF
TIMER 0
INTERRUPT
F/F
T1IF
COMP0 PIN
TIMER 1
INTERRUPT
Figure 13-2 8-bit Timer / Counter Mode
June. 2001 Ver 1.2 43
Page 46
GMS81C1404/GMS81C1408
These 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 2, 4, 8, 32,128, 512 , 2048 (select ed by con trol bits T0CK2, T0CK1 and T0 CK0 of register TM0) and
1, 2, 8 (selected by control bi ts T1CK1 an d T1CK0 of reg ister TM1). In the Timer 0, timer register T0 increases
from 00
until it matches TDR0 and then reset to 00H. The
H
match output of Timer 0 generates Timer 0 interrupt
TDR1
8
ount
c
7
6
5
4
Timer 1 (T1IF)
Interrupt
~
~
Occur interruptOccur interruptOccur interrupt
up-
3
2
1
0
(latched in T0F bit). As TDRx and Tx register are in same
address, when reading it as a Tx, written to TDRx.
In counter function, the counter is increased every 0-to 1
(rising edge) transition of EC0 pin. In order to use counter
function, the bit RA0 of the R A Direction Regis ter RAIO
is set to “0”. The Timer 0 can be used as a counter by pin
EC0 input, but Timer 1 can not.
n
n-1
~
~
9
P
CP
Interrupt period
= P
x (n+1)
CP
~
~
TIME
TDR1
Timer 1 (T1IF)
Interrupt
T1ST
Start & Stop
T1CN
Control count
Figure 13-3 Counting Example of Timer Data Registers
disable
clear & start
stop
~
~
Occur interruptOccur interrupt
T1ST = 0
T1ST = 1
enable
~
~
T1CN = 0T1CN = 1
up-
Figure 13-4 Timer Count Operation
unt
co
TIME
44
June. 2001 Ver 1.2
Page 47
13.2 16-bit Timer/Counter Mode
The Timer register is bein g run with 16 bi ts. A 16-bit ti mer/
counter register T0, T1 are increased from 0000
matches TDR0, TDR1 and then resets to 0000
match output generates Timer 0 interrupt not Timer 1 interrupt.
until it
H
. The
H
GMS81C1404/GMS81C1408
The clock source of the Timer 0 is selected either internal
or external clock by bit T0CK2, T0CK1 and T0SL0.
In 16-bit mode, the bits T1CK1,T1CK0 an d 16BIT of TM1
should be set to “1” respectively.
EC0
fxin
TM0
TM1
Edge Detector
÷
÷
÷
÷
÷
÷
÷
--
--
POL
X
2
4
8
32
128
512
2048
CAP0
16BITPWMECAP1
10011
T0CK[2:0]
MUX
T0CN
T0CK2T0CK1T0CK0T0CNT0ST
0
1
XXXXX
T1CK1T1CK0T1CNT1ST
T1 (8-bit)
TDR1 (8-bit)
Figure 13-5 16-bit Timer / Counter Mode
ADDRESS : D0H
RESET VALUE : --000000
ADDRESS : D2H
RESET VALUE : 00000000
XX
X: The value “0” or “1” corresponding your operation.
T0ST
0 : Stop
1 : Clear and Start
T0 (8-bit)
COMPARATOR
TDR0 (8-bit)
CLEAR
T0IF
F/F
TIMER 0
INTERRUPT
COMP0 PIN
13.3 8-bit Compare Output (16-bit)
The GMS81C1404 and GMS81C1408 has a function of
Timer Compare Output. To pulse out, the timer match can
goes to port pin(COMP0) as s hown in Figure 13-2 and Fig ure 13-5 . Thus, pulse out is generated by the timer match.
These operation is implemented to pin, RB4/COMP0/
PWM.
This pin output the signal having a 50: 50 duty sq uare
wave, and output frequency is same as below equation.
In this mode, the bit PWMO of RB function register (RBFUNC) should be set to “1”, and the bit PWME of timer1
mode register (TM1) should be set to “0”.
In addition, 16-bit Compare output mode is available, also.
13.4 8-bit Capture Mode
The Timer 0 capture mode is set by bit CAP0 of timer
mode register TM0 (bi t CAP1 of tim er mode reg ister TM1
for Timer 1) as shown in Figure 13-6 .
As mentioned above, not on ly Timer 0 but Timer 1 can also
be used as a capture mode.
The Timer/Counter register is increased in response inter-
nal or external input. This counting fun ction is same with
normal timer mode, and Timer interrupt is generated when
June. 2001 Ver 1.2 45
Page 48
GMS81C1404/GMS81C1408
timer register T0 (T1) increases and matches TDR0
(TDR1).
This timer interrupt in capture mode is very useful when
the pulse width of captured signal is more wider than the
maximum period of Timer.
For example, in Figure 13-8 , the pulse width of captured
signal is wider than the timer data value (FF
) over 2
H
times. When external interrupt is occurred, the captured
value (13
) is more little than wanted value. It can be ob-
H
tained correct value by counting the number of timer overflow occurrence.
Timer/Counter still does the above, but with the added feature that a edge transition at external input INTx pin causes
the current value in the Timer x register (T0,T1), to be cap-
TM0
TM1
--
--
POL
Edge Detector
16BITPWMECAP1
X
001
CAP0
T0CK[2:0]
T0CK2T0CK1T0CK0T0CNT0ST
1
XXXXX
T1CK1T1CK0T1CNT1ST
tured into registers CDRx (CDR0, CDR1), respectively.
After captured, Timer x register is cleared and restarts by
hardware.
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.
The CDRx, TDRx and Tx are in same address. In
Note:
the capture mo de, reading ope ration is read the
CDRx, not Tx because path is opened to the CDRx,
and TDRx is only for writing operation.
16-bit capture mode is the same as 8-bit capture, except
that the Timer register is being run will 16 bits.
The clock source of the Timer 0 i s selected either internal
or external clock by bit T0CK2, T0CK1 and T0CK0.
In 16-bit mode, the bits T1CK1,T1CK0 an d 16BIT of TM1
should be set to “1” respectively.
TM0
TM1
EC0
fxin
INT0
--
--
POL
X
Edge Detector
2
÷
4
÷
8
÷
32
÷
128
÷
512
÷
2048
÷
CAP0
1
16BITPWME
10
T0CK[2:0]
MUX
CAPTURE
IEDS[1:0]
T0CK2T0CK1T0CK0T0CNT0ST
XXXXX
1
T0CN
CAP1
X
T1CK1T1CK0
11
T0 + T1 (16-bit)
CDR1
CDR0
(8-bit)
(8-bit)
T0ST
T1CNT1ST
XX
X: The value “0” or “1” corresponding your operation.
0 : Stop
1 : Clear and Start
TDR1
TDR0
(8-bit)
(8-bit)
Figure 13-9 16-bit Capture Mode
CLEAR
COMPARATOR
ADDRESS : D0H
RESET VALUE : --000000
ADDRESS : D2H
RESET VALUE : 00000000
T0IF
INT0IF
INT 0
INTERRUPT
TIMER 0
INTERRUPT
13.6 PWM Mode
The GMS81C1404 and GMS81C1 408 has a two high
speed PWM (Pulse Width Modulation) functio ns which
shared with Timer1 (Timer 3). In this docum ent, it will be
explained only PWM0.
In PWM mode, pin RB4/COMP0/PW M0 outputs up to a
10-bit resolution PWM output. This p in sh ould be configure as a PWM output by setting “1” bit PWM0O in RBFUNC register. (PWM1 output by setting “1” bit PWM1O
in RBFUNC)
The period of the PWM output is determined by the
T1PPR (PWM0 Period Register) and PWM0HR[3:2]
(bit3,2 of PWM0 High Register) and the dut y of the PWM
output is determined by the T1PDR (PWM0 Duty Register) and PWM0HR[1:0] (bit1,0 of PWM0 High Register).
48
The user writes the lower 8-bit p e riod value to the T1PPR
and the higher 2-bit period value to th e PWM0HR[3:2].
And writes duty value to the T1PDR and the
PWM0HR[1:0] same way.
The T1PDR is configure as a doub le buffering for g litchless PWM output. In Figure 13-10 , the duty data is transferred from the master to the slave when the period data
matched to the counted value. (i .e. at t he beg inning of next
duty cycle)
PWM Period = [PWM0HR[3:2]T1PPR] X Source Clock
PWM Duty = [PWM0HR[1:0]T1PDR] X Source Clock
The relation of frequency and resolution is in inverse proportion. Table 13-2 shows the relation of PWM frequency
vs. resolution.
June. 2001 Ver 1.2
Page 51
GMS81C1404/GMS81C1408
If it needed more higher frequency of PWM, it should be
reduced resolution.
The bit POL of TM1 decides the polarity of duty cycle.
If the duty value is set same to the period value, the PWM
output is determined by the bit POL (1: High, 0: Low). And
if the duty value is set to “00
”, the PWM output is deter-
H
mined by the bit POL (1: Low, 0: High).
TM1
POL
16BIT
PWME
CAP1
T1CK1T1CK0
It can be changed duty value when the PWM ou tput. However the changed duty value is output after the current period is over. And it can be maintained the duty value at
present output when changed only period value shown as
Figure 13-12 . As it were, the abs olute duty time is not
changed in varying frequency. But the changed peri od value must greater than the duty value.
Note:
If changing the Timer1(3) to PWM funct ion, it
should be stop the timer cl ock firs tly, and then
set period and duty register value. If user
writes register values while timer is in operation, these register could be set with certain
values.
Figure 13-12 Example of Changing the Period in Absolute Duty Cycle (@8MHz)
June. 2001 Ver 1.2
Page 53
14. Serial Peripheral Interface
GMS81C1404/GMS81C1408
The Serial Peripheral Interface (SPI) module is a serial interface useful for communicating with other peripheral of
microcontroller devices. These peripheral devices may be
SPI Mode Control Register
SIOM
POLSerial Clock Polarity Selection bit
SRDYSerial Ready Enable bit
SM[1:0]Serial Operation Mode Selection bits
SPI Data Register
SIOR
POLSRDYSM1SM0SCK1SCK0SIOSTSIOSF
0 : Data Transmission at falling edge
(Received data latch at rising edge)
1 : Data Transmission at rising edge
(Received data latch at falling edge)
0 : Disable (RC3)
1 : Enable (SRDYIN
00 : Normal Port (RC4, RC5, RC6)
01 : Transmit Mode (SCK, RC5, SOUT)
10 : Receive Mode (SCK, SIN, RC6)
11 : Transmit & Receive Mode (SCK, SIN, SOUT)
/ SRDYOUT)
.
serial EEPROM s, shift regist ers, di spla y driver s, A/D converters, etc.
The SPI allows 8-bit s of data to be s ynchronously t ransmitted and received. To accomplish comm unication, typically
three pins are used:
- Serial Data In RC5/SIN
- Serial Data OutRC6/SOUT
- Serial ClockRC4/SCK
Additonarlly a fourth pi n may be u sed when i n a mas ter o r
a slave mode of operation:
- Serial Transfer ReadyRC3/SRDYIN/SRDYOUT
SIOST
SCK
(POL=1)
SCK
(POL=0)
SOUT
SIN
SPIF
(SPI Int. Req)
D1D2D3D4D6D7D0D5
D1D2D3D4D6D7D0D5
The serial data transfer operation mode is decided by setting the SM1 and SM0 of SPI Mode Control Register, and
the transfer clock rate is decided by setting the SCK1 and
SCK0 of SPI Mode Control Register as shown in Figure
14-1 . And the polarity of transfer clock is selected by setting the POL.
The bit SRDY is used for master / slave selection. If this
bit is set to “1” and SCK[1:0] is set to “11”, the controll er
is performed to slave controller. As it were, th e port RC3
is served for SRDYOUT.
The buzzer driver consists of 6-bit binary counter, the
buzzer register BUR and the clock se lector. It generates
square-wave w hich is very wide range frequency (480
Hz~250 KHz at fxin = 4 MHz) by user programmable
counter.
Pin RB1 is assigned for output port of Buzzer driver by setting the bit BUZO of RBFUNC to “1”.
The 6-bit buzzer counter is cleared and start the counting
by writing signal to the register BUR. It is increased from
00H until it matches 6-bit register BUR.
BUR
fxinMUX
BUCK1BUCK0BUR5BUR4BUR3BUR2BUR1BUR0
Input clock selection
8
÷
16
÷
32
÷
64
÷
BUCK[1:0]
÷
16
÷
32
÷
64
÷
00 : fxin
01 : fxin
10 : fxin
11 : fxin
8
Buzzer Period Data
COUNTER (6-bit)
BUR (6-bit)
Also, it is cleared by counter overflow and count up to ou tput the square wave pulse of duty 50%.
The bit 0 to 5 of BUR determines output frequency for
buzzer driving. Frequency calculation is following as
shown below.
The bits BUCK1, BUCK0 of BUR selects the source clock
from prescaler output.
ADDRESS : DEH
RESET VALUE : 11111111
Bit Manipulation Not Available
F/F
COMPARATOR
BUZO
[RBFUNC.1]
RB1/BUZ PIN
Figure 15-1 Buzzer Driver
June. 2001 Ver 1.2 53
Page 56
GMS81C1404/GMS81C1408
16. 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 reference voltage is selected to V
or AVref
DD
by setting of the bit AVREFS in RBFUNC register. If external analog reference AVref is selected, the bit ANSEL0
should not be set to “1”, because this pin is used to an analog reference of A/D converter.
The A/D module has two registers which are the control
register ADCM and A/D result register ADCR. The
ADCM register, shown in Figure 16-2 , controls the operation of the A/D converter module. The port pins can be
configure as analog inputs or digital I/O.
ADS[2:0]
RA7/AN7
ANSEL7
RA6/AN6
ANSEL6
RA5/AN5
111
110
101
To use analog inputs, each port is assigned analog input
port by setting the bit ANSEL[7:0] in RAFUNC register.
And selected the corresponding channel to b e converted by
setting ADS[2:0].
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 ADCR contains the results of the A/D
conversion. When the conversion is completed, the result
is loaded into the ADCR, the A/D conversion status bit
ADSF is set to “1”, and the A/D interrupt flag ADIF is set.
The block di agram of the A /D mo dule is shown in Figu re
16-1 . The A/D status bit ADSF is set automatically wh en
A/D conversion is completed, cleared when A/D conversion is in process. The conversion time takes maximum 10
uS (at fxin=8 MHz).
1 : A/D Conversion is enable
0 : A/D Converter module shut off
and consumes no operation current
Figure 16-2 A/D Converter Registers
A/D Converter Cautions
(1) Input range of AN0 to AN7
The input voltage of AN0 to AN7 should be within the
specification range. In particular, if a voltage above
(or AVref)
imum rating range), the conversion value for that channel can not
be indeterminate. The conversion values of t he other channels
may also be affected.
or below V
(2) Noise countermeasures
A/D Status bit
0 : A/D Conversion is in process
1 : A/D Conversion is completed
A/D Start bit
1 : A/D Conversion is started
After 1 cycle, cleared to “0”
0 : Bit force to zero
ADDRESS : EBH
RESET VALUE : Undefined
SS
is input (even if within the absolute max-
VDD
In order to maintain 8-bit resolution, attention must be paid to
A/D START (ADST = 1)
noise on pins AVref(or VDD)and AN0 to AN7. Since
the effect
increases in proportion to the output impedance of the an-
a capacitor be con-
AN0~AN7
NOP
ADSF = 1
NO
YES
READ ADCR
Figure 16-3 A/D Converter Operation Flow
alog input source, it is recommended that
nected externally as shown in Figure 1 6-4 in order to redu ce
noise.
Analog
Input
100~1000pF
Figure 16-4 Analog Input Pin Connecting Capacitor
June. 2001 Ver 1.2 55
Page 58
GMS81C1404/GMS81C1408
(3) Pins AN0/RB0 and AN1/RA1 to AN7/RA7
The analog input pins AN0 to AN7 also function as input/
output port (PORT RA and RB0) pins. When A/D conversion is performed with any of pins AN0 to AN7 selected,
be sure not to execute a PORT input instruction while conversion is in progress, as this may reduce the conversion
resolution.
Also, if digital pulses are applied to a pin adjacent to the
pin in the process of A/D conversion, the expected A/D
conversion value may not be obtainable due to coupling
noise. Therefore, avoid applying pulses to pins adjacent to
the pin undergoing A/D convers ion.
(4) AVref pin input impedance
A series resistor string of approximately 10KΩ is connected be-
tween the AVref
pin and the V
SS
pin.
Therefore, if the output impedance of the reference voltage
SS
pin, and
to the
source is high, this will result in parallel connectio n
series resistor string between the AVref
there will be a large reference voltage error.
pin and the V
56
June. 2001 Ver 1.2
Page 59
17. INTERRUPTS
GMS81C1404/GMS81C1408
The GMS81C1404 and GMS81C1408 interrupt circuits
consist of Interrupt enable registe r (IENH, IENL), Interrupt request flags of IRQH, IRQL, Interrupt Edge Selection Register (IEDS), priority circuit and Master enable
flag(“I” flag of PSW). The configuration of interrupt circuit is shown in Figure 17-1 and Interrupt priority is shown
in Table 17-1 .
The External Interrupts INT0, INT1, INT2 and INT3 can
each be transition-activated (1-to-0, 0-to-1 and both transition).
The flags that actu ally generate these in terrupts are bit
INT0IF, INT1IF, INT2IF and INT3IF in Register IRQH.
When an external interrupt is generated, the flag that gen-
Internal bus line
IENH
External Int. 0
External Int. 1
External Int. 2
External Int. 3
IEDS
Timer 0
Timer 1
IEDS
Timer 2
Timer 3
IRQH
INT0IF
INT1IF
T0IF
T1IF
INT2IF
INT3IF
T2IF
T3IF
7
6
5
4
3
2
1
0
erated it is cleared by the hardware when the service routine is vectored to only if the interrupt was transitio nactivated.
The Timer 0, Timer 1, Timer 2 and Timer 3 Interrupts are
generated by T0IF, T1IF, T2IF an d T3 IF, whi ch are s et by
a match in their respective timer/counter register. The AD
converter Interrupt is generated by ADIF 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 (when the bit WDTON
is set to “0”). The Basic Interval Timer Interrupt is gen erated by BITIF which is set by a overflowing of the B asic
Interval Timer Register(BITR).
I-flag is in PSW, it is cleared by “DI”, set by
“EI” instruction.When it goes interrupt service,
Interrupt Enable
Register (Higher byte)
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.
I Flag
Priority Control
Interrupt Master
Enable Flag
Release STOP
To CPU
A/D Converter
WDT
BIT
SPI
IRQL
ADIF
WDTIF
BITIF
SPIF
7
6
5
5
IENL
Interrupt Enable
Register (Lower byte)
Internal bus line
Interrupt
Vector
Address
Generator
Figure 17-1 Block Diagram of Interrupt Function
June. 2001 Ver 1.2 57
Page 60
GMS81C1404/GMS81C1408
The interrupts are controlled by the interrupt master enable
flag I-flag (bit 2 of PSW), the i nterrupt enable register
(IENH, IENL) an d the interrupt re quest flags (in IRQH,
IRQL) except Power-on reset and software BRK interrupt.
Interrupt enable registers are shown in Figure 17-2 . These
registers are composed of interrupt en able flags o f each interrupt source, 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.
RESET
INT0
INT1
Timer 0
Timer 1
INT2
INT3
Timer 2
Timer 3
A/D C
WDT
BIT
SPI
10
11
12
1
2
3
4
5
6
7
8
9
FFFE
FFFA
FFF8
FFF6
FFF4
FFF2
FFF0
FFEE
FFEC
FFEA
FFE8
FFE6
Table 17-1 Interrupt Priority
ADDRESS : E2H
RESET VALUE : 00000000
ADDRESS : E3H
RESET VALUE : 0000----
H
H
H
H
H
H
H
H
H
H
H
H
Enables or disables the interrupt individually
If flag is cleared, the interrupt is disabled.
0 : Disable
1 : Enable
Interrupt Request Register High
IRQH
IRQL
INT0IFINT1IFT0IFT1IFINT2IFINT3IFT2IFT3IF
Interrupt Req u est Register Low
ADIFWDTIFBITIFSPIF----
Shows the interrupt occurrence
0 : Not occurred
1 : Interrupt request is occurred
Figure 17-2 Interrupt Enable Registers and Interrupt Request Registers
When an interrupt is occurred, the I-flag is cleared and disable any further interrupt, the return address and PSW are
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 request flag bits.
ADDRESS : E4H
RESET VALUE : 00000000
ADDRESS : E5H
RESET VALUE : 0000----
The interrupt request flag bit(s) must be clea red by software before re-enabling interrupts to avoid recursive interrupts. The Interrupt Request flags are able to be read and
written.
58
June. 2001 Ver 1.2
Page 61
17.1 Interrupt Sequence
GMS81C1404/GMS81C1408
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 f
µs at f
=4MHz) after the completion of the current in-
XIN
OSC
(2
struction execution. The interrupt service task is terminated 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 17-3 Timing chart of Interrupt Acceptance and Interrupt Return Instruction
Basic Interval Timer
Vector Table Address
012
0FFE6
H
0FFE7
H
Correspondence between vector table address for BIT interrupt
and the entry address of the interrupt service program.
0E3
H
H
0E312
0E313
Entry Address
0E
H
2E
H
H
H
A interrupt request is not accepted until 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
area for saving registers.
June. 2001 Ver 1.2 59
Page 62
GMS81C1404/GMS81C1408
The following method is used to save/restore the generalpurpose 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
17.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 17-4 .
General-purpose register save/restore using push and pop
instructions;
BRK or
TCALL0
main task
acceptance of
interrupt
interrupt return
INTERRUPT
ROUTINE
interrupt
service task
B-FLAG
=1
BRK
saving
registers
restoring
registers
=0
TCALL0
ROUTINE
17.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.
RETI
RET
Figure 17-4 Execution of BRK/TCALL0
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.
60
June. 2001 Ver 1.2
Page 63
Main Program
service
Occur
TIMER1 interrupt
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.
Occur
INT0
TIMER 1
service
enable INT0
disable other
EI
enable INT0
enable other
INT0
service
GMS81C1404/GMS81C1408
Example: Even though Timer1 interrupt is in progress,
INT0 interrupt serviced without any susp end.
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
Figure 17-5 Execution of Multi Interrupt
June. 2001 Ver 1.2 61
Page 64
GMS81C1404/GMS81C1408
17.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 0E6
The edge detection of external interrupt has three transition
activated mode: rising edge, falling edge, and both edge.
The INT0, INT1,INT2 and INT3 edge are latched into
INT0IF, INT1IF, INT2IF and INT3IF at every machine
cycle. The values are not ac tually polled by the circuitry
until the next machine cycle. If a request is active and conditions are right for it to be ackno wledged, 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 beginning of execution of the first instruction of
the service routine.
H
62
June. 2001 Ver 1.2
Page 65
shows interrupt response timings.
GMS81C1404/GMS81C1408
Interrupt
goes
active
max. 12 f
Interrupt
latched
8 f
OSC
OSC
Interrupt
processing
Interrupt
routine
Figure 17-7 Interrupt Response Timing Diagram
June. 2001 Ver 1.2 63
Page 66
GMS81C1404/GMS81C1408
18. 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 has two types of clock sourc e.
The first type is an on-chip RC oscillator which does not
require any external components. This RC oscillator is separate from the external oscillator of the Xi n pin. It means
that the watchdog timer will run, even if the clock on the
Xin pin of the device has been stopped, for ex ample, by entering the STOP mode.
The other type is a prescaled system clock.
The watchdog timer consists of 7-bit binary counter and
the watchdog timer data register. When the value of 7-bit
binary counter is equal to the lower 7 bits of WDTR, the
interrupt request flag is generated. This can be used as
WDT interrupt or reset the CPU in accordance with the bit
WDTON.
Because the watchdog timer counter is enabled af-
Note:
ter clearing Basic Interval Timer, after the bit WDTON set to “1”, maximum error of tim er is depend on
prescaler ratio of Basic Interval Timer.
The 7-bit binary counter is cleared by setting WDTCL(bit7
of WDTR) and the WDTCL is cleared automatically after
1 machine cycle.
The RC oscillated watchdog timer is activated by setting
the bit RCWDT as shown below.
:
LDMCKCTLR,#3FH; enable the RC-osc WDT
LDMWDTR,#0FFH; set the WDT period
STOP; enter the STOP mode
NOP
NOP; RC-osc WDT running
:
The RC oscillation period is vary with temperature, V
DD
and process variations fr om part to part (approximately ,
40~120uS). The following equation shows the RC os cillated watchdog timer time-out.
T
RCWDT
=CLK
RC
×28×[
WD TR.6~0]+(CLK
RC
×28)/2
where, CLKRC = 40~ 120uS
In addition, this watchdog timer can be used as a simple 7bit timer by interrupt WDTIF. The interval of watchdog
timer interrupt is decided by Basic Interval Timer. Interval
equation is as below.
T
= [WDTR.6~0] ×× Interval of BIT
WDT
Clock Control Register
CKCTLR
Watchdog Timer Register
WDTR
8
÷
16
÷
32
fxin
÷
÷
÷
÷
÷
÷
8
64
128
256
512
1024
Internal RC OSC
-
WAKEUP RCWDT WDTON
-
WDTCL7-bit Watchdog Counter Register
BTS[2:0]
3
MUX
0X1
RCWDT
BTCL
0
1
Clear
BITR (8-bit)
BTCLBTS2BTS1BTS0
XXXX
WDTR (8-bit)
7-bit Counter
BITIF
Figure 18-1 Block Diagram of Watchdog Timer
WDTCLWDTON
OFD
Overflow Detection
Basic Interval Timer
Interrupt
ADDRESS : ECH
RESET VALUE : -0010111
Bit Manipulation Not Available
ADDRESS : EDH
RESET VALUE : 01111111
Bit Manipulation Not Available
1
CPU RESET
0
Watchdog Timer
Interrupt Request
64
June. 2001 Ver 1.2
Page 67
19. Power Saving Mode
GMS81C1404/GMS81C1408
For applications where power consumption is a critical
factor, device provides two kinds of pow er saving functions, STOP mode and Wake-up Timer mode.
The power saving function is activated by execution of
PeripheralSTOPWake-up Timer
RAMRetainRetain
Control RegistersRetainRetain
I/O PortsRetainRetain
CPUStopStop
Timer0, Timer2StopOperation
OscillationStopOscillation
PrescalerStop
Entering Condition
[WAKEUP]
Release Sources
RESET, RCWDT, INT0~3,
01
EC0~1, SPI
Table 19-1 Power Saving Mode
19.1 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, port direction registers. Oscillator stops and the systems internal
operations are all held up.
• The states of the RAM, registers, and latches valid
immediately before the system is put in the STOP
state are all held.
• The program counter stop the address of the
instruction to be executed after the instruction
“STOP” which starts the STOP operating mode.
The Stop mode is activated by execution of STOP instruction after clearing the bit WAKEUP of CKCTLR
to “0”. (This register should be written by byte operation. If this register is set by bit manipulation instruction, for example “set1” or “clr1” instruction, it may be
undesired operation)
In the Stop mode of operation, V
imize power consumption. Care must be taken, however,
to ensure that V
invoked, and that V
is not reduced before the Stop mode is
DD
is restored to its normal op erating
DD
level, before the Stop mode is terminated.
can be reduced to min-
DD
STOP instruction after setting the corresponding status
(WAKEUP) of CKCTLR.
Table 19-1 shows the status of each Power Saving Mode.
2048 only
÷
RESET, RCWDT, INT0~3,
EC0~1, SPI, TIMER0, TIMER2
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.
Note: After STOP instruction, at least two or more NOP in -
struction should be written
Ex)LDM CKCTLR,#0000_1110B
STOP
NOP
NOP
In the STOP operation, the dissipation of the power associated with the oscillator and the internal hardware is lowered; however, the power dis sipation associated with the
pin interface (depending on the external circuitry and program) is not directly determined by the hardware operation
of the STOP feature. This point should be little current
flows when the input level is stable at the power voltage
level (V
DD/VSS
); however, when the input level gets high-
er than the power voltage level (by approximately 0.3 to
0.5V), a current begins to flow. Therefore, if cutting off the
output transistor at an I/O port puts the pin signal in to the
high-impedance state, a current flow across the ports input
transistor, requiring to fix the level by pull-up or other
means.
June. 2001 Ver 1.2 65
Page 68
GMS81C1404/GMS81C1408
Release the STOP mode
The exit from STOP mode is hardware reset or external interrupt. Reset re-defines all the Control registers but do es
not change the on-chip RAM. Extern al 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 no t
vector to interrupt service routine. (refer to Figure 19-1 )
By reset, exit from Stop mode is shown in Figure 19-3
.When exit from Stop mode by external interrupt, enough
oscillation stabilization time is required to nor mal operation. Figure 19-2 shows th e timin g di agram. When release
the Stop mode, the Basic interval timer is activated on
wake-up. It is increased from 00
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 oscillator has started and stabilized..
until FFH . The count
H
STOP
INSTRUCTION
Corresponding Inte rr upt
Enable Bit (IENH, IENL)
Enable Bit PSW[2]
Next
INSTRUCTION
Master Interrupt
STOP Mode
Interrupt Request
IEXX
=1
STOP Mode Release
I-FLAG
=1
Interrupt Service Routine
=0
=0
Oscillator
(X
pin)
IN
Internal
Clock
External
Interrupt
BIT
Counter
N-1
N-2
Normal Operation
Figure 19-2 Timing of STOP Mode Release by External Interrupt
~
~
~
~
~
~
STOP Instruction Execution
N+1NN+2
STOP ModeNormal Operation
Figure 19-1 STOP Releasing Flow by Interrupts
~
~
~
~
~
~
~
~
Clear Basic Interval Timer
~
~
0001FE FF 0000
Stabilizing Time
t
ST
~
~
> 20mS
66
June. 2001 Ver 1.2
Page 69
GMS81C1404/GMS81C1408
STOP Mode
Oscillator
(X
pin)
IN
Internal
Clock
RESET
Internal
RESET
STOP Instruction Execution
Time can not be control by software
Figure 19-3 Timing of STOP Mode Release by RESET
~
~
~
~
~
~
~
~
19.2 STOP Mode using Internal RCWDT
In the STOP mode using Internal RC-Oscillated Watchdog
Timer, the on-chip oscillator is stopped. But internal RC
oscillation circuit is oscillated in this mode. The on-chip
RAM and Control registers are held. The port pins out the
values held by their respective port data register, port direction registers.
The Internal RC-Oscillated Watchdog Timer mode i s
activated by execution of STOP instruction afte r setting the bit RCWDT of CKCTLR to “1”. ( This register
should be written by byte operation. If this register is
set by bit manipulation instruction, for example “set1”
or “clr1” instruction, it may be undesired operation )
Note: After STOP instruction, at least two or more NOP in-
struction should be written
Ex)
Release the STOP mode using internal RCWDT
The exit from STOP mode using Internal RC-Oscillated
Watchdog Timer is hardwa re reset or external interrupt.
Reset re-defines all the Control registers but does not
change the on-chip RAM. External interrupts allow both
LDM WDTR
LDM CKCTLR
STOP
NOP
NOP
,#1111_1111B
,#0010_1110B
~
~
~
~
~
~
~
~
~
~
Stabilizing Time
t
= 64mS @4MHz
ST
on-chip RAM and Control registers to retain their valu es.
If I-flag = 1, the normal interrupt response takes place. In
this case, if the bit WDTON of CKCTLR is set to “0” and
the bit WDTE of IENH is set to “1”, the device will execute the watchdog timer interrupt service routine.(Figure
19-4 ) However, if the bit WDTON of CKCTLR is set to
“1”, the device will generate the internal RESET signal
and execute the reset processing. (Figure 19-5 )
If I-flag = 0, the chip will resume execution starting wi th
the instruction following the STOP instruction. It wil l not
vector to interrupt service routine.( refer to Figure 19-1 )
When exit from STOP mode using Internal RC-Oscillated
Watchdog Timer by external interrupt, th e oscillati on stabilization time is required to no rmal op erati on. Figu re 194 shows the timing diagram. When release the Internal
RC-Oscillated Watchdog Timer mode, the basic interval
timer is activated on wake-up. It is increased from 00
til FF
. The count overflow is set to start normal opera-
H
H
un-
tion. Therefore, before STOP instruction, user must be set
its relevant prescaler divide ratio to have l ong enough time
(more than 20msec). This guarantees that oscillator has
started and stabilized.
By reset, exit from STOP mode using internal RC-Oscillated Watchdog Timer is shown in Figure 19-5 .
June. 2001 Ver 1.2 67
Page 70
GMS81C1404/GMS81C1408
Oscillator
pin)
(X
IN
Internal
RC Clock
Internal
Clock
External
Interrupt
(or WDT Interrupt)
BIT
Counter
N-2
N-1
~
~
~
~
~
~
STOP Instruction Execution
N+1NN+2
~
~
~
~
~
~
~
~
Clear Basic Interval Timer
~
~
0001FE FF 0000
~
~
Figure 19-4 STOP Mode Releasing by External Interrupt or WDT Interrupt(using RCWDT)
Oscillator
(X
pin)
IN
Internal
RC Clock
Internal
Clock
RESET
RESET by WDT
Internal
RESET
Normal Operation
STOP ModeNormal Operation
STOP Mode
~
~
~
~
~
~
~
~
STOP Instruction Execution
Time can not be control by software
Stabilizing Time
> 20mS
t
ST
~
~
~
~
~
Stabilizing Time
= 64mS @4MHz
t
ST
~
~
~
~
~
Figure 19-5 STOP Mode Releasing by RESET(using RCWDT)
19.3 Wake-up Timer Mode
In the Wake-up Timer mode, the on-chip oscillator is not
stopped. Except the Prescaler(only 2048 devided ratio),
Timer0 and Timer2, all functions are stopped, but the onchip RAM and Control registers are held. The port pins o ut
the values held by their respective port data register, port
direction registers.
68
The Wake-up Timer mode i s ac tivate d by execu tion of
STOP ins truction af ter setting the bit WAK EUP of
CKCTLR to “1”. (This register should be written by
byte operation. If this register is set by bit manipulation
instruction, for example “set1” or “clr1” instruction, it
may be undesired operation)
June. 2001 Ver 1.2
Page 71
GMS81C1404/GMS81C1408
Note: After STOP instruction, at least two or more NOP in-
In addition, the clock source of timer0 and timer2 should
be selected to 2048 devided ratio. Otherwise, the wake-up
function can not work. And the timer0 and timer2 can be
operated as 16-bit timer with timer1 and timer3(refer to
timer function). The period of wake-up function is varied
by setting the timer data register0, TDR0 or timer data
register2, TDR2.
~
Oscillator
(X
pin)
IN
CPU
Clock
Interrupt
Request
STOP Instruction
Execution
Normal Operation
~
~
~
~
~
~
~
Wake-up Timer Mode
(stop the CP U clock)
Release the Wake-up Timer mode
The exit from Wak e-up Timer mode is hardw are reset,
Timer0(Timer2) overflow or external interrupt. Reset redefines all the Contro l registers bu t does not chang e the onchip RAM. External interrupts and Timer0(Timer2) overflow allow both on-chip RAM and Control registers to retain their values.
If I-flag = 1, the normal interrupt response takes place. If Iflag = 0, the chip will resume execution starting with the
instruction following the STOP instruction. It will not vector to interrupt service routine.(refer to Figure 19-1 )
When exit from Wake-up Timer mode by external interrupt or timer0(Timer2) overflow, the oscillation stabilizing
time is not required to normal operation. Because this
mode do not stop the on-chip oscillator shown as Figure
19-6 .
Normal Operation
Do not need Stabilizing Time
Figure 19-6 Wake-up Timer Mode Releasing by External Interrupt or Timer0(Timer2) Interrupt
19.4 Minimizing Current Consumption
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 asso-
ciated with the oscillator and the internal hardware
is lowered; however, the power dissipation as sociated with the pin interface (depending on the external
circuitry and program) is not directly determined by
the hardware operation of the STOP featu re. This
point should be little current flows when the input
level is stable at the power voltage level (V
however, when the in put lev el bec om es higher than
the power voltage level (by approximately 0.3V), a
current begins to f low. Therefore, if cutting off the
output transistor at an I/O port puts the pin signal
into the high-impe dance state, a curre nt flow acro ss
the ports input transistor, requiring it to fix the level
by pull-up or other means.
DD/VSS
It should be set properly that current flow through 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 uncertain 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
is external pull-down register, it is set to low.
June. 2001 Ver 1.2 69
Page 72
GMS81C1404/GMS81C1408
INPUT PIN
internal
V
DD
i
pull-up
GND
X
Weak pull-up current flows
Figure 19-7 Application Example of Unused Input Port
V
V
DD
V
DD
O
V
DD
OPEN
O
INPUT PIN
i=0
OPEN
i
Very weak current flows
X
When port is configure as an input, input level should
be closed to 0V or 5V to avoid power consumption.
i=0
DD
O
GND
O
OUTPUT PIN
ON
ON
OFF
i
GND
X
In the left case, much current flows from port to GND.
OFF
ON
OFF
Figure 19-8 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 consumption, ther e should be low output
to the port.
L
OFF
ON
GND
O
i=0
GND
V
DD
L
70
June. 2001 Ver 1.2
Page 73
20. RESET
GMS81C1404/GMS81C1408
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 4 MHz) add with
7 oscillator periods are required to start execution as shown
in Figure 20-1 .
~
Oscillator
pin)
(X
IN
~
RESET
~
ADDRESS
BUS
DATA
BUS
?
?
t
~
Stabilizing Time
= 64mS at 4MHz
ST
Figure 20-1 Timing Diagram after RESET
Internal RAM is not affected by reset. W hen V
is turned
DD
on, the RAM content is in determinate. Therefore, this
RAM should be initialized before reading or testing it.
Initial state of each register is shown as Table 9-1 .
~
1234567
~
~
??
~
~
~
~
~
?
??
RESET Process Step
FFFE FFFF
FE?ADL
ADH
Start
OP
MAIN PROGRAM
June. 2001 Ver 1.2 71
Page 74
GMS81C1404/GMS81C1408
21. POWER FAIL PROCESSOR
The GMS81C1404 and GM S81C1408 has an 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 V
falls below 2.5~3.5V(2.0~3.0V) range for
DD
longer than 50 nS, the Power fail situation may reset MCU
according to PFS bit of PFDR. And power fail dete ct level
is selectable by mask option. On the other hand, in the
OTP, power fail detect level is decided by setting the bit
PFDLEVEL of CONFIG register when program the OTP.
As below PFDR register is not implemented on the in-cir-
Power Fail Detector Register
PFDR
--
-
Reserved
--
cuit emulator, user can not experiment with it. Therefore,
after final development of user program, this function may
be experimented.
Power fail detect level is decided by mask option
Note:
checking the bit PFDLEVEL of MASK ORDER
SHEET (refer to MASK ORDER SHEET)
In thc case of OTP, Po wer fa il d ete ct level is decided by setting the b it PFDLEVEL o f CONFIG regis ter
(refer to Figure 22-1 .
PFDISPFDMPFS
ADDRESS : EFH
RESET VALUE : -----100
Power Fail Status
0 : Normal Operate
1 : This bit force to “1” when
Power fail was detected
Operation Mode
0 : System Clock Freeze during power fail
1 : MCU will be reset during power fail
Disable Flag
0 : Power fail detection enable
1 : Power fail detection disable
Figure 21-1 Power Fail Detector Registe r
RESET VECTOR
PFS =1
NO
RAM CLEAR
INITIALIZE RAM DATA
INITIALIZE ALL PORTS
INITIALIZE REGISTERS
FUNTION
EXECUTION
YES
Skip the
initial routine
Figure 21-2 Example S/W of RESET by Power fail
72
June. 2001 Ver 1.2
Page 75
When PFDM = 1
When PFDM = 0
V
DD
Internal
RESET
V
DD
Internal
RESET
V
DD
Internal
RESET
V
DD
System
Clock
V
DD
System
Clock
t < 64mS
64mS
64mS
64mS
GMS81C1404/GMS81C1408
PFVDDMAX
PFV
MIN
DD
MAX
PFV
DD
PFV
MIN
DD
MAX
PFV
DD
MIN
PFV
DD
PFVDDMAX
PFV
MIN
DD
MAX
PFV
DD
PFV
MIN
DD
Figure 21-3 Power Fail Processor Situations
June. 2001 Ver 1.2 73
Page 76
GMS81C1404/GMS81C1408
22. OTP PROGRAMMING (GMS87C1404/GMS87C1408 only)
22.1 DEVICE CONFIGURATION AREA
The Device Configuration Area can be programm ed or left
unprogrammed to select device configuration such as security bit.
Ten memory lo c atio ns (0F 50
0F50
H
DEVICE
CONFIGURATION
AREA
0FF0
H
~ 0FE0H) are designated as
H
0F50
ID
ID
ID
ID
ID
ID
ID
ID
ID
ID
CONFIG
0F60
0F70
0F80
0F90
0FA0
0FB0
0FC0
0FD0
0FE0
0FF0
H
H
H
Configuration Register
H
CONFIG
H
H
H
H
H
H
H
-
Customer ID recording locations where the user can store
check-sum or other customer identification numbers.
This area is not accessible during normal execution but is
readable and writable during program / verify.
X- register auto-increment : A ← ( M ) , X ← X + 1
Load memory with immediate data : ( M ) ← imm
Load X-register
X ← ( M )
Load Y-register
Y ← ( M )
Store accumulator contents in memory
( M ) ← A
X- register auto-increment : ( M ) ← A, X ← X + 1
Store X-register contents in memory
( M ) ← X
Store Y-register contents in memory
( M ) ← Y
Transfer accumulator contents to X-register : X ← A
Transfer accumulator contents to Y-register : Y ← A
Transfer stack-pointer contents to X-register : X ← sp
Transfer X-register contents to accumulator: A ← X
Transfer X-register contents to stack-pointer: sp ← X
Transfer Y-register contents to accumulator: A ← Y
Exchange X-register contents with accumulator :X ↔ A
Exchange Y-register contents with accumulator :Y ↔ A
Exchange memory contents with accumulator
( M ) ↔ A
Exchange X-register contents with Y-register : X ↔ Y
OPERATION
FLAG
NVGBHIZC
N-----Z-
--------
N-----Z-
N-----Z-
--------
--------
--------
N-----ZN-----ZN-----ZN-----ZN-----ZN-----Z-
--------
--------
N-----Z-
--------
iv
.June. 2001 Ver 1.2
Page 87
3. 16-BIT OPERATION
NO.MNEMONIC
1ADDW dp1D25
2CMPW dp5D24
3DECW dpBD26
4INCW dp9D26
5LDYA dp7D25
6STYA dpDD25
7SUBW dp3D25
4. BIT MANIPULATION
NO.MNEMONIC
1
AND1 M.bit
2
AND1B M.bit
3
BIT dp
4
BIT !abs
5
CLR1 dp.bit
6
CLRA1 A.bit
7
CLRC
8
CLRG
9
CLRV
10
EOR1 M.bit
11
EOR1B M.bit
12
LDC M.bit
13
LDCB M.bit
14
NOT1 M.bit
15
OR1 M.bit
16
OR1B M.bit
17
SET1 dp.bit
18
SETA1 A.bit
19
SETC
20
SETG
21
STC M.bit
22
TCLR1 !abs
23TSET1 !abs3C36
GMS81C1404/GMS81C1408
OP
BYTENOCYCLE
CODE
OP
BYTENOCYCLE
CODE
8B34Bit A ND C-flag : C ← ( C ) ∧ ( M .bit )
8B34Bit A ND C-flag and NOT : C ← ( C ) ∧ ~( M .bit )
0C24Bit test A with memory :
1C35
y124Clear bit : ( M.bit ) ← “0”
2B22Clear A bit : ( A.bit )← “0”
2012Clear C-flag : C ← “0”
4012Clear G-flag : G ← “0”
8012Clear V-flag : V ← “0”
AB35Bit exclusive-OR C-flag : C ← ( C ) ⊕ ( M .bit )
AB35Bit exclusive-OR C-flag and NOT : C ← ( C ) ⊕ ~(M .bit)
CB34Load C-flag : C ← ( M .bit )
CB34Load C-flag with NOT : C ← ~( M .bit )
4B35Bit c omplem ent : ( M .bit ) ← ~( M .bit )
6B35Bit OR C-flag : C ← ( C ) ∨ ( M .bit )
6B35B it OR C-flag and NOT : C ← ( C ) ∨ ~( M .bit )
x124Set bit : ( M.bit ) ← “1”
0B22Set A bit : ( A.bit ) ← “1”
A012Set C-flag : C ← “1”
C012Set G-flag : G ← “1”
EB36Store C-flag : ( M .bit ) ← C
5C36
NO
16-Bits add without carry
YA ← ( YA ) + ( dp +1 ) ( dp )
Compare YA contents with memory pair contents :
(YA) − (dp+1)(dp)
16-Bits substact without carry
YA ← ( YA ) - ( dp + 1) ( dp)
NO
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 )
OPERATION
OPERATION
) , 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-
June. 2001 Ver 1.2 v
Page 88
GMS81C1404/GMS81C1408
5. BRANCH / JUMP OPERATION
NO.MNEMONIC
1
BBC A.bit,rel
2
BBC dp.bit,rel
3
BBS A.bit,rel
4
BBS dp.bit,rel
5
BCC rel
6
BCS rel
7
BEQ rel
8
BMI rel
9
BNE rel
10
BPL rel
11
BRA rel
12
BVC rel
13
BVS rel
14
CALL !abs
15
CALL [dp]
16
CBNE dp,rel
17
CBNE dp+X,rel
18
DBNE dp,rel
19
DBNE Y,rel
20
JMP !abs
21
JMP [!abs]
22
JMP [dp]
23
PCALL upage
24
TCALL n
CODE
OP
BYTENOCYCLE
NO
y224/6
y335/7
x224/6
x335/7
5022/4
D022/4
F022/4
9022/4
7022/4
1022/4
2F24
3022/4
B022/4
3B38
5F28
FD35/7
8D36/8
AC35/7
7B24/6
1B33
1F35
3F24
4F26
nA18
OPERATION
Branch if bit clear :
if ( bit ) = 0 , then pc ← ( pc ) + rel
Branch if bit set :
if ( bit ) = 1 , then pc ← ( pc ) + rel
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
Subroutine call
M( sp)←( pc
if !abs, pc← abs ; if [dp], pc
), sp←sp - 1, M(sp)← (pcL), sp ←sp - 1,
H
( dp ), pc
←
L
Compare and branch if not equal :
if ( A ) ≠ ( M ) , then pc ← ( pc ) + rel.
Decrement and branch if not equal :
if ( M ) ≠ 0 , then pc ← ( pc ) + rel.
Unconditional jump
pc ← jump address