Additional information of this manual may be served by HYNIX Semiconductor offices in Korea or Distributors and Representatives listed at address directory.
HYNIX Semiconductor reserves the right to make changes to any information here in at any time without notice.
The information, diagrams and other data in this manual are correct and reliable; however, HYNIX Semiconductor is in no
way responsible for any violations of patents or other rights of the third party generated by the use of this manual.
Instruction Set ....................................................v
C. MASK ORDER SHEET........................xi
Page 6
Page 7
GMS81C2112/GMS81C2120
GMS81C2112/GMS81C2120
CMOS Single-Chip 8-Bit Microcontroller
with A/D Converter & VFD Driver
1. OVERVIEW
1.1 Description
The GMS81C2112 and GMS81C2120 are advanced CMOS 8-b it micro contr oller with 12 K/20K bytes of ROM. Thes e are a
powerful microcontroller which provides a highly flexible and cost effective solution to many VFD applications. These provide the following standard features: 12K/20K bytes of ROM, 448 bytes of RAM, 8-bit timer/counter, 8-bit A/D converter,
10-bit High Speed PWM Output, Programmable Buzzer Driving Port, 8-bit Basic Interval Timer, 7-bit Watch dog Timer,
Serial Peripheral Interface, on-chip oscillator and clo ck circuitry. They also come with h igh voltage I/O p ins that can dir ectl y
drive a VFD (Vacuum Fluores cent Displ ay). I n addit ion, t he GMS81C21 12 and GMS 81C212 0 suppor t po wer saving modes
to reduce power consumption.
Device nameROM SizeRAM SizeOTPPackage
GMS81C211212K bytes
GMS81C212020K bytesGMS87C2120
1.2 Features
• 20K/12K bytes ROM(EPROM)
• 448 Bytes of On-Chip Data RAM
(Including STACK Area)
• 8-Channel 8-bit On-Chip Analog to Digital Converter
• Oscillator:
- Crystal
- Ceramic Resonator
- External R Oscillator
• Low Power Dissipation Modes
- STOP mode
- Wake-up Timer Mode
- Standby Mode
• Operating Voltage: 2.7V ~ 5.5V (at 4.5MHz)
• Operating Frequency: 1MHz ~ 4.5MHz
• Enhanced EMS Improvement
Power Fail Processor
(Noise Immunity Circuit)Enhanced EMS
Improvement
Power Fail Processor
(Noise Immunity Circuit)
42SDIP, 44MQFP,
40PDIP
• Eight Interrupt Sources
- Two External Sources (INT0, INT1)
- Two Timer/Counter Sources (Timer0, Timer1)
- Four Functional Sources (SPI,ADC,WDT,BIT)
JUNE. 2001 Ver 1.001
Page 8
GMS81C2112/GMS81C2120
1.3 Development Tools
The GMS81C21xx are supported by a full-featured macro
assembler, an in-circuit emulator CHOICE-Dr.
TM
and
OTP programmers. There are third diffe rent type program mers such as emulator add-on board type, single type, gang
type. For mode detail, Refer to “21. OTP PROGRAMMING” on page 83. Macro assembler operates under the
MS-Windows 95/98
: Supply voltage to the ladder resistor of ADC circuit. To enhance the resolution of analog to digital converter, use independent po wer source as wel l as poss ible, oth er
than digital power source.
SS
AV
: ADC circuit ground.
RESET
X
: Reset the MCU.
IN
: Input to the inverting oscillator amplifier and input to
the internal clock operating circuit.
OUT
X
: Output from the inverting oscillator amplifier.
RA(V
In addition, RA serves the functions of the V
features. V
)
: RA is one-bit high-voltage input only port pin.
disp
is used as a high-voltage i nput power supply
disp
disp
special
pin when selected by the mask option.
Port pinAlternate function
V
RA
R00~R07
: R0 is an 8-bit hi gh-voltage CMOS bidir ectional
(High-voltage input power supply)
disp
I/O port. R0 pins 1 or 0 written to the Port Direction Register can be used as outputs or inputs. In addition, R0
serves the functions of the various following special features.
: R2 is an 8-bit high-voltage CMOS bidirectional
I/O port. R2 pins 1 or 0 writt en to th e Port Direction R eg ister can be used as outputs or inputs.
R30~R34
: R3 is a 5-bit high-voltage CMOS bidirectional
I/O port. R3 pins 1 or 0 writt en to th e Port Direction R eg ister can be used as outputs or inputs.
R53~R57
: R5 is an 5-bit CMOS bidirectional I/O port. R5
pins 1 or 0 written to the Port Direction Register can be
used as outputs or inputs. In addition, R5 serves the functions of the various following special features.
Port pinAlternate function
R53
R54
R55
R56
R60~R67
SCLK (Serial clock)
SIN (Serial data input)
SOUT (Serial data output)
PWM1O (PWM1 Output)
T1O (Timer/Counter 1 output)
: R6 is an 8-bit CMOS bidirectional I/O port. R6
pins 1 or 0 written to the Port Direction Register can be
used as outputs or inputs. In addition, R6 is shared with the
ADC input.
Serial clock source
R54 (SIN)I/O (I)Serial data input
R55 (SOUT)I/O (O)Serial data output
R56 (PWM1O/T1O)I/O (O)
5-bit high-voltage I/O ports
PWM 1 pulse output /Timer/Counter 1 out-
put
R57I/O
R60~R67 (AN0~AN7)I/O (I)8-bit general I/O portsAnalog voltage input
DD
AV
AV
V
V
SS
DD
SS
-Supply voltage input pin for ADC
-Ground level input pin for ADC
-Supply voltage
-Circuit ground
Table 5-1 GMS81C2120 Port Function Description
JUNE. 2001 Ver 1.009
Page 16
GMS81C2112/GMS81C2120
Data Bus
V
DD
V
SS
Pin
Data Reg.
Direction
Reg.
Rd
MUX
Selection
SCLK Output
SCLK Input
V
DD
Mask
N-MOS
Open Drain Select
Option
Pull-up
Tr.
Data Bus
V
DD
V
SS
Pin
Data Reg.
Direction
Reg.
Rd
Selection
SIN Input
V
DD
Mask
N-MOS
Open Drain Select
Option
Pull-up
Tr.
6. PORT STRUCTURES
R57
Data Reg.
Dir.
Reg.
Data Bus
MUX
Rd
R00/INT0, R01/INT1, R02/EC0
Selection
Data Reg.
Data Reg.
Dir.
Reg.
Data Bus
Rd
V
DD
VSS
V
DD
Mask
Option
Pull-up
Tr.
Mask
Option
V
DD
R53/SCLK
Pin
R54/SIN
Pin
EX) INT0
Alternate Function
Vdisp
10JUNE. 2001 Ver 1.00
Page 17
GMS81C2112/GMS81C2120
RESET
V
DD
V
SS
OTP :disconnected
Main :connected
XOUT
V
DD
XIN
Stop
Mainclk Off
V
SS
Pin
Data Reg.
Dir.
Rd
V
DD
Vdisp
Reg.
Data Bus
MUX
MUX
Selection
Data Reg.
Secondary
Function
Mask
Option
R55/SOUT
SOUT output
Data Reg.
Direction
Reg.
IOSWB
Data Bus
IOSWIN Input
RA/Vdisp
Rd
Selection
MUX
N-MOS
Open Drain Select
RESET
V
DD
Pull-up
Tr.
Mask
Option
V
DD
Pin
V
SS
V
DD
XIN, XOUT
Data bus
Rd
Vdisp
Mask
Option
R03/BUZO
R04~R07, R20~R27, R30~R34
V
DD
Data Reg.
Mask
Dir.
Reg.
Data Bus
Rd
MUX
Option
Vdisp
Pin
JUNE. 2001 Ver 1.0011
Page 18
GMS81C2112/GMS81C2120
R56/PWM1O/T1O
Selection
SOUT output
MUX
Data Reg.
Direction
Reg.
Data Bus
R60~R67/AN0~AN7
Data Reg.
N-MOS
Open Drain Select
Rd
V
DD
Pull-up
Tr.
Mask
Option
V
DD
Pin
V
SS
V
DD
Pull-up
Tr.
Mask
V
DD
Option
Direction
Reg.
Data Bus
A/D
Converter
Analog
Input Mode
A/D Ch.
Selection
Rd
Pin
V
SS
12JUNE. 2001 Ver 1.00
Page 19
7. ELECTRICAL CHARACTERISTICS
7.1 Absolute Maximum Ratings
GMS81C2112/GMS81C2120
Supply voltage.............................................-0.3 to +7.0 V
Storage Temperature ....................................-40 to +85 °C
Voltage on Normal voltage pin
with respect to Ground (V
..............................................................-0.3 to V
SS
)
+0.3 V
DD
Voltage on High voltage pin
with respect to Ground (V
............................................................-45V to V
Maximum current out of V
Maximum current into V
Maximum current sunk by (I
)
SS
DD
pin..........................150 mA
SS
pin ..............................80 mA
DD
per I/O Pin) ..........20 mA
OL
+0.3 V
7.2 Recommended Operating Conditions
ParameterSymbolCondition
Supply Voltage
Operating Frequency
Operating Temperature
T
V
f
DD
XIN
OPR
fXI = 4.5 MHz
VDD = V
Maximum output current sourced by (I
per I/O Pin)
OH
............................. ...... ................................................ 8 mA
Maximum current (ΣI
Maximum current (ΣI
Note:
Stresses above those listed under “Absolute Maximum Ratings” may cause per manent damage to the d evice. This is a stress ra ting only and functional ope r ati on of
the device at any oth er c ond iti ons ab ov e tho se ind ic ated in
the oper ati o na l se c ti ons of this s pecificatio n i s no t i mp l ie d .
Exposure to absolute maximum rating conditions for extended periods may affect device reliability.
Min.Max.
2.75.5V
DD
-4085
)......................................100 mA
OL
)........................................50 mA
OH
Specifications
14.5MHz
Unit
°
C
7.3 A/D Converter Characteristics
(TA=25°C, VDD=5V, VSS=0V, AVDD=5.12V, AVSS=0V @
ParameterSymbolCondition
Analog Power Supply Input Voltage Range
Analog Input Voltage Range
Current Following
Between AV
DD
and
AV
SS
Overall Accuracy
Non-Linearity Error
Differential Non-Linearity Error
Zero Offset Error
Full Scale Error
Gain Error
Conversion Time
1. Data in “T yp” column is at 25°C unless otherwise stated. These parameters are for design guidance only and are not tested.
AV
V
I
AVDD
CA
N
N
DNLE
N
N
N
T
CONV
DD
AN
IN
NLE
ZOE
FSE
NLE
=4MHz)
f
XIN
f
XIN
=4MHz
Specifications
AV
Min.
AV
SS
SS
-0.3
Typ.
1
AV
Max.
AV
DD
DD
+0.3
--200uA
--±2LSB
--±2LSB
--±2LSB
--±2LSB
--±2LSB
--±2LSB
--20us
Unit
V
V
JUNE. 2001 Ver 1.0013
Page 20
GMS81C2112/GMS81C2120
DC Electrical Characteristics for Standard Pins(5V)
7.4
(VDD = 5.0V ± 10%, V
= 0V, TA = -40 ~ 85°C, f
SS
= 4 MHz, Vdisp = VDD-40V to VDD)
XIN
,
Specification
ParameterPinSymbolTest Condition
Min
XIN
Input High Voltage
RESET,SIN,R55,SCLK,
&
1,EC0
INT0
R53~R57,R6
XIN
,SIN,,R55,SCLK,
Input Low Voltage
RESET
&
INT0
1,EC0
R53~R57,R6
Output High
Voltage
Output Low
Voltage
Input High
Leakage Current
Input Low
Leakage Current
Input Pull-up
Current(*Option)
Power Fa il
Detect Voltage
Current dissipation
in active mode
Current dissipation
in standby mode
Current dissipation
in stop mode
Hysteresis
Internal RC WDT
Frequency
RC Oscillation
Frequency
1. Data in “Typ.” column is at 4.5V, 25°C unless otherwise stated. These parameters are for design guidance only and are not tested.
R53~R57,R6,BUZO,
PWM1O/T1O,SCLK,SOUT
R53~R57,R6,BUZO,
PWM1O/T1O,SCLK,SOUT
R53~R57,R6
R53~R57,R6
R53~R57,R6
V
DD
V
DD
V
DD
V
DD
,SIN,R55,SCLK,
RESET
,
INT1,EC0
INT0
XOUT
XOUT
V
V
V
V
V
V
V
V
OL1
V
OL2
I
IH1
I
IL1
I
PU
V
PFD
I
DD
I
STBY
I
STOP
V
T+~VT-
T
RCWDT
f
RCOSC
IH1
IH2
IH3
IL1
IL2
IL3
OH
External Clock
External Clock-0.3
I
= -0.5mAVDD-0.5
OH
I
= 1.6mA
OL
I
= 10mA
OL
XIN
f
=4.5MHz8mA
XIN
f
=4.5MHz3mA
XIN
f
=Off
SXIN
=32.7KHz
f
R= 120K
0.9V
DD
0.8V
DD
0.7V
DD
-0.3
-0.3
-1uA
50100180uA
0.4V
830KHz
Ω
1.522.5MHz
1
Typ.
Max
VDD+0.3
VDD+0.3
VDD+0.3
0.1V
DD
0.2V
DD
0.3V
DD
0.4
2
1uA
2.7V
10uA
Unit
V
V
V
V
14JUNE. 2001 Ver 1.00
Page 21
7.5 DC Electrical Characteristics for High-Voltage Pins
GMS81C2112/GMS81C2120
(VDD = 5.0V ± 10%, V
= 0V, TA = -40 ~ 85°C, f
SS
= 4 MHz, Vdisp = VDD-40V to VDD)
XIN
Specification
ParameterPinSymbolTest Condition
Input High Voltage R0,R2,R30~R34,RA
Input Low VoltageR0,R2,R30~R34,RA
Output High
Voltage
Output Low
Voltage
Input High
Leakage Current
Input Pull-down
Current(*Option)
R0,R2,R30~R34
R0,R2,R30~R34
R0,R2,R30~R34,RA
R0,R2,R30~R34
Input High Voltage R0,R2,R30~R34,RA
1. Data in “Typ.” column is at 4.5V, 25°C unless otherwise stated. These parameters are for design guidance only and are not tested.
V
IH
V
IL
I
= -15mA
OH
I
V
OH
OH
I
OH
= -10mA
= - 4mA
Vdisp = VDD-40
V
OL
150KΩ atVDD-
40
I
IH
I
PD
V
IH
VIN=VDD-40V
to V
DD
Vdisp=VDD-35V
VIN=V
DD
Min
0.7V
DD
VDD-400.3V
-3.0
V
DD
VDD-2.0
V
-1.0
DD
2006001000uA
0.7V
DD
Typ.
1
Max
VDD+0.3
DD
V
-37
DD
VDD-37
20uA
VDD+0.3
Unit
V
V
V
V
V
JUNE. 2001 Ver 1.0015
Page 22
GMS81C2112/GMS81C2120
7.6 AC Characteristics
(TA=-40~ 85°C, VDD=5V±10%, VSS=0V)
ParameterSymbolPins
Operating Frequency
External Clock Pulse Width
External Clock Transition Time
Oscillation Stabilizing Time
External Input Pulse Width
External Input Pulse Transi-
tion Time
RESET Input Width
XI
f
CP
t
CPW
t
RCP,tFCP
t
ST
t
EPW
t
REP,tFEP
t
RST
Specifications
Min.Typ.Max.
XIN1-8MHz
XIN80--nS
XIN--20nS
XIN, XOUT--20mS
INT0, INT1, EC02--
INT0, INT1, EC0--20nS
RESET8--
t
1/f
CP
CPW
t
CPW
0.5V
-0.5V
V
DD
Unit
t
SYS
t
SYS
RESETB
INT0, INT1
EC0
t
REP
t
SYS
t
EPW
t
FEP
t
t
RCP
RST
t
EPW
t
FCP
Figure 7-1 Timing Chart
0.2V
0.2V
DD
0.8V
DD
DD
16JUNE. 2001 Ver 1.00
Page 23
7.7 AC Characteristics
GMS81C2112/GMS81C2120
(TA=-40~+85°C, VDD=5V±10%, VSS=0V, f
ParameterSymbolPins
Serial Input Clock Pulse
Serial Input Clock Pulse Width
Serial Input Clock Pulse Transition
Time
SIN Input Pulse Transition Time
SIN Input Setup Time (External SCLK)
SIN Input Setup Time (Internal SCLK)
SIN Input Hold Time
Serial Output Clock Cycle Time
Serial Output Clock Pulse Width
Serial Output Clock Pulse Transition
Time
Serial Output Delay Time
XIN
t
SCYC
t
SCKW
t
FSCK
t
RSCK
t
FSIN
t
RSIN
t
SUS
t
SUS
t
HS
t
SCYC
t
SCKW
t
FSCK
t
RSCK
s
OUT
=4MHz)
Specifications
Unit
Min.Typ.Max.
SCLK
SCLK
2t
SYS
+70
t
SYS
-8ns
-8ns
+200
SCLK--30ns
SIN--30ns
SIN100--ns
SIN200-ns
SIN
SCLK
SCLK
t
SYS
t
4t
SYS
SYS
-30
-ns
-
16t
SYS
ns
ns
+70
SCLK30ns
SOUT100ns
SCLK
SIN
SOUT
t
0.8V
0.2V
t
SCYC
FSCK
DD
DD
t
SCKW
t
SUS
t
FSIN
t
DS
0.8V
DD
0.2V
DD
Figure 7-2 Serial I/O Timing Chart
t
RSCK
t
SCKW
t
HS
0.8V
DD
0.2V
DD
t
RSIN
JUNE. 2001 Ver 1.0017
Page 24
GMS81C2112/GMS81C2120
7.8 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.
R40~R43, R6, R53~R57
BUZO, PWM1O/T1O
V
SCLK, SOUT pins
OH
4.8 4.9
R40~R43, R6, R53~R57
BUZO, PWM1O/T1O
OL
SCLK, SOUT pins
5.0
V
(V)
OH
I
OH
(mA)
-1.6
-1.2
-0.8
-0.4
I
OL
(mA)
16
I
OH
VDD=4.0V
Ta=25°C
0
I
OL
VDD=4.0V
Ta=25°C
−
V
OH
3.6 3.7
−
V
OL
I
OH
(mA)
-1.6
-1.2
-0.8
-0.4
I
OL
(mA)
16
I
OH
VDD=5.0V
Ta=25°C
0
I
OL
VDD=5.0V
Ta=25°C
−
4.64.7
−
V
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
−
I
V
OH
VDD=3.0V
Ta=25°C
2.62.7
−
I
V
OL
VDD=3.0V
Ta=25°C
OL
OH
2.8 2.9
3.0
3.8 3.9
4.0
V
(V)
OH
I
OH
(mA)
-1.6
-1.2
-0.8
-0.4
I
OL
(mA)
16
0
V
(V)
OH
12
8
4
0
I
OH
(mA)
-16
-12
-8
-4
I
OH
VDD=5.0V
Ta=25°C
0
0.60.8
−
V
OH
1.02.0
1.0 1.2
R0, R2,RA
R30~R34 pins
3.0 4.0
1.4
5.0
V
(V)
V
(V)
12
8
4
1.4
5.0
V
(V)
V
(V)
OL
OH
I
OH
(mA)
-16
-12
-8
-4
0
I
0
0.6 0.8
−
V
OH
VDD=4.0V
Ta=25°C
1.0 2.0
1.0 1.2
OH
3.0 4.0
OL
OH
12
I
OH
(mA)
-16
-12
-8
-4
8
4
0
I
0
0.60.8
−
V
OH
VDD=3.0V
Ta=25°C
1.02.0
OH
1.0 1.2
3.0 4.0
1.4
5.0
V
(V)
V
(V)
OL
OH
18JUNE. 2001 Ver 1.00
Page 25
GMS81C2112/GMS81C2120
RESET, R55, SIN, SCLK
V
IH2
INT0, INT1, EC0 pinsXIN pins
45
RESET, R55, SIN, SCLK
V
IL2
INT0, INT1, EC0 pinsXIN pins
23
45
−
V
V
DD
V
IH3
f
=4.5MHz
XIN
(V)
Ta=25°C
4
3
2
1
V
DD
(V)
6
V
DD
(V)
6
0
1
23
−
V
V
DD
V
IL3
f
=4.5MHz
XIN
(V)
Ta=25°C
4
3
2
1
0
1
23
IH3
IL3
R53~R57, R6 pins
V
(V)
45
R53~R57, R6 pins
45
6
V
6
DD
(V)
DD
4
3
2
1
0
IL2
4
3
2
1
0
V
DD
f
XIN
Ta=25°C
1
V
DD
f
XIN
Ta=25°C
1
−
=4.5MHz
23
−
=4.5MHz
−
V
V
DD
f
=4.5MHz
XIN
Ta=25°C
23
V
DD
f
=4.5MHz
XIN
Ta=25°C
IH1
−
V
IL1
23
45
45
V
DD
(V)
6
V
DD
(V)
6
V
IH1
(V)
4
3
2
1
0
V
IL1
(V)
4
3
2
1
0
V
IH2
(V)
V
(V)
I
DD
(mA)
4.0
3.0
2.0
1.0
0
I
DD
Ta=25°C
−
V
DD
f
= 4.5MHz
XIN
23
Normal Operation
2.5MHz
45
−
V
I
SBY
DD
= 4.5MHz
XIN
Stand-by Mode
2.5MHz
45
V
DD
(V)
6
I
DD
Ta=25°C
(mA)
4.0
3.0
2.0
1.0
V
DD
(V)
6
0
f
23
I
DD
(µA)
2.0
1.5
1.0
0.5
0
I
STOP
−
V
DD
23
Stop Mode
45
6
85°C
25°C
-20°C
V
DD
(V)
JUNE. 2001 Ver 1.0019
Page 26
GMS81C2112/GMS81C2120
SP
01
H
Stack Address ( 100H ~ 1FEH )
Bit 15Bit 087
Hardware fixed
00H~FF
H
8. MEMORY ORGANIZATION
The GMS81C2112 and GMS81C2120 have separate address spaces for Program memory and Data Memory. Pro gram memory can only be read, not written to. It can be up
8.1 Registers
This device has six registers that are the Program Counter
(PC), a Accumulator (A), two index registers (X, Y), the
Stack Pointer (SP), and the Program Status Word (PSW).
The Program Counter consists of 16-bit register.
A
X
Y
SP
PCH
Figure 8-1 Configuration of Registers
Accumulator:
PCL
PSW
The Accumulator is the 8-bit general purpose register, used for data operation such as transfer, temporary saving, and conditional judgement, etc.
The Accumulator can be used as a 16-bit register with Y
Register as shown below.
ACCUMULATOR
X REGISTER
Y REGISTER
STACK POINTER
PROGRAM COUNTER
PROGRAM STATUS
WORD
to 12K/20K bytes of Program memory. Data memory can
be read and written to up to 448 by tes includ ing the s tack
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 user-processed data
may be lost.
The stack can be located at any position within 100
1FF
of the internal data memory. The SP is not initialized
H
to
H
by hardware, requiring to write the initial v alue (the lo cation with which the use of the stack starts) by using the initialization routine. Normally, the initial value of “FF
” is
H
used.
Note:
The Stack Pointer must be initi alized by softwa re be-
cause its value is undefined after RESET.
Example: To initialize the SP
LDX#0FFH
TXSP; SP ← FFH
Y
YA
A
Two 8-bit Registers can be used as a "YA" 16-bit Register
Figure 8-2 Configuration of YA 16-bit Register
X, Y Registers
: In the addressing mode which uses these
index registers, the register conten ts a re added to the specified address, which becomes the actual address. These
modes are extremely effective for referencing subroutine
tables and memory tables . The index regi sters also h ave increment, decrement, comparison and data transfer functions, and they can be used as simple accumulators.
Stack Pointer
: The Stack Pointer is an 8-bit register used
for occurrence interrupts and calling out subroutines. Stack
Pointer identifies the location in the stack to be access
(save or restore).
Program Counter
: The Program Counter is a 16-bit wide
which consists of two 8-bit registers, PCH and PCL. This
counter indicates the address of the next instruction to be
executed. In reset state, the program counter has reset routine address (PC
Program Status Word
:0FFH, PCL:0FEH).
H
: The Program Status Word (PSW)
contains several bits that reflect the current state of the
CPU. The PSW is described in Figure 8-3. It contains the
Negative flag, the Overflow flag, the Break flag the Half
Carry (for BCD operation), the Interrupt enable flag, the
Zero flag, and the Carry flag.
[Carry flag C]
This flag stores any carry or borrow from the ALU of CPU
after an arithmetic operation and is also changed by the
Shift Instruction or Rotate Instruction.
[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.
20JUNE. 2001 Ver 1.00
Page 27
NEGATIVE FLAG
OVERFLOW FLAG
when G=1, page is selected to “page 1”
SELECT DIRECT PAGE
BRK FLAG
Figure 8-3 PSW (Program Status Word) Register
MSBLSB
N
PSW
V G B H I Z C
GMS81C2112/GMS81C2120
RESET VALUE : 00
CARRY FLAG RECEIVES
CARRY OUT
ZERO FLAG
INTERRUPT ENABLE FLAG
HALF CARRY FLAG RECEIVES
CARRY OUT FROM BIT 1 OF
ADDITION OPERLANDS
H
[Interrupt disable flag I]
This flag enables/disables all interrupts except interrupt
caused by Reset or software BRK instruction. All interrupts are disabled when cleared to “0”. This flag immediately becomes “0” when an interrupt is served. It is set by
the EI instruction and cleared by the DI instruction.
[Half carry flag H]
After operation, this is set when there is a carry from bit 3
of ALU or there is no borrow from bit 4 of ALU. This bit
can not be set or cleared except CLRV instruction with
Overflow flag (V).
[Break flag B]
This flag is set by software BRK instruction to distinguish
BRK from TCALL instruction with the same vector address.
[Direct page flag G]
This flag assigns RAM page for direct addressing mode. In
the direct addressing mode, addressing area is from zero
page 00
addressing area is assigned 100
to 0FFH when this flag is "0". If it is set to "1",
H
to 1FFH. It is set by
H
SETG instruction and cleared by CLRG.
[Overflow flag V]
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.0021
Page 28
GMS81C2112/GMS81C2120
At execution of
a CALL/TCALL/PCALL
01FE
01FD
01FC
01FB
SP before
execution
SP after
execution
PCH
PCL
01FE
01FC
Push
down
01FE
01FD
01FC
01FB
SP before
execution
SP after
execution
At acceptance
of interrupt
01FE
01FD
01FC
01FB
At execution
of PUSH instruction
PUSH A (X,Y,PSW)
A
01FE
01FD
PCH
PCL
PSW
01FE
01FB
Push
down
Push
down
01FE
01FD
01FC
01FB
At execution
of RET instruction
01FE
01FD
01FC
01FB
At execution
of POP instruction
POP A (X,Y,PSW)
PCH
PCL
01FC
01FE
A
01FD
01FE
Pop
up
Pop
up
At execution
of RET instruction
01FE
01FD
01FC
01FB
0100H
01FEH
PCH
PCL
PSW
01FB
01FE
Stack
depth
Pop
up
Figure 8-4 Stack Operation
22JUNE. 2001 Ver 1.00
Page 29
8.2 Program Memory
0FFE0H
E2
AddressVector Area Memory
E4
E6
E8
EA
EC
EE
F0
F2
F4
F6
F8
FA
FC
FE
-
-
Serial Communication Interface
Basic Interval Timer
-
-
-
Timer/Counter 0 Interrupt
-
External Interrupt 0
-
RESET Vector Area
External Interrupt 1
Watchdog Timer Interrupt
"-" means reserved area.
NOTE:
Timer/Counter 1 Interrupt
-
A/D Converter
GMS81C2112/GMS81C2120
A 16-bit program counter is capable of addressing up to
64K bytes, but this device has 2 0K bytes program memory
space only physically implemented. Accessing a location
above FFFF
will cause a wrap-around to 0000H.
H
Figure 8-5, shows a map of Pr ogram Memory. After reset,
the CPU begins execution from reset vector which is stored
in address FFFE
and FFFFH as shown in Figure 8-6.
H
As shown in Figure 8-5, each area is assigned a fix ed location in Program Memory. Program Memory area contains
the user program.
B000
H
D000
H
FEFF
H
FF00
FFC0
FFDF
FFE0
FFFF
H
H
TCALL area
H
H
Vector Area
H
Interrupt
PCALL area
GMS81C2120, 20K ROM
GMS81C2112, 12K ROM
Example: Usage of TCALL
LDA#5
TCALL 0FH;
:;
:;
;
;TABLE CALL ROUTINE
;
FUNC_A: LDALRG0
RET
;
FUNC_B: LDALRG1
RET
;
;TABLE CALL ADD. AREA
;
ORG0FFC0H;
DWFUNC_A
DWFUNC_B
1BYTE INSTRUCTION
IN STEAD OF 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
Any area from 0FF00
. The interrupt service locations spaces 2-byte
H
and 0FFF9H for External Interru pt 1,
and 0FFFBH for External Interrupt 0, etc.
H
H
to 0FFFFH, if it is not going to be
H
used, its service location is available as general purpose
Program Memory.
Figure 8-5 Program Memory Map
Page Call (PCALL) area contains subroutine program to
reduce program byte length by using 2 bytes PCALL instead of 3 bytes CALL instruction. If it is frequently called,
it is more useful to save program byte length .
Table Call (TCALL) c auses the CPU to jump to each
TCALL address, where it commences the execution of the
service routine. The Table Call service area spaces 2-byte
for every TCALL: 0FFC0
TCALL14, etc., as shown in Figure 8-7.
JUNE. 2001 Ver 1.0023
for TCALL15, 0FFC2H for
H
Figure 8-6 Interrupt Vector Area
Page 30
GMS81C2112/GMS81C2120
11111111 11010110
01001010
PC:
FH FH DH 6H
4A
~
~
~
~
25
0FFD6
H
0FF00
H
0FFFF
H
D1
NEXT
0FFD7
H
➊
➋
➌
0D125
H
Reverse
Address
0FF00
0FFFF
PCALL Area Memory
H
PCALL Area
(256 Bytes)
H
AddressP ro gra m Mem o r y
0FFC0
H
C1
C2
C3
C4
C5
C6
C7
C8
C9
CA
CB
CC
CD
CE
CF
D0
D1
D2
D3
D4
D5
D6
D7
D8
D9
DA
DB
DC
DD
DE
DF
NOTE:
* means that the BRK software interrupt is using
same address with TCALL0.
; MAIN PROGRAM *
;*******************************************
;
RESET:DI;Disable All Interrupts
RAM_CLR: LDA#0;RAM Clear(!0000H->!00BFH)
;
;
ORG0B000H; GMS81C2120(20K)ROM Start address
CLRG
LDX#0
STA{X}+
CMPX#0C0H
BNERAM_CLR
LDX#0FFH;Stack Pointer Initialize
TXSP
LDMR0, #0;Normal Port 0
LDMR0IO,#82H;Normal Port Direction
:
:
:
LDMTDR0,#125;8us x 125 = 1mS
LDMTM0,#0FH;Start Timer0, 8us at 4MHz
LDMIRQH,#0
LDMIRQL,#0
LDMIENH,#0E0H ;Enable Timer0, INT0, INT1
LDMIENL,#0
LDMIEDS,#05H;Select falling edge detect on INT pin
LDMR0FUNC,#03H ;Set external interrupt pin(INT0, INT1)
EI;Enable master interrupt
:
:
:
:
NOT_USED :NOP
:
RETI
JUNE. 2001 Ver 1.0025
Page 32
GMS81C2112/GMS81C2120
8.3 Data Memory
Figure 8-8 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.
0000
H
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.
User Memory
00BF
00C0
00FF
0100
01FF
H
H
H
H
H
Control
Registers
User Memory
or Stack Area
PAGE0
PAGE1
When “G-flag=0”,
this page is selected
When “G-flag=1”
Figure 8-8 Data Memory Map
User Memory
The GMS81C21xx have 448 × 8 bits for the user me mo ry
(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
More detailed informations of each register are explained
in each peripheral section.
Note:
Write only registers can not be accessed by bit manipulation instruction. Do not use read-modify-write instruction. Use byte manipulation instruction, for example “LDM”.
Example; To write at CKCTLR
LDMCLCTLR,#09H
;Divide ratio(
÷16
)
Stack Area
The stack provides the area where the return address is
saved before a jump is performed during the processing
routine at the execution of a subroutine call instruction or
the acceptance of an interrupt.
When returning from the processing routine, execu ting the
subroutine return instruction [RET] restores the contents of
the program counter from the stack; ex ecuting the interrupt
return instruction [RETI] restores the contents of the program counter and flags.
The save/restore locations in the stack are determined by
the stack pointed (SP). The SP is automatically decreased
after the saving, and increased before the restoring. This
means the value of the SP indicates the stack location
number for the next save. Refer to Figure 8-4 on page 22.
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.
3. RA is one-bit high-voltage input only port pin. In addition, RA
serves the functions of the Vdisp special features. Vdisp is
used as a high-voltage input power supply pin when selected
by the mask option.
JUNE. 2001 Ver 1.0027
Page 34
GMS81C2112/GMS81C2120
AddressName
Bit 7
Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
C0HR0R0 Port Data Register (Bit[7:0])
C1HR0IOR0 Port Direction Register (Bit[7:0])
C4HR2R2 Port Data Register (Bit[7:0])
C5HR2IOR2 Port Direction Register (Bit[7:0])
C6HR3R3 Port Data Register
C7HR3IOR3 Port Direction Register
(Bit[4:0])
(Bit[4:0])
CAHR5R5 Port Data Register (Bit[7:3])
CBHR5IOR5 Port Direction Register (Bit[7:3])
CCHR6R6 Port Data Register (Bit[7:0])
CDHR6IOR6 Port Direction Register (Bit[7:0])
D0HTM0--CAP0T0CK2T0CK1T0CK0T0CNT0ST
D1H
T0/TDR0/
CDR0
Timer0 Register / Timer0 Data Register / Capture0 Data Register
D2HTM1POL16BITPWM1ECAP1T1CK1T1CK0T1CNT1ST
D3H
D4H
D5HPWM1HR PWM1 Hig h Register
TDR1/
T1PPR
T1/CDR1/
T1PDR
Timer1 Data Register / PWM1 Period Register
Timer1 Register / Capture1 Data Register / PWM1 Duty Register
(Bit[3:0])
DEHBURBUCK1BUCK0BUR5BUR4BUR3BUR2BUR1BUR0
E0HSIOMPOLIOSWSM1SM0SCK1SCK0SIOSTSIOSF
E1HSIORSPI DATA REGISTER
E2HIENHINT0EINT1ET0ET1E
E3HIENLADEWDTEBITESPIE---E4HIRQHINT0IFINT1IFT0IFT1IF
E5HIRQLADIFWDTIFBITIFSPIIF----
E6HIEDSIED1HIED1LIED0HIED0L
EAHADCM-ADENADS3ADS2ADS1ADS0ADSTADSF
EBHADCRADC Result Data Register
ECH
These registers of shaded area can not be access by bit manipulation instruction as " SET1, CLR1 ", but should be access by register operation instruction as " LDM dp,#imm ".
These registers of shaded area can not be access by bit manipulation instruction as " SET1, CLR1 ", but should be access 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.
Bit 7
Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
PWM1O/
T1O
Table 8-3 Control Registers of GMS81C2120
------
JUNE. 2001 Ver 1.0029
Page 36
GMS81C2112/GMS81C2120
8.4 Addressing Mode
The GMS800 series MCU uses six addressing modes;
• Register addressing
• Immediate addressing
• Direct page addressing
• Absolute addressing
• Indexed addressing
• Register-indirect addressing
(1) Register Addressing
Register addressing accesses the A, X, Y, C and PSW.
(2) Immediate Addressing
→
→
→ →
#imm
In this mode, second byte (operand) is accessed as a data
immediate ly.
Example:
0435ADC#35H
MEMORY
04
35
A+35H+C → A
(3) Direct Page Addressing
→
→
→ →
dp
In this mode, a address is specified within direct page.
Example; G=0
C535LDA35H;A ←RAM[35H]
35H
data
➋
~
~
0E550H
0E551H
C5
35
(4) Absolute Addressing
~
~
→
→
→ →
➊
!abs
data → A
Absolute addressing sets corresponding memory data to
Data, i.e. second byte (Operand I) of command bec omes
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.
In this mode, a address is specified within direct page by
the X register and the content of X is increased by 1.
LDA, STA
Example; G=0, X=35
DBLDA{X}+
H
→
→
→ →
{X}+
Y indexed direct page (8 bit offset)
→
→
→ →
dp+Y
This address value is the second byte (Operand) of command plus the data of Y-register, which assign s 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
H
JUNE. 2001 Ver 1.0031
Page 38
GMS81C2112/GMS81C2120
H
D500FALDA!0FA00H+Y
0F100H
0F101H
0F102H
0FA55H
~
~
D5
00
FA
data
➊
0FA00H+55H=0FA55H
~
~
➋
data → A
➌
(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; G=0
3F35JMP[35H]
1625ADC[25H+X]
35H
36H
~
~
0E005H
~
~
0FA00H
Y indexed indirect
05
E0
data
16
25
→
→
→ →
~
~
~
~
0E005H
➋
[dp]+Y
25 + X(10) = 35
➊
A + data + C → A
➌
Processes memory data as Data, assigned by the data
[dp+1][dp] of 16-bit pair memory paired by Operan d in Direct pageplus Y-register data.
Processes memory data as Data, assigned by 16-bit pair
memory which is determined by pair data
[dp+X+1][dp+X] Operand plusX-register dat a in Direct
page.
The program jumps to address specified by 16-bit absolute
address.
JMP
Example; G=0
32JUNE. 2001 Ver 1.00
Page 39
1F25E0JMP[!0C025H]
PROGRAM MEMORY
GMS81C2112/GMS81C2120
➊
0E025H
0E026H
0E725H
0FA00H
25
E7
~
~
NEXT
~
~
1F
25
E0
➋
~
~
jump to
address 0E30AH
~
~
JUNE. 2001 Ver 1.0033
Page 40
GMS81C2112/GMS81C2120
R0 Data Register
R0
ADDRESS: 0C0
H
RESET VALUE: Undefined
R07 R06 R05 R04 R03
R02 R01
R00
Port Direction
R0 Direction Register
R0IO
ADDRESS : 0C1
H
RESET VALUE : 00
H
0: Input
1: Output
Input / Output data
R0 Function Selection Register
R0FUNC
ADDRESS : 0F4
H
RESET VALUE : ----0000
B
0: R00
1: INT0
0
0: R01
1: INT1
0: R02
1: BUZO
0: R03
1: EC0
123----
9. I/O PORTS
The GMS81C21xx has five ports (R0, R2, R3, R5, and
R6).These ports pins may be multiplexed with an alternate
function for the peripheral features on the device.
All pins have data direction registers which can define
these ports as output or input. A “1” in the port direction
register configure the corresponding port pin as output.
Conversely, write “0” to the corresponding bit to specif y it
as input pin. For example, to use the even numbered bit of
R0 as output ports and the odd numbe red bits as input
ports, write “55
” to address 0C1H (R0 port direction reg-
H
ister) during initial setting as shown in Figure 9-1.
All the port direction registers in the GMS81C2120 have 0
written to them by reset function. On the other hand, its initial status is input.
0C0
0C1
0C2
0C3
WRITE "55
H
R0 direction
H
H
R1 direction
H
R0 data
R1 data
" TO PORT R0 DIRECTION REGISTER
H
0 1 0 1 0 1 0 1
76543210
I O I O I O I O
76543210
I : INPUT PORT
O : OUTPUT PORT
BIT
PORT
R0 and R0IO register:
bidirectional I/O port (address 0C0
R0 is an 8-bit high-voltage CMOS
). Each port can be set
H
individually as input and output through the R0IO register
(address 0C1
). Each port can directly drive a vacuum flu-
H
orescent display. R03 port is multiplexed with Buzzer Output Port(BUZO), R02 port is multiplexed with Event
Counter Input Port (EC0), and R01~R00 are multiplexed
with External Interrupt Input Port(INT1, INT0)
) controls to
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 Buzzer Output, External Event Counter Input
and External Interrupt Input, write "1" to the corresponding bit of R0FUNC. Regardless of the direction register
R0IO, R0FUNC is sel ected to use as alterna te functions,
port pin can be used as a corresponding alternate features
(BUZO, EC0, INT1, INT0)
Figure 9-1 Example of Port I/O Assignment
RA(Vdisp) register:
only port pin. In addition, RA se rves the funct ions of the
special features. V
V
disp
power supply pin when selected by the mask option.
RA Data Register
RA
Port pinAlternate function
RA
RA is one-bit high-voltage input
is used as a high-voltage input
disp
ADDRESS: 0FB
RESET VALUE: Undefined
RA0
Input data
V
(High-voltage input power supply)
disp
H
34JUNE. 2001 Ver 1.00
Page 41
GMS81C2112/GMS81C2120
R5 Data Register
R5
ADDRESS: 0CA
H
RESET VALUE: Undefined
R57
R56 R55 R54 R53
- - -
R5 Direction Register
R5IO
ADDRESS : 0CB
H
RESET VALUE : 00000---
B
Input / Output data
R5 Function Selection Register
R5FUNC
ADDRESS : 0F6
H
RESET VALUE : -0------
B
0: R56
1:
- -----6-
R5 N-MOS Open Drain
R5NODR
ADDRESS: 0F9
H
RESET VALUE: 00000---
B
N-MOS Open Drain Selection
Selection Register
0: Disable
1: Enable
Port Direction
0: Input
1: Output
PWM1O/T1O
R2 and R2IO register:
bidirectional I/O port (address 0C4
R2 is an 8-bit high-volta ge CMOS
). Each port can be set
H
individually as input and output th rou gh t he R2IO regis t er
(address 0C5
). Each port can directly drive a vacuum flu-
H
orescent display.
R2 Data Register
R2
R27 R26 R25 R24 R23 R22 R21 R20
Input / Output data
R2 Direction Register
R2IO
R3 and R3IO register:
R3 is a 5-bit high-voltage CMOS
bidirectional I/O port (address 0C6
ADDRESS: 0C4
RESET VALUE: Undefined
ADDRESS : 0C5
RESET VALUE : 00
Port Direction
0: Input
1: Output
). Each port can be set
H
H
H
H
individually as input and output th rou gh t he R3IO regis t er
(address 0C7
).
H
R5FUNC.
The control register R5NODR (address 0F9
) controls to
H
select N-MOS open drain port. To select N -MOS open
drain port, write "1" to the corresponding bit of R5 FUNC.
R3 Data Register
-
R3
- - R34 R33
R3 Direction Register
R3IO
- -
R5 and R5IO register:
port (address 0CA
input and output through the R5IO register (address
0CB
).In addition, Po rt R5 is multiplexed wi th Pulse
H
Width Modulator (PWM).
Port Pin
R56
The control register R5FUNC (address 0F6
select PWM function.After reset, the R5IO register value
is "0", port may be used as general I/O ports. To select
). Each pin can be set individually as
H
PWM1 Data Output
Timer 1 Data Output
PWM function, write "1" to the corresponding bit of
-
ADDRESS: 0C6
RESET VALUE: Undefined
R32 R31 R30
ADDRESS : 0C7
RESET VALUE : ---00000
H
Input / Output data
H
Port Direction
0: Input
1: Output
R5 is an 5-bit bidirectional I/O
Alternate Function
) controls to
H
B
R6 and R6IO register:
port (address 0CC
H
R6 is an 8-bit bidirectional I/O
). Each port can be set individually as
input and output through the R6IO register (address
0CD
). R67~R60 ports are multiplexed with Analog Inpu t
) controls to
select alternate function. After reset, this value is "0", port
may be used as general I/O ports. To select alter nate func-
JUNE. 2001 Ver 1.0035
Page 42
GMS81C2112/GMS81C2120
tion such as Analog Input, write "1" to the corresponding
bit of R6FUNC. Regardless of the direction register R6IO,
R6FUNC is selected to use as alternate functions, port pin
can be used as a corresponding alternate features
(AN7~AN0)
R6 Data Register
R6
R67 R66 R65 R64 R63
R6 Direction Register
ADDRESS: 0CC
RESET VALUE: Undefined
R62 R61
Input / Output data
ADDRESS : 0CD
RESET VALUE : 00
R6IO
Port Direction
0: Input
1: Output
R6 Function Selection Register
R6FUNC
0: R67
1: AN7
0: R66
1: AN6
0: R65
1: AN5
0: R64
1: AN4
H
R60
H
ADDRESS : 0F7
RESET VALUE : 00
1234567
0
0: R61
1: AN1
0: R62
1: AN2
0: R63
1: AN3
H
H
0: R60
1: AN0
H
36JUNE. 2001 Ver 1.00
Page 43
10. BASIC INTERVAL TIMER
GMS81C2112/GMS81C2120
The GMS81C21xx has one 8-bit Basic Interval Timer that
is free-run, can not stop. Block di agram is shown in Figure
10-1. In addition, the Basic Interval Tim er generates the
time base for watchdog timer counting. It also provides a
Basic interval timer interrupt (BITIF).
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 overfl ows fr om FF
to 00H, this overflow causes to
H
generate the Basic interval timer interrupt. The BITIF is interrupt request flag of Basic interval timer. The Basic Interval Timer is controlled by the clock control register
(CKCTLR) shown in Figure 10-2.
When write "1 " to bi t BTCL of CKCTLR, BITR reg ister is
cleared to "0" and restart to count-up. The bit BTCL be-
Internal RC OSC
WAKEUP
STOP
comes "0" after one machine cycle by hardware.
If the STOP instruction 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 o scillator, 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.
Source clock can be selected by lower 3 bits of CKCTLR.
BITR and CKCTLR are located at same address, and address 0EC
is read as a BITR, and written to CKCTLR.
H
8
÷
16
÷
32
÷
64
X
PIN
IN
÷
MUX
128
÷
256
÷
Prescaler
512
÷
1024
÷
Select Input clock
]
[0EC
Basic Interval Timer
clock control register
H
3
BTS[2:0]
CKCTLR
1
0
RCWDT
source
clock
[0EC
Internal bus line
8-bit up-counter
BITR
]
H
clear
BTCL
Read
overflow
Basic Interval
BITIF
To Watchdog timer (WDTCK)
Timer Interrupt
Figure 10-1 Block Diagram of Basic Interval Timer
JUNE. 2001 Ver 1.0037
Page 44
GMS81C2112/GMS81C2120
CKCTLR
[2:0]
000
001
010
011
100
101
110
111
76543210
CKCTLR
-
Caution:
Both register are in same address,
when write, to be a CKCTLR,
when read, to be a BITR.
Source clock
÷
8
f
XIN
÷
f
16
XIN
÷
f
32
XIN
÷
f
64
XIN
÷
f
128
XIN
÷
f
256
XIN
÷
f
512
XIN
÷
f
1024
XIN
Interrupt (overflow) Period (ms)
Table 10-1 Basic Interval Timer Interrupt Time
WAKEUP
RCWDT
WDTON
BTCL
BTCL
BTS1
BTS0BTS2
Basic Interval Timer source clock select
000: f
001: f
010: f
011: f
100: f
101: f
110: f
111: f
Clear bit
0: Normal operation (free-run)
1: Clear 8-bit counter (BITR) to “0”. This bit becomes 0 automatically
0: Operate as a 7-bit general timer
1: Enable Watchdog Timer operation
See the section “Watchdog Timer”.
Example 1:
Basic Interval Timer Interrupt request flag is generated
every 4.096ms at 4MHz.
:
LDMCKCTLR,#03H
SET1BITE
EI
:
Example 2:
Basic Interval Timer Interrupt request flag is generated
every 1.024ms at 4MHz.
:
LDMCKCTLR,#01H
SET1BITE
EI
:
38JUNE. 2001 Ver 1.00
Page 45
11. WATCHDOG TIMER
GMS81C2112/GMS81C2120
The watchdog timer rapidly detects the CPU malfunction
such as endless looping caused by noise or the like, and resumes the CPU to the normal state.
The watchdog timer signal for detecting malfunction can
be selected either a reset CPU or a interrupt request.
When the watchdog timer is not being used for malfunction detection, it can be used as a timer to generate an interrupt at fixed intervals. The purpo se of the watchdog
timer is to detect the malfunction (runa way) 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 source.
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 Xin 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.
Note:
Because the watchdog timer counter is enabled after clearing Basic Inte rval Timer, af ter the bit WDTO N set to
"1", maximum error of timer 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 RCWDT oscillation period is vary with temperature,
VDD and process variations from part to part (approximately, 40~120uS). The following equation shows the
RCWDT oscillated watchdog timer time-out.
T
RCWD T
=CLK
×28×[
RCWD T
where, CLK
WD TR.6~0]+(CLK
= 40~ 120uS
RCWD T
RCWD T
×28)/2
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]
WDT
××××
Interval of BIT
clear
BASIC INTERVAL TIMER
OVERFLOW
Count
source
WDTCL
[0ED
Watchdog
Counter (7-bit)
7-bit compare data
WDTR
]
H
Internal bus line
7
clear
comparato r
Watchdog Timer
Register
“0”
“1”
enable
WDTON in CKCTLR [0EC
WDTIF
to reset CPU
Watchdog Timer interrupt
]
H
Figure 11-1 Block Diagram of Watchdog Timer
JUNE. 2001 Ver 1.0039
Page 46
GMS81C2112/GMS81C2120
Watchdog Timer Control
Figure 11-2 shows the watchdog timer control register.
The watchdog timer is automatically disab led aft e r reset.
The CPU malfunction is detected during setting of the detection time, selecting of output, and clearing of the binary
counter. Clearing the binary counter is repeated within the
detection time.
If the malfunction occurs for any cause, the watchdog timer output will become active at the rising overflow from
WDTR
WWWW
76543210
WDTCL
Clear count flag
0: Free-run count
1: When the WDTCL is set to "1", binary counter
is cleared to “0”. And the WDTCL becomes “0” automatically
after one machine cycle. Counter count up again.
WWWW
the binary counters unless the binary counter is cleared. At
this time, when WDTON=1, a reset is generated, which
drives the RESET
When WDTON=0, a watchdog timer interrupt (WDTIF) is
generated.
The watchdog timer temporarily stops counting in the
STOP mode, and when the STOP mode is released, it automatically restarts (continues counting).
7-bit compare data
Figure 11-2 WDTR: Watchdog Timer Data Register
Example: Sets the watchdog timer detection time to 0.5 sec at 4.19MHz
Watchdog timer is enabled by setting WDTON (bit 4 in
CKCTLR) to “1”. WDTON is initialized to “0” during reset and it should be set to “1” to operate after reset is released.
Example: Enables watchdog timer for Reset
:
LDMCKCTLR,#xx1x_xxxxB;
:
:
WDTON
← 1
The watchdog timer is disabled by clearing bit 5 (WDTON) of CKCTLR. The watchdog timer is halted in STOP
mode and restarts automatically after STOP mode is released.
Source clock
BIT overflow
Binary-counter
WDTR
WDTIF interrupt
WDT resetreset
1
2
n
3
Watchdog Timer Interrupt
The watchdog timer can be also used as a simple 7-bit timer by clearin g bit5 of CKCTLR to “0”. The in terval of
watchdog timer interrupt is decided by Basic Interval Timer. Interval equation is shown as below.
The stack pointer (SP) should be initialized before using
the watchdog timer output as an interrupt source.
Example: 7-bit timer interrupt set up.
10
3
WDTR ← "0100_0011
TWDT R Interval of BIT
=
×
LDMCKCTLR,#xx0xxxxxB;
LDMWDTR,#7FH;
WDTCL
:
2
"
B
30
Counter
Clear
Match
Detect
WDTON
←1
←0
Figure 11-3 Watchdog timer Timing
If the watchdog timer output becomes active, a reset is generated, which drives the RESET
pin low to reset the inter-
nal hardware.
The main clock oscillator also turns on wh en a watchdog
timer reset is generated in sub clock mode.
JUNE. 2001 Ver 1.0041
Page 48
GMS81C2112/GMS81C2120
12. TIMER/EVENT COUNTER
The GMS81C21xx has two Timer/Counter registers. Each
module can generate an interrupt to indicate that an event
has occurred (i.e. timer match).
Timer 0 and Timer 1 are can be used either two 8-bit Timer/Counter or one 16-bit Timer/Counter with combine
them.
In the "timer" function, the register is increased every internal clock input. Thus , one can th ink of it as count ing in ternal clock input. Since a least clock consists of 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 to 1/8).
In the “counter” function, the register is increase d in re-
sponse to a 1-to-0 (falling edge) or 0-to-1(ris ing edge) transition at its corresponding external input pin, EC0.
In addition the “capture” function, the register is increased
in response external or internal clock sources same with
timer or counter function. When external clock edge input,
the count register is captured into capture data register
CDRx.
Timer1 is 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 m ode register
TM0 and TM1 as shown in Figure 12-1 and Table 12-1.
Table 12-1 Operating Modes of Timer0 and Timer1
42JUNE. 2001 Ver 1.00
Page 49
TM0
R/WR/WR/WR/WR/WR/W
543210
-- T0CN
BTCL
T0STT0Ck0T0CK1CAP0 T0Ck2
Bit NameBit PositionDescription
CAP0TM0.50: Timer/Counter mode
1: Capture mode selection flag
T0CK2
T0CK1
T0CK0
TM0.4
TM0.3
TM0.2
000: 8-bit Timer, Clock source is f
001: 8-bit Timer, Clock source is f
010: 8-bit Timer, Clock source is f
011: 8-bit Timer, Clock source is f
100: 8-bit Timer, Clock source is f
101: 8-bit Timer, Clock source is f
110: 8-bit Timer, Clock source is f
(External clock)
111: EC0
T0CNT M0 .10: Stop the time r
1: A logic 1 starts the timer.
T0STTM0.00: When cleared, stop the counting.
1: When set, Timer 0 Count Register is cleared and start again.
ADDRESS: 0D0
INITIAL VALUE: --000000
÷ 2
XIN
÷ 4
XIN
÷ 8
XIN
÷ 32
XIN
÷ 128
XIN
÷ 512
XIN
÷ 2048
XIN
H
GMS81C2112/GMS81C2120
B
TM1
R/WR/WR/WR/WR/WR/WR/WR/W
76543210
PWM1E
16BITPOL T1CN
CAP1
BTCL
T1STT1CK0T1CK1
Bit NameBit PositionDescription
POLTM1.70: PWM Duty Active Low
1: PWM Duty Active High
16BITTM1.60: 8-bit Mode
1: 16-bit Mode
PWMIETM1.50: Disable PWM
1: Enable PWM
CAP1TM1.40: Timer/Counter mode
1: Capture mode selection flag
T1CK1
T1CK0
TM1.3
TM1.2
00: 8-bit Timer, Clock source is f
01: 8-bit Timer, Clock source is f
10: 8-bit Timer, Clock source is f
11: 8-bit Timer, Clock source is Using the the Timer 0 Clock
T0CNTM1.10: Stop the timer
1: A logic 1 starts the timer.
T0STTM1.00: When cleared, stop the counting.
1: When set, Timer 0 Count Register is cleared and start again.
R/W R/W R/W R/W R/W R/W R/W R/W
76543210
TDR0
R/W R/W R/W R/W R/W R/W R/W R/W
76543210
TDR1
ADDRESS: 0D2
INITIAL VALUE: 00
XIN
÷ 2
XIN
÷ 8
XIN
ADDRESS: 0D1
INITIAL VALUE: Undefined
ADDRESS: 0D3
INITIAL VALUE: Undefined
H
H
H
H
Read: Count value read
Write: Compare data write
Figure 12-1 TM0, TM1 Registers
JUNE. 2001 Ver 1.0043
Page 50
GMS81C2112/GMS81C2120
12.1 8-bit Timer / Counter Mode
The GMS81C21xx has two 8-bit Timer/Counte rs, Timer 0 ,
Timer 1 as shown in Figure 12-2.
The "timer" or "counter" function is selected by mode registers TMx as shown in Fi gure 12-1 and Table 12-1. To use
76543210
EC0 PIN
XIN PIN
TM0
TM1
EDGE
DETECTOR
Prescaler
--T0CN
--XXXX
76543210
16BITPOLT1CN T1STT1CK0T1CK1
X0XXXX
2
÷
4
÷
8
÷
÷
÷
512
÷
2048
÷
0X
PWM1E
00
T0CK[2:0]
111
000
001
010
011
100
101
110
MUX
CAP1
BTCL
BTCL
T0CN
TIMER 0
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 12-1).
T0STT0CK0T0CK1CAP0 T0CK2
X means don’t care
X means don’t care
T0ST
0: Stop
1: Clear and start
T0 (8-bit)
TDR0 (8-bit)
ADDRESS: 0D0
INITIAL VALUE: --000000
ADDRESS: 0D2
INITIAL VALUE: 00
Comparator
clear
H
B
H
H
T0IF
F/F
TIMER 0
INTERRUPT
T0O PIN
T1CK[1:0]
T1ST
11
1
÷
00
2
÷
01
8
÷
10
MUX
T1CN
TIMER 1
0: Stop
1: Clear and start
T1 (8-bit)
TDR1 (8-bit)
clear
Comparator
T1IF
F/F
TIMER 1
INTERRUPT
T1O PIN
Figure 12-2 8-bit Timer/Counter 0, 1
44JUNE. 2001 Ver 1.00
Page 51
GMS81C2112/GMS81C2120
Example 1:
Timer0 = 2ms 8-bit timer mode at 4M Hz
Timer1 = 0.5ms 8-bit timer mode at 4MHz
LDMTDR0,#250
LDMTDR1,#250
LDMTM0,#0000_1111B
LDMTM1,#0000_1011B
SET1T0E
SET1T1E
EI
LDMTDR0,#250
LDMTDR1,#250
LDMTM0,#0001_1111B
LDMTM1,#0000_1011B
SET1T0E
SET1T1E
EI
Note:
The contents of Timer data register TDRx should be
initialized 1
set.
~FFH, not 0H, because it is undefined after re-
H
These timers have each 8-bit count register and data register. The count register is increased by every intern al or external clock input. The internal clock has a prescaler divide
ratio option of 2, 4, 8, 32,128, 512, 2048 selected by control bits T0CK[2:0] of register (TM0) and 1, 2, 8 selected
by control bits T1CK[1:0] of register (TM1). In the Timer
0, timer register T0 increases from 00
TDR0 and then reset to 00
. The match output of Timer 0
H
until it matches
H
generates Timer 0 interru pt (latched in T0IF 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-to1(1-to-0) (rising & falling edge) transi tion of EC0 pin. In
order to use counte r fun ctio n, th e bit EC0 o f t he R0
tion Selection
Register
(R0FUNC.2) is set to "1". The Timer
Func-
0 can be used as a counter by pin EC0 input, but Timer 1
can not.
JUNE. 2001 Ver 1.0045
Page 52
GMS81C2112/GMS81C2120
8-bit Timer Mode
In the timer mode, the internal clock is used for counting
up. Thus, you can think of it as counting internal clock input. The contents of TDRn are compared with the contents
of up-counter, Tn. If match is found, a timer 1 interrupt
(T1IF) is generated and the up-counter is cleared to 0.
Start count
Source clock
Up-counter
TDR1
T1IF interrupt
Example:
When
INTERRUPT PERIOD =
TDR1
7D
0
Timer 1 (T1IF)
Interrupt
0
n
Make 2msinterrupt using by Timer0 at 4MHz
LDMTM0,#0FH; divide by 32
LDMTDR0,#125; 8us x 125= 1ms
SET1T0E; Enable Timer 0 Interrupt
EI; Enable Master Interrupt
TM0 = 0000 1111
TDR0 = 125
f
= 4 MHz
XIN
~
~
(8-bit Timer mode, Prescaler divide ratio = 32)
B
= 7D
D
H
4 × 10
0
Occur interruptOccur interruptOccur interrupt
23
1
Figure 12-3 Timer Mode Timing Chart
1
1
6
Hz
(TDR0 = T0)
3
2
32 × 125 = 1 ms
×
MATCH
up-count
~
~
6
5
4
Interrupt period
= 8 µs x 125
7A
Counting up is resumed after the up-counter is cleared.
As the value of TDRn is changeable by software, time in-
terval is set as you want
~
~
~
~
n-2
~
~
~
~
~
~
7D
7C
7B
n-1
Match
Detect
Count Pulse
Period
8 µs
n
0
Counter
Clear
2
14
~
~
3
TIME
Figure 12-4 Timer Count Example
46JUNE. 2001 Ver 1.00
Page 53
8-bit Event Counter Mode
GMS81C2112/GMS81C2120
In this mode, counting up is started by an external trigger.
This trigger means falling edge or rising edge of the EC0
pin input. Source clock is used as an internal clock selected
with timer mode register TM0. The conten ts of ti mer data
register TDR0 is compared with the contents of the upcounter T0. If a match is found, an timer interrupt request
flag T0IF is generated, and the counter is cleared to “0”.
The counter is restart and count up continuously by every
falling edge or rising edge of the EC0 pin input.
The maximum frequency applied to the EC0 pin is f
XIN
[Hz].
Start count
ECn pin input
Up-counter
TDR1
T1IF interrupt
0
1
n
2
Figure 12-5 Event Counter Mode Timing Chart
In order to use event counter function, the bit 2 of the R5
function register (R5FUNC.2) is required to be set to “1”.
After reset, the value of timer data register TDR0 is undefined, it should b e initialized to between 1
~FFH not to
H
"0"The interval period of Timer is calculated as below
equation.
Period (sec)
---------- -
2 Divide Ratio TDR0
f
XIN
×××=
1
/2
~
~
~
~
~
~
~
~
~
~
~
~
n-1
1
0n
2
TDR1
Timer 1 (T1IF)
Interrupt
T1ST
Start & St op
T1CN
Control count
disable
clear & start
stop
~
~
Occur interruptOccur interrupt
T1ST = 1
T1ST = 0
enable
~
~
up-count
T1CN = 1
T1CN = 0
Figure 12-6 Count Operation of Timer / Event counter
TIME
JUNE. 2001 Ver 1.0047
Page 54
GMS81C2112/GMS81C2120
12.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
until it
H
. The
H
match output generates Timer 0 interrupt not Timer 1 interrupt.
The clock source of the Timer 0 is selected either internal
or external clock by bit T0CK[2:0].
In 16-bit mode, the bits T1CK[1:0] and 16BIT of TM1
should be set to "1" respectively.
The GMS81C21xx has a function of Timer Compare Output. To pulse out, the timer match can goes to port
pin(T0O, T1O) as shown in Figure 12-2 and Figure 12-7.
Thus, pulse out is generated by the timer match. These operation is implemented to pin, T0O, PWM1O/T1O.
In this mode, the bit PWM1O/T1O of R5 function register
(R5FUNC.6) should be set to "1", and the bit PWM1E of
timer1 mode register (TM1) should be set to "0". In addi-
12.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 12-8.
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 internal or external input. This counting function is same with
normal timer mode, and Timer in terrup t is gener ated wh en
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 12-10, the pulse width of captured
signal is wider than the timer data value (FF
times. When external interrupt is occurred, the captured
value (13
) is more little than wanted value. It can be ob-
H
) over 2
H
GMS81C2112/GMS81C2120
tion, 16-bit Compare output mode is available, also.
This pin output the signal having a 50 : 50 duty square
wave, and output frequency is same as below equation.
tained correct value by counting the number o f 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 captured into registers CDRx (CDR0, CDR1), respectively.
After captured, Timer x register is cleared and restarts by
hardware.
Note:
The CDRx, TDRx and Tx are in same address. In
the capture mode, reading operation is read the CDRx, not
Tx because path is opened to the CDRx, and TDRx is only
for writing operation.
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.
Figure 12-10 Excess Timer Overflow in Capture Mode
JUNE. 2001 Ver 1.0051
Page 58
GMS81C2112/GMS81C2120
12.5 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.
The clock source of the Timer 0 is 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.
EC0 PIN
XIN PIN
INT0 PIN
TM0
TM1
Edge
Detector
Prescaler
76543210
X
CAP1
IEDS[1:0]
BTCL
BTCL
T0CN
“01”
“10”
“11”
T0STT0CK0T0CK1CAP0 T0CK2
X means don’t care
X means don’t care
TDR1 + TDR0
(16-bit)
clear
Capture
CDR1 + CDR0
(16-bit)
Higher byte
CAPTURE DATA
--T0CN
--XXXX
76543210
16BITPOLT1CN T1STT1CK0T1CK1
X1XX11
T0CK[2:0]
2
÷
4
÷
8
÷
÷
÷
512
÷
2048
÷
1
PWM1E
0X
111
000
001
010
011
100
101
110
MUX
ADDRESS: 0 D0
INITIAL VALUE: --000000
ADDRESS: 0D2
INITIAL VALUE: 00
T0ST
0: Stop
1: Clear and start
Lower byte
INT0IF
H
B
H
H
INT0
INTERRUPT
Figure 12-11 16-bit Capture Mode
52JUNE. 2001 Ver 1.00
Page 59
GMS81C2112/GMS81C2120
Example 1:
Timer0 = 16-bit timer mode, 0.5s at 4MHz
LDMTM0,#0000_1111B;8uS
LDMTM1,#0100_1100B;16bit Mode
LDMTDR0,#<62500 ;8uS X 62500
LDMTDR1,#>62500 ;=0.5s
SET1T0E
EI
:
:
Example 2:
Timer0 = 16-bit event counter mode
LDMR0FUNC,#0000_0100B;EC0 Set
LDMTM0,#0001_1111B;Counter Mode
LDMTM1,#0100_1100B;16bit Mode
LDMTDR0,#<0FFH ;
LDMTDR1,#>0FFH ;
SET1T0E
EI
:
:
12.6 PWM Mode
The GMS81C2120 has a high speed PWM (Pulse Width
Modulation) functions which shared with Timer1.
In PWM mode, pin R5 6/P WM1O/ T1O out p uts up t o a 10bit resolution PWM output . This pin should be configured
as a PWM output by setting "1" bit PWM1O in R5FUNC.6
register.
The period of the PWM output is determined by the
T1PPR (PWM1 Period Register) and PWM1HR[3:2]
(bit3,2 of PWM1 High Register) and the dut y of the PWM
output is determined by the T1PDR (PWM1 Duty Register) and PWM1HR[1:0] (bit1,0 of PWM1 High Register).
The user writes the lower 8-bit period value to the T1PPR
and the higher 2-bit period value to the PWM1HR[3:2].
Example 3:
Timer0 = 16-bit capture mode
LDMR0FUNC,#0000_0001B;INT0 set
LDMTM0,#0010_1111B;Capture Mode
LDMTM1,#0100_1100B;16bit Mode
LDMTDR0,#<0FFH ;
LDMTDR1,#>0FFH ;
LDMIEDS,#01H;Falling Edge
SET1T0E
EI
:
:
And writes duty value to the T1PDR and the
PWM1HR[1:0] same way.
The T1PDR is configured as a double buffering for glitchless PWM output. In Figure 12-12, 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 = [PWM1HR[3:2]T1PPR] X Source Clock
PWM Duty = [PWM1HR[1:0]T1PDR] X Source Clock
The relation of frequency and resolution is in inverse proportion. Table 12-2 shows the relation of PWM frequency
vs. resolution.
JUNE. 2001 Ver 1.0053
Page 60
GMS81C2112/GMS81C2120
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).
It can be changed duty value when the PWM ou tput. How-
ever 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 12-14. As it were, the ab solute duty time is not
changed in varying frequency. But the changed peri od value must greater than the duty value.
ADDRESS : D2H
RESET VALUE : 00000000
ADDRESS : D5H
RESET VALUE : ----0000
Bit Manipulation Not Available
Duty High
X : The value "0" or "1" corresponding your operation.
XI
f
T0 clock source
[T0CK]
1
÷
2
÷
8
÷
T1CK[1:0]
MUX
T1ST
0 : Stop
1 : Clear and Start
1
T1CN
Slave
Master
T1PPR(8-bit)
COMPARATOR
(2-bit)
T1 ( 8-bit )
COMPARATOR
T1PDR(8-bit)
PWM1HR[1:0]
T1PDR(8-bit)
Figure 12-12 PWM Mode
CLEAR
SQ
R
POL
PWM1O
[R5FUNC.6]
R56/
PWM1O/T1O
54JUNE. 2001 Ver 1.00
Page 61
Source
clock
T1
PWM1E
T1ST
T1CN
PWM1O
[POL=1]
PWM1O
[POL=0]
020304057F
0100
Duty Cycle [ 80H x 250nS = 32uS ]
Period Cycle [ 3FFH x 250nS = 255.75uS, 3.9KHz ]
GMS81C2112/GMS81C2120
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
80
~
~
~
810203
~
~
~
~
3FF
~
~
0100
T1CK[1:0] = 00 ( f
PWM1HR = 0CH
T1PPR = FFH
T1PDR = 80H
T1CK[1:0] = 10 ( 1uS )
PWM 1HR = 00H
T1PPR = 0EH
T1PDR = 05H
Source
clock
T1
PWM1O
POL=1
02 03 04
01
Duty Cycle
[ 05H x 2uS = 10uS ]
XI
)
PWM1HR3 PWM1HR2
Period
PWM1HR1 PWM1HR0
Duty
Figure 12-13 Example of PWM at 4MHz
Write T1PPR to 0AH
0608 090B 0C 0D
05
T1PPR (8-bit)
11FFH
T1PDR (8-bit)
0080H
Period changed
02 03 04
01
0E
Duty Cycle
[ 05H x 2uS = 10uS ]
06 07 08 09
05
02 03 04070A
01
0A
Duty Cycle
[ 05H x 2uS = 10uS ]
05
Period Cycle [ 0EH x 2uS = 28uS, 35.5KHz ]
Period Cycle [ 0AH x 2uS = 20uS, 50KHz ]
Figure 12-14 Example of Changing the Period in Absolute Duty Cycle (@4MHz)
JUNE. 2001 Ver 1.0055
Page 62
GMS81C2112/GMS81C2120
13. ANALOG 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 AV
of ladder resistance
DD
of A/D module.
The A/D module has two registers which are the control
register ADCM and A/D result register ADR. The register
ADCM, shown in Figure 13-1, 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, each port is assigned analog input
port by setting the bit ANSEL[7:0] in R6FUNC register.
R/W R/W R/W R/W R/W R
BTCL
ADEN
ADS1 ADS0 -ADS2
ADCM
76543210
-
ADST
And selected the corresponding channel to b e converted by
setting ADS[3:0].
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 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
13-2. The A/D status bit ADSF is set automatically when
A/D conversion is completed, cleared when A/D conversion is in process. The conversion time takes maximum 20
XI
uS (at f
ADSF
=4 MHz)
ADDRESS: 0EA
INITIAL VALUE: -0-0 0001
A/D status bit
0: A/D conversion is in progress
1: A/D conversion is completed
H
B
ADCR
RRRRRR
R
76543210
A/D Conversion Data
R
BTCL
Figure 13-1 A/D Converter Control Register
A/D start bit
Setting this bit starts an A/D conversion.
After one cycle, bit is cleared to “0” by hardware.
A/D converter Enable bit
0: A/D converter module turn off and
current is not flow.
1: Enable A/D converter
ADDRESS: 0EB
INITIAL VALUE: Undefined
H
56JUNE. 2001 Ver 1.00
Page 63
GMS81C2112/GMS81C2120
.
R60/AN0
R61/AN1
R62/AN2
R63/AN3
R64/AN4
R65/AN5
R66/AN6
R67/AN7
R6FUNC[7:0]
ANSEL0
ANSEL1
ANSEL2
ANSEL3
ANSEL4
ANSEL5
ANSEL6
ADS[2:0]
000
001
010
011
100
101
110
111
AV
DD
S/H
Sample & Hold
“0”
“1”
ADEN
LADDER R E SISTOR
8-bit DAC
SUCCESSIVE
APPROXIMATION
CIRCUIT
ADR (8-bit)
A/D result register
A/D
INTERRUPT
ADIF
ADDRESS: E9
RESET VALUE: Undefined
H
ANSEL7
Figure 13-2 A/D Block Diagram
JUNE. 2001 Ver 1.0057
Page 64
GMS81C2112/GMS81C2120
AN11~AN0
100~1000pF
Analog
Input
(2) Noise countermeasures
In order to maintain 8-bit resolution, attention must be paid to
ENABLE A/D CONVERTER
A/D INPUT CHANNEL SELECT
ANALOG REFERENCE SELECT
A/D START ( ADST = 1 )
noise on pins AVDD and AN7 to AN0. Since
es in proportion to the output impedance of the analog input source, it is recommended that
externally as shown in Figure 13-4 in order to reduce noise.
Figure 13-4 Analog Input Pin Connecting Capacitor
the effect increas-
a capacitor be connected
NOP
ADSF = 1
YES
READ ADCR
NO
Figure 13-3 A/D Converter Operation Flow
A/D Converter Cautions
(1) Input range of AN7 to AN0
The input voltage of AN7 to AN0 should be within the
specification range. In particular, if a vo ltage above A
or below AVSS
rating range), the con version value for t hat ch annel can n ot be in determinate. The conversion values of the ot her channels may
also be affected.
is input (even if within the absolute maximum
VDD
(3) Pins AN7/R67 to AN0/R60
The analog input pins AN7 to AN0 also function as input/
output port (PORT R6) pi ns. When A/D convers ion i s performed with any of pins AN7 to AN0 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 expe cted 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 conversion.
(4) AVDD pin input impeda n ce
A series resistor string of approximately 10KΩ is connected be-
tween the AVDD
pin and the AVS S pin.
Therefore, if the output impedance of the reference voltage
source is high, this will result in parallel connectio n
series resistor string between the AVDD
and there will be a large reference voltage error.
pin and the AVSS pin,
to the
58JUNE. 2001 Ver 1.00
Page 65
14. SERIAL PERIPHERAL INTERFACE
GMS81C2112/GMS81C2120
The Serial Peripheral Interface (SPI) module is a serial interface useful for communicating with other peripheral of
microcontroller devices. These peripheral devices may be
serial EEPROMs, shift registers, display drivers, A/D converters, etc. The Se rial Peripheral Interf ace(SPI) is 8-bit
SCK[1:0]
POL
“0”
“1”
IOSW
XIN PIN
Timer0
Overflow
SCLK PIN
SOUT
IOSWIN
PIN
Prescaler
SCK[1:0]
4
÷
16
÷
“11”
not “11”
SOUT
00
01
10
11
MUX
clock synchronous type and consists of serial I/O register,
serial I/O mode register, clock selection circuit octal
counter and control circuit. The SOUT pin is designed to
input and output. So Serial Peripheral Interface(SPI) can
be operated with minimum two pin
SPI
SIOSF
Complete
Clock
overflow
Octal
Counter
SIOIF
Serial communication
Interrupt
SIOST
Start
Clock
CONTROL
CIRCUIT
SIN PIN
IOSWIN
1
0
Input shift register
SIOR
Internal Bus
Figure 14-1 SPI Block Diagram
Shift
JUNE. 2001 Ver 1.0059
Page 66
GMS81C2112/GMS81C2120
Serial I/O Mode Register(SIOM) controls serial I/O function. According to SCK1 and SCK0, the internal clock or
external clock can be selected. The serial transmission operation mode is decided by setting the SM1 and SM0, and
the polarity of transfer clock is selected by setting the POL.
Serial I/O Data Register(S IOR) is a 8-bit shift regi ster.
First LSB is send or is received. When receiving mode, serial input pin is selected by IOSW. The SPI allows 8-bits
of data to be synchronously transmitted and received.
R/W
R/W
R/W R/W R/W R/W R/W R
BTCL
SCK1 SCK0SM1
SM0
SIOM
76543210
IOSWPOLSIOST
To accomplish communication, typically three pins are
used:
- Serial Data In R54/SIN
- Serial Data OutR55/SOUT
- Serial ClockR53/SCLK
.
SIOSF
ADDRESS: 0E0
INITIAL VALUE: 0000 0001
Serial transmission status bit
0: Serial transmission is in progress
1: Serial transmission is completed
Serial transmission start bit
Setting this bit starts an Serial transmission.
After one cycle, bit is cleared to “0” by hardware.
Serial transmission Clock selection
00: f
4
÷
XIN
16
01: f
÷
XIN
10: TMR0OV(Timer0 Overflow)
11: External Clock
H
B
SIOR
R/W R/W R/W R/WR/W R/W
R/W
76543210
Sending Data at Sending Mode
Receiving Data at Receiving Mode
R/W
BTCL
Figure 14-2 SPI Control Register
Serial transmission Operation Mode
00: Normal Port(R55,R54,R53)
01: Sending Mode(SOUT,R54,SCLK)
10: Receiving Mode(R55,SIN,SCLK)
11: Sending & Receiving Mode(SOUT,SIN,SCLK)
Serial In put Pin Selection bit
0: SIN Pin Selection
1: IOSWIN Pin Selection
Serial Clock Polarity Selection bit
0: Data Transmission at Falling Edge
Received Data Latch at Rising Edge
1: Data Transmission at Rising Edge
Received Data Latch at Falling Edge
ADDRESS: 0E1
INITIAL VALUE: Undefined
H
60JUNE. 2001 Ver 1.00
Page 67
14.1 Transmission/Receiving Timing
GMS81C2112/GMS81C2120
The serial transmission is started by setting SIOST(bit1 of
SIOM) to “1”. After one cycle of SCK, SIOST is cleared
automatically to “0”. The serial output data from 8-bit shift
register is output at falling edge of SCLK. And input data
SIOST
SCLK [R53]
(POL=0)
SOUT [R55]
SIN [R54]
(IOSW=0)
IOSWIN [R 5 5 ]
(IOSW=1)
SIOSF
(SPI Status)
SPIIF
(SPI Int. Req)
D1D2D3D4D6D7D0D5
D1D2D3D4D6D7D0D5
D1D2D3D4D6D7D0D5
is latched at rising edge of SCLK pin. When transmis sion
clock is counted 8 times, serial I/O counter is cleared as
‘0”. Transmission clock is halted in “H” state and serial I/
O interrupt(IFSIO) occurred.
SIOST
SCLK [R53]
(POL=1)
SOUT [R55]
SIN [R54]
(IOSW=0)
IOSWIN [R 5 5 ]
(IOSW=1)
SIOSF
(SPI Status)
SPIIF
(SPI Int. Req)
Figure 14-3 SPI Timing Diagram at POL=0
D1D2D3D4D6D7D0D5
D1D2D3D4D6D7D0D5
D1D2D3D4D6D7D0D5
Figure 14-4 SPI Timing Diagram at POL=1
JUNE. 2001 Ver 1.0061
Page 68
GMS81C2112/GMS81C2120
14.2 The method of Serial I/O
Select transmission/receiving mode
Note:
When external clock is used, the frequency should
be less than 1MHz and recommended duty is 50%.
In case of sending mode, write data t o be s end to SIOR.
Set SIOST to “1” to start serial transmission.
Note:
If both transmission mode is selected and transmis-
sion is performed simultaneously it would be made error.
14.3 The Method to Test Correct Transmission
Serial I/O Interrupt
Service Routine
SIOSF
1
SE = 0
The SIO interrupt is generated at the completion of SIO
and SIOSF is set to “1”. In SIO interrupt service routine,
correct transmission should be tested.
In case of receiving mode, the received data is acquired
by reading the SIOR.
0
Abnormal
Write SIOM
SR
Normal Operation
- SE : Interrupt Enable Register Low IENL(Bit3)
- SR : Interrupt Request Flag Register Low IRQL(Bit3)
0
1
Overrun Error
Figure 14-5 Serial Method to Test Transmission
62JUNE. 2001 Ver 1.00
Page 69
15. BUZZER FUNCTION
GMS81C2112/GMS81C2120
The buzzer driver block consists of 6-bit binary counter,
buzzer register BUR, and clock source selector. It generates square-wave which has very wide range frequency
(480Hz ~ 250kHz at f
= 4MHz) by user software.
XIN
A 50% duty pulse can be output to R03/BUZO pin to use
for piezo-electric buzzer drive
port of Buzzer driver by setting the bit 3 of R0FUNC(address
0F4
) to “1”.
H
At this time, the pin R03 must be defined as
. Pin R03 is assigned for output
output mode (the bit 3 of R0IO=1).
Example: 5kHz output at 4MHz.
LDMR0IO,#XXXX_1XXXB
LDMBUR,#0011_0010B
LDMR0FUNC,#XXXX_1XXXB
X means don’t care
6-BIT COUNTER
Compare data
BUR
]
H
6-bit binary
XIN PIN
Prescaler
8
÷
00
16
÷
01
32
÷
10
64
÷
11
MUX
2
[0DE
The bit 0 to 5 of BUR determines output frequency for
buzzer driving.
Equation of frequency calcu lation is shown below .
Divide Ratio: Prescaler divide ratio by BUCK[1:0]
BUR: Lower 6-bit value of BUR. Buzzer period value.
XIN
The frequency of output signal is controlled by the buzzer
control register BUR.The bit 0 to bit 5 of BUR determine
output frequency for buzzer driving.
R03 port data
[0F4
0
1
3
R0FUNC
]
H
R03/BUZO PIN
Port selection
Comparator
6
÷
F/F
2
Internal bus line
Figure 15-1 Block Diagram of Buzzer Driver
ADDRESS: 0DE
RESET VALUE: Undefined
BUR[5:0]
Buzzer Period Data
Source clock select
00:
01: ÷ 16
10: ÷ 32
11: ÷ 64
H
8
÷
R0FUNC
ADDRESS : 0F4
RESET VALUE : ---- 0000
WW
--
BUZO EC0 INT1 INT0
--
R03/BUZO Selection
0: R03 port (Turn off buzzer)
1: BUZO port (Turn on buzzer)
H
W
W
B
BUR
WW
BUCK1
BUCK0
WWWWWW
Figure 15-2 R0FUNC and Buzzer Register
JUNE. 2001 Ver 1.0063
Page 70
GMS81C2112/GMS81C2120
Note:
BUR is undefined after rese t, so it m ust be in itialize d
to between 1
and 3FH by software.
H
Note that BUR is a write-only register.
BUR
[5:0]
00
01
02
03
04
05
06
07
08
09
0A
0B
0C
0D
0E
0F
10
11
12
13
14
15
16
17
18
19
1A
1B
1C
1D
1E
1F
0001101100011011
250.000
125.000
83.333
62.500
50.000
41.667
35.714
31.250
27.778
25.000
22.727
20.833
19.231
17.857
16.667
15.625
14.706
13.889
13.158
12.500
11.905
11.364
10.870
10.417
10.000
9.615
9.259
8.929
8.621
8.333
8.065
7.813
BUR[7:6]
125.000
62.500
41.667
31.250
25.000
20.833
17.857
15.625
13.889
12.500
11.364
10.417
9.615
8.929
8.333
7.813
7.353
6.944
6.579
6.250
5.952
5.682
5.435
5.208
5.000
4.808
4.630
4.464
4.310
4.167
4.032
3.906
62.500
31.250
20.833
15.625
12.500
10.417
8.929
7.813
6.944
6.250
5.682
5.208
4.808
4.464
4.167
3.906
3.676
3.472
3.289
3.125
2.976
2.841
2.717
2.604
2.500
2.404
2.315
2.232
2.155
2.083
2.016
1.953
31.250
15.625
10.417
7.813
6.250
5.208
4.464
3.906
3.472
3.125
2.841
2.604
2.404
2.232
2.083
1.953
1.838
1.736
1.645
1.563
1.488
1.420
1.359
1.302
1.250
1.202
1.157
1.116
1.078
1.042
1.008
0.977
The 6-bit counter is cleared and starts the counting by writing signal at BUR register. It is incremental from 00
until
H
it matches 6-bit BUR value.
When main-frequency is 4MHz, buzzer frequency is
shown as below table.
BUR
[5:0]
20
21
22
23
24
25
26
27
28
29
2A
2B
2C
2D
2E
2F
30
31
32
33
34
35
36
37
38
39
3A
3B
3C
3D
3E
3F
7.576
7.353
7.143
6.944
6.757
6.579
6.410
6.250
6.098
5.952
5.814
5.682
5.556
5.435
5.319
5.208
5.102
5.000
4.902
4.808
4.717
4.630
4.545
4.464
4.386
4.310
4.237
4.167
4.098
4.032
3.968
3.907
BUR[7:6]
3.788
3.676
3.571
3.472
3.378
3.289
3.205
3.125
3.049
2.976
2.907
2.841
2.778
2.717
2.660
2.604
2.551
2.500
2.451
2.404
2.358
2.315
2.273
2.232
2.193
2.155
2.119
2.083
2.049
2.016
1.984
1.953
1.894
1.838
1.786
1.736
1.689
1.645
1.603
1.563
1.524
1.488
1.453
1.420
1.389
1.359
1.330
1.302
1.276
1.250
1.225
1.202
1.179
1.157
1.136
1.116
1.096
1.078
1.059
1.042
1.025
1.008
0.992
0.977
0.947
0.919
0.893
0.868
0.845
0.822
0.801
0.781
0.762
0.744
0.727
0.710
0.694
0.679
0.665
0.651
0.638
0.625
0.613
0.601
0.590
0.579
0.568
0.558
0.548
0.539
0.530
0.521
0.512
0.504
0.496
0.488
64JUNE. 2001 Ver 1.00
Page 71
16. INTERRUPTS
GMS81C2112/GMS81C2120
The GMS81C21xx 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). Nine interrupt sources are provided. The
configuration of interrupt circuit is shown in Figure 16-2.
The External Interrupts INT0 and INT1 each can be transition-activated (1-to-0 or 0-to -1 transition) by selection
IEDS.
The flags that actu ally generate these in terrupts are bit
INT0F and INT1F in register IRQH. When an external interrupt is generated, the flag that generated it is cleared by
the hardware when the service routine is vectored to only
if the interrupt was transition-activated.
The Timer 0 ~ Timer 1 Interrupts are generated by TxIF
which is set by a match in their respective timer/counter
register. The Basic Interval Timer Interrupt is generated by
BITIF which is set by an overflow in the timer register.
The AD converter Interrupt is generated by ADIF whi ch is
set by finishing the analog to digital conversion.
The Watchdog timer Interrupt is generated by WDTIF
which set by a match in Watchdog timer register.
The Basic Interval Timer Interrupt is generated by BITIF
which are set by a overflow in the timer counter register.
The interrupts are controlled by the interrupt master enable
flag I-flag (bit 2 of PSW on page 21), the interrupt enable
register (IENH, IENL), and the interrupt request flags (in
IRQH and IRQL) except Power-on reset and software
BRK interrupt. Below table shows the Interrupt priority.
Vector addresses are shown in Figure 8-6 on page 23. Interrupt enable registers are shown in Figure 16-3. These
registers are composed of interrupt enab le flags of each interrupt source and these flags determines whether an interrupt will be accepted or not. When enable flag is “0”, a
corresponding interrupt source is prohibited. Note that
PSW contains also a master enable bit, I-flag, which disables all interrupts at once.
R/W
R/W
SPIF
--
--
--
-
-
INT1IF
WDTIF
R/W
T0IF T1IF
R/W
BITIF
R/W R/W
IRQH
IRQL
INT0IF
MSB
R/W R/W
ADIF
MSBLSB
Figure 16-1 Interrupt Request Flag
-
-
-
-
-
-
-
-
ADDRESS: 0E4
INITIAL VALUE: 0000 ----
LSB
Timer/Counter 1 interrupt request flag
Timer/Counter 0 interrupt request flag
External interrupt 1 request flag
External interrupt 0 request flag
ADDRESS: 0E5
INITIAL VALUE: 0000 ----
Serial Communication interrupt request flag
Basic Interval imer interrupt request flag
Watchdog timer interrupt request flag
A/D Conver interrupt request flag
H
H
B
B
JUNE. 2001 Ver 1.0065
Page 72
GMS81C2112/GMS81C2120
.
Internal bus line
INT0
INT1
Timer 0
Timer 1
A/D Converter
Watchdog Timer
BIT
Communication
Serial
IRQH
[0E4
IRQL
[0E5
]
H
]
H
INT0IF
INT1IF
T0IF
T1IF
ADIF
WDTIF
BITIF
SIOIF
[0E2H]
[0E3
IENH
]
H
Interrupt Enable
Register (Higher byte)
Interrupt Enable
IENL
Register (Lower byte)
Internal bus line
I-flag is in PSW, it is cleared by "DI", set by
"EI" instruction. When it goes interrupt service,
I-flag is cleared by hardware, thus any other
interrupt are inhibited. When interrupt service is
completed by "RETI" instruction, I-flag is set to
"1" by hardware.
Release STOP
To CPU
I-flag
Priority Control
Interrupt Master
Enable Flag
Interrupt
Vector
Address
Generator
Figure 16-2 Block Diagram of Interrupt
R/W
T1E
R/W
SPIE
--
--
--
-
-
IENH
R/W R/W
INT0E
INT1E
R/W
T0E
MSB
IENL
R/W R/W
ADE
WDTE
R/W
BITE
MSBLSB
Figure 16-3 Interrupt Enable Flag
-
-
-
-
ADDRESS: 0E2
INITIAL VALUE: 0000 ----
LSB
H
B
Timer/Counter 1 interrupt enable flag
Timer/Counter 0 interrupt enable flag
External interrupt 1 enable flag
External interrupt 0 enable flag
-
-
-
-
ADDRESS: 0E3
INITIAL VALUE: 0000 ----
H
B
VALUE
0: Disable
1: Enable
Serial Communication interrupt enable flag
Basic Interval imer interrupt enable flag
Watchdog timer interrupt enable flag
A/D Convert interrupt enable flag
66JUNE. 2001 Ver 1.00
Page 73
16.1 Interrupt Sequence
GMS81C2112/GMS81C2120
An interrupt request is held until the interrupt is accepted
or the interrupt latch is cleared to “0” by a reset or an instruction. Interrupt acceptance sequence requires 8
µs at f
=4.19MHz) after the completion of the current
MAIN
f
XIN
(2
instruction execution. The interrupt service task is term inated upon execution of an interrupt return instruction
[RETI].
Interrupt acceptance
1. The interrupt master enable flag (I-flag) is cleared to
“0” to temporarily disable the acceptance of any following maskable interrupts. When a non-maskable interrupt is accepted, the acceptance of any following
interrupts is temporarily disabled.
System clock
Instruction Fetch
Address Bus
PC
SPSP-1
2. Interrupt request flag for the interr upt source accepted is
cleared to “0”.
3. The contents of the program counter (return address)
and the program status word are saved (pushed) ont o the
stack area. The stack pointer decreases 3 times.
4. The entry address of the interrupt service program is
read from the vector table address and the entry address
is loaded to the program counter.
5. The instruction stored at the entry address of the interrupt service program is executed.
SP-2V.H.New PC
V.L.
Data Bus
Internal Read
Internal Write
V.L. and V.H. are vector addresses.
ADL and ADH are start addresses of interrupt service routine as vector contents.
Not used
PCHPCL
Interrupt Processing StepInterrupt Service Task
Figure 16-4 Timing chart of Interrupt Acceptance and Interrupt Return Instruction
Basic Interval Timer
Vector Table Address
0FFE6
0FFE7
Correspondence between vector table address for BIT interrupt
and the entry address of the interrupt service program.
012
0E3
H
H
H
H
0E312
0E313
Entry Address
0E
2E
H
H
H
H
A interrupt request is not accepted until the I-flag is set to
“1” even if a requested interrupt has higher priority than
that of the current interrupt being serviced.
PSWADLOP codeADH
V.L.
When nested interrupt service is required, the I -flag should
be set to “1” by “EI” instruction in the interrupt service
program. In this case, acceptable interrupt sources are selectively enabled by the individual interrupt enable flags.
Saving/Restoring General-purpose Register
During interrupt acceptance processing, the program
counter and the program status word are automatically
saved on the stack, but accumulator and other registers ar e
not saved itself. These registers are saved by the software
if necessary. Also, when multiple interrupt services are
nested, it is necessary to avoid using the same data memory
JUNE. 2001 Ver 1.0067
Page 74
GMS81C2112/GMS81C2120
B-FLAG
BRK
INTERRUPT
ROUTINE
RETI
TCALL0
ROUTINE
RET
BRK or
TCALL0
=0
=1
area for saving registers.
The following method is used to save/restore the general-
purpose registers.
Example: Register save using push and pop instructions
INTxx:PUSHA
PUSHX
PUSHY
interrupt processing
POPY
POPX
POPA
RETI
;SAVE ACC.
;SAVE X REG.
;SAVE Y REG.
;RESTORE Y REG.
;RESTORE X REG.
;RESTORE ACC.
;RETURN
General-purpose register save/restore using push and pop
instructions;
main task
acceptance of
interrupt
interrupt
service task
saving
registers
16.2 BRK Interrupt
Software interrupt can be invoked by BRK instruction,
which has the lowest priority order.
Interrupt vector address of BRK is shared with the vector
of TCALL 0 (Refer to Program Memory Section). When
BRK interrupt is generated, B-flag of PSW is set to distinguish BRK from TCALL 0.
Each processing step is determined by B-flag as shown in
Figure 16-5.
interrupt return
restoring
registers
Figure 16-5 Execution of BRK/TCALL0
68JUNE. 2001 Ver 1.00
Page 75
16.3 Multi Interrupt
GMS81C2112/GMS81C2120
If two requests of different priority levels are received simultaneously, the request of higher priority level is serviced. If requests of the interrupt are received at the same
time simultaneously, an internal polling sequence determines by hardware which request is serviced.
Main Program
service
Occur
TIMER1 interrupt
Occur
INT0
TIMER 1
service
enable INT0
disable other
EI
enable INT0
enable other
INT0
service
However, multiple processing through software for special
features is possible. Generally when an interrupt is accepted, the I-flag is cleared to disable any further interru pt. But
as user sets I-flag in interrupt routine, some further interrupt can be serviced even if certain interrupt is in progress.
Example:
During Timer1 interrupt is in progress, INT0 in-
terrupt serviced without any suspen d.
TIMER1: PUSHA
PUSHX
PUSHY
LDMIENH,#80H;
LDMIENL,#0;
EI;
:
:
:
:
:
:
LDMIENH,#0F0H ;
LDMIENL,#0F0H
POPY
POPX
POPA
RETI
Enable INT0 only
Disable other
Enable Interrupt
Enable all interrupts
In this example, the INT0 interrupt can be serviced without any
pending, even TIMER1 is in progress.
Because of re-setting the interrupt enable registers IENH,IENL
and master enable "EI" in the TIMER1 routine.
Figure 16-6 Execution of Multi Interrupt
JUNE. 2001 Ver 1.0069
Page 76
GMS81C2112/GMS81C2120
16.4 External Interrupt
The external interrupt on INT0 and INT1 pins are edge
triggered depending o n the edge select ion register IEDS
(address 0F8
) as shown in Figure 16-7.
H
The edge detection of external interrupt has three transition
activated mode: rising edge, falling edge, and both edge.
INT1 pin
INT0 pin
22
IEDS
[0E6H]
Figure 16-7 External Interrupt Block Diagram
INT1IF
INT1 INTERRUPT
INT0IF
INT0 INTERRUPT
Edge selection
Register
INT0 and INT1 are mu ltiplexed with general I/O ports
(R00 and R01). To use as an external interrupt pin, the bit
of R4 port mode regis ter R0FUNC should be set to “1” correspondingly.
Example:
To use as an INT0 and INT1
:
:
;
**** Set port as an input port R00,R01
LDMR0IO,#1111_1100B
;
;
**** Set port as an inter rupt port
LDMR0FUNC,#0000_0011B
;
;
**** Set Falling-edge Detection
LDMIEDS,#0000_0101B
:
:
:
Response Time
The INT0 and INT1 edge are latched into INT0IF and
INT1IF at every machine cycle. The values are not actually
polled by the circuitry until the next machine cycle. If a request is active and conditions are right for it to be acknowledged, a hardware subroutine call to the reques ted 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.
For applications where power consumption is a critical
factor, device provides four kinds of power saving functions, STOP mode, Sub-active mode and Wake-up Timer
mode (Stand-by mode, Watc h mode). Table 17-1 shows
the status of each Power Saving Mode.
Wake-up Timer
PeripheralSTOP Mode
RAMRetainRetain
Control RegistersRetainRetain
I/O PortsRetainRetain
CPUStopStop
Timer0StopOperation
OscillationStopOscillation
PrescalerStop
Entering Condition
[WAKEUP]
Table 17-1 Power Saving Mode
01
Mode
Stand-by Mode
÷
2048 only
The power saving function is activated by execution of
STOP instruction and by execution of STOP instruction after setting the corresponding status (WAKEUP) of
CKCTLR. We shows the release sources from each Power
Saving Mode
Wake-up Timer
Release SourceSTOP Mode
RESETOO
RCWDTOO
EXT.INT0
OO
EXT.INT1
Timer0XO
Table 17-2 Release Sources from Power Saving Mode
Mode
Stand-by Mode
72JUNE. 2001 Ver 1.00
Page 79
17.1 Operating Mode
fXI : Main clock frequency
GMS81C2112/GMS81C2120
SYS
f
: fXI,f
XI
XI
÷4
÷
,f
8,f
cpu : system clock
tmr : timer0 clock
peri : peripheral clock
CKCTLR = CKCTLR[6:5]
STANDBY Mode
XI
: oscillation
f
cpu : stop
tmr : ps11(f
peri : stop
XI
XI
÷
32
CKCTLR[10]
+
STOP
)
TIMER0
EXT_INT
RESET
RC_WDT
ACTIVE Mode
XI
: oscillation
f
cpu : f
tmr : f
peri : f
CKCTLR[00]
+
STOP
STOP Mode
SYS
SYS
SYS
EXT_INT
RESET
RC_WDT
XI
: stop
f
cpu : stop
tmr : stop
peri : stop
System Clock Mode Register
SCMR
CS[1:0]Clock selection enable bits
---CS1CS0---
00 : fXI 10 : fXI ÷ 8
XI
01 : f
÷ 4 11 : fXI ÷ 32
ADDRESS : FAH
RESET VALUE : ---00---
JUNE. 2001 Ver 1.0073
Page 80
GMS81C2112/GMS81C2120
IEXX
=0
=1
STOP
INSTRUCTION
STOP Mode
Interrupt Request
STOP Mode Release
I-FLAG
=1
Interrupt Service Routine
Next
INSTRUCTION
=0
Master Interrupt
Enable Bit PSW[2]
Corresponding Inte rr upt
Enable Bit (IENH, IENL)
17.2 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
Release the STOP mode
The exit from STOP mode is hardware reset or external interrupt. Reset re-defines all the Contro l registers but do es
not change the on-chip RAM. External interrupts allow
both on-chip RAM and Co ntrol regi sters to reta in their v alues.
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 17-1)
When exit from Stop mode by external interrupt, enough
oscillation stabilization t ime is required to normal o peration. Figure 17-2 shows the timing diagram. When release
the Stop mode, the Basic interval timer is activated on
wake-up. It is increased from 00
until FFH. The count
H
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.
By reset, exit from Stop mode is shown in Figure .
The reset should not be activated before V
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 writ ten
Ex)LDM CKCTLR ,#0 00 0_1 110 B
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 dissipation associated with the
pin interface (depending on the external circuitry and program) is not directly determ ined by the hard ware operatio n
of the STOP feature. This point should be little current
flows when the input level is s table at the power voltage
level (V
er than the power voltage level (by approximately 0.3 to
0.5V), a current begins to flow. Therefore, if cutting off the
DD/VSS
output transistor at an I/O port puts the pin signal into the
high-impedance state, a current flow across the ports input
transistor, requiring to fix the level by pull-up or other
means.
); however, when the input lev el get s high -
is restored to
Figure 17-1 STOP Releasing Flow by Interrupts
74JUNE. 2001 Ver 1.00
Page 81
GMS81C2112/GMS81C2120
.
~
Oscillator
pin)
(X
IN
Internal Clock
External Interrupt
BIT Counter
~
~
~
~
~
~
STOP Instruction
Executed
n
n+1 n+2n+3
Normal OperationStop OperationNormal Operation
~
~
~
~
Before executing Stop instruction, Basic Interval Timer must be set
properly by software to get stabilization time which is longer than 20ms.
0
Clear
Figure 17-2 STOP Mode Release Timing by External Interrupt
~
~
~
~
~
~
~
~
~
1
~
~
tST > 20ms
by software
FE
FF
0
12
STOP Mode
Oscillator
(XI pin)
Internal
Clock
RESETB
Internal
RESETB
STOP Instruction Execution
Time can not be control by software
~
~
~
~
~
~
~
~
Figure 17-3 Timing of STOP Mode Release by RESET
17.3 Wake-up Timer Mode
In the Wake-up Timer mode, the on-chip oscillator is not
stopped. Except the Prescaler(onl y 2048 divi ded ratio) and
Timer0, all functions are stopped, but the on-c hip RAM
and Control registers are held. The port pins out the values
held by their respective port data register, port direction
registers.
The Wake-up Timer mode is activated by execution of
STOP instruction after setting the bit WAKEUP of
CKCTLR to “1”. (This register should be written by
byte operation. If this register is set by bit ma nipulation
instruction, for example "set1" or "clr1" instruction, it
may be undesired operation)
Note:
After STOP instruction, at least two or more NOP in-
In addition, the clock source of timer0 should be selected
to 2048 divided ratio. Otherwise, the wake-u p function can
not work. And the timer0 can be operated as 16-bit timer
with timer1. (refer to timer function)The period of wakeup function is varied by setting the timer data register 0,
TDR0.
JUNE. 2001 Ver 1.0075
Page 82
GMS81C2112/GMS81C2120
Release the Wake-up Timer mode
The exit from Wake-up Timer mode is hardware reset,
Timer0 overflow or external interrupt. Reset re-defines all
the Control registers but does not change the on-chip
RAM. External interrupts and Timer0 overflow allow both
on-chip RAM and Control registers to retain their values.
If I-flag = 1, the normal in terrupt response takes place. I f I-
~
Oscillator
(XI pin)
CPU
Clock
Interrupt
Request
STOP Instruction
Execution
Normal Operation
Figure 17-4 Wake-up Timer Mode Releasing by External Interrupt or Timer0 Interrupt
~
~
~
~
~
~
~
Wake-up Timer Mode
( stop the CPU clock )
17.4 Internal RC-Oscillated Watchdog Timer Mode
In the Internal RC-Oscillated Wat chdog Timer mode, 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 WAKEUP and RCWDT of CKCTLR to "
01 ". (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 u ndesired operation)
Note:
Caution: After STOP instruction, at le ast two or more
NOP instruction should be written
Ex)
The exit from Internal RC-Oscillated Watchdog Timer
mode is hardware reset or external interrupt. Reset re-defines all the Control registers but does not change the onchip RAM. External interrupts allow both on-chip RAM
LDM WDTR
LDM CKCTLR
STOP
NOP
NOP
,#1111_1111B
,#0010_1110B
flag = 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 17-1)
When exit from Wake-up Timer mode by external interrupt or timer0 overflow, the oscillation stabilization time is
not required to normal operation. Because this mode do not
stop the on-chip oscillator shown as Figure 17-4.
Normal Operation
Do not need Stabilization Time
and Control registers to retain their values.
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 17-5)
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 17-6)
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 17-1)
When exit from Internal RC-Oscillated Watchdog Timer
mode by external interrupt, the oscillation stabilization
time is required to norma l operation. Figure 17-5 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
until FFH. The
H
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 oscillator has started and
stabilized.
By reset, exit from internal RC-Oscillated Watchdog Timer mode is shown in Figure 17-6.
76JUNE. 2001 Ver 1.00
Page 83
Oscillator
(XI pin)
Internal
RC Clock
Internal
Clock
External
Interrupt
( or WDT Interrupt )
BIT
Counter
N-2
N-1
~
~
~
~
~
~
STOP Instruction Execution
N+1NN+2
GMS81C2112/GMS81C2120
~
~
~
~
~
~
~
~
Clear Basic Interval Timer
~
~
0001FE FF 0000
~
~
Figure 17-5 Internal RCWDT Mode Releasing by External Interrupt or WDT Interrupt
Oscillator
(XI pin)
Internal
RC Clock
Internal
Clock
RESET
RESET by WDT
Internal
RESET
Normal Operation
RCWDT ModeNormal Operation
RCWDT Mode
~
~
~
~
~
~
~
~
STOP Instruction Execution
Time can not be control by software
Stabilization Time
> 20mS
t
ST
~
~
~
~
~
~
~
~
~
~
Stabilization Time
t
= 64mS @4MHz
ST
Figure 17-6 Internal RCWDT Mode Releasing by RESET
17.5 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 associat ed with the
pin interface (depending on the external circuitry and program) is not directly determined by the hardware operation
of the STOP feature. Th is point sh ould be little c urrent flows
when the input level is stable at the power voltage level
(V
); however, when the input level becomes higher
DD/VSS
JUNE. 2001 Ver 1.0077
Page 84
GMS81C2112/GMS81C2120
than the power voltage level (by approximately 0.3V), a cu rrent begins to flow. Therefore, if cutting off the output transistor at an I/O port puts the pin signal into the highimpedance state, a curr ent flow across th e ports input transistor, requiring it to fix the level by pull-up or other means.
It should be set properly in order 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 wi th
external circuit. In input mode, the pin impedance viewing
from external MCU is very high that the current does n’t
flow.
INPUT PIN
V
DD
internal
pull-up
V
DD
V
DD
O
i
V
GND
X
Weak pull-up current flows
DD
OPEN
O
But input voltage lev el shou ld be V
or VDD. Be careful
SS
that if unspecified voltage, i.e. if unfirmed voltage level
(not V
or VDD) is applied to input pin, there can be little
SS
current (max. 1mA at around 2V) flow.
If it is not appropriate to set as an input m ode, then set to
output mode considering th ere is no current flow. Settin g
to High or Low is decided considering its relationship with
external circuit. For example, if there is external pull-u p resistor then it is set to output mode, i.e. to High, and if there
is external pull-down register, it is set to low.
V
INPUT PIN
OPEN
i
Very weak current flows
X
i=0
i=0
DD
O
GND
O
When port is configured as an input, input level should
be closed to 0V or 5V to avoid power consumption.
Figure 17-7 Application Example of Unused Input Port
OUTPUT PIN
ON
ON
OFF
i
GND
X
In the left case, much current flows from port to GND.
OFF
ON
OFF
Figure 17-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 consumpt ion, there should be low output
to the port .
L
OFF
ON
GND
O
i=0
GND
V
DD
L
78JUNE. 2001 Ver 1.00
Page 85
18. OSCILLATOR CIRCUIT
X
OUT
X
IN
GMS81C2112/GMS81C2120
The GMS81C21xx has an oscillation circuits internally.
X
and X
IN
are input and output for main frequency re-
OUT
spectively, inverting ampl ifier which can be configured for
C1
C2
Recommend
Crystal Oscillator
Ceramic Resonator
Crystal or Ceramic Oscillator
Open
External Clock
External OscillatorRC Oscillator
X
OUT
X
IN
4.19MHz
C1,C2 = 20pF
C1,C2 = 30pF
being used as an on-chip oscillator , as shown in Figure 18-
1.
X
OUT
X
IN
V
SS
X
OUT
R
EXT
X
IN
For selection R value,
Refer to AC Characteristics
(mask option)
Figure 18-1 Oscillation Circuit
Oscillation circuit is designed to be used either with a ceramic resonator or crystal oscillator. Since each crystal and
ceramic resonator have their own characteristics, the user
should consult the crystal manufacturer for appropriate
values of external components.
Oscillation circuit is designed to be used either with a ceramic resonator or crystal oscillator. Since each crystal and
ceramic resonator have their own characteristics, the user
should consult the crystal manufacturer for appropriate
values of external components.
In addition, see Figure 18-2 for the layout of the crystal.
Note:
Minimize the wiring leng th. Do not allow the wiring to
intersect with other signa l cond uctors . Do not all ow the wiring to come near changing high current. Set the potential of
the grounding position of the oscillator capacitor to that of
SS
V
. Do not ground it to any g round pattern where high cur-
rent is present. Do not fetch signals from the oscillator.
Figure 18-2 Layout of Oscillator PCB circuit
JUNE. 2001 Ver 1.0079
Page 86
GMS81C2112/GMS81C2120
7036P
V
CC
10uF
+
10k
Ω
to the RESET pin
19. RESET
The GMS81C21xx have two types of reset generatio n procedures; one is an external reset input, the other is a watch-
dog timer reset. Table 19-1 shows on-chip hardwar e initialization by reset action.
On-chip HardwareInitial ValueOn-chip HardwareInitial Value
Program counter(PC)
(FFFF
H
Peripheral clockOff
) - (FFFEH)
RAM page register(RPR)0Watchdog timerDisable
G-flag(G)0Control registersRefer to Table 8-1 on page 27
Operation modeMain-frequency clockPower fail detectorDisable
Table 19-1 Initializing Internal Status by Reset Action
19.1 External Reset Input
The reset input is the RESET pin, which is the input to a
Schmitt Trigger. A reset in accomplished by holding the
RESET pin low for at least 8 oscillator periods, within the
operating voltage range and oscillation stable, it is applied,
and the internal state is initialized. A fter reset, 64ms (at 4
MHz) add with 7 oscillator periods are required to start execution as shown in Figure 19-2.
Internal RAM is not affected by reset. When V
is turned
DD
on, the RAM content is indeterminate. Therefore, this
RAM should be initialized before read or tested it.
A connection for simple p ower-on-reset is shown in Figure
19-1.
When the RESET pin input goes to high, the reset operation is released and the program execution starts at the vector address stored at addresses FFFE
- FFFFH.
H
~
Oscillator
(X
pin)
IN
RESET
~
ADDRESS
BUS
DATA
BUS
?
?
t
ST
~
Stabilization Time
= 62.5mS at 4.19MHz
Figure 19-2 Timing Diagram after RESET
19.2 Watchdog Timer Reset
Refer to “11. WATCHDOG TIMER” on page 39.
Figure 19-1 Simple Power-on-Reset Circuit
~
~
~
1234567
~
?
~
~
~
~
~
??
??
RESET Process Step
t
ST
1
= x 256
f
÷1024
MAIN
FFFE FFFF
FE?ADL
ADH
Start
OP
MAIN PROGRAM
80JUNE. 2001 Ver 1.00
Page 87
20. POWER FAIL PROCESSOR
GMS81C2112/GMS81C2120
The GMS81C21xx has an on-chip power fail detection circuitry to immunize against power noise. A configuration
register, PFDR, can enable or disable the po wer fail detect
circuitry. Whenever V
falls close to or below power fail
DD
voltage for 100ns, the power fail situation may reset or
freeze MCU according to PFDM bit of PFDR. Refer to
“7.4 DC Electrical Characteristics for Standard Pins(5V)”
on page 14.
In the in-circuit emulator, power fail function is not implemented and user can not experiment with it. Theref ore, af ter final development of user program, this function may
be experimented or evaluated.
Note:
User can select po wer fail v olt age le vel ac cordi ng to
PFD0, PFD1 bit of CONFIG register(703F
(GMS87C21xx) but
must select
the power fail v oltage leve l
to define PFD option of “Mask Order & Verification Sheet”
at the mask chip(GMS81C21xx).
Because the power fail voltage level of mask chip
(GMS81C21xx) is determined according to mask option.
) at the OTP
H
Note:
If power fail voltage is selected to 3.0V on 3V oper-
ation, MCU is freezed at all the times.
Power FailFunctionOTPMASK
Enable/Disable PFDIS flagPFDIS flag
Level Selection
PFS0 bit
PFS1 bit
Mask option
Table 20-1 Power fail processor
.
PFDR
76543210
R/W R/W R/W
PFDM
PFDIS
PFS
Figure 20-1 Power Fail Voltage Detector Register
ADDRESS: 0EF
INITIAL VALUE: ---- -100
Power Fail Status
0: Normal operate
1: Set to “1” if power fail is detected
Operation Mode
0 : Normal operation regardless of powe r fail
1 : MCU will be reset by power fail detection
Disable Flag
0: Power fail detection enable
1: Power fail detection disable
H
B
JUNE. 2001 Ver 1.0081
Page 88
GMS81C2112/GMS81C2120
RESET VECTOR
V
DD
Internal
RESET
PFS =1
NO
RAM CLEAR
INITIALIZE RAM DATA
INITIALIZE ALL PORTS
INITIALIZE REGISTERS
FUNTION
EXECUTION
YES
PFS = 0
Skip the
initial routine
Figure 20-2 Example S/W of RESET flow by Power fail
64mS
V
MAX
PFD
V
MIN
PFD
When PFR = 1
V
DD
Internal
RESET
V
DD
Internal
RESET
t <64mS
64mS
64mS
Figure 20-3 Power Fail Processor Situations
MAX
V
PFD
V
MIN
PFD
MAX
V
PFD
V
MIN
PFD
82JUNE. 2001 Ver 1.00
Page 89
21. OTP PROGRAMMING
21.1 DEVICE CONFIGURATION AREA
The Device Configuration Area can be programm ed or left
unprogrammed to select device configuration such as security bit.
Sixteen memory locatio ns (7030
~ 703FH) are designated
H
7030
H
DEVICE
CONFIGURATION
AREA
703F
H
GMS81C2112/GMS81C2120
as Customer ID recording locat ions where the user can
store check-sum or other customer iden tification n umbers.
This area is not accessible during normal execution but is
readable and writable during program / verify.
2R53CTL3Read/Write Control
3R54CTL2A ddress /Data Control
4R55CTL1Write Control 1
5R56CTL0Write Control 0
7RESETBVPPProgramming Power (0V, 12.75V)
8XIEPROM EnableHigh Active, Latch Address in falling edge
9XONCNo connection
Table 21-1 Pin Description in EPROM Mode (GMS81C2120)
84JUNE. 2001 Ver 1.00
Page 91
GMS81C2112/GMS81C2120
EPROM
Enable
VPP
CTL0/1
CTL2
CTL3
A_D7~
A_D0
VDD
T
0V
0V
0V
V
VDDS
DD1H
T
VPPS
T
SET1
T
HLD1
V
IHP
T
VPPR
T
CD1
HA
High 8bit
Address
Input
T
DLY1
T
CD1
V
DD1H
LA
Low 8bit
Address
Input
T
HLD2
~
~
~
~
~
~
~
~
V
~
~
~
~
DATA IN
~
~
Write Mode
DD1H
T
DLY2
DATA
Verify
T
CD1
OUT
T
CD1
Low 8bit
Address
Input
Figure 21-3 Timing Diagram in Program (Write & Verify) Mode
~
~
~
~
~
~
~
~
~
~
~
~
LADATA IN
~
~
Write Mode
DATA
OUT
Verify
JUNE. 2001 Ver 1.0085
Page 92
GMS81C2112/GMS81C2120
EPROM
Enable
VPP
CTL0/1
CTL2
CTL3
A_D7~
A_D0
VDD
T
0V
0V
0V
V
VDDS
DD2H
T
VPPS
T
T
SET1
VPPR
After input a high address,
output data following low address input
T
HLD1
T
CD1
HA
High 8bit
Address
Input
T
DLY1
V
IHP
T
CD2
V
DD2H
LA
Low 8bit
Address
Input
V
DD2H
T
CD1
DATA
DATA
Output
T
HLD2
Low 8bit
Address
Input
T
DLY2
T
CD2
LADATA
DATA
Output
Anothe high address step
HA
High 8bit
Address
Input
LA
Low 8bit
Address
Input
DATA
DATA
Output
Figure 21-4 Timing Diagram in READ Mode
ParameterSymbolMINTYPMAXUnit
Programming Supply Current
Supply Current in EPROM Mode
VPP Level during Programming
VDD Level in Program Mode
VDD Level in Read Mode
CTL3~0 High Level in EPROM Mode
CTL3~0 Low Level in EPROM Mode
A_D7~A_D0 High Level in EPROM Mode
A_D7~A_D0 Low Level in EPROM Mode
VDD Saturation Time
VPP Setup Time
VPP Saturation Time
EPROM Enable Setup Time after Data Input
EPROM Enable Hold Time after T
SET1
Table 21-2 AC/DC Requirements for Program/Read Mode
I
VPP
I
VDDP
V
V
DD1H
V
DD2H
V
V
V
V
T
VDDS
T
VPPR
T
VPPS
T
SET1
T
HLD1
IHP
IHC
ILC
IHAD
ILAD
--50mA
--20mA
11.512.012.5V
566.5V
-2.7-V
0.8V
DD
--
0.9V
DD
--
--V
0.2V
DD
V
--V
0.1V
DD
V
1--mS
--1mS
1--mS
200nS
500nS
86JUNE. 2001 Ver 1.00
Page 93
GMS81C2112/GMS81C2120
EPROM Enable Delay Time after T
HLD1
EPROM Enable Hold Time in Write Mode
EPROM Enable Delay Time after T
HLD2
CTL2,1 Setup Time after Low Address input and Data input
CTL1 Setup Time before Data output in Read and Verify Mode
Table 21-2 AC/DC Requirements for Program/Read Mode
START
Set VDD=V
Set VPP=V
Verify blank
First Address Location
DD1H
IHP
PASS
Report
Programming failure
FAIL
T
DLY1
T
HLD2
T
DLY2
T
CD1
T
CD2
Verify of all address
VDD=6V & 2.7V
Programming OK
200nS
100nS
200nS
100nS
100nS
Report
Verify failure
FAIL
Verify
PASS
Report
Next address location
Apply 3x program cycle
NO
N=1
EPROM Write
100uS program time
Verify
PASS
Last address
?
YES
N=N+1
YES
NO
FAIL
N
Figure 21-5 Programming Flow Chart
VPP=0V
VDD=0V
END
JUNE. 2001 Ver 1.0087
Page 94
GMS81C2112/GMS81C2120
88JUNE. 2001 Ver 1.00
Page 95
APPENDIX
Page 96
A. CONTROL REGISTER LIST
GMS800 Series
AddressRegister NameSymbolR/W
00C0R0 port data registerR0R/WUndefined34
00C1R0 port I/O direction registerR0IOW0 0 0 0 0 0 0 034
00C4R2 port data registerR2R/WUndefined35
00C5R2 port I/O direction registerR2IOW0 0 0 0 0 0 0 035
00C6R3 port data registerR3R/WUndefined35
00C7R3 port I/O direction registerR3IOW- - - 0 0 0 0 035
00CAR5 port data registerR5R/WUndefined35
00CBR5 port I/O direction registerR5IOW0 0 0 0 0 - - -35
00CCR6 port data registerR6R/WUndefined35
00CDR6 port I/O direction registerR6IOW0 0 0 0 0 0 0 035