Hynix GMS81C7008Q Hynix semiconductor inc. 8-bit single-chip microcontroller Datasheet

HYNIX SEMICONDUCTOR INC.
8-BIT SINGLE-CHIP MICROCONTROLLERS
GMS81C7008
GMS81C7016
User’s Manual (Ver. 2.01)
REVISION HISTORY
VERSION 2.01 (APR., 2001) This book
Delete product of 52SDIP package also, no longer produce 52pin MCU.
The compay name Hyundai Electronics Industires Co., Ltd. changed to Hynix Semiconductor Inc.
VERSION 2.00 (FEB., 2001)
Delete product of 52LQFP package.
Fixed some errata that pin number 25 and 26 on 52SDIP package are reversed.
VERSION 1.02 (NOV., 2000)
Fixed the name of LCR register on page 39 and 75, the BUR register on page 66.
VERSION 1.01 (SEP., 2000) sticker
Correct the bit LVDE of LVDR register on page 91.
Version 2.01
Published by
MCU Application Team
2001 Hynix semiconductor Inc. All right reserved.
Additional information of this manual may be served by Hynix semiconductor offices in Korea or Distributors and Representatives listed
at address directory.
Hynix semiconductor reserves the right to make changes to any information here in at any time without notice.
The information, diagrams and other data in this manual are correct and reliable; however, Hynix semiconductor is in no way responsible
for any violations of patents or other rights of the third party generated by the use of this manual.
GMS81C7008/7016/7108/7116
Table of Contents
1. OVERVIEW............................................1
14. ANALOG DIGITAL CONVERTER .....57
Description .........................................................1
Features .............................................................1
Development Tools ............................................2
Ordering Information ..........................................2
15. SERIAL COMMUNICATION ..............59
Transmission/Receiving Timing ...................... 60
The method of Serial I/O ................................. 61
The Method to Test Correct Transmission ...... 61
2. BLOCK DIAGRAM .................................3
16. BUZZER FUNCTION .........................62
3. PIN ASSIGNMENT ................................4
17. INTERRUPTS ....................................64
4. PACKAGE DIMENSION ........................5
5. PIN FUNCTION......................................6
6. PORT STRUCTURES............................9
7. ELECTRICAL CHARACTERISTICS ....11
Interrupt Sequence .......................................... 66
BRK Interrupt .................................................. 67
Multi Interrupt .................................................. 67
External Interrupt ............................................. 68
Key Scan Interrupt .......................................... 68
Absolute Maximum Ratings .............................11
Recommended Operating Conditions ..............11
DC Electrical Characteristics ...........................11
A/D Converter Characteristics .........................13
AC Characteristics ...........................................13
Serial Interface Timing Characteristics ............15
Typical Characteristics .....................................16
18. LCD DRIVER .....................................70
8. MEMORY ORGANIZATION.................18
Watch Timer .................................................... 78
Watchdog Timer .............................................. 78
Registers ..........................................................18
Program Memory .............................................21
Data Memory ...................................................24
List of Control Registers ...................................25
Addressing Mode .............................................28
9. I/O PORTS ...........................................32
Registers for Port .............................................32
I/O Ports Configuration ....................................33
10. CLOCK GENERATOR .......................37
11. OPERATION MODE ..........................39
LCD Control Registers .................................... 70
Duty and Bias Selection of LCD driver ............ 72
Selecting Frame Frequency ............................ 72
LCD Display Memory ...................................... 75
Control Method of LCD Driver ......................... 76
19. WATCH / WATCHDOG TIMER .........78
20. POWER DOWN OPERATION...........81
SLEEP Mode ................................................... 81
STOP Mode .................................................... 82
21. OSCILLATOR CIRCUIT.....................85
22. RESET ...............................................86
External Reset Input ........................................ 86
Watchdog Timer Reset ................................... 86
23. POWER FAIL PROCESSOR.............87
Operation Mode Switching ...............................40
24. DEVELOPMENT TOOLS...................89
12. BASIC INTERVAL TIMER..................42
OTP Programming .......................................... 89
Emulator EVA. Board Setting .......................... 90
13. TIMER/EVENT COUNTER ................44
8-bit Timer / Counter Mode ..............................47
16-bit Timer / Counter Mode ............................51
8-bit Capture Mode ..........................................52
16-bit Capture Mode ........................................53
Timer output port mode ....................................53
PWM Mode ......................................................54
APR., 2001 Ver 2.01
Appendix
A. MASK ORDER SHEET .......................... i
B. INSTRUCTION ...................................... ii
Terminology List .................................................ii
Instruction Map .................................................. iii
GMS81C7008/7016/7108/7116
Instruction Set ................................................... iv
C. SOFTWARE EXAMPLE ........................ x
APR., 2001 Ver 2.01
GMS81C7008/7016
GMS81C7008/16
CMOS SINGLE-CHIP 8-BIT MICROCONTROLLER
WITH LCD DRIVER & A/D CONVERTER
1. OVERVIEW
1.1 Description
The GMS81C7008/7016 is advanced CMOS 8-bit microcontrollers with 8K/16K bytes of ROM. There are a powerful microcontroller
which provides a highly flexible and cost effective solution to many LCD applications. These provide the following standard features:16K/
8K bytes of mask type ROM or 16K bytes OTP 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, watch dog timer, serial peripheral interface, on chip oscillator and
clock circuitry. They also come with 4com/24seg LCD driver. In addition, it support power saving mode to reduce power consumption.
Device name
ROM Size
RAM Size
I/O
OTP
GMS81C7008
8K bytes
448 bytes
49
GMS87C7016
GMS81C7016
16K bytes
448 bytes
49
GMS87C7016
Package
64SDIP, 64MQFP
1.2 Features
• 8K/16K Bytes On-chip Programmable ROM
• 448 Bytes of On-chip Data RAM
(Included stack area and 27 nibbles LCD Display
RAM)
• Instruction Execution Time
1µs at 4MHz (2cycle NOP Instruction)
• One 8-bit Basic Interval Timer
• One Watch Timer
• One Watchdog Timer
• Four 8-bit Timer/Event Counter
(or Two 16-bit Timer/Event Counter)
• Two channel 10-bit High Speed PWM Output
• Three External Interrupt input ports
• One Programmable 6-bit Buzzer Driving port
- 500Hz ~ 250kHz@4MHz
• 49 I/O Ports
• Eight channel 8-bit A/D converter
• One 8-bit Serial Communication Interface
• LCD Display/ Controller
- Static Mode (27SEG x 1COM, Static)
- 1/2 Duty Mode (26SEG x 2COM, 1/2 or 1/3 Bias)
- 1/3 Duty Mode (25SEG x 3COM, 1/3 Bias)
- 1/4 Duty Mode (24SEG x 4COM, 1/3 Bias)
APR., 2001 Ver 2.01
- Internal Built-in Resistor Circuit for Bias
• Thirteen Interrupt sources
- Basic Interval Timer: 1
- External input: 3
- Timer/Event counter: 4
- ADC: 1
- Serial Interface: 1
- WT:1
- WDT: 1
- Key Scan: 1
• Main Clock Oscillation (1.0~4.5MHz)
- Crystal
- Ceramic Resonator
- External R Oscillator (Built-in Capacitor)
• Sub Clock Oscillation
- 32.768kHz Crystal Oscillator
• Power Saving Operation Mode
- Main / Sub Active mode changeable
- 2/8/16/64 divided system clock selectable
• Power Down Mode
- STOP mode
- SLEEP mode
- Sub active Mode
• 2.7V to 5.5V Wide Operating Voltage Range
• Noise Immunity Circuit for EMS
1
GMS81C7008/7016
• Available 16K bytes OTP version
- Power fail processor
- Built in Noise filter
• 64SDIP, 64LQFP package types
1.3 Development Tools
Windows 95/98TM.
Note: There are several setting switches in the Emulator.
User should read carefully and do setting properly before
developing the program refer to "24.2 Emulator EVA. Board
Setting" on page 90. Otherwise, the Emulator may not work
properly.
Software
- MS- Window base assembler
- Linker / Editor / Debugger
Hardware
(Emulator)
- CHOICE-Dr.
- CHOICE-Dr. EVA 81C51/81C7X B/D
OTP programmer
- CHOICE-SIGMA (Single type)
- CHOICE-GANG4 (4-gang type)
Please contact sales part of Hynix semiconductor.
The GMS81C7008/16 is supported by a full-featured macro assembler, an in-circuit emulator CHOICE-Dr.TM and OTP programmers. There are two different type programmers, one is
single type, another is gang type. For more detail, refer to OTP
Programming chapter. Macro assembler operates under the MS-
1.4 Ordering Information
Device name
ROM Size (bytes)
RAM size
Package
Mask ROM version
GMS81C7008 K
GMS81C7016 K
GMS81C7008 Q
GMS81C7016 Q
8K bytes
16K bytes
8K bytes
16K bytes
448 bytes
448 bytes
448 bytes
448 bytes
64SDIP
64SDIP
64MQFP
64MQFP
OTP ROM version
GMS87C7016 K
GMS87C7016 Q
16K bytes OTP
16K bytes OTP
448 bytes
448 bytes
64SDIP
64MQFP
2
APR., 2001 Ver 2.01
GMS81C7008/7016
2. BLOCK DIAGRAM
GMS81C7008/7016
Common Drive Output
COM0
COM1/SEG26
COM2/SEG25
COM3/SEG24
Segment Drive Output
SEG0 ~ SEG23
R40-R47
R50-R56
R60-R67
LCD Power
Supply
VCL0
VCL1
VCL2
BIAS
LCD Power
PSW
R4
LCD Controller / Driver (LCDC)
Control Circuit
Accumulator
ALU
R5
Data
Memory
Stack Pointer
R6
PC
LCD Display
Memory
Program
Memory
Interrupt Controller
RESET
System controller
System
Clock Controller
Data Table
8-bit Basic
Interval Tim er
Timing generator
XIN
XOUT
SXIN
SXOUT
VDD
VSS
AVDD
AVSS
Power
Supply
High freq.
Low freq.
Clock
Generator
Power
Supply
Circuit
Watch/
Watchdog
Timer
R3
PC
High Speed
PWM
Buzzer
Driver
R30 / BUZ
R31 / PWM0 / T1O
R32 / PWM1 / T3O
R33
R34 / WDTO
R35 / SXOUT
R36 / SXIN
APR., 2001 Ver 2.01
8-bit
A /D C onverter
8-bit
SIO Timer/Counter
Key
Scan
R2
R0
R1
R20 / AN0
R21 / AN1
R22 / AN2
R23 / AN3
R24 / AN4
R25 / AN5
R26 / AN6
R27 / AN7
R00 / INT0
R01 / INT1
R02 / INT2
R03 / EC0
R04 / EC2
R05 / SCK
R06 / SO
R07 / SI
R10
R11
3
GMS81C7008/7016
3. PIN ASSIGNMENT
64SDIP
(Top View)
AN0
AN1
AN2
AN3
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
VDD
COM3
COM2
COM1
COM0
SEG23
SEG22
SEG21
SEG20
SEG19
SEG18
SEG17
SEG16
SEG15
SEG14
SEG13
SEG12
SEG11
SEG10
SEG9
SEG8
SEG7
SEG6
SEG5
SEG4
SEG3
SEG2
SEG1
SEG0
R30
R31
R32
SEG24
SEG25
SEG26
R67
R66
R65
R64
R63
R62
R61
R60
R57
R56
R55
R54
R53
R52
R51
R50
R47
R46
R45
R44
R43
R42
R41
R40
BUZ
PWM0 / T1O
PWM1 / T3O
R66
R67
SEG26
SEG25
SEG24
52
53
54
55
56
57
58
59
60
61
62
63
64
GMS81C7008/7016
32
31
30
29
28
27
26
25
24
23
22
21
20
SEG2
SEG1
SEG0
R30
R31
R32
R33
R34
R10
R11
R00
R01
R02
R42
R41
R40
BUZ
PWM0/T1O
PWM1/T3O
WDTO
KS0
KS1
INT0
INT1
INT2
4
AN4
AN5
AN6
AN7
SI
SO
SCK
EC2
EC0
SXIN
SXOUT
AN2
AN3
R22
R23
AVSS
BIAS
XIN
XOUT
RESET
R36
R35
VSS
R24
R25
R26
R27
R07
R06
R05
R04
R03
AN0
AN1
SEG22
SEG23
COM0
COM1
COM2
COM3
VDD
VCL0
VCL1
VCL2
AVDD
R20
R21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
64MQFP
(Top View)
51
50
49
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
SEG21
SEG20
SEG19
SEG18
SEG17
SEG16
SEG15
SEG14
SEG13
SEG12
SEG11
SEG10
SEG9
SEG8
SEG7
SEG6
SEG5
SEG4
SEG3
R65
R64
R63
R62
R61
R60
R57
R56
R55
R54
R53
R52
R51
R50
R47
R46
R45
R44
R43
AN4
AN5
AN6
AN7
SI
SO
SCK
EC2
EC0
INT2
INT1
INT0
KS1
KS0
WDTO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
GMS81C7008/7016
SXIN
SXOUT
VCL0
VCL1
VCL2
AVDD
R20
R21
R22
R23
AVSS
BIAS
XIN
XOUT
RESET
R36
R35
VSS
R24
R25
R26
R27
R07
R06
R05
R04
R03
R02
R01
R00
R11
R10
R34
R33
APR., 2001 Ver 2.01
GMS81C7008/7016
4. PACKAGE DIMENSION
64SDIP
UNIT: INCH
0.750 Typ.
min. 0.015
0.205 max.
2.280
2.260
0.070 Typ.
0.140
0.120
0.050
0.030
0.022
0.016
0.680
0.660
0.012
0.008
0-15°
64MQFP
24.15
23.65
20.10
19.90
18.15
17.65
14.10
13.90
UNIT: MM
0.36
0.10
SEE DETAIL “A”
3.18 max.
1.95
REF
0.50
0.35
APR., 2001 Ver 2.01
1.03
0.73
0.23
0.13
0-7°
1.00 Typ.
DETAIL “A”
5
GMS81C7008/7016
5. PIN FUNCTION
VDD: Supply voltage.
ware assignable. These pins are not served on 81C71XX.
VSS: Circuit ground.
In addition, R0 serves the functions of the various following special features.
RESET: Reset the MCU.
AVDD: Supply voltage to the ladder resistor of ADC circuit. To
enhance the resolution of analog to digital converter, use independent power source as well as possible, other than digital power source.
AVSS: ADC circuit ground.
Port pin
R00
R01
Alternate function
KS0 (Key scan 0)
KS1 (Key scan 1)
XOUT: Output from the inverting oscillator amplifier.
R20~R27: R2 is an 8-bit CMOS bidirectional I/O port. R2 pins 1
or 0 written to the Port Direction Register can be used as outputs
or inputs. Also, pull-up resistors and open-drain outputs are software assignable.R24~R27 are not served on 81C71XX.
BIAS: LCD bias voltage input pin.
In addition, R2 is shared with the ADC input.
XIN: Input to the inverting oscillator amplifier and input to the internal main clock operating circuit.
VCL0~VCL2: LCD driver power supply pins. The voltage on
each pin is VCL2> VCL1> VCL0. For details, Refer to “18. LCD
DRIVER” on page 70.
COM0~COM3: LCD common signal output pins. Also, the pins
of COM1,COM2 and COM3 are shared with LCD segment signal outputs of SEG26, SEG25, SEG24 as application requirement.
SXIN: Input to the internal subsystem clock operating circuit. In
addition, SXIN is shared with the R36 which is selected by the
software option.
SXOUT: Output from the inverting subsystem oscillator amplifier. In addition, SXOUT is shared with the R35 which is selected
by the software option.
R00~R07: R0 is an 8-bit CMOS bidirectional I/O port. R0 pins 1
or 0 written to the Port Direction Register can be used as outputs
or schmitt trigger inputs. Also, pull-up resistors and open-drain
outputs are software assignable.
In addition, R0 serves the functions of the various following special features.
Port pin
R00
R01
R02
R03
R04
R05
R06
R07
Alternate function
INT0 (External interrupt 0)
INT1 (External interrupt 1)
INT2 (External interrupt 2)
EC0 (Event counter input 0)
EC2 (Event counter input 2)
SCK (Serial clock)
SO (Serial data output)
SI
(Serial data input)
R10~R11: R1 is a 2-bit CMOS bidirectional I/O port. R1 pins 1
or 0 written to the Port Direction Register can be used as outputs
or inputs. Also, pull-up resistors and open-drain outputs are soft-
6
Port pin
R20
R21
R22
R23
R24
R25
R26
R27
Alternate function
AN0 (Analog Input 0)
AN1 (Analog Input 1)
AN2 (Analog Input 2)
AN3 (Analog Input 3)
AN4 (Analog Input 4)
AN5 (Analog Input 5)
AN6 (Analog Input 6)
AN7 (Analog Input 7)
R30~R36: R3 is a 7-bit CMOS bidirectional I/O port. R3 pins 1
or 0 written to the Port Direction Register can be used as outputs
or inputs. Also, pull-up resistors and open-drain outputs are software assignable. R33, R34 are not served on 81C71XX.
In addition, R3 serves the functions of the various following special features.
Port pin
R30
R31
R32
R33
R34
R35
R36
Alternate function
BUZ (Buzzer driving output)
PWM0 / T1O (PWM 0 output
/ Timer 1 output)
PWM1 /T3O (PWM 1 output
/ Timer 3 output)
WDTO (Watchdog timer output)
SXOUT (Sub clock output)
SXIN (Sub clock input)
SEG0~SEG7: These pins generate LCD segment signal output.
Every LCD segment pins are shared with normal R4 input/output
port. R4 is an 8-bit CMOS bidirectional I/O port. R4 pins 1 or 0
written to the Port Direction Register can be used as outputs or in-
APR., 2001 Ver 2.01
GMS81C7008/7016
puts.
LCD pin function
SEG0 (LCD segment 0 signal output)
SEG1 (LCD segment 1 signal output)
SEG2 (LCD segment 2 signal output)
SEG3 (LCD segment 3 signal output)
SEG4 (LCD segment 4 signal output)
SEG5 (LCD segment 5 signal output)
SEG6 (LCD segment 6 signal output)
SEG7 (LCD segment 7 signal output)
Port pin
R40
R41
R42
R43
R44
R45
R46
R47
SEG8~SEG15: These pins generate LCD segment signal output.
Every LCD segment pins are shared with normal R5 input/output
port. R5 is an 8-bit CMOS bidirectional I/O port. R5 pins 1 or 0
written to the Port Direction Register can be used as outputs or inputs.
LCD pin function
Port pin
SEG8 (LCD segment 8 signal output)
SEG9 (LCD segment 9 signal output)
SEG10 (LCD segment 10 signal output)
SEG11 (LCD segment 11 signal output)
SEG12 (LCD segment 12 signal output)
SEG13 (LCD segment 13 signal output)
SEG14 (LCD segment 14 signal output)
SEG15 (LCD segment 15 signal output)
R50
R51
R52
R53
R54
R55
R56
R57
APR., 2001 Ver 2.01
SEG16~SEG23: These pins generate LCD segment signal output.
Every LCD segment pins are shared with normal R6 input/output
port. 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.
LCD pin function
Port pin
SEG16 (LCD segment 16 signal output)
SEG17 (LCD segment 17 signal output)
SEG18 (LCD segment 18 signal output)
SEG19 (LCD segment 19 signal output)
SEG20 (LCD segment 20 signal output)
SEG21 (LCD segment 21 signal output)
SEG22 (LCD segment 22 signal output)
SEG23 (LCD segment 23 signal output)
R60
R61
R62
R63
R64
R65
R66
R67
7
GMS81C7008/7016
PIN NAME
(Alternate)
Function
In/Out
(Alternate)
Basic
VDD
-
Supply voltage
VSS
-
Circuit ground
RESET
I
Reset signal input
AVDD
-
Supply voltage input pin for ADC
AVSS
-
Ground level input pin for ADC
XIN
I
Oscillation input
XOUT
O
Oscillation output
BIAS
I
LCD bias voltage input
VCL0~VCL2
I
LCD driver power supply
COM0
O
LCD common signal output
Alternate
COM1(SEG26)
O(O)
COM2(SEG25)
O(O)
COM3(SEG24)
O(O)
R00 (INT0)
I/O (I)
External interrupt 0 input
R01 (INT1)
I/O (I)
External interrupt 1 input
R02 (INT2)
I/O (I)
External interrupt 2 input
R03 (EC0)
I/O (I)
R04 (EC2)
I/O (I)
R05 (SCK)
I/O (I/O)
Serial clock I/O
R06 (SO)
I/O (O)
Serial data output
R07 (SI)
I/O (I)
Serial data input
R10, R11(KS0, KS1)
I/O (I)
2-bit general I/O ports
Key scan input
R20~R27(AN0~AN7)
I/O(I)
8-bit general I/O ports
Analog voltage input
R30(BUZ)
I/O(O)
Buzzer driving output
R31(PWM0 / T1O)
I/O(O)
PWM 0 output / Timer 1 output
R32(PWM1 / T3O)
I/O(O)
PWM 1 output / Timer 2 output
R33
I/O
LCD common signal output
8-bit general I/O ports
LCD segment signal output
Timer/Counter 0 external input
Timer/Counter 1 external input
7-bit general I/O ports
-
R34(WDTO)
I/O(O)
Watchdog timer output
R35(SXOUT)
I/O(O)
Sub clock output
R36(SXIN)
I/O(I)
Sub clock input
SEG0 ~ SEG7
(R40~R47)
O (I/O)
LCD segment signal output
8-bit general I/O ports
SEG8 ~ SEG15
(R50~R57)
O (I/O)
LCD segment signal output
8-bit general I/O ports
SEG16 ~ SEG23
(R60~R67)
O (I/O)
LCD segment signal output
8-bit general I/O ports
Table 5-1 Port Function Description
8
APR., 2001 Ver 2.01
GMS81C7008/7016
6. PORT STRUCTURES
R00/INT0, R01/INT1, R02/INT2, R03/EC0,
R04/EC2, R05/SCK, R07/S
Pull up
Reg.
Pull up
Reg.
Pull-up Tr.
Data Bus
VDD
Data Reg.
Data Reg.
MUX
RD
Noise
Canceller
Tr.: Transistor
Reg.: Register
VDD
OTP MCU :disconnected
Mask MCU :connected
RESET
Noise
Canceller
Pull-up Tr.
VDD
Internal RESET
OTP MCU :connected
Mask MCU :disconnected
Open Drain
Reg.
Data Bus
RD
RESET
R30/BUZ, R31/PWM0/T1O, R32/PWM1/T3O,
R34/WDTO, R06
Pull up
Reg.
Pin
VSS
VSS
MUX
VDD
Dir. Reg.
Pin
Dir. Reg.
INT0 ~ INT2
EC0,EC2
SI,SCK
Pull-up Tr.
Open Drain
Reg.
Open Drain
Reg.
Data Bus
R10~R11, R33, R35, R36
VSS
Data Reg.
VDD
High Voltage On(OTP)
BUZ,SO,WDTO
PWM0,PWM1
Pin
Dir. Reg.
M UX
RD
VSS
VSS
SXIN, SXOUT
R20/AN0~R27/AN7
LCR.7=0
Pull up
Reg.
Pull-up Tr.
SXIN
(R36)
Data Bus
Open Drain
Reg.
SXOUT
(R35)
VDD
VSS
VDD
Data Reg.
Pin
Dir. Reg.
Sub clock OFF
Internal
System Clock
VSS
MUX
AN0 ~ AN7
APR., 2001 Ver 2.01
RD
Analog
Switch
9
GMS81C7008/7016
R40~R47, R50~R57, R60~R67 / SEG0~SEG23
XIN, XOUT
VDD
Data Bus
VDD
Data Reg.
Pin
Dir. Reg.
XIN
XOUT
VSS
MUX
RD
VSS
STOP & Main
Clock OFF
Main Clock
VCL2
LCD Data
VCL2 Enable
VCL1
LCD Data
VCL1 Enable
LCD Data
VCL0 Enable
VCL0
LCD Data
GND Enable
VSS
COM0~COM3 / SEG24~SEG26
VCL2
LCD Data
VCL2 Enable
VCL1
LCD Data
VCL1 Enable
LCD Data
VCL0 Enable
Pin
VCL0
LCD Data
GND Enable
VSS
10
APR., 2001 Ver 2.01
GMS81C7008/7016
7. ELECTRICAL CHARACTERISTICS
7.1 Absolute Maximum Ratings
Supply voltage ........................................... -0.3 to +6.0 V
Maximum current (ΣIOL) .................................... 100 mA
Storage Temperature ................................-40 to +125 °C
Maximum current (ΣIOH)...................................... 60 mA
Voltage on any pin with respect to Ground (VSS)
............................................................... -0.3 to VDD+0.3
Maximum current out of VSS pin ........................100 mA
Maximum current into VDD pin ............................80 mA
Maximum current sunk by (IOL per I/O Pin) ........20 mA
Note: Stresses above those listed under “Absolute Maximum Ratings” may cause permanent damage to the device. This is a stress rating only and functional operation of
the device at any other conditions above those indicated in
the operational sections of this specification is not implied.
Exposure to absolute maximum rating conditions for extended periods may affect device reliability.
Maximum output current sourced by (IOH per I/O Pin)
...............................................................................15 mA
7.2 Recommended Operating Conditions
Specifications
Parameter
Symbol
Condition
Unit
Min.
Max.
Supply Voltage
VDD
fXIN=4.19MHz
fSXIN=32.768kHz
2.7
5.5
V
Operating Frequency
fXIN
VDD=2.7~5.5V
1
4.5
MHz
Sub Operating Frequency
fSXIN
VDD=2.7~5.5V
30
35
kHz
Operating Temperature
TOPR
-20
+85
°C
7.3 DC Electrical Characteristics
(TA=-20~85°C, VDD=2.7~5.5V),
Specifications
Parameter
Input High Voltage
Input Low Voltage
Output High Voltage
Output Low Voltage
Input High
Leakage Current
APR., 2001 Ver 2.01
Symbol
Condition
Unit
Min.
Typ.
Max.
VIH1
RESET, R0 (except R06)
0.8 VDD
-
VDD
V
VIH2
Other pins
0.7 VDD
-
VDD
V
VIL1
RESET, R0 (except R06)
0
-
0.2 VDD
V
VIL2
Other pins
0
-
0.3 VDD
V
VOH1
R0,R1,R2,R3 IOH1=-0.5mA
VDD-0.1
-
-
V
VOH2
SEG, COM IOH2=-30µA
-
-
0.4
V
VOL1
R0,R1,R2,R3 IOL1=0.4mA
-
-
0.2
V
VOL2
SEG, COM IOL2=30µA
VDD-0.2
-
-
V
IIH1
VIN=VDD , All input pins except XIN, SXIN
-
-
1
µA
IIH2
VIN=VDD, XIN, SXIN
-
-
20
µA
11
GMS81C7008/7016
Specifications
Parameter
Symbol
Condition
Unit
Min.
Typ.
Max.
Input Low
Leakage Current
IIL1
VIN=0, All input pins except XIN, SXIN
-
-
-1
µA
IIL2
VIN=0, XIN, SXIN
-
-
-20
µA
Pull-up Resistor1
RPORT
VIN=0V, VDD=5.5V, R0, R1, R2
60
160
350
kΩ
45
65
85
kΩ
LCD Voltage Dividing
Resistor
RLCD
VDD=5.5V
Voltage Drop
|VDD-COMn| , n=0~3
VDC
VDD=2.7 ~ 5.5V
-15µA per common pin
-
-
120
mV
Voltage Drop
|VDD-SEGn| , n=0~26
VDS
VDD=2.7 ~ 5.5V
-15µA per segment pin
-
-
120
mV
VCL2 Output Voltage
VCL2
VDD-0.3
VDD
VDD+0.3
VCL1 Output Voltage
VCL1
0.66VDD
-0.2
0.66VDD
0.66VDD
+0.3
VCL0 Output Voltage
VCL0
0.33VDD
-0.3
0.33VDD
0.33VDD
+0.3
RC Oscillation Frequency
Supply Current1
( ) means at 3V operation
VDD=2.7 ~ 5.5V, 1/3 bias
BIAS pin and VCL2 pin are shorted
V
fRC
R=60kΩ, VDD= 5V
1
2
3
MHz
IDD1
Main clock operation mode 2
VDD=5.5V±10%, XIN=4MHz, SXIN=32kHz
-
2.9
(1.3)
7.0
(3.0)
mA
IDD2
Sleep mode (Main active) 3
VDD=5.5V±10%, XIN=4MHz, SXIN=32kHz
-
0.4
(0.1)
1.7
(1.0)
mA
IDD3
Stop mode 2
VDD=5V±10%, XIN= 0Hz, SXIN=32kH z
2.0
(1.0)
12
(5)
µA
IDD4
Sub clock operation mode 4
VDD=5.5V±10%, XIN=0Hz, SXIN=32kHz
-
350
(70)
500
(200)
µA
IDD5
Sleep mode (Sub active)5
VDD=3V±10%, XIN= 0Hz, SXIN=32kH z
-
10
(3)
50
(20)
µA
IDD6
Stop mode4
VDD=5V±10%, XIN= 0Hz, SXIN=0H z
SXIN, SXOUT are used as R35, R36.
-
1.0
(0.5)
12
(5)
µA
1. Supply current in the following circuits are not included; on-chip pull-up resistors, internal LCD voltage dividing resistors, comparator voltage divide resistor, LVD circuit and output port drive currents.
2. This mode set System Clock Mode Register(SCMR) to xxxx0000B that is fXIN/2
3. This mode set SCMR to xxxx0000B (fXIN/2) and set SMR to “1”.
4. Main-frequency clock stops and sub-frequency clock in not used and set SCMR to xxxx0011B.
5. Main-frequency clock stops and sub-frequency clock in not used, set SCMR to xxxx0011B and set SMR to “1”.
12
APR., 2001 Ver 2.01
GMS81C7008/7016
7.4 A/D Converter Characteristics
(TA=25°C, VSS=0V, VDD=5.0V, AVDD=5.0V @fXIN=4MHz)
Specifications
Parameter
Symbol
Test Condition
Unit
Min.
Typ.1
Max.
Analog Input Voltage Range
VAIN
VSS-0.3
-
AVDD+0.3
V
Non-linearity Error
NNLE
-
±1.0
±1.5
LSB
Differential Non-linearity Error
NDNLE
-
±1.0
±1.5
LSB
Zero Offset Error
NZOE
-
±0.5
±1.5
LSB
Full Scale Error
NFSE
-
±0.25
±0.5
LSB
Gain Error
NGE
-
±1.0
±1.5
LSB
Overall Accuracy
NACC
-
±1.0
±1.5
LSB
AVDD Input Current
IREF
-
-
200
µA
Conversion Time
TCONV
-
-
20
µs
Analog Power Supply Input Range
AVDD
3.0
2.7
-
VDD
V
VDD=AVDD=5.0V
VDD=5.0V
VDD=3.0V
1. Data in “Typ” column is at 25°C unless otherwise stated. These parameters are for design guidance only and are not tested.
7.5 AC Characteristics
(TA=-20~+85°C, VDD=5V±10%, VSS=0V)
Specifications
Parameter
Symbol
Pins
Unit
Min.
Typ.
Max.
fMAIN
XIN
0.455
-
4.2
MHz
fSUB
SXIN
30
32.768
35
kHz
tMCPW
XIN
80
-
-
nS
tSCPW
SXIN
14.7
-
-
µS
tMRCP,tMFCP
XIN
-
-
20
nS
tSRCP,tSFCP
SXIN
-
-
3
µS
Main oscillation Stabilizing
Time
tMST
XIN, XOUT at 4MHz
-
-
20
mS
Sub oscillation Stabilizing Time
tSST
SXIN, SXOUT
-
0.5
1
S
Interrupt Pulse Width
tIW
INT0, INT1, INT2
2
-
-
tSYS1
RESET Input Width
tRST
RESET
8
-
-
tSYS1
Event Counter Input Pulse
Width
tECW
EC0, EC2
2
-
-
tSYS1
Operating Frequency
External Clock Pulse Width
External Clock Transition Time
1. tSYS is one of 2/fMAIN or 8/fMAIN or 16/fMAIN or 64/fMAIN in the main clock operation mode,
tSYS is one of 2/fSUB or 8/fSUB or 16/fSUB or 64/fSUB in the sub clock operation mode.
APR., 2001 Ver 2.01
13
GMS81C7008/7016
1/fMAIN
tMCPW
tMCPW
VDD-0.5V
XIN
0.5V
tSYS
tMRCP
tMFCP
tSCPW
1/fSUB
tSCPW
VDD-0.5V
SXIN
0.5V
tSRCP
tIW
INT0, INT1
INT2
tSFCP
tIW
0.8VDD
0.2VDD
tRST
RESET
0.2VDD
tECW
tECW
0.8VDD
EC0, EC2
0.2VDD
Figure 7-1 Timing Chart
14
APR., 2001 Ver 2.01
GMS81C7008/7016
7.6 Serial Interface Timing Characteristics
(TA=-20~+85°C, VDD=2.7~5.5V, VSS=0V, fXIN=4MHz)
Specifications
Parameter
Symbol
Pins
Unit
Min.
Typ.
Max.
Serial Input Clock Pulse
tSCYC
SCK
2tSYS+200
-
8
ns
Serial Input Clock Pulse Width
tSCKW
SCK
tSYS+70
-
8
ns
SIN Input Setup Time (External SCK)
tSUS
SIN
100
-
-
ns
SIN Input Setup Time (Internal SCK)
tSUS
SIN
200
-
-
ns
SIN Input Hold Time
tHS
SIN
tSYS+70
-
-
ns
Serial Output Clock Cycle Time
tSCYC
SCK
4tSYS
-
16tSYS
ns
Serial Output Clock Pulse Width
tSCKW
SCK
tSYS-30
-
-
ns
Serial Output Clock Pulse Transition
Time
tFSCK
tRSCK
SCK
-
-
30
ns
Serial Output Delay Time
sOUT
SO
-
-
100
ns
tSCYC
tRSCK
tFSCK
SCLK
tSCKW
tSCKW
0.8VDD
0.2VDD
tSUS
tHS
0.8VDD
0.2VDD
SIN
tDS
SOUT
0.8VDD
0.2VDD
Figure 7-2 Serial I/O Timing Chart
APR., 2001 Ver 2.01
15
GMS81C7008/7016
7.7 Typical Characteristics
This graphs and tables provided in this section are for design guidance only and are not tested or guaranteed.
The data presented in this section is a statistical summary
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
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.
IOH−VOH, VDD=3.0V
IOH
(mA) Ta=25°C
IOH
(mA)
-8
IOH−VOH, VDD=5.0V
Ta=25°C
R
(kΩ)
-20
RPU−Ta, VDD=5.0V
R0,R1,R2,R3 pin
200
-6
-15
-4
-10
-2
-5
100
0
0
0.5
1.0 1.5
2.0
2.5
IOL−VOL, VDD=3.0V
IOL
(mA)
0
1
2
I −VOL,
IOL OL
(mA)
Ta=25°C
Ta=25°C
3
4
VOH
5 (V)
-20
VDD=5.5V
fXIN
(MHz)
20
40
4
15
30
3
10
20
2
5
10
0.5
VIH1
(V)
1.0 1.5
2.0
2.5
VOL
(V)
VDD−VIH1
R0 (except R06)
fXIN=4MHz
Ta=25°C
0
1
VIH2
(V)
2
3
4
VOL
5 (V)
VDD−VIH2 R1~R6 pin
(include R06)
fXIN=4MHz
Ta=25°C
VIH1
(V)
2
2
2
1
1
1
5
VDD
6 (V)
R = 6.2kΩ
R = 20kΩ
R = 60kΩ
0
2
R = 180kΩ
3
4
VDD
6 (V)
5
XIN, SXIN
fXIN=4MHz
Ta=25°C
4
3
4
Ta
(°C)
Ta=25°C
VDD−VIH3
3
3
80
fXIN−VDD
2
3
2
40
0
4
1
0
1
4
0
16
VOH
(V)
3
4
5
VDD
6 (V)
0
1
2
3
4
5
VDD
6 (V)
APR., 2001 Ver 2.01
GMS81C7008/7016
VIH1
(V)
VDD−VIL1
R0 (except R06)
fXIN=4MHz
Ta=25°C
VDD−VIL2 R1~R6 pin
(include R06)
VIH2
(V)
fXIN=4MHz
Ta=25°C
VDD−VIL3
VIH1
(V)
4
4
4
3
3
3
2
2
2
1
1
1
0
1
2
3
4
5
VDD
6 (V)
0
2
Normal Operation (Main opr.)
IDD1−VDD
IDD
(mA)
IDD
(µA)
fXIN=4MHz
Ta=25°C
4
XIN, SXIN
fXIN=4MHz
Ta=25°C
3
4
5
VDD
6 (V)
0
1
SLEEP Mode (Main opr.)
ISLEEP(IDD2)−
−VDD
2
4
5
VDD
6 (V)
STOP Mode
ISTOP(IDD3)−
−VDD
IDD
(µA)
fXIN=4MHz
Ta=25°C
3
400
4
300
3
200
2
100
1
fXIN=0Hz
Ta=25°C
3
2
1
0
2
3
4
5
VDD
6 (V)
0
2
Normal Mode (Sub opr.)
IDD4−VDD
IDD
(µA)
4
5
VDD
6 (V)
0
2
SLEEP Mode (Sub opr.)
ISLEEP(IDD5)−
−VDD
IDD
(µA)
fSXIN=32kHz
Ta=25°C
3
400
12
4
300
9
3
200
6
2
100
3
1
0
2
3
4
APR., 2001 Ver 2.01
5
VDD
6 (V)
0
2
3
4
5
VDD
6 (V)
4
5
VDD
6 (V)
STOP Mode
ISTOP(IDD6)−
−VDD
IDD
(µA)
fSXIN=32kHz
Ta=25°C
3
fSXIN=0Hz
Ta=25°C
0
2
3
4
5
VDD
6 (V)
17
GMS81C7008/7016
8. MEMORY ORGANIZATION
The GMS81C7008/16 has separate address spaces for Program
memory and Data Memory. Program memory can only be read,
not written to. It can be up to 8K/16K bytes of Program memory.
Data memory can be read and written to up to 448 bytes including
the stack area and the LCD display RAM area.
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.
PCH
A
ACCUMULATOR
X
X REGISTER
Y
Y REGISTER
SP
STACK POINTER
PCL
PROGRAM COUNTER
PSW
PROGRAM STATUS
WORD
Figure 8-1 Configuration of Registers
Accumulator: The Accumulator is the 8-bit general purpose register, used for data operation such as transfer, temporary saving,
and conditional judgement, etc.
The Accumulator can be used as a 16-bit register with Y Register
as shown below.
Y
Y
The stack can be located at any position within 011BH to 01FFH
of the internal data memory. The SP is not initialized by hardware, requiring to write the initial value (the location with which
the use of the stack starts) by using the initialization routine. Normally, the initial value of “FFH” is used.
Bit 15
Stack Area (100H ~ 1FFH)
8 7
01H
SP
Bit 0
00H~FFH
Hardware fixed
SP (Stack Pointer) could be in 00H~FFH.
LCD display RAM area is located in 100H~11AH,
User must have concerning that Stack data does not
cross over LCD RAM area.
Note: The Stack Pointer must be initialized by software because its value is undefined after RESET.
Example: To initialize the SP
LDX
#0FFH
TXSP
; SP ← FFH
A
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 contents are added to the specified address,
which becomes the actual address. These modes are extremely effective for referencing subroutine tables and memory tables. The
index registers also have increment, decrement, comparison and
data transfer functions, and they can be used as simple accumulators.
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).
Generally, SP is automatically updated when a subroutine call is
executed or an interrupt is accepted. However, if it is used in ex-
18
cess of the stack area permitted by the data memory allocating
configuration, the user-processed data may be lost.
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 (PCH:0FFH,
PCL:0FEH).
Program Status Word: The Program Status Word (PSW) contains several bits that reflect the current state of the CPU. The
PSW is described in Figure 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 not 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.
APR., 2001 Ver 2.01
GMS81C7008/7016
PSW
MSB
N V G B H
I
Z
LSB
C RESET VALUE: 00H
CARRY FLAG RECEIVES
CARRY OUT
NEGATIVE FLAG
OVERFLOW FLAG
ZERO FLAG
SELECT DIRECT PAGE
when G=1, page is selected to “page 1”
BRK FLAG
INTERRUPT ENABLE FLAG
HALF CARRY FLAG RECEIVES
CARRY OUT FROM BIT 1 OF
ADDITION OPERLANDS
Figure 8-3 PSW (Program Status Word) Register
[Interrupt disable flag I]
This flag enables/disables all interrupts except interrupt caused
by Reset or software BRK instruction. All interrupts are disabled
when cleared to “0”. This flag immediately becomes “0” when an
interrupt is served. It is set by the EI instruction and cleared by
the DI instruction.
[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).
struction and cleared by CLRG.
RAM Page
Instruction
Bit1 of
RPR
Bit0 of
RPR
0 page
CLRG
X
X
0 page
SETG
0
0
1 page
SETG
0
1
Reserved
SETG
1
0
Reserved
SETG
1
1
[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 00H to
0FFH when this flag is "0". If it is set to "1", addressing area is
assigned by RPR register (address 0F3H). It is set by SETG in-
When content of RPR is above 2, malfunction will be occurred.
[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(7FH) or 128(80H). The CLRV instruction clears the overflow flag. There
is no set instruction. When the BIT instruction is executed, bit 6
of memory is copied to this flag.
[Negative flag N]
This flag is set to match the sign bit (bit 7) status of the result of
a data or arithmetic operation. When the BIT instruction is executed, bit 7 of memory is copied to this flag.
APR., 2001 Ver 2.01
19
GMS81C7008/7016
At execution of
a CALL/TCALL/PCALL
01FF
At acceptance
of interrupt
Push
down
01FF
PCH
01FE
PCL
01FD
01FD
PSW
01FC
01FC
01FE
PCH
PCL
At execution
of RET instruction
Push
down
01FF
PCH
01FE
PCL
At execution
of RET instruction
01FF
PCH
01FE
PCL
01FD
01FE
PSW
01FC
01FC
Pop
up
SP before
execution
01FF
01FF
01FD
01FC
SP after
execution
01FD
01FC
01FF
01FF
At execution
of PUSH instruction
PUSH A (X,Y,PSW)
01FF
A
01FE
Push
down
Pop
up
At execution
of POP instruction
POP A (X,Y,PSW)
01FF
A
01FE
01FD
01FD
01FC
01FC
Pop
up
0100H
Stack
depth
01FFH
SP before
execution
01FF
01FE
SP after
execution
01FE
01FF
Figure 8-4 Stack Operation
20
APR., 2001 Ver 2.01
GMS81C7008/7016
8.2 Program Memory
A 16-bit program counter is capable of addressing up to 64K
bytes, but this device has 8K/16K bytes program memory space
only physically implemented. Accessing a location above FFFFH
will cause a wrap-around to 0000H.
Figure 8-5, shows a map of Program Memory. After reset, the
CPU begins execution from reset vector which is stored in address FFFEH and FFFFH as shown in Figure 8-6.
As shown in Figure 8-5, each area is assigned a fixed location in
Program Memory. Program Memory area contains the user program.
C000H
save program byte length.
Table Call (TCALL) causes 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:
0FFC0H for TCALL15, 0FFC2H for TCALL14, etc., as shown in
Figure 8-7.
Example: Usage of TCALL
The interrupt causes the CPU to jump to specific location, where
it commences the execution of the service routine. The External
interrupt 0, for example, is assigned to location 0FFFAH. The interrupt service locations spaces 2-byte interval: 0FFF8H and
0FFF9H for External Interrupt 1, 0FFFAH and 0FFFBH for External Interrupt 0, etc.
TCALL area
FFDFH
FFE0H
FFFFH
GMS81C7016
FFC0H
PCALL area
FEFFH
FF00H
GMS81C7008 8K ROM
E000H
16K ROM
Any area from 0FF00H to 0FFFFH, if it is not going to be used,
its service location is available as general purpose Program Memory.
Interrupt
Vector Area
Address
0FFE0H
E2
E4
E6
E8
EA
EC
EE
F0
F2
F4
F6
F8
FA
FC
FE
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
APR., 2001 Ver 2.01
Vector Area Memory
Timer/Counter 3
Timer/Counter 2
Watch Timer
A/D Converter
Serial Peripheral Interface
External Interrupt
2
Timer/Counter 1
Timer/Counter 0
External Interrupt 1
External Interrupt 0
Watchdog Timer
Basic Interval Timer
Key Scan
RESET
NOTE:
“-” means reserved area.
Figure 8-6 Interrupt Vector Area
21
GMS81C7008/7016
Address
0FF00H
PCALL Area Memory
Address
PCALL Area
(256 Bytes)
0FFC0H
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
0FFFFH
Program Memory
TCALL 15
TCALL 14
TCALL 13
TCALL 12
TCALL 11
TCALL 10
TCALL 9
TCALL 8
TCALL 7
TCALL 6
TCALL 5
TCALL 4
TCALL 3
TCALL 2
TCALL 1
TCALL 0 / BRK *
NOTE:
* means that the BRK software interrupt is using
same address with TCALL0.
Figure 8-7 PCALL and TCALL Memory Area
PCALL→
→ rel
TCALL→
→n
4F35
4A
PCALL 35H
TCALL 4
4A
4F
01001010
35
~
~
~
~
~
~
0D125H
1
~
~
NEXT
Reverse
PC: 11111111 11010110
FH FH
DH 6H
0FF00H
0FF35H
0FFFFH
22
NEXT
3
0FF00H
0FFD6H
25
0FFD7H
D1
2
0FFFFH
APR., 2001 Ver 2.01
GMS81C7008/7016
Example: The usage software example of Vector address for GMS81C7016.
;
ORG
0FFE0H
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
TIMER3
TIMER2
WATCH_TIMER
ADC
SIO
NOT_USED
NOT_USED
INT2
TIMER1
TIMER0
INT1
INT0
WD_TIMER
BIT_TIMER
KEYSCAN
RESET
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
ORG
ORG
0C000H
0E000H
; in case of 16K ROM Start address
; in case of 8K ROM Start address
Timer-3
Timer-2
Watch Timer
ADC
Serial Interface
Int.2
Timer-1
Timer-0
Int.1
Int.0
Watchdog Timer
Basic Interval Timer
Key Scan Timer
Reset
;*******************************************
;
MAIN
PROGRAM
*
;*******************************************
;
RESET: LDM
SCMR,#0
;When main clock mode
DI
;Disable All Interrupts
LDM
WDTR,#0
;Disable Watch Dog Timer
LDM
RPR,#1
CLRG
LDX
#0
RAM_CLR: LDA
#0
;RAM Clear(!0000H ~ !00BFH)
STA
{X}+
CMPX #0C0H
BNE
RAM_CLR
SETG
LDX
#0
RAM_CLR1:
LDA
#0
STA
{X}+
CMPX #1BH
;DISPLAY RAM Clear(!0100H ~ !011AH)
BNE
RAM_CLR1
CLRG
;
LDX
#0FFH
;Stack Pointer Initialize
TXSP
;
LDM
R0, #0
;Normal Port 0
LDM
R0DD,#82H
;Normal Port Direction
LDM
R0PU,#0
;Normal Pull Up
:
:
:
LDM
TDR0,#250
;8us x 250 = 2000us
LDM
TM0,#0000_1111B
;Start Timer0, 8us at 4MHz
LDM
IRQH,#0
LDM
IRQL,#0
LDM
IENH,#0000_1110B
;Enable INT0, INT1, Timer0
LDM
IENL,#0
LDM
IEDS,#15H
;Select falling edge detect on INT pin
LDM
PMR,#3H
;Set external interrupt pin(INT0, INT1)
EI
;Enable master interrupt
APR., 2001 Ver 2.01
23
GMS81C7008/7016
8.3 Data Memory
Figure 8-8 shows the internal Data Memory space available. Data
Memory is divided into four groups, a user RAM, control registers, Stack, and LCD memory.
0000H
User Memory
(192 Bytes)
Control Registers
The control registers are used by the CPU and Peripheral function
blocks for controlling the desired operation of the device. Therefore these registers contain control and status bits for the interrupt
system, the timer/ counters, analog to digital converters and I/O
ports. The control registers are in address range of 0C0H to 0FFH.
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.
PAGE0
More detailed informations of each register are explained in each
peripheral section.
00BFH
00C0H
Control
Registers
00FFH
0100H LCD display RAM
(27 Nibbles)
011AH
011BH
User Memory
or Stack Area
(229 Bytes)
Note: Write only registers can not be accessed by bit manipulation instruction (SET1, CLR1). Do not use read-modify-write instruction. Use byte manipulation instruction, for
example “LDM”.
PAGE1
Example; To write at CKCTLR
LDM
01FFH
CKCTLR,#09H ;Divide ratio(÷16)
Figure 8-8 Data Memory Map
Stack Area
User Memory
The both GMS81C7008/16 has 448 × 8 bits for the user memory
(RAM).
There are two page internal RAM. Page is selected by G-flag and
RAM page selection register RPR. When G-flag is cleared to “0”,
always page 0 is selected regardless of RPR value. If G-flag is set
to “1”, page will be selected according to RPR value.
Page 0
G=0
Page 1
RPR=1, G=1
Page 0: 00~FFH
Page 1: 100~1FFH
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, executing the subroutine return instruction [RET] restores the contents of the program counter from the stack; executing the interrupt return
instruction [RETI] restores the contents of the program counter
and flags.
The save/restore locations in the stack are determined by the
stack pointed (SP). The SP is automatically decreased after the
saving, and increased before the restoring. This means the value
of the SP indicates the stack location number for the next save.
Refer to Figure 8-4 on page 20.
Figure 8-9 RAM page configuration
24
APR., 2001 Ver 2.01
GMS81C7008/7016
8.4 List of Control Registers
Address
Register Name
Symbol
R/W
Initial Value
Page
7 6 5 4 3 2 1 0
00C0
R0 port data register
R0
R/W
00000000
page 33
00C1
R1 port data register
R1
R/W
- - - - - - 00
page 33
00C2
R2 port data register
R2
R/W
00000000
page 33
00C3
R3 port data register
R3
R/W
- 0000000
page 33
00C4
R4 port data register
R4
R/W
00000000
page 34
00C5
R5 port data register
R5
R/W
00000000
page 34
00C6
R6 port data register
R6
R/W
00000000
page 35
00C8
R0 port I/O direction register
R0DD
W
00000000
page 35
00C9
R1 port I/O direction register
R1DD
W
- - - - - - 00
page 36
00CA
R2 port I/O direction register
R2DD
W
00000000
page 36
00CB
R3 port I/O direction register
R3DD
W
- 0000000
page 35
00CC
R4 port I/O direction register
R4DD
W
00000000
page 36
00CD
R5 port I/O direction register
R5DD
W
00000000
page 36
00CE
R6 port I/O direction register
R6DD
W
00000000
page 36
00D0
R0 port pull-up register
R0PU
W
00000000
page 33
00D1
R1 port pull-up register
R1PU
W
- - - - - - 00
page 33
00D2
R2 port pull-up register
R2PU
W
00000000
page 33
00D3
R3 port pull-up register
R3PU
W
- 0000000
page 33
00D4
R0 port open drain control register
R0CR
W
00000000
page 33
00D5
R1 port open drain control register
R1CR
W
- - - - - - 00
page 33
00D6
R2 port open drain control register
R2CR
W
00000000
page 33
00D7
R3 port open drain control register
R3CR
W
- 0000000
page 33
00D8
Ext. interrupt edge selection register
IEDS
R/W
- - 000000
page 69
00D9
Port mode register
PMR
R/W
0 0 0 0 0 0 0 0 page 62, page 69
00DA
Interrupt enable lower byte register
IENL
R/W
0 - - 00000
page 65
00DB
Interrupt enable upper byte register
IENH
R/W
- 0000000
page 65
00DC
Interrupt request flag lower byte register
IRQL
R/W
0 - - 00000
page 64
00DD
Interrupt request flag upper byte register
IRQH
R/W
- 0000000
page 64
00DE
Sleep mode register
SMR
W
- - - - - - - 0
page 81
00DF
Watch dog timer register
WDTR
R/W
- - 010010
page 79
00E0
Timer0 mode register
TM0
R/W
- - 000000
page 45
T0
R
00000000
page 45
Timer0 data register
TDR0
W
11111111
page 45
Timer0 input capture register
CDR0
R
00000000
page 45
TM1
R/W
00000000
page 45
Timer0 counter register
00E1
00E2
Timer1 mode register
Table 8-1 Control Registers
APR., 2001 Ver 2.01
25
GMS81C7008/7016
Address
Register Name
Symbol
R/W
Initial Value
Page
7 6 5 4 3 2 1 0
Timer1 data register
00E3
TDR1
W
11111111
page 45
T1PPR
W
11111111
page 54
T1
R
00000000
page 45
Timer1 input capture register
CDR1
R
00000000
page 45
Timer1 pulse duty register
T1PDR
R/W
00000000
page 54
PWM0HR
W
- - - - 0000
page 54
TM2
R/W
- - 000000
page 46
T2
R
00000000
page 46
Timer2 data register
TDR2
W
11111111
page 46
Timer2 input capture register
CDR2
R
00000000
page 46
Timer3 mode register
TM3
R/W
00000000
page 46
Timer3 data register
TDR3
W
11111111
page 46
T3PPR
W
11111111
page 54
T3
R
00000000
page 46
Timer3 input capture register
CDR3
R
00000000
page 46
Timer3 pulse duty register
T3PDR
R/W
00000000
page 46
PWM1HR
W
- - - - 0000
page 54
PWM0 pulse period register
Timer1 counter register
00E4
00E5
PWM0 high register
00E6
Timer2 mode register
Timer2 counter register
00E7
00E8
00E9
PWM1 pulse period register
Timer3 counter register
00EA
00EB
PWM1 high register
00EC
A/D converter mode register
ADCM
R/W
- 0000001
page 58
00ED
A/D converter data register
ADR
R
Undefined
page 58
00EF
Watch timer mode register
WTMR
R/W
- 0 - - 0000
page 79
00F0
Key scan port mode register
KSMR
R/W
- - - - - - 00
page 69
00F1
LCD control register
LCR
R/W
00000000
page 71
00F2
LCD port mode register high
LPMR
R/W
- - 000000
page 71
00F3
RAM paging register
RPR
R/W
- - - - - - 0 0 page 24, page 71
Basic interval timer register
BITR
R
00000000
page 43
CKCTLR
W
- - - 00111
page 43
00F4
Clock control register
00F5
System clock mode register
SCMR
R/W
00000000
page 38
00FB
LVD register
LVDR
R/W
00000 - - -
page 87
00FD
Buzzer data register
BUR
W
00000000
page 62
00FE
Serial I/O mode register
SIOM
R/W
00000001
page 59
00FF
Serial I/O Data register
SIOR
R/W
Undefined
page 59
Table 8-1 Control Registers
W
R/W
Registers are controlled by byte manipulation instruction such as LDM etc., do not use bit manipulation
instruction such as SET1, CLR1 etc. If bit manipulation instruction is used on these registers,
content of other seven bits are may varied to unwanted value.
Registers are controlled by both bit and byte manipulation instruction.
- : this bit location is reserved.
26
APR., 2001 Ver 2.01
GMS81C7008/7016
Three registers are mapped on same address.
Address
Timer/Counter mode
Capture mode
PWM mode
E1H
T0 [R], TDR0 [W]
CDR0 [R], TDR0 [W]
-
E3H
TDR1 [W]
TDR1 [W]
T1PPR [W]
E4H
T1 [R]
CDR1 [R]
T1PDR [R/W]
E7H
T2 [R], TDR2 [W]
CDR2 [R], TDR2 [W]
-
E9H
TDR3 [W]
TDR3 [W]
T3PPR [W]
EAH
T3 [R]
CDR3 [R]
T3PDR [R/W]
Two registers are mapped on same address.
Address
Basic Interval Timer
F4H
BITR [R], CKCTLR [W]
APR., 2001 Ver 2.01
27
GMS81C7008/7016
8.5 Addressing Mode
The GMS800 series MCU uses six addressing modes;
E45535
LDM
35H,#55H
• Register addressing
• Immediate addressing
• Direct page addressing
data← 55H
data
0135H
• Absolute addressing
• Indexed addressing
➊
• Register-indirect addressing
~
~
0F100H
~
~
➋
E4
0F101H
55
0F102H
35
(1) Register Addressing
Register addressing accesses the A, X, Y, C and PSW.
(2) Immediate Addressing → #imm
(3) Direct Page Addressing → dp
In this mode, second byte (operand) is accessed as a data immediately.
In this mode, a address is specified within direct page.
Example:
0435
Example; G=0
C535
ADC
LDA
;A ←RAM[35H]
35H
#35H
MEMORY
35H
04
35
A+35H+C → A
data
~
~
➋
~
~
0E550H
C5
0E551H
35
➊
data → A
When G-flag is 1, then RAM address is defined by 16-bit address
which is composed of 8-bit RAM paging register (RPR) and 8-bit
immediate data.
Example: G=1, RPR=01
28
APR., 2001 Ver 2.01
GMS81C7008/7016
(4) Absolute Addressing → !abs
ADC, AND, CMP, EOR, LDA, OR, SBC, STA, XMA
Absolute addressing sets corresponding memory data to Data, i.e.
second byte (Operand I) of command becomes lower level address and third byte (Operand II) becomes upper level address.
With 3 bytes command, it is possible to access to whole memory
area.
Example; X=15H, G=1
D4
ADC, AND, CMP, CMPX, CMPY, EOR, LDA, LDX, LDY, OR,
SBC, STA, STX, STY
115H
Example;
0735F0
ADC
data
~
~
07
0F101H
35
0F102H
F0
➋
~
~
data → A
➊
D4
➋
~
~
0F100H
;ACC←RAM[X]
data
0E550H
0F035H
{X}
~
~
;A ←ROM[0F035H]
!0F035H
LDA
A+data+C → A
➊
address: 0F035
X indexed direct page, auto increment→
→ {X}+
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=35H
The operation within data memory (RAM)
ASL, BIT, DEC, INC, LSR, ROL, ROR
DB
LDA
{X}+
Example; Addressing accesses the address 0135H regardless of
G-flag.
983501
INC
;A ←ROM[135H]
!0135H
35H
➋
data
~
~
~
~
data → A
➊
36H → X
DB
data
135H
~
~
➌
~
~
➋
data+1 → data
0F100H
98
➊
0F101H
35
address: 0135
0F102H
01
X indexed direct page (8 bit offset) → dp+X
This address value is the second byte (Operand) of command plus
the data of -register. And it assigns the memory in Direct page.
ADC, AND, CMP, EOR, LDA, LDY, OR, SBC, STA STY,
XMA, ASL, DEC, INC, LSR, ROL, ROR
(5) Indexed Addressing
Example; G=0, X=0F5H
X indexed direct page (no offset) → {X}
In this mode, a address is specified by the X register.
APR., 2001 Ver 2.01
29
GMS81C7008/7016
C645
LDA
Example; G=0
45H+X
3F35
3AH
data
➌
~
~
➋
~
~
0E550H
C6
0E551H
45
JMP
35H
0A
36H
E3
data → A
➊
[35H]
~
~
~
~
0E30AH
45H+0F5H=13AH
➋
➊
NEXT
jump to
address 0E30AH
~
~
~
~
0FA00H
3F
35
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 assigns Memory in Direct page.
This is same with above (2). Use Y register instead of X.
Y indexed absolute → !abs+Y
Sets the value of 16-bit absolute address plus Y-register data as
Memory.This addressing mode can specify memory in whole area.
X indexed indirect → [dp+X]
Processes memory data as Data, assigned by 16-bit pair memory
which is determined by pair data [dp+X+1][dp+X] Operand plus
X-register data in Direct page.
ADC, AND, CMP, EOR, LDA, OR, SBC, STA
Example; G=0, X=10H
1625
ADC
[25H+X]
Example; Y=55H
D500FA
LDA
0F100H
!0FA00H+Y
00
0F102H
FA
05
E0
0E005H
~
~ ➋
~
~
D5
0F101H
35H
36H
➊
0E005H
~
~
~
~
~
~
25 + X(10) = 35H
~
~
➋
0FA00H
0FA55H
➊
data
0FA00H+55H=0FA55H
data
➌
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.
16
25
➌ A + data + C → A
Y indexed indirect → [dp]+Y
Processes memory data as Data, assigned by the data [dp+1][dp]
of 16-bit pair memory paired by Operand in Direct pageplus Yregister data.
ADC, AND, CMP, EOR, LDA, OR, SBC, STA
Example; G=0, Y=10H
JMP, CALL
30
APR., 2001 Ver 2.01
GMS81C7008/7016
1725
ADC
Example; G=0
[25H]+Y
1F25E0
25H
05
26H
E0
~
~
0E015H
0FA00H
[!0E025H]
PROGRAM MEMORY
~
~
➋
➊
0E005H + Y(10)
= 0E015H
data
~
~
JMP
0E025H
25
0E026H
E7
~
~
~
~
17
25
➊
0E725H
➌
NEXT
~
~
A + data + C → A
0FA00H
Absolute indirect → [!abs]
~
~
➋
jump to
address 0E30AH
~
~
1F
25
E0
The program jumps to address specified by 16-bit absolute address.
JMP
APR., 2001 Ver 2.01
31
GMS81C7008/7016
9. I/O PORTS
The GMS81C7008/16 has seven ports (R0, R1, R2, R3, R4, R5
and R6), and LCD segment port SEG0~SEG23, and LCD common p ort COM0~COM3, which are multiplexed with
SEG24~SEG26.
These ports pins may be multiplexed with an alternate function
for the peripheral features on the device. In general, in a initial reset state, R0,R1,R2, R3 ports are used as a general purpose input
port and R4, R5, R6 and R7 ports are used as LCD segment drive
output port.
9.1 Registers for Port
Port Data Registers
The Port Data Registers in I/O buffer in each seven ports
(R0,R1,R2,R3,R4,R5,R6) are represented as a Type D flip-flop,
which will clock in a value from the internal bus in response to a
"write to data register" signal from the CPU. The Q output of the
flip-flop is placed on the internal bus in response to a "read data
register" signal from the CPU. The level of the port pin itself is
placed on the internal bus in response to "read data register" signal from the CPU. Some instructions that read a port activating
the "read register" signal, and others activating the "read pin" signal
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 specify it as input pin. For example, to use
the even numbered bit of R0 as output ports and the odd numbered bits as input ports, write “55H” to address 0C8H (R0 port
direction register) during initial setting as shown in Figure 9-1.
WRITE “55H” TO PORT R0 DIRECTION REGISTER
R0 DATA
0C1H
R1 DATA
~
~
0C8H
0C9H
When ports are configured as inputs and pull-up resistor is selected by software, they are pulled to high.
VDD
VDD
Port Direction Registers
0C0H
When a port is used as input, input logic is firmly either low or
high, therefore external pull-down or pull-up resisters are required practically. The GMS81C7008/16 has internal pull-up, it
can be logic high by pull-up that can be able to configure either
connect or disconnect individually by pull-up control registers
R0PU, R1PU, R2PU and R3PU.
0 1 0 1 0 1 0 1
7 6 5 4 3 2 1 0
I O I O I O
R1 DIRECTION
7 6 5 4 3 2 1 0
PORT PIN
Pull-up control bit
0: Disconnect
1: Connect
GND
Figure 9-2 Pull-up Port Structure
BIT
~
~
R0 DIRECTION
PULL-UP RESISTOR
Typ. 160kΩ
I O PORT
Open drain port Registers
The R0, R1, R2 and R3 ports have open drain port resistors
R0CR~R3CR.
Figure 9-3 shows a open drain port configuration by control register. It is selected as either push-pull port or open-drain port by
R0CR, R1CR, R2CR and R3CR.
I : INPUT PORT
O : OUTPUT PORT
PORT PIN
Figure 9-1 Example of port I/O assignment
All the port direction registers in the MCU have 0 written to them
by reset function. On the other hand, its initial status is input.
GND
Open drain port selection bit
0: Push-pull
1: Open drain
Pull-up Control Registers
The R0, R1, R2 and R3 ports have internal pull-up resistors.
Figure 9-2 shows a functional diagram of a typical pull-up port.
It is connected or disconnected by Pull-up Control register
(PURn). The value of that resistor is typically 180kΩ.
32
Figure 9-3 Open-drain Port Structure
APR., 2001 Ver 2.01
GMS81C7008/7016
9.2 I/O Ports Configuration
R0 and R0DD register: R0 is an 8-bit CMOS bidirectional I/O
port (address 0C0H). Each I/O pin can independently used as an
input or an output through the R0DD register (address 0C8H).
Each port also can be set individually as pull-up port through the
R0PU (address 0D0H), and as open drain register through the
R0CR (address 0D4H).
PMR
7
6
R00
R01
R02
R03
R04
R05
R06
R07
Alternate function
INT0 (External interrupt 0)
INT1 (External interrupt 1)
INT2 (External interrupt 2)
EC0 (Event counter input 0)
EC2 (Event counter input 2)
SCK (Serial clock)
SO (Serial data output)
SI (Serial data input)
Regardless of the direction register R0DD, the control registers of
PMR and SIOM are selected to use as alternate functions, port pin
can be used as a corresponding alternate features
.
R0 Data Register
R0
ADDRESS: 0C0H
RESET VALUE: 00H
5
4
3
2
1
0
0: R00
1: INT0
0: R04
1: EC2
In addition, port R0 is multiplexed with various special features.
The control register through the PMR (address 0D9H) and the
SIOM (address 0FEH) control the selection of alternate function.
After reset, this value is “0”, port may be used as normal I/O port.
To use alternate function such as external interrupt, event counter
input, serial interface data input, serial interface data output or serial interface clock, write “1” in the corresponding bit of PMR
(address 0D9H) and SIOM (address 0FEH).
Port pin
ADDRESS: 0D9H
RESET VALUE: 00H
Port Mode Register
0: R01
1: INT1
0: R30
1: BUZ
0: R31
1: PWM0/T1O
0: R02
1: INT2
0: R03
1: EC0
0: R32
1: PWM1/T3O
ADDRESS: 0D8H
RESET VALUE: 00H
Edge Detection Register
IEDS
-
-
5
4
3
INT2
2
1
0
INT0
INT1
External Interrupt Edge Select
00: Reserved
01: Falling (1-to-0 transition)
10: Rising (0-to-1 transition)
11: Both (Rising & Falling)
R1 and R1DD register: R1 is an 2-bit CMOS bidirectional I/O
port (address 0C1H). Each I/O pin can independently used as an
input or an output through the R1DD register (address 0C9H).
Each port also can be set individually as pull-up port through the
R1PU (address 0D1H), and as open drain register through the
R1CR (address 0D5H).
ADDRESS: 0C1H
RESET VALUE: 00H
R1 Data Register
R07 R06 R05 R04 R03 R02 R01 R00
R1
-
-
-
-
-
-
R01 R00
Input / Output data
Input / Output data
R0 Direction Register
ADDRESS: 0C8H
RESET VALUE: 00H
ADDRESS: 0C9H
RESET VALUE: 00H
R1 Direction Register
R0DD
R1DD
Port Direction
0: Input
1: Output
APR., 2001 Ver 2.01
-
-
-
-
-
-
Port Direction
0: Input
1: Output
33
GMS81C7008/7016
ADDRESS: 0D1H
RESET VALUE: 00H
R1 Pull-up Register
R1PU
-
-
-
-
-
-
R2 Data Register
R2
R07 R06 R05 R04 R03 R02 R01 R00
Port Pull-up
0: Pull-up resistor Off
1: Pull-up resistor On
R1 Open drain control Register
R1CR
-
-
-
-
-
ADDRESS: 0D5H
RESET VALUE: 00H
ADDRESS: 0C2H
RESET VALUE: 00H
Input / Output data
R2 Direction Register
ADDRESS: 0CAH
RESET VALUE: 00H
R2DD
Port Direction
0: Input
1: Output
Port Open drain
0: Push Pull
1: Open drain
R2 and R2DD register: R2 is an 8-bit CMOS bidirectional I/O
port (address 0C2H). Each I/O pin can independently used as an
input or an output through the R2DD register (address 0CAH).
Each port also can be set individually as pull-up port through the
R2PU (address 0D2H), and as open drain register through the
R2CR (address 0D6H).
R2 Pull-up Register
ADDRESS: 0D2H
RESET VALUE: 00H
R2PU
Port Pull-up
0: Pull-up resistor Off
1: Pull-up resistor On
In addition, port R2 is multiplexed with analog input port.
R2 Open drain control Register
Port pin
R20
R21
R22
R23
R24
R25
R26
R27
34
Alternate function
AN0 (Analog Input 0)
AN1 (Analog Input 1)
AN2 (Analog Input 2)
AN3 (Analog Input 3)
AN4 (Analog Input 4)
AN5 (Analog Input 5)
AN6 (Analog Input 6)
AN7 (Analog Input 7)
ADDRESS: 0D6H
RESET VALUE: 00H
R2CR
Port Open drain
0: Push Pull
1: Open drain
APR., 2001 Ver 2.01
GMS81C7008/7016
R3 and R3DD register: R3 is an 8-bit CMOS bidirectional I/O
port (address 0C3H). Each I/O pin can independently used as an
input or an output through the R3DD register (address 0CBH).
Each port also can be set individually as pull-up port through the
R3PU (address 0D3H), and as open drain register through the
R3CR (address 0D7H).
PMR
7
6
5
4
BUZ (Buzzer driving output)
PWM0 / T1O (PWM 0 output
/ Timer 1 output)
PWM1 /T3O (PWM 1 output
/ Timer 3 output)
WDTO (Watchdog timer output)
SXOUT (Sub clock output)
SXIN (Sub clock input)
R32
R33
R34
R35
R36
2
1
0
0: R00
1: INT0
0: R01
1: INT1
0: R30
1: BUZ
Alternate function
R30
R31
3
0: R04
1: EC2
In addition, port R3 is multiplexed with various special features.
Port pin
ADDRESS: 0D9H
RESET VALUE: 00H
Port Selection Register
0: R31
1: PWM0/T1O
0: R32
1: PWM1/T3O
Watch Dog Timer Register
WDTR
-
-
0: R02
1: INT2
0: R03
1: EC0
ADDRESS: 0DFH
RESET VALUE: --01_0010B
WDOE WDEN WDCK1 WDCK0 WDOM WDCLR
0: R34
1: WDTO
R3 Data Register
R3
-
ADDRESS: 0C3H
RESET VALUE: 00H
R06 R05 R04 R03 R02 R01 R00
Input / Output data
R3 Direction Register
R3DD
LCD Control Register
LCR
ADDRESS: 0F1H
RESET VALUE: 00H
S U BM BTC LCDEN BRC DTY1 DTY0 LCK1 LCK0
0: SXOUT, SXIN(Sub Clock Oscillation)
1: R35, R36(Sub Clock Disable)
ADDRESS: 0CBH
RESET VALUE: 00H
-
Port Direction
0: Input
1: Output
R3 Pull-up Register
R3PU
ADDRESS: 0D3H
RESET VALUE: 00H
-
Port Pull-up
0: Pull-up resistor Off
1: Pull-up resistor On
R3 Open drain control Register
R3CR
ADDRESS: 0D7H
RESET VALUE: 00H
Port Open drain
0: Push Pull
1: Open drain
APR., 2001 Ver 2.01
35
GMS81C7008/7016
R4 and R4DD register: R4 is an 8-bit CMOS bidirectional I/O
port (address 0C4H). Each I/O pin can independently used as an
input or an output through the R4DD register (address 0CCH).
After Reset, R4 port is used as LCD segment o utput
SEG0~SEG7. To use general I/O ports user should be written appropriate value into the LPMR (0F3H).
R5 Data Register
R5
ADDRESS: 0C5H
RESET VALUE: 00H
R57 R56 R55 R54 R53 R52 R51 R50
Input / Output data
LCD pin function
Port pin
SEG0 (LCD segment 0 signal output)
SEG1 (LCD segment 1 signal output)
SEG2 (LCD segment 2 signal output)
SEG3 (LCD segment 3 signal output)
SEG4 (LCD segment 4 signal output)
SEG5 (LCD segment 5 signal output)
SEG6 (LCD segment 6 signal output)
SEG7 (LCD segment 7 signal output)
R40
R41
R42
R43
R44
R45
R46
R47
R5 Direction Register
ADDRESS: 0CDH
RESET VALUE: 00H
R5DD
Port Direction
0: Input
1: Output
R6 and R6DD register: R6 is an 8-bit CMOS bidirectional I/O
port (address 0C6H). Each I/O pin can independently used as an
input or an output through the R6DD register (address 0CE H).
R4 Data Register
R4
ADDRESS: 0C4H
RESET VALUE: 00H
R47 R46 R45 R44 R43 R42 R41 R40
After Re set, R6 port is used as LCD segm ent output
SEG16~SEG23. To use general I/O ports user should be written
appropriate value into the LPMR (0F3H).
Input / Output data
R4 Direction Register
ADDRESS: 0CCH
RESET VALUE: 00H
R4DD
Port Direction
0: Input
1: Output
LCD pin function
Port pin
SEG16 (LCD segment 16 signal output)
SEG17 (LCD segment 17 signal output)
SEG18 (LCD segment 18 signal output)
SEG19 (LCD segment 19 signal output)
SEG20 (LCD segment 20 signal output)
SEG21 (LCD segment 21 signal output)
SEG22 (LCD segment 22 signal output)
SEG23 (LCD segment 23 signal output)
R60
R61
R62
R63
R64
R66
R66
R67
R5 and R5DD register: R5 is an 8-bit CMOS bidirectional I/O
port (address 0C5H). Each I/O pin can independently used as an
input or an output through the R4DD register (address 0CDH).
After Reset, R5 port is used as LCD segment o utput
SEG8~SEG15. To use general I/O ports user should be written
appropriate value into the LPMR (0F3H).
LCD pin function
Port pin
SEG8 (LCD segment 8 signal output)
SEG9 (LCD segment 9 signal output)
SEG10 (LCD segment 10 signal output)
SEG11 (LCD segment 11 signal output)
SEG12 (LCD segment 12 signal output)
SEG13 (LCD segment 13 signal output)
SEG14 (LCD segment 14 signal output)
SEG15 (LCD segment 15 signal output)
R50
R51
R52
R53
R54
R55
R56
R57
36
R6 Data Register
R6
ADDRESS: 0C6H
RESET VALUE: 00H
R67 R66 R65 R64 R63 R62 R61 R60
Input / Output data
R6 Direction Register
ADDRESS: 0CEH
RESET VALUE: 00H
R6DD
Port Direction
0: Input
1: Output
APR., 2001 Ver 2.01
GMS81C7008/7016
10. CLOCK GENERATOR
As shown in Figure 10-1, the clock generator produces the basic
clock pulses which provide the system clock to be supplied to the
CPU and the peripheral hardware. It contains two oscillators: a
main-frequency clock oscillator and a sub-frequency clock oscillator. Power consumption can be reduced by switching them to
the low power operation frequency clock can be easily obtained
by attaching a resonator between the XIN and XOUT pin and the
SXIN and SXOUT pin, respectively. The system clock can also be
obtained from the external oscillator.
Instruction cycle time
CPU clock
The clock generator produces the system clocks forming clock
pulse, which are supplied to the CPU and the peripheral hardware. The internal system clock can be selected by bit2, and bit3
of the System Clock Mode Register(SCMR).
XIN = 4MHz
SXIN = 32.768kHz
÷2
0.5 us
61 us
÷8
2.0 us
244 us
÷ 16
4.0 us
488 us
÷ 64
16.0 us
1953 us
The register is shown in Figure 10-2.
To the peripheral block, the clock among the not-divided original
clocks, divided by 2, 4,..., up to 1024 can be provided. Peripheral
clock is enabled or disabled by STOP instruction.
SYCC<1>
SYCC<0>
SLEEP Mode
STOP Mode
SCS[1:0]
select clock
XIN PIN
CLOCK PULSE
GENERATOR
OSC Stop
fEX
0
1
SXIN PIN
÷2
÷8
Internal system clock (CPU clock)
MUX
÷16
÷64
OSC Stop
LCR<7>
PRESCALER
PS0
÷1
PS1
÷2
PS2
÷4
PS3
÷8
PS4
÷16
PS5
÷32
PS6
÷64
PS7
÷128
PS8
÷256
PS9
PS10
÷512 ÷1024
Peripheral clock
fEX(MHz)
4
PS0
PS1
PS2
PS3
PS4
PS5
PS6
PS7
PS8
Frequency
4M
2M
1M
500K
250K
125K
62.5K
31.25K
15.63K
period
250n
500n
1u
2u
4u
8u
16u
32u
64u
PS9
PS10
7.183K 3.906K
128u
256u
Figure 10-1 Block Diagram of Clock Generator
APR., 2001 Ver 2.01
37
GMS81C7008/7016
The system clock is decided by bit1 (SYCC1) of the system clock
mode register(SCMR). In selection Sub clock, to oscillate or stop
the Main clock is decided by bit0 (SYCC0) of SCMR. On the ini-
SCMR
7
-
6
5
4
-
-
-
tial reset, internal system clock is PS1 which is the fastest and
other clock can be provided by bit2 and bit3 of SCMR.
R/W R/W R/W R/W
3
2
1
0
BTCL
SCS1 SCS0 SYCC1 SYCC0
ADDRESS: 0F5H
INITIAL VALUE: 00H
System (CPU) clock control
00: main clock on
01: main clock on
10: sub clock on (main clock on)
11: sub clock on (main clock off)
System clock source select
00: XIN÷2 or SXIN÷2
01: XIN÷8 or SXIN÷8
10: XIN÷16 or SXIN÷16
11: XIN÷64 or SXIN÷64
Figure 10-2 SCMR: System Clock Control Registers
38
APR., 2001 Ver 2.01
GMS81C7008/7016
11. OPERATION MODE
Sub-clock operating mode
The system clock controller starts or stops the main-frequency
clock oscillator and switches between the sub frequency clock.
The operating mode is generally divided into the main-clock
mode and the sub-clock mode, which are controlled by System
clock mode register (SCMR). Figure 11-1shows the operating
mode transition diagram.
This mode is low-frequency operating mode
In this mode, the high-frequency clock oscillation is stops and
low-frequency clock oscillation is active to operate the CPU and
the peripheral hardware on the low-frequency clock, thereby reducing power consumption
System clock control is performed by the system clock mode register, SCMR. During reset, this register is initialized to “0” so that
the main-clock operating mode is selected.
SLEEP mode
In this mode, the CPU clock stops while peripherals and the oscillation source continue to operate normally.
Main-clock operating mode
STOP mode
This mode is fast-frequency operating mode.
The CPU and the peripheral hardwares are operated on the highfrequency clock. At reset release, this mode is invoked.
Main - Oscillating
Sub - Oscillating
In this mode, the system operations are all stopped, holding the
internal states valid immediately before the stop at the low power
consumption level.
Main - According to SCMR
Sub - Oscillating
Instruction
te 2
Release
te 1
no
OP
I
r to
Re
fe
NOTE2:
RESET
All Int.
n
ST
RESET
Key Scan Int.
Watch Timer Int.
Timer interrupt (EC0, EC2)
External Int.
SIO Int.
Watchdog Timer Int.
o
cti
no
Main: Oscillating
Sub: Oscillating
NOTE1:
tr u
In s
Main: Stopped
Sub: Oscillating
r to
RESET
Operation
t
se
Re
fe
Re
ns
tr u
cti
o
n
Reset
Sub-clock
Main-clock
Mode Instruction Mode
Re
se
t
STOP
Mode
SLEEP
Mode
Main: According to SCMR
Sub: Oscillating
CPU stops,
Peripherals are operate.
CPU and Peripherals are stops,
Figure 11-1 Operating Mode
APR., 2001 Ver 2.01
39
GMS81C7008/7016
11.1 Operation Mode Switching
In the Main-clock operation mode, only the high-frequency clock
oscillator is used.
In the Sub-clock operation mode, the high-frequency clock oscillation stops, enabling the low power voltage operation or the low
power consumption operation. Instruction execution does not
stop when the operation speed switching is performed. However,
some peripheral hardware capabilities may be affected. For details, refer to the description of the relevant operation.
The following describes the switching between the Main-clock
and the Sub-clock operations. During reset, the system clock
mode register is initialized at the Main-clock mode. It must be set
to the Sub-clock operation for the low-power consumption mode.
;20ms software delay at fXIN=4MHz
DELAY:
DLP0:
DLP1:
LDY
LDA
NOP
INC
BCC
INC
CMPY
BCC
RET
#0
#0
A
DLP1
Y
#20
DLP0
Switching from main clock operation to subclock operation
Shifting from the Normal operation to the SLEEP
mode
First, write “10B” into lower 2 bits of SCMR to switch the main
system clock to the sub-frequency clock.
Next, write “11B” to turn off main frequency oscillation.
By setting bit 0 of SMR, the CPU clock stops and the SLEEP
mode is invoked. The CPU stops while other peripherals are operate normally.
Example:
The way of release from this mode is RESET and all available interrupts.
:
:
MOV
MOV
:
:
For more detail, See "20.1 SLEEP Mode" on page 81
SCMR,#0000_XX10B
SCMR,#0000_XX11B
;Switch to sub mode
;Turn off main clock
Returning from sub clock operation to main
clock operation
First, write “10B” into lower 2 bits of the SCMR to turn on the
main-frequency oscillation, when the stabilization (warm-up) has
been taken by the software delay routine. Sub clock operation
mode can also be released by setting the RESET pin to low,
which immediately performs the reset operation. After reset, the
GMS81C7008/16 is placed in main frequency operation mode.
Example:
:
:
:
MOV SCMR,#0000_XX10B
CALL DELAY
MOV SCMR,#0000_XX00B
:
:
:
40
;Turn on main-clock
;Wait until stable
;Move to main mode
Shifting from the Normal operation to the STOP
mode
By executing STOP instruction, the main-frequency clock oscillation stops and the STOP mode is invoked. But sub-frequency
clock oscillation is operated continuously.
After the STOP operation is released by reset, the operation mode
is changed to Main-clock mode.
The methods of release are RESET, Key scan interrupt, Watch
Timer interrupt, Timer/Event counter1 (EC0, EC2 pin), and External Interrupt.
For more details, see "20.2 STOP Mode" on page 82.
Note: In the STOP and Sub clock operating modes, the
power consumed by the oscillator and the internal hardware is reduced. However, the power for the pin interface
(depending on external circuitry and program) is not directly
associated with the low-power consumption operation. This
must be considered in system design as well as interface
circuit design.
APR., 2001 Ver 2.01
GMS81C7008/7016
~
~
Sub freq. clock
(SXIN pin)
~
~
~
~
Main freq. clock
(XIN pin)
~
~
~
~
Operation clock
Main-clock operation
Sub-clock operation
Changed to the Sub-clock
SCMR ← XXXX XX10B
Turn off main clock
SCMR ← XXXX XX11B
(a) Main clock mode → Sub clock mode
~
~
~
~
Main freq. clock
(XIN pin)
Stabilizing Time > 20ms
~
~
Sub freq. clock
(SXIN pin)
Operation clock
~
~
Sub-clock operation
Changed to the Transition
SCMR ← XXXX XX10B
Main-clock operation
Changed to the Main-clock
SCMR ← XXXX XX00B
or 01B
(b) Sub clock → Main clock
Figure 11-2 System Clock Switching Timing
APR., 2001 Ver 2.01
41
GMS81C7008/7016
12. BASIC INTERVAL TIMER
The GMS81C7008/16 has one 8-bit Basic Interval Timer that is
free-run and can not stop. Block diagram is shown in Figure 12-1.
Timer is controlled by the clock control register (CKCTLR)
shown in Figure 12-2.
In addition, the Basic Interval Timer generates the time base for
watchdog timer counting. It also provides a Basic interval timer
interrupt (BITIF). As the count overflow from FFH to 00H, this
overflow causes the interrupt to be generated. The Basic Interval
Source clock can be selected by lower 3 bits of CKCTLR.
The registers BITR and CKCTLR are located at same address,
and address 0F9H is read as a BITR, and written to CKCTLR.
÷8
SCMR[1:0]
÷16
0X
fSXIN
1X
Prescaler
÷32
fXIN
÷64
÷128
MUX
source
clock
8-bit up-counter
overflow
BITIF
Basic Interval Timer Interrupt
÷256
[0F9H]
÷512
÷1024
To Watchdog timer (WDTCK)
clear
Select Input clock 3
BTS[2:0]
[0F4H]
CKCTLR
BTCL
BITR
Read
Basic Interval Timer
clock control register
Internal bus line
Figure 12-1 Block Diagram of Basic Interval Timer
Interrupt (overflow) Period (ms)
BTS[2:0]
000
001
010
011
100
101
110
111
CPU Source clock
÷8
÷16
÷32
÷64
÷128
÷256
÷512
÷1024
@ fXIN = 4MHz
@ fSXIN = 32.768kHz
0.512
1.024
2.048
4.096
8.192
16.384
32.768
65.536
62.5ms
125ms
250ms
500ms
1000ms
2000ms
4000ms
8000ms
Table 12-1 Basic Interval Timer Interrupt Time
42
APR., 2001 Ver 2.01
GMS81C7008/7016
CKCTLR
7
-
6
-
5
-
W
4
W
W
W
W
3
2
1
0
BCK BTCL
BTCL BTS2 BTS1 BTS0
ADDRESS: 0F4H
INITIAL VALUE: ---0 0111B
Basic Interval Timer source clock select
000: fXIN ÷ 8
or fSXIN ÷ 8
001: fXIN ÷ 16
or fSXIN ÷ 16
010: fXIN ÷ 32
or fSXIN ÷ 32
011: fXIN ÷ 64
or fSXIN ÷ 64
100: fXIN ÷ 128 or fSXIN ÷ 128
101: fXIN ÷ 256 or fSXIN ÷ 256
110: fXIN ÷ 512 or fSXIN ÷ 512
111: fXIN ÷ 1024 or fSXIN ÷ 1024
Caution:
Both register are in same address,
when write, to be a CKCTLR,
when read, to be a BITR.
Clear bit
0: Normal operation, free-run
1: Clear 8-bit counter (BITR) to “0” and count up again.
This bit becomes to “0” automatically after one machine cycle.
For the test purpose.
This bit must be cleared to “0” for normal operation,
otherwise BIT clock source is form sub-clock.
R
7
R
6
R
5
BITR
R
4
R
3
BTCL
R
2
R
1
R
0
ADDRESS: 0F4H
INITIAL VALUE: Undefined
8-BIT FREE-RUN BINARY COUNTER
Figure 12-2 BITR: Basic Interval Timer Mode Register
Example 1:
Interrupt request flag is generated every 8.192ms at 4MHz.
:
LDM
SET1
EI
:
CKCTLR,#0CH
BITE
APR., 2001 Ver 2.01
43
GMS81C7008/7016
13. TIMER/EVENT COUNTER
The GMS81C7008/16 has four Timer/Event counters. Each module can generate an interrupt to indicate that an event has occurred
(i.e. timer match).
Timer 0 and Timer 1 are can be used either two 8-bit Timer/
Counter or one 16-bit Timer/Counter with combine them. Also
Timer 2 and Timer 3 can be joined as a 16-bit Timer/Counter.
In the “timer” function, the register is increased every internal
clock input. Thus, one can think of it as counting internal clock
input. The count rate is 1/2 to 1/2048 of the oscillator frequency.
In addition the “capture” function, the register is incremented in
response external or internal clock sources same with timer or
counter function. When external clock edge input, the count register is captured into Capture data register correspondingly.
It has five operating modes: “8-bit timer/counter”, “16-bit timer/
counter”, “8-bit capture”, “16-bit capture”, “PWM mode” which
are selected by bit in Timer mode register TMn.
In operation of Timer 2, Timer 3, their operations are same with
Timer 0, Timer 1, respectively.
In the “counter” function, the register is incremented in response
to a 0-to-1 (rising edge) transition at its corresponding external
input pin, EC0 or EC2 pin.
When programming the software, you may refer to following example.
Example 1:
Example 3:
Timer 0 = 8-bit timer mode, 8ms interval at 4MHz
Timer 1 = 8-bit timer mode, 4ms interval at 4MHz
Timer 2 = 16-bit event counter mode
Timer0 = 8-bit timer mode, 2ms interval at 4MHz
Timer1 = 8-bit capture mode, 2us sampling count.
LDM
LDM
LDM
LDM
LDM
SCMR,#0
;Main clock mode
TDR0,#249
TM0,#0001_0011B
TDR1,#124
TM1,#0000_1111B
LDM
LDM
LDM
LDM
TDR2,#1FH
TDR3,#4CH
TM2,#0001_1111B
TM3,#0100_1100B
SET1
SET1
EI
:
:
T0E
T2E
LDM
LDM
TDR0,#249
TM0,#0FH
;250x8=2000us
;FXIN/32, 8us
LDM
LDM
LDM
LDM
IEDS,#XXXX_01XXB
PMR,#XXXX_XX1XB
TDR1,#0FFH
TM1,#0001_1011B
SET1
SET1
SET1
EI
:
:
T0E
T1E
INT1E
;FALLING
;AS INT1
;2us
;ENABLE TIMER 0
;ENABLE TIMER 1
;ENABLE EXT. INT1
X: don’t care.
Example 4:
Example 2:
Timer0 = 16-bit timer mode, 0.5s at 4MHz
Timer2 = 2ms 8-bit timer mode at 4MHz
Timer3 = 250us 8-bit timer mode at 4MHz
44
LDM
LDM
LDM
LDM
LDM
SCMR,#0
;Main clock mode
TDR0,#23H
TDR1,#0F4H
TM0,#0FH
;FXIN/32, 8us
TM1,#4CH
LDM
LDM
LDM
LDM
TDR2,#249
TDR3,#124
TM2,#0FH
TM3,#0DH
SET1
SET1
SET1
EI
:
:
T0E
T2E
T3E
Timer0 = 8-bit timer mode, 2ms interval at 4MHz
Timer2 = 16-bit capture mode, 8us sampling count.
LDM
LDM
TDR0,#249
TM0,#0FH
LDM
LDM
LDM
LDM
LDM
LDM
IEDS,#XX11_XXXXB
PMR4,#XXXX_X1XXB
TDR2,#0FFH
TDR3,#0FFH
TM2,#XX10_1111B
TM3,#X10X_11XXB
SET1
SET1
SET1
EI
:
:
T0E
T2E
INT2E
;MAX
;MAX
;/32
;FXUN/32, 8us
;FXIN/8, 2us
;ENABLE TIMER 0
;ENABLE TIMER 2
;ENABLE EXT. INT2
X: don’t care.
APR., 2001 Ver 2.01
GMS81C7008/7016
Timer 0 mode register
TM0
7
6
R/W
5
R/W
4
R/W
3
R/W
2
R/W
1
R/W
0
-
-
CAP 0 T0C K2 B
T0CK1
TCL T0C K0 T0CN
T0S T
ADDRESS: 0E0H
INITIAL VALUE: 00H
Timer/Counter 0 start/stop control flag
0: stop count
1: clearing the T0 counter and start count again
Timer/Counter 0 enable flag
0: Disable count
1: Enable count
Basic Interval Timer source clock select
or fSXIN ÷ 2
000: fXIN ÷ 2
or fSXIN ÷ 4
001: fXIN ÷ 4
or fSXIN ÷ 8
010: fXIN ÷ 8
or fSXIN ÷ 32
011: fXIN ÷ 32
100: fXIN ÷ 128 or fSXIN ÷ 128
101: fXIN ÷ 512 or fSXIN ÷ 512
110: fXIN ÷ 2048 or fSXIN ÷ 2048
111: EC0 (External event input 0)
Capture mode enable
0: Timer mode
1: Capture mode
Timer 1 mode register
R/W
7
R/W
1
R/W
0
TM1
PO L0 16BIT0 PW M E0 CA P1 T1C
K1 T1CK0 T1CN
B TCL
T1S T
R/W
6
R/W
5
R/W
4
R/W
3
R/W
2
PWM duty control
0: Active low
1: Active high
ADDRESS: 0E2H
INITIAL VALUE: 00H
Timer/Counter 1 start/stop control flag
0: stop count
1: clearing the T1 counter and start count again
Timer/Counter 1 enable flag
0: Disable count
1: Enable count
Mode selection
0: 8-bit mode
1: 16-bit mode
Timer/Counter 1 source clock select
00: fXIN
or fSXIN
01: fXIN ÷ 2 or fSXIN ÷ 2
(depend on SCMR)
10: fXIN ÷ 8 or fSXIN ÷ 8
11: Timer 0 clock
Capture mode enable
0: Timer mode
1: Capture mode
PWM enable bit
0: Disable
1: Enable
W
7
W
6
W
5
W
4
W
3
W
2
W
1
W
0
TDR0~TDR3
ADDRESS: 0E1H, 0E3H, 0E7H, 0E9H
INITIAL VALUE: 0FFH
Compare data registers
Figure 13-1 TM0, TM1, TDRn Registers
APR., 2001 Ver 2.01
45
GMS81C7008/7016
Timer 2 mode register
TM2
7
6
R/W
5
R/W
4
R/W
3
R/W
2
R/W
1
R/W
0
-
-
CAP 2 T2C K2 B
T2CK1
TCL T2C K0 T2C N
T2S T
ADDRESS: 0E6H
INITIAL VALUE: 00H
Timer/Counter 2 start/stop control flag
0: stop count
1: clearing the T0 counter and start count again
Timer/Counter 2 enable flag
0: Disable count
1: Enable count
Timer/Counter 2 source clock select
or fSXIN ÷ 2
000: fXIN ÷ 2
or fSXIN ÷ 4
001: fXIN ÷ 4
or fSXIN ÷ 8
010: fXIN ÷ 8
or fSXIN ÷ 32
011: fXIN ÷ 32
100: fXIN ÷ 128 or fSXIN ÷ 128
101: fXIN ÷ 512 or fSXIN ÷ 512
110: fXIN ÷ 2048 or fSXIN ÷ 2048
111: EC2 (External event input 2)
Capture mode enable
0: Timer mode
1: Capture mode
Timer 3 mode register
R/W
7
R/W
1
R/W
0
TM3
PO L1 16B IT1 PW M E1 CA P3 T3C
K1 T3C K0 T3CN
B TCL
T3S T
R/W
6
R/W
5
R/W
4
R/W
3
R/W
2
PWM1 duty control
0: Active low
1: Active high
ADDRESS: 0E8H
INITIAL VALUE: 00H
Timer/Counter 3 start/stop control flag
0: stop count
1: clearing the T3 counter and start count again
Timer/Counter 3 enable flag
0: Disable count
1: Enable count
Mode selection
0: 8-bit mode
1: 16-bit mode
Timer/Counter 3 source clock selection
or fSXIN
00: fXIN
01: fXIN ÷ 2 or fSXIN ÷ 2
(depend on SCMR)
10: fXIN ÷ 8 or fSXIN ÷ 8
11: Timer 2 clock
Capture mode enable
0: Timer mode
1: Capture mode
PWM enable bit
0: Disable
1: Enable
T0~T3
CDR0~CDR3
R
7
R
6
R
5
R
4
R
3
R
2
R
1
R
0
ADDRESS: 0E1H, 0E4H, 0E7H, 0EAH
INITIAL VALUE: 00H
Count registers
Figure 13-2 TM2, TM3 Registers
46
APR., 2001 Ver 2.01
GMS81C7008/7016
13.1 8-bit Timer / Counter Mode
The GMS81C7008/16 has four 8-bit Timer/Counters, Timer 0,
Timer 1, Timer 2, Timer 3 which are shown in Figure 13-3, Figure 13-4.
16BIT0 and PWME bits should be cleared to “0”. These timers
have each 8-bit count register and data register. The count register
is increased by every internal or external clock input. The internal
clock has a prescaler divide ratio option of 2~2048 selected by
control bits of register TMn (n=0,1,2,3).
The “timer” or “counter” function is selected by control registers
TMn. To use as an 8-bit timer/counter mode, CAP0, CAP1,
TM0
7
6
-
-
X
X
5
4
3
2
1
0
ADDRESS: 0E0H
INITIAL VALUE: 00H
BTCL T0CK0 T0CN T0ST
CAP0 T0CK2 T0CK1
X
0
X
X
X
X
ADDRESS: 0E2H
INITIAL VALUE: 00H
POL0 16BIT0 PWM E0 CAP1 T1CK1
BTCL T1CK0 T1CN T1ST
TM1
X
0
0
0
X
X
X
X
X means don’t care
T0CK[2:0]
Edge Detector
EC0 PIN
111
fXIN
0X
fSXIN
1X
Prescaler
SCMR[1:0]
÷2048
÷512
÷128
÷32
÷8
÷4
÷2
T0ST
0: Stop
1: Clear and start
110
101
0
100
T0 (8-bit)
1
011
010
001
T0CN
clear
[0E1H]
TIMER 0
INTERRUPT
T0IF
Comparator
000
MUX
TDR0 (8-bit)
TIMER 0
[0E1H]
T1CK[1:0]
T1ST
÷8
÷2
÷1
0: Stop
1: Clear and start
11
10
01
0
1
00
MUX
PMR.6
[0D9H.6]
T1 (8-bit)
F/F
clear
[0E4H]
T1CN
T1IF
Comparator
TDR1 (8-bit)
R31/T1O/PWM0
PIN
TIMER 1
INTERRUPT
TIMER 1
[0E3H]
Figure 13-3 8-bit Timer/Counter 0, 1
APR., 2001 Ver 2.01
47
GMS81C7008/7016
As TDRx and Tx register are in same address, when reading it as
a Tx, written to TDRx.
Note: The contents of Timer data register TDRx should be
initialized with 1H~FFH, not to 0H, because it is not to defined before reset.
In counter function, the counter is increased every 0-to-1 (rising
edge) transition of EC0 or EC2 pin. In order to use counter function, the bit 3 and bit 4 of the Port mode register PMR are set to
“1” by software. The Timer 0 can be used as a counter by pin EC0
input. Similarly, Timer 2 can be used by pin EC2 input.
In the Timer 0, timer register T0 increments from 00H until it
matches with TDR0 and then reset to 00H. The match output of
Timer 0 generates Timer 0 interrupt (latched in T0IF bit)
TM2
7
6
-
-
X
X
5
4
3
2
1
0
ADDRESS: 0E6H
INITIAL VALUE: 00H
CAP2 T2CK2 T2CK1
BTCL T2CK0 T2CN T2ST
X
0
X
X
X
X
ADDRESS: 0E8H
INITIAL VALUE: 00H
POL1 16BIT1 PWME1 CAP3 T3CK1
BTCL T3CK0 T3CN T3ST
TM3
X
0
0
0
X
X
X
X
X means don’t care
T2CK[2:0]
Edge Detector
EC2 PIN
111
fXIN
0X
fSXIN
1X
Prescaler
SCMR[1:0]
÷2048
÷512
÷128
÷32
÷8
÷4
÷2
T2ST
0: Stop
1: Clear and start
110
101
0
100
1
T2 (8-bit)
011
010
001
clear
[0E7H]
T2CN
TIMER 2
INTERRUPT
T2IF
Comparator
000
MUX
TDR2 (8-bit)
TIMER 2
[0E7H]
T3CK[1:0]
T3ST
÷8
÷2
÷1
10
01
0
1
T3 (8-bit)
F/F
clear
[0EAH]
00
MUX
PMR.7
[0D9H.7]
0: Stop
1: Clear and start
11
T3CN
T3IF
Comparator
TDR3 (8-bit)
R32/T3O/PWM0
PIN
TIMER 3
INTERRUPT
TIMER 3
[0E9H]
Figure 13-4 8-bit Timer/Counter 2, 3
48
APR., 2001 Ver 2.01
GMS81C7008/7016
8-bit Timer Mode
(T1IF) is generated and the up-counter is cleared to 0. Counting
up is resumed after the up-counter is cleared.
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 (n=0,1,2,3) are compared with the contents of
up-counter, Tn (n=0,1,2,3). If match is found, a timer 1 interrupt
As the value of TDRn can be re-written by software, time interval
is set as you want
Start count
~
~
Source clock
~
~
Up-counter
0
2
1
n-2
3
n-1
n
0
3
4
Counter
Clear
~
~
TDR1
2
1
n
~
~
Match
Detect
~
~
T1IF interrupt
Figure 13-5 Timer Mode Timing Chart
Example: Make 1msinterrupt using by Timer0 at 4MHz
LDM
LDM
SET1
EI
TM0,#0FH
TDR0,#124
T0E
;
;
;
;
divide by 32
8us x (124+1)= 1ms
Enable Timer 0 Interrupt
Enable Master Interrupt
TM0 = 0000_1111B (8-bit Timer mode, Prescaler divide ratio → ÷32)
TDR0 = 124D = 7CH
fXIN = 4 MHz
1
INTERRUPT PERIOD =
× 32 × (124+1) = 1 ms
4 × 106 Hz
When
TDR1
MATCH
(TDR0 = T0)
t
un
-c
o
8 µs
~~
~~
up
~~
7B
7A
6
Count Pulse
Period
7D
7C
7D
5
4
3
2
1
0
0
TIME
Interrupt period
= 8 µs x 125
Timer 1 (T1IF)
Interrupt
Occur interrupt
Occur interrupt
Occur interrupt
Figure 13-6 Timer Count Example
APR., 2001 Ver 2.01
49
GMS81C7008/7016
8-bit Event Counter Mode
After reset, the value of timer data register TDRn is undefined, it
should be initialized to between 1H~FFHnot to "0". The interval
period of Timer is calculated as below equation.
In this mode, counting up is started by an external trigger. This
trigger means rising edge of the EC0 or EC2 pin input. Source
clock is used as an internal clock selected with timer mode register TM0, TM1, TM2 or TM3. The contents of timer data register
TDRn (n = 0,1,2,3,........,FF) are compared with the contents of
the up-counter Tn. If a match is found, an timer interrupt request
flag TnIF is generated, and the counter is cleared to “0”. The
counter is restart and count up continuously by every rising edge
of the ECn pin input.
1
Period (sec) = ---------- × 2 × Divide Ratio × TDRn
f XIN
The maximum frequency applied to the ECn pin is fXIN/2 [Hz].
In order to use event counter function, the bit 3, 4 of the Port
Mode Register PMR (address 0D9H) is required to be set to “1”.
~
~
Start count
ECn pin input
~
~
1
0
2
~
~
Up-counter
n-1
n
1
0
2
~
~
n
~
~
TDR1
~
~
T1IF interrupt
Figure 13-7 Event Counter Mode Timing Chart
TDR1
disable
~~
clear & start
enable
up
-
co
u
nt
stop
~~
TIME
Timer 1 (T1IF)
Interrupt
Occur interrupt
Occur interrupt
T1ST
Start & Stop
T1ST = 1
T1ST = 0
T1CN
Control count
T1CN = 1
T1CN = 0
Figure 13-8 Count Operation of Timer / Event counter
50
APR., 2001 Ver 2.01
GMS81C7008/7016
13.2 16-bit Timer / Counter Mode
Even if the Timer 0 (including the Timer 1) is used as a 16-bit
timer, the Timer 2 and Timer 3 can still be used as either two 8bit timer or one 16-bit timer by setting the TM2. Reversely, even
if the Timer 2 (including the Timer 3) is used as a 16-bit timer,
the Timer 0 and Timer 1 can still be used as 8-bit timer independently.
The Timer register is being run with all 16 bits. A 16-bit timer/
counter register T0, T1 are incremented from 0000H until it
matches TDR0, TDR1 and then resets to 0000H. The match output generates Timer 0 interrupt.
The clock source of the Timer 0 is selected either internal or external clock by bit T0SL1, T0SL0.
TM0
TM1
7
6
-
-
X
X
5
4
3
2
1
0
ADDRESS: 0E0H
INITIAL VALUE: 00H
BTCL T0CK0 T0CN T0ST
CAP0 T0CK2 T0CK1
0
X
X
X
X
X
ADDRESS: 0E2H
INITIAL VALUE: 00H
BTCL T1CK0 T1CN T1ST
POL0 16BIT0 PWME0 CAP1 T1CK1
X
1
0
0
1
1
X
X
X means don’t care
T0CK[2:0]
Edge Detector
EC0 PIN
T0ST
0: Stop
1: Clear and start
111
fXIN
0X
fSXIN
1X
Prescaler
SCMR[1:0]
÷2048
÷512
÷128
÷32
÷8
÷4
÷2
0
110
T0
T1
1
101
clear
(16-bit)
100
011
TIMER 0 INTERRUPT
(Not Timer 1 interrupt)
T0IF
T0CN
Comparator
010
001
TDR0
TDR1
Higher byte
MUX
R31/T1O/PWM0
PIN
F/F
000
Lower byte
PMR.6
[0D9H.6]
COMPARE DATA
TIMER 0 + TIMER 1 → TIMER 0 (16-bit)
TM2
TM3
7
6
-
-
X
X
5
4
3
2
1
0
ADDRESS: 0E6H
INITIAL VALUE: 00H
CAP2 T2CK2 T2CK1
BTCL T2CK0 T2CN T2ST
0
X
X
X
X
X
ADDRESS: 0E8H
INITIAL VALUE: 00H
POL1 16BIT1 PWME1 CAP3 T3CK1
BTCL T3CK0 T3CN T3ST
X
1
0
0
1
1
X
X
X means don’t care
T2CK[2:0]
Edge Detector
EC2 PIN
T2ST
0: Stop
1: Clear and start
111
fXIN
1X
fSXIN
1X
Prescaler
SCMR[1:0]
÷2048
÷512
÷128
÷32
÷8
÷4
÷2
0
110
1
101
T2
T3
clear
(16-bit)
100
011
TIMER 2 INTERRUPT
(Not Timer 3 interrupt)
T2IF
T2CN
Comparator
010
001
TDR3
TDR2
000
Higher byte
MUX
R32/T3O/PWM1
PIN
F/F
Lower byte
COMPARE DATA
PMR.7
[0D9H.7]
TIMER 0 + TIMER 1 → TIMER 0 (16-bit)
Figure 13-9 16-bit Timer/Counter
APR., 2001 Ver 2.01
51
GMS81C7008/7016
13.3 8-bit Capture Mode
The capture mode can be used to measure the pulse width between two edges. The Timer 0 capture mode is set by bit CAP0
of Timer Mode Register TM0, and the Timer 1 capture mode is
set by CAP1 of Timer Mode Register TM1 as shown in Figure
13-10. Timer 2 and Timer 3 have same architecture with Timer 0
and Timer 1.
Timer/Counter still does the above, but with the added feature
that a edge transition at external input INTn pin causes the current
.
f xin
f timer = ------------------------------------------------------------------------------2 × prescaler value × ( TDR + 1 )
The Timer/Counter register is incremented in response internal or
external input. This counting function is same with normal timer
mode, and Timer interrupt is generate when timer register T0 (T1,
T2, T3) increase and match TDR0 (TDR1, TDR2, TDR3).
TM0
7
6
-
-
X
X
5
4
3
2
1
0
ADDRESS: 0E0H
INITIAL VALUE: 00H
CAP0 T0CK2 T0CK1
BTCL T0CK0 T0CN T0ST
1
X
X
X
X
X
ADDRESS: 0E2H
INITIAL VALUE: 00H
BTCL T1CK0 T1CN T1ST
POL0 16BIT0 PWME0 CAP1 T1CK1
TM1
X
0
0
1
X
X
X
X
IEDS[1:0]
01
10
INT0 PIN
INT0IF
INT0
INTERRUPT
11
CDR0
CDR0
(8-bit)
T0CK[2:0]
Edge Detector
EC0 PIN
fXIN
fSXIN
0X fEX
1X
Prescaler
111
SCMR[1:0]
T0ST
0: Stop
1: Clear and start
capture
÷2048
÷512
÷128
÷32
÷8
÷4
÷2
÷1
clear
110
101
clear
T0 (8-bit)
CDR0
(8-bit)
100
011
010
001
000
T0CN
Comparator
T0IF
TIMER 0
INTERRUPT
TDR0 (8-bit)
CDR0
(8-bit)
COMPARE DATA
MUX
01
INT1 PIN
10
INT1IF
INT1
INTERRUPT
11
IEDS[3:2]
CDR1
CDR0
(8-bit)
T1CK[1:0]
÷8
÷2
÷1
clear
11
10
01
00
MUX
T1ST
0: Stop
1: Clear and start
capture
clear
T1 (8-bit)
CDR0
(8-bit)
T1CN
Comparator
TDR1 (8-bit)
CDR0
(8-bit)
T1IF
TIMER 1
INTERRUPT
R31/T1O/PWM0
PIN
F/F
COMPARE DATA
PMR.6
[0D9H.6]
Figure 13-10 8-bit Capture Mode (Timer0/Timer1 case)
52
APR., 2001 Ver 2.01
GMS81C7008/7016
value in the Timer counter register (T0,T1), to be captured and
stored into registers CDRn (CDR0, CDR1), respectively. After
capture, the Timer counter register is cleared and restarts by hardware. At this time, reading the address E1H as a CDR0, not T0.
T0, TDR0, CDR0 are located at same address. The other
CDR1~CDR3 are same. Refer to Timer registers of page 27.
Note: The CDRn and Tn are in same address.In the capture mode, reading operation is read as CDRn, not Tn because addressing path is opened to the CDRn.
It has three transition modes: “falling edge”, “rising edge”, “both
edge” which are selected by interrupt edge selection register
IEDS. Refer to “17.4 External Interrupt” on page 68. In addition,
the transition at INTn pin generate an interrupt.
7
6
-
-
X
X
TM0
5
4
3
2
1
0
ADDRESS: 0E0H
INITIAL VALUE: 00H
BTCL T0CK0 T0CN T0ST
CAP0 T0CK2 T0CK1
1
X
X
X
X
X
ADDRESS: 0E2H
INITIAL VALUE: 00H
POL0 16BIT0 PWME0 CAP1 T1CK1
BTCL T1CK0 T1CN T1ST
TM1
X
1
0
1
1
1
X
X
X means don’t care
IEDS[1:0]
01
10
INT0 PIN
INT0
INTERRUPT
INT0IF
11
MSB
CDR1
T0CK[2:0]
Edge Detector
EC0 PIN
fXIN
0X
fSXIN
1X
fEX
Prescaler
SCMR[1:0]
LSB
CDR0
T0ST
capture
111
÷2048
÷512
÷128
÷32
÷8
÷4
÷2
16 BITS
clear
clear
110
101
100
011
010
001
000
0: Stop
1: Clear and start
T1
T0CN
Comparator
TDR1
MUX
T0
TDR0
T0IF
TIMER 0
INTERRUPT
R31/T1O/PWM0
PIN
F/F
COMPARE DATA
PMR.6
[0D9H.6]
Figure 13-11 16-bit Capture Mode
13.4 16-bit Capture Mode
16-bit capture mode is the same as 8-bit capture, except that the
Timer register is being run will 16 bits. Configuration is shown in
Figure 13-11.
13.5 Timer output port mode
The GMS81C7008/16 has a function of Timer compare output.
To pulse out, the timer match can goes out to port pin (T1O, T3O)
as shown in Figure 13-3, Figure 13-4 and Figure 13-9.
Thus pulse out is generated by the timer match. These operation
is implemented to pin T1O, T3O. This pin output the signal having 50% duty square wave and output frequency is same as below
APR., 2001 Ver 2.01
equation.
To use this function, the bit 6 and bit 7 of Port Mode Register
(PMR) are set or clear properly. In addition, 16-bit Timer output
mode is available, also
53
GMS81C7008/7016
13.6 PWM Mode
The GMS81C70xx and GMS81C71xx have two high speed
PWM (Pulse Width Modulation) functions which shared with
7
6
5
4
Timer 1 and Timer 3.
3
2
1
0
ADDRESS: 0E2H
INITIAL VALUE: 00H
BTCL T1CK0 T1CN T1ST
POL0 16BIT0 PWME0 CAP1 T1CK1
TM1
PWM0HR
X
0
1
0
-
-
-
-
-
-
-
-
X
X
X
X
ADDRESS: 0E5H
INITIAL VALUE: 00H
PWM03 PWM02 PWM01 PWM00
X
X
X
Period high
PWM[03:02] [0E5H]
X
Duty high
[0E3H]
2 Bit T1PPR (8-bit)
T1CK[1:0]
fXIN
fSXIN
0X fEX
1X
Prescaler
SCMR[1:0]
Comparator
T1ST
÷1
÷2
÷8
00
01
2 Bit
10
11
S
R
T1 (8-bit)
POL0
clear
(note1)
R31/T1O/PWM0
PIN
Q
PMR.6
[0D9H.6]
T1CN
MUX
2 Bit T1PDR (8-bit)
T0 clock source
(from Timer 0)
Note1: In the PWM mode, 2 bits are added
by hardware automatically.
PWM[01:00]
2 Bit T1PDR (8-bit)
[0E4H]
[0E5H]
7
6
5
4
3
2
1
0
ADDRESS: 0E8H
INITIAL VALUE: 00H
BTCL T3CK0 T3CN T3ST
POL1 16BIT1 PWME1 CAP3 T3CK1
TM3
PWM1HR
X
0
1
0
-
-
-
-
-
-
-
-
X
X
X
X
ADDRESS: 0EBH
INITIAL VALUE: 00H
PWM13 PWM12 PWM11 PWM10
X
X
X
Period high
PWM[13:12] [0EBH]
X
Duty high
[0E9H]
2 Bit T3PPR (8-bit)
T3CK[1:0]
fXIN
0X
fSXIN
1X
Prescaler
SCMR[1:0]
÷1
÷2
÷8
Comparator
T3ST
00
01
2 Bit
10
11
MUX
S
R
T3 (8-bit)
clear
(note1)
R32/T3O/PWM1
PIN
Q
POL1
PMR.7
[0D9H.7]
T3CN
2 Bit T3PDR (8-bit)
T2 clock source
(from Timer 2)
PWM[11:10]
2 Bit T3PDR (8-bit)
[0EBH]
[0EAH]
Figure 13-12 PWM Mode
54
APR., 2001 Ver 2.01
GMS81C7008/7016
Note: Whenever change the register content of Period or
Duty of PWM output, the timer counter Tn must be stopped
and restart again by software.
The PWM0 will be explained in this chapter. Other PWM1 has
same architecture. Pin R32/T1O/PWM0 outputs up to a 10-bit
resolution PWM output. This pin should be configure as a PWM
output to set bit PRM0.6 to “1”.
The period of the PWM output is determined by the T1PPR
(PWM0 Period Register) and PWM0HR[3:2] and the duty is deter mi n ed b y t h e T1 P D R ( PWM 0 D u ty Re g is ter ) a nd
PWM0HR[1:0].
PWM0HR
The user writes the lower 8-bit period value to the T1PPR and the
higher 2-bit period value to the PWM0HR[3:2].
And writes duty value to the T1PDR and the PWM0HR[1:0]
same way.
The T1PDR is configure as a double buffering for glitchless
PWM output. In, the duty data is transferred from the master to
the slave when the period data matched to the counted value. (i.e.
at the beginning of next duty cycle)
The relation between frequency and resolution is in inverse proportion. Table 13-1 shows the PWM frequency in each clock
source. If it needed higher frequency of PWM, it should be reduced resolution.
[0E5H]
- - - - 1 1 1 0
T1PPR
1 1
[0E3H]
[0E4H]
T1PDR
1 1 1 0 0 1 1 1
1 0
0 1 0 1 0 1 1 1
Period
Duty
Period; (3E7H+1) x 500nS = 500uS
~
~
Duty; (257H+1) x 500nS = 300uS
PWM output
~
~
01H
02H
03H
04H
256H
257H
258H
3E7H
00H
01H
02H
~
~
~
~
Clock source
~
~ ~
~
00H
~
~
~ ~
T1
Figure 13-13 Example of Register setting
The bit POL0 of TM0 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 POL0 (1: High, 0: Low). And if the duty
value is set to “00H”, the PWM output is determined by the bit
POL0 (1: Low, 0: High).
It can be changed duty value when the PWM output. However the
changed duty value is output after the current period is over. And
it can be maintained the duty value at present output when
APR., 2001 Ver 2.01
changed only period value shown as Figure 13-14. As it were, the
absolute duty time is not changed in varying frequency. But the
changed period value must greater than the duty value.
At PWM output start command, one first pulse would be output
abnormally. Because if user writes register values while timer is
in operation, these register could be set with certain values at first.
To prevent this operation, user must stop PWM timer clock and
then set the duty and the period register values.
55
GMS81C7008/7016
Example:
Resolutio
n
PWM clock source
Timer1 = 2kHz, 30% duty PWM mode
fXIN÷1
fXIN÷2
fXIN÷1024
10-bit
3.9kHz
1.95kHz
3.8Hz
9-bit
7.8kHz
3.9kHz
7.6Hz
8-bit
15.6kHz
7.8kHz
15.3Hz
7-bit
31.2kHz
15.6kHz
30.5Hz
LDM
LDM
LDM
LDM
LDM
TM1,#00H
T1PPR,#0E8H
T1PDR,#58H
PWM0HR,0000_1110B
TM1,#1010_1011B
Refer to Figure 13-13.
Table 13-1 PWM Frequency vs. Resolution at 4MHz
T1CK[1:0] = 10 (2uS)
PWMHR = 00H
T1PPR = 0DH
Write “09H” to T1PPR
T1PDR = 04H
Period changed
Source
clock
T1
00 01 02 03 04 05 06 07 08
09 0A 0B 0C 0D 00 01 02 03 04 05 06 07 08 09 00 01 02 03
04
PWM
POL=1
Duty Cycle
[ (4+1) x 2uS = 10uS ]
Period Cycle [ (DH+1) x 2uS = 28uS, 35.7kHz ]
Duty Cycle
[ (4+1) x 2uS = 10uS ]
Duty Cycle
[ (4+1) x 2uS =10uS ]
Period Cycle [ (9+1) x 2uS = 20uS, 50kHz ]
Figure 13-14 Example of changing the period in absolute duty cycle at 4MHz
56
APR., 2001 Ver 2.01
GMS81C7008/7016
14. 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 AVDD of
ladder resistance of A/D module.
The A/D module has two registers which are the control register
ADCM and A/D result register ADR. The register ADCM, shown
in Figure 14-4, controls the operation of the A/D converter module. The port pins can be configured as analog inputs or digital I/
O. To use analog inputs, I/O is selected input mode by R2DD direction register.
How to Use A/D Converter
The processing of conversion is start when the start bit ADST is
set to “1”. After one cycle, it is cleared by hardware. The register
ADR contains the results of the A/D conversion. When the conversion is completed, the result is loaded into the ADR, the A/D
conversion status bit ADSF is set to “1”, and the A/D interrupt
flag AIF is set. The block diagram of the A/D module is shown in
Figure 14-1. The A/D status bit ADSF is set automatically when
A/D conversion is completed, cleared when A/D conversion is in
process. The conversion time takes maximum 20 uS (at fXIN=4
MHz).
“0”
AVDD
ADS[2:0]
000
R20/AN0
8-bit DAC
ADEN
LADDER RESISTOR
“1”
001
R21/AN1
R22/AN2
R23/AN3
010
011
SUCCESSIVE
APPROXIMATION
CIRCUIT
100
S/H
R24/AN4
101
R25/AN5
R26/AN6
R27/AN7
ADIF
A/D
INTERRUPT
Sample & Hold
110
ADR
111
ADDRESS: EDH
RESET VALUE: Undefined
A/D result register
Figure 14-1 A/D Block Diagram
A/D Converter Cautions
.
(1) Input voltage range of AN0 to AN7
The input voltage of AN0 to AN7 should be within the specification range. In particular, if a voltage above AVDD or below AVSS
is input (even if within the absolute maximum rating range), the
conversion value for that channel can not be indeterminate. The
conversion values of the other channels may also be affected.
Analog
Input
AN0~AN7
100~1000pF
(2) Noise countermeasures
In order to maintain 8-bit resolution, attention must be paid to
noise on pins AVDD and AN0 to AN7. Since the effect increases
in proportion to the output impedance of the analog input source,
it is recommended that a capacitor be connected externally as
shown in Figure 14-2 in order to reduce noise.
APR., 2001 Ver 2.01
Figure 14-2 Analog Input Pin Connecting Capacitor
57
GMS81C7008/7016
(3) AD pin sharing with normal I/O port
The analog input pins AN0 to AN7 also function as input/output
port (PORT R20~R27) pins. When A/D conversion is performed
with any of pins AN0 to AN7 selected, be sure not to execute a
PORT input instruction while conversion is in progress, as this
may reduce the conversion resolution.
ENABLE A/D CONVERTER
A/D INPUT CHANNEL SELECT
ANALOG REFERENCE SELECT
Also, if digital pulses are applied to a pin adjacent to the pin in the
process of A/D conversion, the expected A/D conversion value
may not be obtainable due to coupling noise. Therefore, avoid applying pulses to pins adjacent to the pin undergoing A/D conversion.
A/D START ( ADST = 1 )
NOP
(4) AVDD pin input impedance
NO
ADSF = 1
A series resistor string of approximately 10kΩ is connected between the AVDD pin and the AVSS pin.
YES
READ ADR
Therefore, if the output impedance of the reference voltage
source is high, this will result in parallel connection to the series
resistor string between the AVDD pin and the AVSS pin, and there
will be a large reference voltage error.
ADCM
-
R/W
-
R/W
7
-
6
5
4
ADEN
-
R/W
R/W
R/W
Figure 14-3 A/D converter Operation Flow
R
3
2
1
0
ADS2 BTCL
ADS1 ADS0 ADST ADSF
ADDRESS: 0ECH
INITIAL VALUE: -0-0 0001B
A/D status bit
0: A/D conversion is in progress
1: A/D conversion is completed
A/D start bit
0: 1: A/D start
Setting this bit starts an A/D conversion.
After one cycle, bit is cleared to “0” by hardware.
Analog input channel select
000: Channel 0 (AN0)
001: Channel 1 (AN1)
010: Channel 2 (AN2)
011: Channel 3 (AN3)
100: Channel 4 (AN4)
101: Channel 5 (AN5)
110: Channel 6 (AN6)
111: Channel 7 (AN7)
A/D converter Enable bit
0: A/D converter module turn off and
current is not flow.
1: Enable A/D converter
R
7
ADR
R
6
R
5
R
4
R
3
BTCL
R
2
R
1
R
0
ADDRESS: 0EDH
INITIAL VALUE: Undefined
A/D Conversion Data
Figure 14-4 A/D Converter Control Register
58
APR., 2001 Ver 2.01
GMS81C7008/7016
15. SERIAL COMMUNICATION
The serial interface is used to transmit/receive 8-bit data serially.
Serial communication block consists of serial I/O data register,
serial I/O mode register, clock selection circuit, octal counter and
control circuit as illustrated in Figure 15-1.Pin R07/SIN, R06/
SOUT and R05/SCLK pins are controlled by the Serial Mode
Register. The contents of the Serial I/O data register can be written into or read out by software.
SIOST”. The octal counter is reset to “0” by this instruction, starts
counting at the falling or rising edge (by POL selection) of the
transmit clock (SCLK), and it increments at the every clock. A serial interrupt request flag is set when the eighth transmit clock
signal is input (the serial interface is reset) or when serial communication is discontinued (the octal counter is reset).
The data in the Serial Data Register can be shifted synchronously
with the transfer clock signal.
The serial communication is activated by the instruction “SET1
SIOM
SCK1
SCK0
SCLK/R05 Port
Clock Source
Prescaler Divide Ratio
0
0
SCLK output
Internal clock
÷4
0
1
SCLK output
Internal clock
÷ 16
1
0
SCLK output
Internal clock
Use clock from Timer 0 overflow
1
1
SCLK input
External clock
-
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R
7
6
5
4
3
2
1
0
POL
MSB
SIO1
SIO0 BTCL
SCK1 SCK0 SIOST SIOSF
ADDRESS: 0FEH
INITIAL VALUE: 0000_0001B
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: fXIN ÷ 4
01: fXIN ÷ 16
10: Timer 0 Overflow
11: External Clock
MSB first or LSB first
0: LSB First
1: MSB First
Serial transmission Operation Mode
00: Normal Port(R05,R06,R07)
01: Sending Mode(SCLK,SOUT,R07)
10: Receiving Mode(SCLK,R06,SIN)
11: Sending & Receiving Mode(SCLK,SOUT,SIN)
Selection Polarity
0: Data in on rising edge, data out on falling edge
1: Data in on falling edge, data out on rising edge
R/W R/W R/W R/W R/W R/W R/W R/W
7
SIOR
6
5
4
3
2
1
0
BTCL
ADDRESS: 0FFH
INITIAL VALUE: Undefined
Sending Data during Sending Mode
Receiving Data during Receiving Mode
Figure 15-1 SCI Control Register
APR., 2001 Ver 2.01
59
GMS81C7008/7016
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 POL bit control which edge
Serial I/O Data Register(SIOR) is an 8-bit shift register.
SCK[1:0]
fXIN
0X
fSXIN
1X
Prescaler
SCMR[1:0]
÷4
÷16
POL
SIOST
SIOSF
start
complete
00
CONTROL CIRCUIT
01
shift clock
clear
clock
Edge Detector
T0OV
(Timer 0 overflow)
10
R05/SCLK PIN
11
SIO[1:0]
Octal Counter
SIOIF
overflow
Serial communication
Interrupt
MUX
SCLK OUT
SCK, SIO
R06/SOUT PIN
Serial IO Data
R07/SIN PIN
[0FFH]
SIO0
SIO1
Figure 15-2 Block Diagram of SCI
15.1 Transmission/Receiving Timing
is latched at rising edge of SCLK pin. When transmission
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(SIOIF) occurred.
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 [R05]
(POL=0)
SOUT [R06]
SIN [R07]
D0
D0
D1
D1
D2
D2
D3
D3
D4
D4
D5
D5
D6
D6
D7
D7
SIOSF
SIOIF
(Interrupt Req.)
Figure 15-3 SPI Timing Diagram at POL=0
60
APR., 2001 Ver 2.01
GMS81C7008/7016
15.2 The method of Serial I/O
1. Select transmission/receiving mode
formed simultaneously it would be made error.
When external clock is used, the frequency should be less than
1MHz and recommended duty is 50%.
4. The SIO interrupt is generated at the completion of SIO and
SIOSF is set to “1”. In SIO interrupt service routine, correct transmission should be tested.
2. In case of sending mode, write data to be send to SIOR.
5. In case of receiving mode, the received data is acquired by
reading the SIOR.
3. Set SIOST to “1” to start serial transmission.
If both transmission mode is selected and transmission is per-
SIOST
SCLK [R05]
(POL=1)
SOUT [R06]
SIN [R07]
D0
D0
D1
D2
D1
D3
D2
D3
D4
D4
D5
D5
D6
D6
D7
D7
SIOSF
SCIIF
Figure 15-4 SPI Timing Diagram at POL=1
15.3 The Method to Test Correct Transmission
Serial I/O Interrupt
Service Routine
SIOSF
0
1
Abnormal
SE = 0
Write SIOM
- SE : Interrupt Enable Register Low IENL(Bit3)
- SR : Interrupt Request Flag Register Low IRQL(Bit3)
SR
0
1
Normal Operation
Overrun Error
Figure 15-5 Serial Method to Test Transmission
APR., 2001 Ver 2.01
61
GMS81C7008/7016
16. BUZZER FUNCTION
The buzzer driver block consists of 6-bit binary counter, buzzer
register, and clock source selector. It generates square-wave
which has very wide range frequency (500Hz ~ 250kHz at fXIN=
4MHz) by user software.
The bit 0 to 5 of BUR determines output frequency for buzzer
driving.
A 50% duty pulse can be output to R30/BUZ pin to use for piezoelectric buzzer drive. Pin R30 is assigned for output port of Buzzer driver by setting the bit 5 of PMR (address D9H) to “1”. At this
time, the pin R30 must be defined as output mode (the bit 0 of
R3DD=1).
f XIN
f BUZ = ---------------------------------------------------------------------------------------2 × DivideRatio × ( BUR [ 5:0 ] + 1 )
Equation of frequency calculation is shown below.
fBUZ: Buzzer frequency
fXIN: Oscillator frequency
Example: 2.4kHz output at 4MHz.
LDM
LDM
R3DD,#XXXX_XXX1B
BUR,#0111_0011B
SET1
CLR1
PMR.5
PMR.5
Divide Ratio: Prescaler divide ratio by BUCK[1:0]
BUR: Lower 6-bit value of BUR. Buzzer period value.
The frequency of output signal is controlled by the buzzer control
register BUR.The BUR[5:0] determine output frequency for
buzzer driving.
;BUZ ON
;BUZ OFF
X means don’t care
BUR[7:6]
SCMR[1:0]
0X
fSXIN
1X
Prescaler
fXIN
÷8
÷16
÷32
÷64
R30 port data
00
01
6-bit Binary Counter
10
11
÷2
MUX
F/F
0
R30/BUZ PIN
1
PMR.5
Comparator
6-bit Compare Data
BUR[5:0]
[0FDH]
Figure 16-1 Block Diagram of Buzzer Driver
ADDRESS: 0FDH
RESET VALUE: Undefined
ADDRESS: 0D9H
RESET VALUE: 00H
W
R/W R/W R/W R/W R/W R/W R/W R/W
PMR
PWM1 PWM0
BUZ EC2 EC0 INT2 INT1 INT0
BUR
W
W
W
W
W
W
W
BUCK1 BUCK0
R30/BUZ Selection
0: R30 port (Turn off buzzer)
1: BUZ port (Turn on buzzer)
BUR[5:0]
Define Frequency of Buzzer signal
Source clock select
00: ÷ 8
01: ÷ 16
10: ÷ 32
11: ÷ 64
Figure 16-2 PMR and Buzzer Register
62
APR., 2001 Ver 2.01
GMS81C7008/7016
Note that BUR is a write-only register.
bit BUR value.
The 6-bit counter is cleared and starts the counting by writing signal at BUR register. It is incremental from 00H until it matches 6-
When main-frequency is 4MHz, buzzer frequency is shown as
below table. The unit is kHz.
BUR
[5:0]
BUCK[1:0]
00
01
10
11
BUR
[5:0]
BUCK[1:0]
00
01
10
11
00
01
02
03
04
05
06
07
250.000
125.000
83.333
62.500
50.000
41.667
35.714
31.250
125.000
62.500
41.667
31.250
25.000
20.833
17.857
15.625
62.500
31.250
20.833
15.625
12.500
10.417
8.929
7.813
31.250
15.625
10.417
7.813
6.250
5.208
4.464
3.906
20
21
22
23
24
25
26
27
7.576
7.353
7.143
6.944
6.757
6.579
6.410
6.250
3.788
3.676
3.571
3.472
3.378
3.289
3.205
3.125
1.894
1.838
1.786
1.736
1.689
1.645
1.603
1.563
0.947
0.919
0.893
0.868
0.845
0.822
0.801
0.781
08
09
0A
0B
0C
0D
0E
0F
27.778
25.000
22.727
20.833
19.231
17.857
16.667
15.625
13.889
12.500
11.364
10.417
9.615
8.929
8.333
7.813
6.944
6.250
5.682
5.208
4.808
4.464
4.167
3.906
3.472
3.125
2.841
2.604
2.404
2.232
2.083
1.953
28
29
2A
2B
2C
2D
2E
2F
6.098
5.952
5.814
5.682
5.556
5.435
5.319
5.208
3.049
2.976
2.907
2.841
2.778
2.717
2.660
2.604
1.524
1.488
1.453
1.420
1.389
1.359
1.330
1.302
0.762
0.744
0.727
0.710
0.694
0.679
0.665
0.651
10
11
12
13
14
15
16
17
14.706
13.889
13.158
12.500
11.905
11.364
10.870
10.417
7.353
6.944
6.579
6.250
5.952
5.682
5.435
5.208
3.676
3.472
3.289
3.125
2.976
2.841
2.717
2.604
1.838
1.736
1.645
1.563
1.488
1.420
1.359
1.302
30
31
32
33
34
35
36
37
5.102
5.000
4.902
4.808
4.717
4.630
4.545
4.464
2.551
2.500
2.451
2.404
2.358
2.315
2.273
2.232
1.276
1.250
1.225
1.202
1.179
1.157
1.136
1.116
0.638
0.625
0.613
0.601
0.590
0.579
0.568
0.558
18
19
1A
1B
1C
1D
1E
1F
10.000
9.615
9.259
8.929
8.621
8.333
8.065
7.813
5.000
4.808
4.630
4.464
4.310
4.167
4.032
3.906
2.500
2.404
2.315
2.232
2.155
2.083
2.016
1.953
1.250
1.202
1.157
1.116
1.078
1.042
1.008
0.977
38
39
3A
3B
3C
3D
3E
3F
4.386
4.310
4.237
4.167
4.098
4.032
3.968
3.906
2.193
2.155
2.119
2.083
2.049
2.016
1.984
1.953
1.096
1.078
1.059
1.042
1.025
1.008
0.992
0.977
0.548
0.539
0.530
0.521
0.512
0.504
0.496
0.488
Table 16-1 Buzzer Frequency at 4MHz
APR., 2001 Ver 2.01
63
GMS81C7008/7016
17. INTERRUPTS
The GMS81C7008/16 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).
Thirteen interrupt sources are provided. The configuration of interrupt circuit is shown in Figure 17-2.
The interrupts are controlled by the interrupt master enable flag
I-flag (bit 2 of PSW on page 19), the interrupt enable register
(IENH, IENL), and the interrupt request flags (in IRQH and
IRQL) except Power-on reset and software BRK interrupt. Below
table shows the Interrupt priority.
The keyscan interrupt is generated when 1-to-0 transition is detected at KS0 or KS0 pin.
Reset/Interrupt
The Basic Interval Timer Interrupt is generated by BITIF which
is set by an overflow in the timer register.
Hardware Reset
Key scan Interrupt
Basic Interval Timer
Watchdog Timer
External Interrupt 0
External Interrupt 1
Timer/Counter 0
Timer/Counter 1
External Interrupt 2
Serial Communication
ADC Interrupt
Watch Timer Interrupt
Timer/Counter 2
Timer/Counter 3
The Watchdog timer Interrupt is generated by WDTIF which set
by a match in Watchdog timer register.
The External Interrupts INT0 ~ INT2 each can be transition-activated (1-to-0 or 0-to-1 transition) by selection IEDS.
The flags that actually generate these interrupts are bit INT0IF,
INT1IF and INT2IF in register IRQH and IRQL. When an external interrupt is generated, the flag that generated it is cleared by
the hardware when the service routine is vectored to only if the
interrupt was transition-activated.
The Timer 0 ~ Timer 3 Interrupts are generated by T0IF~T3IF
which are set by a match in their respective timer/counter register.
The Serial Communication Interrupts are generated by SIOIF
which is set by 8-bit serial data transmitting or receiving through
SCK, SIN, SOUT pin.
The Watch Timer Interrupt is generated by WTIF which is set by
an 14-bit binary counter overflow.
R/W
-
-
R/W
R/W
R/W
R/W
R/W
INT2IF
-
-
SIOIF
ADIF
WTIF
T2IF
T3IF
MSB
Key scan
Basic Interval Timer
Watchdog timer
1
2
3
4
5
6
7
8
9
10
11
12
13
LSB
Timer/Counter 3
Timer/Counter 2
Watch timer
A/D Converter
Serial Communication
MSB
RESET
KS
BIT
WDT
INT0
INT1
Timer 0
Timer 1
INT2
SCI
ADC
WT
Timer 2
Timer 3
ADDRESS: 0DCH
INITIAL VALUE: 0--0 0000B
External interrupt 2
IRQH
Priority
Vector addresses are shown in Figure 8-6 on page 21. Interrupt
enable registers are shown in Figure 17-3. These registers are
composed of interrupt enable 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, Iflag, which disables all interrupts at once.
The AD converter Interrupt is generated by ADIF which is set by
finishing the analog to digital conversion.
IRQL
Symbol
-
R/W
R/W
R/W
R/W
-
KSIF
BITIF WDTIF INT0IF INT1IF T0IF
R/W
R/W
R/W
T1IF
ADDRESS: 0DDH
INITIAL VALUE: -000 0000B
LSB
Timer/Counter 1 interrupt request flag
Timer/Counter 0
External interrupt 1
External interrupt 0
Figure 17-1 Interrupt Request Flag
64
APR., 2001 Ver 2.01
GMS81C7008/7016
.
Internal bus line
[0DAH]
Interrupt Enable
Register (Lower byte)
IENL
IRQL [0DCH]
INT2IF
INT2
Serial
Communication
A/D Converter
SIOIF
Watch Timer
WTIF
Timer 2
T2IF
Timer 3
T3IF
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
Priority Control
ADIF
IRQH [0DDH]
Key Scan
KSIF
BIT
To CPU
I-flag
Interrupt Master
Enable Flag
BITIF
Watchdog Timer
WDTIF
INT0
INT0IF
INT1
INT1IF
Timer 0
T0IF
Timer 1
T1IF
Interrupt
Vector
Address
Generator
[0DBH]
Interrupt Enable
Register (Higher byte)
IENH
Internal bus line
Figure 17-2 Block Diagram of Interrupt
IENL
R/W
-
-
R/W
R/W
R/W
R/W
R/W
INT2E
-
-
SIOE
ADE
WTE
T2E
T3E
MSB
ADDRESS: 0DAH
INITIAL VALUE: 0--0 0000B
LSB
Timer/Counter 3 interrupt enable flag
Timer/Counter 2 interrupt enable flag
Watch Timer interrupt enable flag
A/D Converter interrupt enable flag
Serial Communication interrupt enable flag
External interrupt 2 enable flag
IENH
-
R/W
R/W
R/W
-
KSE
BITE
WDTE INT0E INT1E
MSB
R/W
R/W
R/W
R/W
T0E
T1E
ADDRESS: 0DBH
INITIAL VALUE: -000 0000B
LSB
Timer/Counter 1 interrupt enable flag
Timer/Counter 0 interrupt enable flag
VALUE
0: Disable
1: Enable
External interrupt 1 enable flag
External interrupt 0 enable flag
Watchdog timer interrupt enable flag
Basic Interval Timer interrupt enable flag
Key scan interrupt enable flag
Figure 17-3 Interrupt Enable Flag
APR., 2001 Ver 2.01
65
GMS81C7008/7016
17.1 Interrupt Sequence
An interrupt request is held until the interrupt is accepted or the
interrupt latch is cleared to “0” by a reset or an instruction. Interrupt acceptance sequence requires 8 fXIN (2 µs at
fMAIN=4.19MHz) after the completion of the current instruction
execution. The interrupt service task is terminated upon execution of an interrupt return instruction [RETI].
Interrupt acceptance
1. The interrupt master enable flag (I-flag) is cleared to
“0” to temporarily disable the acceptance of any following maskable interrupts. When a non-maskable interrupt is accepted, the acceptance of any following
interrupts is temporarily disabled.
2. Interrupt request flag for the interrupt source accepted is
cleared to “0”.
3. The contents of the program counter (return address)
and the program status word are saved (pushed) onto the
stack area. The stack pointer decreases 3 times.
4. The entry address of the interrupt service program is
read from the vector table address and the entry address
is loaded to the program counter.
5. The instruction stored at the entry address of the interrupt service program is executed.
System clock
Instruction Fetch
SP
Address Bus
PC
Data Bus
Not used
SP-1
PCH
PCL
SP-2
PSW
V.L.
V.L.
ADL
V.H.
ADH
New PC
OP code
Internal Read
Internal Write
Interrupt Processing Step
Interrupt Service Task
V.L. and V.H. are vector addresses.
ADL and ADH are start addresses of interrupt service routine as vector contents.
Figure 17-4 Timing chart of Interrupt Acceptance and Interrupt Return Instruction
Watch Timer
Vector Table Address
0FFE4H
0FFE5H
012H
0E3H
Entry Address
0E312H
0E313H
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.
0EH
2EH
Saving/Restoring General-purpose Register
Correspondence between vector table address for Watch Timer Interrupt
and the entry address of the interrupt service program.
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.
66
During interrupt acceptance processing, the program counter and
the program status word are automatically saved on the stack, but
accumulator and other registers are not saved itself. These registers are saved by the software if necessary. Also, when multiple
interrupt services are nested, it is necessary to avoid using the
same data memory area for saving registers.
The following method is used to save/restore the general-purpose
registers.
APR., 2001 Ver 2.01
GMS81C7008/7016
Example: Register save using push and pop instructions
INTxx:
PUSH
PUSH
PUSH
A
X
Y
;SAVE ACC.
;SAVE X REG.
;SAVE Y REG.
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.
;RESTORE Y REG.
;RESTORE X REG.
;RESTORE ACC.
;RETURN
However, multiple processing through software for special features is possible. Generally when an interrupt is accepted, the Iflag is cleared to disable any further interrupt. But as user sets Iflag in interrupt routine, some further interrupt can be serviced
even if certain interrupt is in progress.
interrupt processing
POP
POP
POP
RETI
Y
X
A
General-purpose register save/restore using push and pop instructions;
main task
acceptance of
interrupt
17.3 Multi Interrupt
interrupt
service task
saving
registers
Example: During Timer1 interrupt is in progress, INT0 interrupt
serviced without any suspend.
TIMER1: PUSH
PUSH
PUSH
LDM
LDM
EI
:
:
restoring
registers
:
:
LDM
LDM
POP
POP
POP
RETI
interrupt return
17.2 BRK Interrupt
Software interrupt can be invoked by BRK instruction, which has
the lowest priority order.
Interrupt vector address of BRK is shared with the vector of
TCALL 0 (Refer to Program Memory Section). When BRK interrupt is generated, B-flag of PSW is set to distinguish BRK from
TCALL 0.
A
X
Y
IENH,#08H
IENL,#00H
IENH,#0FFH ;Enable all interrupts
IENL,#0FFH
Y
X
A
.
Main Program
service
INT0
service
EI
Occur
TIMER1 interrupt
BRK or
TCALL0
TIMER 1
service
enable INT0
disable other
Each processing step is determined by B-flag as shown in Figure
17-5.
B-FLAG
;Enable INT0 only
;Disable other
;Enable Interrupt
Occur
INT0
=0
=1
BRK
INTERRUPT
ROUTINE
TCALL0
ROUTINE
RETI
RET
enable INT0
enable other
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 17-5 Execution of BRK/TCALL0
APR., 2001 Ver 2.01
Figure 17-6 Execution of Multi Interrupt
67
GMS81C7008/7016
17.4 External Interrupt
The external interrupt on INT0, INT1 and INT3 pins are edge
triggered depending on the edge selection register IEDS (address
0D8H) as shown in Figure 17-7.
The edge detection of external interrupt has three transition activated mode: rising edge, falling edge, and both edge.
INT0 pin
INT0IF
INT0 INTERRUPT
INT1 pin
INT1IF
INT1 INTERRUPT
INT2 pin
INT2IF
INT2 INTERRUPT
2
2
2
IEDS
Edge selection
Register
Example: To use as an INT0 and INT2
:
:
;**** Set port as an input port R00,R02
LDM
R0DD,#1111_1010B
;
;**** Set port as an external interrupt port
LDM
PMR,#05H
;
;**** Set Falling-edge Detection
LDM
IEDS,#0001_0001B
:
:
Response Time
The INT0 ~ INT2 edge are latched into INT1IF ~ INT2IF at every
machine cycle. The values are not actually polled by the circuitry
until the next machine cycle. If a request is active and conditions
are right for it to be acknowledged, a hardware subroutine call to
the requested service routine will be the next instruction to be executed. The DIV itself takes twelve cycles. Thus, a minimum of
twelve complete machine cycles elapse between activation of an
external interrupt request and the beginning of execution of the
first instruction of the service routine.
Figure 17-8 shows interrupt response timings.
[0D8H]
Figure 17-7 External Interrupt Block Diagram
INT0 ~ INT2 are multiplexed with general I/O ports (R00~R02).
To use as an external interrupt pin, the bit of Port Mode Register
PMR should be set to “1” correspondingly as shown in Figure 179.
max. 12 fXIN period
Interrupt Interrupt
goes
latched
active
8 fXIN period
Interrupt
processing
Interrupt
routine
Figure 17-8 Interrupt Response Timing Diagram
17.5 Key Scan Interrupt
GMS81C7008/16 has the key-scan block which consists of
Port selection Multiplexer, Interrupt controller, Key scan
mode register and Falling edge detector shown as Figure
17-10.
When the key scan interrupt is used, key scan register
KSMR (address 0F0H) should be set to “1” as KS0 and
68
KS1. After reset, initial setting is general R10 and R00
ports.
If key scan is detected at any one or more of these pins, the
KSIF request flag is set to “1”. This generates an interrupt
request. It also can be used in the way of release from
STOP mode.
APR., 2001 Ver 2.01
GMS81C7008/7016
R/W
PMR
R/W
PWM1 PWM0
R/W
R/W
BUZ
EC2S BTCL
EC0S INT2S INT1S INT0S
R/W
R/W
R/W
R/W
MSB
ADDRESS: 0D9H
INITIAL VALUE: 00H
0: R32
1: PWM1/T3O
LSB
0: R00
1: INT0
0: R31
1: PWM0/T1O
0: R01
1: INT1
0: R30
1: BUZ
0: R02
1: INT2
0: R04
1: EC2
0: R03
1: EC0
IEDS
MSB
-
-
-
-
R/W
R/W
R/W
R/W
R/W
LSB
R/W
ADDRESS: 0D8H
INITIAL VALUE: 00H
BTCL IED1L IED0H IED0L
IED2H IED2L IED1H
INT2
INT1
INT0
Edge selection register
00: Reserved
01: Falling (1-to-0 transition)
10: Rising (0-to-1 transition)
11: Both (Rising & Falling)
Figure 17-9 PMR and IEDS Registers
.
ADDRESS: 0F0H
RESET VALUE: 00H
Key Scan Mode Register
KSMR
-
-
-
-
-
-
KS1 KS0
Pull up Resistor
Typ. 160kΩ
VDD
Reserved
[0F0H]
Port selection
0: R10
1: KS0
Port selection
0: R11
1: KS1
KSMR
R1PU[1:0]
Edge detector
R10/KS0
KSIF
Key Scan Interrupt
R11/KS1
Figure 17-10 Key Scan Port Block Diagram
APR., 2001 Ver 2.01
69
GMS81C7008/7016
18. LCD DRIVER
The GMS81C7008/16 has the circuit that directly drives the liquid crystal display (LCD) and its control circuit. In addition,
VCLn pin is provided as the drive power pin.
Basically, the GMS81C7008/16 has 24 seg.× 4 com. ports of
LCD driver. Extend display modes are shown in left table.
Figure 18-1shows the configuration of the LCD driver.
********Caution********
GMS81C7008/16
1/4 duty:
24 seg × 4com
1/3 duty:
25 seg × 3com
1/2 duty:
26 seg × 2com
Static:
27 seg × 1com
When you developing the software using by
Emulator, you must select the External bias resistor mode because of no internal bias resistor
inside the Emulator (EVA. chip).
(27 × 4 bits)
R4 or Segment
Segment Driver
Display Memory
Display Data Buffer register
Display Data Select Control
Select
SEG or Normal port
by LPMR [0F2H]
SEG7/R47
LPMR[1:0]
SEG8/R50
“Same with above”
LPMR[3:2]
“Same with above”
LPMR[5:4]
SEG15/R57
SEG16/R60
SEG23/R67
fMAIN÷27
01
M UX
÷ 64
÷ 128 MUX
÷ 256
COM0
COM. or SEG.
00
Common Driver
÷ 32
fSUB
LCD
Timing Control
WTCK[1:0]
Prescaler
INTERNAL BUS LINE
SEG0/R40
COM1/SEG26
COM2/SEG25
COM3/SEG24
Control frame frequency
LCR
Enable LCD
Control bias voltage and resistor
[0F1H]
Power & Bias control
LCR[3:2] of address 0F1H
BIAS
VCL2
VCL1
VCL0
Figure 18-1 LCD Driver Block Diagram
18.1 LCD Control Registers
The LCD driver is controlled by the LCD control register LCR
70
which is shown in Figure 18-2. LCD block input the clock from
APR., 2001 Ver 2.01
GMS81C7008/7016
the Watch Timer. When LCD is operate, the Watch Timer much
LCR
R/W
7
R/W
6
SUBM
BTC LCDEN BRC DTY1 DTY0 LCK1 LCK0
R/W
5
R/W
4
R/W
3
be enabled by WTEN (bit 6 of address 0EFH).
R/W
2
R/W
1
R/W
0
ADDRESS: 0F1H
INITIAL VALUE: 00H
Sub clock port mode
0: SXIN, SXOUT
1: R35, R36
Selection frame frequency
00: 1024Hz
When
01: 512Hz
fXIN = 4.19MHz
10: 256Hz
fSXIN = 32.768kHz
11: 128Hz
Bias transistor control
0: off
1: on
Duty control
00: 1/4 duty
01: 1/3 duty (SEG24 active)
10: 1/2 duty (SEG24, SEG25 active)
11: Static (SEG24, SEG25, SEG26 active)
LCD display control
0: LCD display all segment 0 data output
1: LCD display enable
LPMR
R/W
7
-
R/W
6
-
Bias resistor control
0: External
1: Internal
No internal bias registers in the Emulator,
so user must select the “0”, External mode at least
during use the Emulator.
OTP and Mask MCU can use both.
R/W R/W
5
4
R6LPMR
R/W R/W
3
2
R5LPMR
R/W R/W
1
0
R4LPMR
ADDRESS: 0F2H
INITIAL VALUE:0000 0000
R4 port selection
00:SEG0~SEG7
01:SEG4~SEG7,R40~R43
10:SEG0~SEG3,R44~R47
11:R40~R47
R5 port selection
00:SEG8~SEG15
01:SEG12~SEG15,R50~R53
10:SEG8~SEG11,R54~R57
11:R50~R57
R6 port selection
00:SEG16~SEG23
01:SEG20~SEG23,R60~R63
10:SEG16~SEG19,R64~R67
11:R60~R67
RPR
-
-
-
-
-
-
7
6
5
4
3
2
-
-
-
-
-
-
R/W
R/W
1
0
RPR1 RPR0
ADDRESS: 0F3H
INITIAL VALUE: 00H
The RPR register is used for RAM page selection.
RAM page
Instruction
PRP1
PRR0
Page 0
CLRG
X
X
Page 0
SETG
0
0
Page 1
SETG
0
1
Reserved
SETG
1
0
Reserved
SETG
1
1
Figure 18-2 LCD Control Register
APR., 2001 Ver 2.01
71
GMS81C7008/7016
18.2 Duty and Bias Selection of LCD driver
5 kinds of driving methods can be selected by DTY (bits 3 and 2
of LCD Control Register and connection of VCL pin externally.
VCL2
VCL1
VCL0
GND
-VCL0
-VCL1
-VCL2
Figure 18-3 shows typical driving waveforms for LCD.).
VCL2
VCL1
VCL0
GND
-VCL0
-VCL1
-VCL2
1/fF
Data “1”
1/fF
Data “0”
Data “1”
(a) 1/4 duty, 1/3 bias
VCL2
VCL1
VCL0
GND
-VCL0
-VCL1
-VCL2
(b) 1/3 duty, 1/3 bias
VCL2
1/fF
1/fF
VCL1 = VCL0
GND
-VCL0 = -VCL1
-VCL2
Data “1” Data “0”
Data “1” Data “0”
(c) 1/2 duty,1/3 bias
VCL2
VCL1
VCL0
GND
-VCL0
-VCL1
-VCL2
Data “0”
(d) 1/2 duty, 1/2 bias
1/fF
Note: fF: LCD Frame Frequency
Data “1”
Data “0”
(e) Static
Figure 18-3 LCD drive waveform (Voltage COM-SEG Pins)
18.3 Selecting Frame Frequency
Frame frequency is set to the base frequency as shown in the following Table 18-1.
The LCK[1:0] of LCR determines the frequency of COM signal
scanning of each segment output. The watch timer must be enabled when the LCD display is turned on. RESET clears the LCD
control register LCR values to logic zero. The LCD display can
continue to operate even during the SLEEP and STOP modes if a
sub-frequency clock is oscillate and used as clock source of LCD
driver.
LCK[1:0]
LCD clock
00
01
10
11
fSUB ÷ 32
fSUB ÷ 64
fSUB ÷ 128
fSUB ÷ 256
Frame Frequency (Hz)
(When fSUB = 32.768 kHz)
1024
512
256
128
Table 18-1 Setting of LCD Frame Frequency
.
72
APR., 2001 Ver 2.01
GMS81C7008/7016
COM0 pin
one frame
(at 1/4 duty, 1/3 bias)
LCD Port Selection
Segment pins are also used for normal I/O pins. The LCD port selection register LPMR is used to set Rn pin for ordinary digital input. Refer to LPMR register as shown in Figure 18-2.
Bias Resistor
To operate LCD, built-in Bias resistor dividing VDD to VSS
section into several stages generates necessary voltage.
The BTC (Bit 6 of LCR) switches Transistor supplying voltage to
serially connected Bias resistor. If it is ‘1’, it turns on, and if it is
‘0’, it turns off. The LCD drive voltage (VCL2) is given by the difference in potential (VDD-VCL2) between pins VDD and VCL2.
Therefore, when the MCU operating voltage is 5V and LCD drive
voltage are the same, the Bias pin is connected to the VCL2 pin as
shown in (a) of Figure 18-5.
MCU Internal
MCU Internal
VDD
VDD
BTC
BTC
BIAS
VCL2
R
VCL1
R
Two pins are connected
each other
VCL2=5V
VCL1=3.33V
VCL0=1.67V
VCL0
R
VCL2
R
VCL1
R
Short two pins
each other externally
VCL2=5V
VCL1=2.5V
VCL0=2.5V
VCL0
R
VSS
VSS
BRC
BTC = “1”
BIAS
2R
Internal Bias resistors
Internal Bias resistors
2R
BRC
BRC = “1”
(a) Internal, Static or 1/3 Bias
BTC = “1”
BRC = “1”
(b) Internal, Static or 1/2 Bias
Typ. R=65kΩ
Figure 18-4 Application Example of 5V LCD Panel
When require supply 3V output to the LCD, the voltage of V CL2
becomes 3V as shown in Figure 18-5. Because VDD is down to
3V through internal 2R resistor.
APR., 2001 Ver 2.01
The LCD light only when the difference in potential between the
segment and common output is ±VCL, and turn off at all other
times. During reset, the power switch of the LCD driver is turned
off automatically, shutting off the VCL voltage.
73
GMS81C7008/7016
MCU Internal
MCU Internal
VDD = 5V
VDD = 5V
BTC
BTC
BIAS
VCL2=3V
VCL1=2V
VCL0=1V
VCL2
R
VCL1
R
VCL0
R
VCL2=3V
VCL1=1.5V
VCL0=1.5V
VCL2
R
VCL1
R
Short two pins
externally
VCL0
R
VSS
VSS
BRC
BTC = “1”
BIAS
2R
Internal Bias resistors
Typ. R=65kΩ
Internal Bias resistors
2R
BRC
BTC = “1”
BRC = “1”
(a) Internal, Static or 1/3 Bias
BRC = “1”
(b) Internal, Static or 1/2 Bias
Typ. R=65kΩ
Figure 18-5 Application Example of 3V LCD Panel
Some user want to use external bias resisor instead of internal,
you can connect external resistor as shown in Figure 18-6. And
the external capacitors are may required for stable display according to your system environment.
MCU Internal
VDD
BTC
BTC = “0”
VDD
Internal Bias resistors
2R
R
R
R
BRC = “0”
BRC
BIAS
Adjust Contrast
VCL2
VCL1
VCL0
VSS
VSS
External circuit
Figure 18-6 External Resistor
74
APR., 2001 Ver 2.01
GMS81C7008/7016
18.4 LCD Display Memory
The LCD driver generates the segment signals and common signals in accordance with the display data and drive
method.
Display data are stored to the display data area (address
100H-11AH) in the data memory.
The display data stored to the display data area are read automatically and sent to the LCD driver by the hardware.
Bit 0
2
3
4
5
6
7
SEG23
117H
SEG22
116H
SEG21
115H
SEG20
114H
SEG19
113H
SEG18
112H
SEG17
111H
SEG16
110H
SEG15
10FH
SEG14
10EH
SEG13
10DH
SEG12
10CH
SEG11
10BH
SEG10
10AH
SEG9
109H
SEG8
108H
SEG7
107H
SEG6
106H
SEG5
105H
SEG4
104H
SEG3
103H
SEG2
102H
SEG1
101H
SEG0
100H
COM3
118H
COM2
119H
SEG24
COM1
11AH
SEG25
COM0
Note:
The bit 4 to 7 of every byte are
reserved. Any read or write is not
effect.
1
SEG26
Figure 18-7 LCD Display Memory
Therefore, display patterns can be changed by only overwriting the contents of the display data area with a program. The table look up instruction is mainly used for this
overwriting.
Figure 18-7 shows the correspondence between the display
data area and the SEG/COM pins. The LCD lights when
the display data is “1” and turn off when “0”.
The number of segment which can be driven differs depending on the LCD drive method, therefore, the number
of display data area bits used to store the data also differs
APR., 2001 Ver 2.01
(Refer to Figure 18-2). Consequently, data memory not
Drive methods
Bit 3
Bit 2
Bit 1
Bit 0
1/4 duty
COM3
COM2
COM1
COM0
1/3 duty
-
COM2
COM1
COM0
1/2 duty
-
-
COM1
COM0
Static
-
-
-
COM0
Table 18-2 The duty vs. COM port Configuration
75
GMS81C7008/7016
used to store display data and data memory for which the
address are not connected to LCD can be used to store ordinary user’s processing data.
turns off the LCD by outputting the non light operation level to
the COM pin. When setting Frame frequency or changing operating mode, LCD display should be off before operation, to prevent
display flickering.
Blanking
Blanking is applied by setting LCDEN (bit 7 of LCR) to “0” and
18.5 Control Method of LCD Driver
Initial Setting
frame frequency of 512Hz.
Flow chart of initial setting is shown in Figure 18-8.
Example: When operating with 1/4 duty LCD using a
Select Frame Frequency
Clear
LCD Display
Memory
LDM
:
SETG
LDM
LDX
C_LCD1: LDA
STA
CMPX
BNE
CLRG
:
:
SET1
:
:
Turn on LCD
LCR,#0101_0001B ;1/4duty, fF=512Hz (fSUB= 32.768kHz)
RPR,#1
#0
#0
;Select LCD Memory
;area (Page 1 = address 1XXH)
;RAM Clear
;RAM(100H~11AH)
{X}+
#01BH
C_LCD1
LCR.5
;Enable LCD display
.
COM0
COM1
Setting of LCD drive method
COM2
COM3
SEG0
Initialize of display memory
SEG1
Example: display “2”
Enable display
(Release of blanking)
bit 7
6
100H
*
*
101H
*
*
5
4
3
2
1
0
*
*
0
0
1
1
*
*
1
1
1
0
Note: * are don’t care.
Figure 18-8 Initial Setting of LCD Driver
Figure 18-9 Example of Connection COM & SEG
Display Data Setting
Normally, display data are kept permanently in the program memory and then stored at the display data area by
the table look-up instruction. This can be explained using
76
numerical display with 1/4 duty LCD as an example. The
COM and SEG connections to the LCD and display data
are the same as those shown is Figure 18-9. Programming
APR., 2001 Ver 2.01
GMS81C7008/7016
example for displaying character is shown below.
GOLCD:
Write into the
LCD Memory
Font data
FONT
:
CLRG
LDX
LDA
TAY
LDA
LDM
SETG
LDX
STA
XCN
STA
CLRG
:
:
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
#DISPRAM
{X}
!FONT+Y
RPR,#1
;LOAD FONT DATA
;Set RPR = 1 to access LCD
;Set Page 1
#0
{X}+
;LOWER 4 BITS OF ACC. -> M(X)
{X}
;UPPER 4 BITS OF ACC. -> M(X+1)
;Set Page = 0
1101_0111B
0000_0110B
1110_0011B
1010_0111B
0011_0110B
1011_0101B
1111_0101B
0000_0111B
1111_0111B
0011_0111B
;
;
;
;
;
;
;
;
;
;
“0”
“1”
“2”
“3”
“4”
“5”
“6”
“7”
“8”
“9”
Note: When power on RESET, sub oscillation start up time
is required. Enable LCD display after sub oscillation is stabilized, or LCD may occur flicker at power on time shortly.
APR., 2001 Ver 2.01
77
GMS81C7008/7016
19. WATCH / WATCHDOG TIMER
19.1 Watch Timer
The watch timer goes the clock continuously even during the
power saving mode. When MCU is in the Stop or Sleep mode,
MCU can wake up itself every 2Hz or 4Hz or 16Hz.
ommend the oscillator 4.194304MHz as a main and 32.768kHz
as a sub. Because above main frequency is equal to 128 times of
sub frequency. Generally main clock (fXIN) at WTCK=10B is not
be used, it is just for test purpose in factory.
The watch timer consists of input clock selector, 14-bit binary
counter, interval selector and Watch Timer Mode Register
WTMR (address 0EFH). The WTMR is 5-bit read/write register
and shown in Figure 19-2. WTMR can select the clock input by
2 bits WTCK[1:0] and interval time selector by 2 bits WTIN[1:0]
and enable/disable bit. The WTEN bit is set to “1” timer start
counting. Input clocks can be selected among three different
source which are sub clock or divided main clock (fXIN ÷128) or
main clock. For the switching between main and sub clock, rec-
01
fXIN
10
1
enable
WTEN
8Hz
16Hz
2-bit Binary Counter
WTMR,#0100_1000B
WDOE[0DFH]
R34/WDTO
to RESET CPU
0
overflow
14-bit Binary Counter
16Hz
fXIN ÷128
0 f
W
4Hz
00
2Hz
fSXIN
4Hz
2Hz
WTCK[1:0]
0: Stop
1: Clear and start
IENL,#XXXX_X1XXB
clear
MUX
10 11
01
LDM
EI
LDM
WDCLR
WDCK[1:0]
00
In the Stop Mode, the main clock is stopped but sub clock is oscillation continuously for watch clock operation. Output timer interval can be selected and Watch Timer Interrupt is generated.
1
enable
WDEN
When
fSXIN = 32.768 kHz
fXIN = 4.194304 MHz
10 01 00
Interval Selector
MUX
WDTIF
Watchdog Timer Interrupt
WDOM
WTIF
Watch Timer interrupt
WTIN[1:0]
Figure 19-1 Block Diagram of Watchdog Timer
19.2 Watchdog Timer
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 as you want.
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.
Watchdog Timer Control
Figure 19-2 shows the watchdog timer control register WDTR
(address 0DFH). The watchdog timer is automatically enabled
initially and watchdog output to reset CPU but clock input source
is disabled. To enable this function, you should write bit WTEN
of WTMR (address 0EFH) set to “1”.
78
The CPU malfunction is detected during setting of the detection
time, selecting of output, and clearing of the binary counter.
Clearing the 2-bit binary counter by bit WDCLR of WDTR is repeated within the detection time.
If the malfunction occurs for any cause, the watchdog timer output will become active from the binary counters unless the binary
counter is cleared. At this time, when WDOM=1, a reset is generated, which drives the RESET pin to low to reset the internal
hardware. When WDOM=0, a watchdog timer interrupt (WDTIF) is generated instead of Reset function. This interrupt can be
used general timer as user want.
When main clock is selected as clock input source on the STOP
mode, clock input is stopped so the watchdog timer temporarily
stops counting. The other side, when sub clock is selected as
clock input source on the STOP mode, sub clock operates always
APR., 2001 Ver 2.01
GMS81C7008/7016
so the watchdog timer works continuously.
WTMR
-
R/W
-
-
-
WTEN
-
-
R/W
R/W
R/W
R/W
WTIN1 WTIN0 WTCK1 WTCK0
ADDRESS: 0EFH
INITIAL VALUE: -0--_0000B
Clock source selection
00: Sub clock
01: Main clock (fXIN ÷ 128)
10: Main clock (test purpose in factory)
11: -
Watch Timer count enable
0: Disable
1: Enable
Watch timer interrupt interval selection
00: 16Hz
When
01: 4Hz
fXIN = 4.19MHz
10: 2Hz
fSXIN = 32.768kHz
11: -
WDTR
-
-
-
-
R/W
W DOE
R/W
R/W
R/W
R/W
R/W
W D E N W D C K 1 W D C K 0 W D O M W D C LR
ADDRESS: 0DFH
INITIAL VALUE: --01_0010B
Clear bit
0: Normal operation
1: Clear and starts counting
R34/WDTO selection
0: R34 port
1: WDTO port
Output Mode
0: Interrupt request
1: Reset CPU
Watchdog Timer count enable
0: Disable
1: Enable
Watchdog timer interrupt interval selection
00: 2 sec.
When
01: 1 sec.
fXIN = 4.19MHz
10: 0.5 sec.
fSXIN = 32.768kHz
11: 0.25 sec.
Figure 19-2 WTMR, WDTR: Watch Timer and Watchdog Timer Data Register
Example: Sets the watchdog timer detection time to 1 sec at 4.19MHz, 32.768kHz
Within 0.75 sec.
Within 0.75 sec.
LDM
LDM
WTMR,#0100_1000B
WDTR,#0001_0111B
;Select sub clock as an input source
SET1
:
:
:
:
SET1
:
:
:
:
SET1
WDCLR
;Clear counter
WDCLR
;Clear counter
WDCLR
;Clear counter
Enable and Disable Watchdog
Watchdog timer is enabled by setting WDEN (bit 4 in CKCTLR)
to “1”. WDEN is initialized to “1” during reset and it should be
clear to “0” disable.
The watchdog timer is disabled by clearing either bit 4 (WDEN)
of WDTR or bit 6 (WTEN) of WTMR. The watchdog timer is
halted in STOP mode and restarts automatically after STOP mode
is released.
Example: Enables watchdog timer for Reset
:
LDM
LDM
:
WTMR,#0100_XXXXB;WTEN ← 1
WDTR,#00X1_XX11B;WDEN ← 1
APR., 2001 Ver 2.01
Clearing 2-bit binary counter of the Watchdog
timer
The watchdog timer count the clock source as 14-bit binary
79
GMS81C7008/7016
counter which is free run can not be cleared. The watchdog timer
has 2-bit binary counter. It is incremented by 14-bit binary
counter match as shown in Figure 19-1. Interrupt request flag or
Reset signal are generated by overflow 2-bit binary counter.
should be cleared by bit WDCLR of WDTR within watchdog
timer overflow.
The time of clearing must be within 3 times of 14-bit binary
counter interval as shown in Figure 19-3.
During normal operation in the software, 2-bit binary counter
The worst case, watchdog time is just 3 times of 14-bit counter.
1FFE
1FFF
1FFE
1
0
2
1
1
0
2
~~
0
0
2
~~
~~
n
1
1FFF
~~
0
1FFE
1FFF
~~
~~
14-bit binary
counter
2-bit binary
counter
1FFE
1FFF
2
3
1
2
0
Counter
Clear
WDTIF interrupt
R34/WDTO pin
(2us at fXIN=4.19MHz)
reset
8 osc.
Even if user set to 1 sec.,
worst case 0.75 second
Write WDCLR = 1 at this point
When WDTR = 0011_0111B
Figure 19-3 Watchdog timer Timing
If the watchdog timer output becomes active, a reset is generated,
which drives the RESET pin low to reset the internal hardware.
80
The main clock oscillator also turns on when a watchdog timer reset is generated in sub clock mode.
APR., 2001 Ver 2.01
GMS81C7008/7016
20. POWER DOWN OPERATION
The GMS81C7008/16 has two power-down modes. In powerdown mode, power consumption is reduced considerably that in
Battery operation Battery life can be extended a lot.
Sleep mode is entered by setting bit 0 of Sleep Mode Register, and STOP Mode is entered by STOP instruction.
20.1 SLEEP Mode
In this mode, the internal oscillation circuits remain active.
Oscillation continues and peripherals are operate normally but
CPU stops. Movement of all Peripherals is shown in Table 20-1.
Sleep mode is entered by setting bit 0 of SMR (address 0DEH).
ADDRESS : 0DEH
RESET VALUE : -------0
W
Sleep Mode Register
SMR
It is released by RESET or interrupt. To be release by interrupt,
interrupt should be enabled before Sleep mode.
0: Release Sleep Mode
1: Enter Sleep Mode
Figure 20-1 SLEEP Mode Register
~
~
Oscillator
(XIN or SXIN pin)
~
~
Internal CPU Clock
Interrupt
Release
Set bit 0 of SMR
Normal Operation
Stand-by Mode
Normal Operation
Figure 20-2 Sleep Mode Release Timing by External Interrupt
.
~
~
~
~
Oscillator
(XIN or SXIN pin)
Internal CPU Clock
Release
Set bit 0 of SMR
Normal Operation
Sleep Mode
0
1
2
Clear & Start
~
~ ~
~
~
~ ~
~
BIT Counter
~
~ ~
~
~
~
RESET
FE
FF
0
1
2
tST = 62.5ms
Normal Operation
at 4.19MHz by hardware
tST =
1
fMAIN ÷1024
x 256
Figure 20-3 SLEEP Mode Release Timing by RESET pin
APR., 2001 Ver 2.01
81
GMS81C7008/7016
20.2 STOP Mode
For applications where power consumption is a critical
factor, device provides reduced power of STOP.
Start The Stop Operation
An instruction that STOP causes to be the last instruction
is executed before going into the STOP mode. In the Stop
Peripheral
mode, the on-chip main-frequency oscillator is stopped.
With the clock frozen, all functions are stopped, but the onchip RAM and Control registers are held. The port pins
output the values held by their respective port data register,
the port direction registers. The status of peripherals during
Stop mode is shown below.
STOP Mode
SLEEP Mode
CPU
All CPU operations are disabled
All CPU operations are disabled
RAM
Retain
Retain
LCD driver operates continuously
LCD driver operates continuously
Basic Interval Timer
Halted
BIT operates continuously
Timer/Event counter
Halted (Only when the Event counter mode
is enabled, Timer operates normally)
Timer/Event counter operates continuously
Watch Timer
Watch Timer operates continuously
Watch Timer operates continuously
Main-oscillation
Stop (XIN pin = “L”, XOUT pin = ”L”)
Oscillation
Sub-oscillation
Oscillation
Oscillation
I/O ports
Retain
Retain
Control Registers
Retain
Retain
Release method
RESET, Key Scan interrupt, SIO interrupt,
Watch Timer interrupt, Timer interrupt
(EC0,2), External interrupt
RESET, All interrupts
LCD driver
Table 20-1 Peripheral Operation during Power Down Mode
Note: Since the XIN pin is connected internally to GND to
avoid current leakage due to the crystal oscillator in STOP
mode, do not use STOP instruction when an external clock
is used as the main system clock.
:
The Interval Timer Register CKCTLR should be initialized (0FH
or 0EH) by software in order that oscillation stabilization time
should be longer than 20ms before STOP mode.
Release the STOP mode
In the Stop mode of operation, VDD can be reduced to minimize
power consumption. Be careful, however, that VDD is not reduced before the Stop mode is invoked, and that VDD is restored
to its normal operating level before the Stop mode is terminated.
The reset should not be activated before VDD is restored to its
normal operating level, and must be held active long enough to
allow the oscillator to restart and stabilize.
And after STOP instruction, at least two or more NOP instruction
should be written as shown in example below.
Example)
;
82
LDM
LDM
STOP
NOP
NOP
CKCTLR,#0EB ;32.8ms
CKCTLR,#0FB ;65.5ms
The exit from STOP mode is using hardware reset or external interrupt, watch timer, key scan or timer/counter.
To release STOP mode, corresponding interrupt should be
enabled before STOP mode.
Specially as a clock source of Timer/Event counter, EC0 or EC2
pin can release it by Timer/Event counterInterrupt request
Reset redefines all the control registers but does not change the
on-chip RAM. External interrupts allow both on-chip RAM and
Control registers to retain their values.
Start-up is performed to acquire the time for stabilizing oscillation. During the start-up, the internal operations are all stopped.
APR., 2001 Ver 2.01
GMS81C7008/7016
~
~ ~
~
~
~
Oscillator
(XIN pin)
~
~
~
~
Internal Clock
~
~
STOP Instruction
Executed
n+1 n+2
n+3
1
0
~
~ ~
~
n
~ ~
~
~
BIT Counter
~
~
External Interrupt
FE
FF
0
1
2
Clear
Normal Operation
Stop Operation
Normal Operation
tST > 20ms
by software
Before executing Stop instruction, Basic Interval Timer must be set
properly by software to get stabilization time which is longer than 20ms.
Figure 20-4 STOP Mode Release Timing by External Interrupt
~
~ ~
~
~
~
Oscillator
(XIN pin)
~
~
~
~
Internal Clock
~
~
STOP Instruction
Executed
n+1 n+2
n+2
n+3
1
0
~
~ ~
~
n
~ ~
~
~
BIT Counter
~
~
RESET
FE
FF
0
1
2
Clear
Normal Operation
Stop Operation
Normal Operation
tST > 62.5ms
at 4.19MHz by hardware
tST =
1
fMAIN ÷1024
x 256
Figure 20-5 STOP Mode Release Timing by RESET
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 associated with the oscillator and the internal hardware is lowered; however, the power dissipation associated with the
APR., 2001 Ver 2.01
pin interface (depending on the external circuitry and program) is not directly determined by the hardware operation
of the STOP feature. This point should be little current flows
when the input level is stable at the power voltage level
(VDD/VSS); however, when the input level becomes higher
than the power voltage level (by approximately 0.3V), a current begins to flow. Therefore, if cutting off the output transistor at an I/O port puts the pin signal into the highimpedance state, a current flow across the ports input transistor, requiring it to fix the level by pull-up or other means.
83
GMS81C7008/7016
It should be set properly that current flow through port doesn't exist.
VDD) is applied to input pin, there can be little current (max. 1mA
at around 2V) flow.
First consider the setting to input mode. Be sure that there is no
current flow after considering its relationship with external circuit. In input mode, the pin impedance viewing from external
MCU is very high that the current doesn’t flow.
If it is not appropriate to set as an input mode, then set to output
mode considering there is no current flow. Setting to High or Low
is decided considering its relationship with external circuit. For
example, if there is external pull-up resistor then it is set to output
mode, i.e. to High, and if there is external pull-down register, it is
set to low.
But input voltage level should be VSS or VDD. Be careful that if
unspecified voltage, i.e. if un-firmed voltage level (not VSSor
VDD
INPUT PIN
INPUT PIN
VDD
VDD
internal
pull-up
VDD
i=0
O
OPEN
O
i
i
GND
Very weak current flows
VDD
X
X
i=0
Weak pull-up current flows
GND
O
OPEN
O
When port is configure as an input, input level should
be closed to 0V or 5V to avoid power consumption.
Figure 20-6 Application Example of Unused Input Port
OUTPUT PIN
OUTPUT PIN
VDD
ON
OPEN
OFF
ON
OFF
O
OFF
VDD
GND
X
ON
i
ON
OFF
L
OFF
ON
i
GND
X
O
VDD
L
i=0
GND
O
In the left case, Tr. base current flows from port to GND.
To avoid power consumption, there should be low output
to the port .
In the left case, much current flows from port to GND.
Figure 20-7 Application Example of Unused Output Port
84
APR., 2001 Ver 2.01
GMS81C7008/7016
21. OSCILLATOR CIRCUIT
The GMS81C7008/16 has two oscillation circuits internally. XIN
and XOUT are input and output for main frequency and SXIN and
SXOUT are input and output for sub frequency, respectively, inverting amplifier which can be configured for being used as an
on-chip oscillator, as shown in Figure 21-1. To use RC oscillation
instead of crystal, user should check mark on the "A. MASK ORDER SHEET" on page i of the appendix of this manual. However
in the OTP device, when the programming RC oscillation can be
selected or not into the configuration bit. For more detail, refer to
"24.1 OTP Programming" on page 89.
Note: When using the sub clock oscillation, connect a resistor in series with R which is shown as below figure.
In order to reduce the power consumption, the sub clock
oscillator employs a low amplification factor circuit. Because of this, the sub clock oscillator is more sensitive to
noise than the main system clock oscillator.
C1
C1
XOUT
C2
4.19MHz
R
C2
XIN
32.768kHz
VSS
SXOUT
SXIN
VSS
Recommend
C1,C2 = 30pF±5pF
R= 47kΩ±5kΩ
Recommend
Crystal Oscillator
C1,C2 = 20pF
Ceramic Resonator
C1,C2 = 30pF
Crystal or Ceramic Oscillator
Open
XOUT
XOUT
REXT
External Clock
XIN
XIN
External Oscillator
For selection R value,
Refer to AC Characteristics
RC Oscillator (mask option)
Figure 21-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 21-2 for the layout of the crystal.
Note: Minimize the wiring length. Do not allow the wiring to
intersect with other signal conductors. Do not allow the wiring to come near changing high current. Set the potential of
the grounding position of the oscillator capacitor to that of
VSS. Do not ground it to any ground pattern where high current is present. Do not fetch signals from the oscillator.
APR., 2001 Ver 2.01
XOUT
XIN
Figure 21-2 Recommend Layout of Oscillator PCB
circuit
85
GMS81C7008/7016
22. RESET
The GMS81C7008/16 has two types of reset generation procedures; one is an external reset input, the other is a watch-dog timer reset. Table 22-1 shows on-chip hardware initialization by
reset action.
On-chip Hardware
Initial Value
(FFFFH) - (FFFEH)
Program counter (PC)
G-flag (G)
VCC
10kΩ
0
Operation mode
Main operating mode
Peripheral clock
On
Watchdog timer
Disable (Because the Watch
timer is disabled)
Control registers
Refer to Table 8-1 on
page 25
to the RESET pin
7036P
+
10uF
Low voltage detector
Enable
Table 22-1 Initializing Internal Status by Reset Action
Figure 22-1 Simple Power-on-Reset Circuit.
22.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. After reset, 64ms (at 4 MHz) add with 7 oscillator periods
are required to start execution as shown in Figure 22-2.
be initialized before read or tested it.
When the RESET pin input goes to high, the reset operation is released and the program execution starts at the vector address
stored at addresses FFFEH - FFFFH.
A connection for simple power-on-reset is shown in Figure .
Internal RAM is not affected by reset. When VDD is turned on,
the RAM content is indeterminate. Therefore, this RAM should
1
?
?
4
5
6
7
~
~
?
?
FFFE FFFF Start
~ ~
~
~
?
?
?
?
FE
ADL
ADH
OP
~
~
DATA
BUS
3
~
~
RESET
ADDRESS
BUS
2
~
~
Oscillator
(XIN pin)
Stabilization Time
tST = 62.5mS at 4.19MHz
RESET Process Step
tST =
1
fMAIN ÷1024
MAIN PROGRAM
x 256
Figure 22-2 Timing Diagram after RESET
22.2 Watchdog Timer Reset
Refer to “18. LCD DRIVER” on page 70.
86
APR., 2001 Ver 2.01
GMS81C7008/7016
23. POWER FAIL PROCESSOR
The GMS81C7008/16 has an on-chip low voltage detection circuitry to detect the VDD voltage. A configuration register, LVDR
(address 0FBH), can enable or disable the low voltage detect circuitry. Whenever VDD falls close to or below 2.2V, the LVD0 is
just set to “1”, and if it recovering 3.4V, LVD0 is held to “1”. If
VDD falls below around 3.4V range, the low voltage situation
may reset the MCU or freeze the clock according to setting of bit
5 (LVDM) of LVDR . The bit 4 LVD1 function is same with
LVD0 except different voltage level 2.1V. The detection voltage
is varied very little. See "7.3 DC Electrical Characteristics" on
page 11 for more detail voltage level.
LVDR
ADDRESS: 0FBH
INITIAL VALUE: 00H
R/W
7
R/W
6
R/W
5
R/W
4
3
LVDE
LVDS
LVDM
LVD1
LVD0
2
1
0
VDD Detection Flag 1
0: Above 3.4V
1: Below 3.4V
VDD Detection Flag 2
0: Above 2.1V
1: Below 2.1V
Operation Mode
0: Clock freeze
1: Reset
In the in-circuit emulator, power fail function is not implemented
and user may not use it. Therefore, after completed development
of user program, this function may be experimented or evaluated
using by OTP.
Power Fail Voltage Selection
0: 3.4V
1: 2.1V
When power fail certainly occur the MCU was reset, program notify this Reset circumstance cause by LVD function. So, does not
erase the all RAM contents and operates subsequently as shown
in Figure .
Enable / Disable Flag
0: Disable
1: Enable
Figure 23-1 Low Voltage Detector Register
RESET VECTOR
LVD0 =1
YES
NO
RAM CLEAR
INITIALIZE RAM DATA
Skip the initial routine when
the Reset cause from power fail.
INITIALIZE ALL PORTS
INITIALIZE REGISTERS
FUNTION
EXECUTION
Figure 23-2 Example S/W of RESET by Power fail
APR., 2001 Ver 2.01
87
GMS81C7008/7016
VDD
LVDVDDMAX
LVDVDDMIN
64mS
Internal
RESET
VDD
When LVDM = 1
Internal
RESET
64mS
t <64mS
VDD
Internal
RESET
LVDVDDMAX
LVDVDDMIN
64mS
LVDVDDMAX
LVDVDDMIN
Figure 23-3 Power Fail Processor Situations
88
APR., 2001 Ver 2.01
GMS81C7008/7016
24. DEVELOPMENT TOOLS
24.1 OTP Programming
The GMS87C7016 is OTP (One Time Programmable) type microcontrollers. Its internal user memory is constructed with
EPROM (Electrically Programmable Read Only Memory).
The CHOICE-SIGMA is a HEI Universal Single Programmer for
all of HEI OTP devices, also the CHOICE-GANG4 can program
four OTPs at once.
The OTP microcontroller is generally used for chip evaluation,
first production, small amount production, fast mass production,
etc.
Programming Procedure
Blank OTP’s internal EPROM is filled by 00H, not FFH.
Note: In any case, you have to use the *.OTP file for programming, not the *.HEX file. After assemble the source
program, both OTP and HEX file are generated by automatically. The HEX file is used during program emulation on
the emulator.
1. Select device GMS87C7016 as you want.
2. Load the *.OTP file from the PC to Programmer. The
file is composed of Motorola-S1 format.
3. Set the programming address range as below table.
4. Mount the socket adapter on the programmer.
5. Set the configuration bytes as your needs.
6. Start program/verify.
Select the option for Program Lock and RC oscillation
87C70XX-64SD
87C71XX-52SD
Except the user program memory C000H~FFFFH, there is configuration byte (address 707FH) for the selection of program lock
and RC oscillation. The configuration byte of OTP is shown as
Figure 24-1. It could be served when user use the OTP programmer (Choice-Sigma or Choice-Gang4).
OTP Configuration Byte
87C70XX-64QF
7
How to Program
To program the OTP devices, user should use HEI own programmer. Ask to HEI sales part for purchasing or more detail.
CHOICE-SIGMA (Single type)
CHOICE-GNAG4 (4-gang type)
Socket adapter:87C70XX-64SD (for 64SDIP)
87C70XX-64QF (for 64MQFP)
Programmer:
6
5
4
3
ADDRESS: 707FH
2
1
LOCK
RC
0
Oscillation Option
0: Crystal or Resonator
1: External RC Oscillator
Lock bit
0: Allow code read out
1: Not allow code read out
Figure 24-1 The OTP Configuration Byte
APR., 2001 Ver 2.01
89
9/&'&
VR1
581
6723
25(6(7
OFF
;287
ON
-B86(5% -B86(5$
;4#+26&,
9B86(5
6XSSO\#.89#+PD[1#533P$,
;5
2 1
5(6(7
SW2
6/((3
*1'
6(*7:
9&/3
6(*78
9&/5
6(*76
&$
6(*74
*1'
6(*6<
28B567
6(*6:
8B;287
&203
*1'
&2052668
56:
6(*66
568
6(*64
553
6(*5<
555
6(*5:
557
6(*58
559
6(*56
54:
6(*54
548
6(*4<
546
6(*4:
544
6(*48
53:
6(*46
538
6(*44
536
6(*<
534
6(*:
566
6(*8
564
6(*6
.89
6(*4
*1'
9&/4
9/&'&
&%
*1'
11&1
5(0287
+721(',
*1'
569
567
554
556
558
55:
549
547
545
543
539
537
535
533
565
563
.89
APR., 2001 Ver 2.01
6(*79
6(*77
6(*75
6(*73
6(*6;
95(*
&2042669
&2062667
6(*65
6(*63
6(*5;
6(*59
6(*57
6(*55
6(*53
6(*4;
6(*49
6(*47
6(*45
6(*43
6(*;
6(*9
6(*7
6(*5
6(*3
-B86(5$
90
OFF
ON
SW5
1
2
SW4
1
2
3
4
5
6
7
8
/&'B9GG
CHOICE-Dr. EVA 81C51/81C7x B/D Rev 1.1 S/N. ---------------
32:(5
External oscillator SW1
socket
+5V
24.2 Emulator EVA. Board Setting
GMS81C7008/7016
-B86(5%
GMS81C7008/7016
DIP Switch and VR Setting
Before execute the user program, keep in your mind the below configuration
DIP S/W, VR
SW1
-
Description
ON/OFF Setting
Emulator Reset Switch. Reset the Emulator.
Reset the Emulator.
Normally OFF.
EVA. chip can be reset by external
user target board.
ON : Reset is available by either
user target system board or Emulator RESET switch.
OFF : Reset the MCU by Emulator
RESET switch. Does not work from
user target board.
SW2-1
EVA.
Chip
1
RESET pin
Pod RESET pin configuration
SW2
Normally OFF.
MCU XOUT pin is disconnected
internally in the Emulator. Some circumstance user may connect this
circuit.
ON : Output XOUT signal
OFF : Disconnect circuit
SW2-2
XOUT pin
EVA.
Chip
2
Oscillator
Pod XOUT pin configuration
External Bias Resistors Connection
EVA. Chip Internal
VDD
SW4
BIAS
Adjust Contrast
VR1 50kΩ
SW4-1
VCL2
1
2
3
SW4-2
10kΩ × 3
VCL1
SW4-3
VCL0
0.47uF × 3
Must be ON position.
It serves the external bias resistors.
If this switches are turned off, LCD
bias voltage does not supplied,
floated because there are no internal bias resistors and bias Tr. inside
the Emulator.
VSS
External Resistor
and Capacitor
SW4
4
5
6
7
LCD Voltage doubling circuit.
Must be OFF position.
It is reserved for the GMS81C5108.
Select the Stack Page.
Must be ON position.
This switch select the Stack page 0
(off) or page 1 (on).
ON : For the 81C7XXX
OFF : For the GMS81C5108
VDD
EVA.
Chip
LVD pin
SW4-8
8
81Cx detect the VDD voltage but Emulator can not do because
Emulator can not operate if VDD is below normal opr. voltage
(5V), This switch serves LVD environment through the applying
0V to LVD pin of EVA. chip during 5V normal operation.
APR., 2001 Ver 2.01
Position ON during normal operation.
ON : Normal operation
OFF : Force to detect the LVD, refer
to "23. POWER FAIL PROCESSOR" on page 87.
91
GMS81C7008/7016
DIP S/W, VR
SW5
Description
ON/OFF Setting
1
Internal power supply to sub-oscillation circuit.
Must be ON position.
2
Reserved for other purpose.
Must be OFF position.
Adjust the LCD contrast. It supply bias voltage and adjust the
VCL2 voltage.
EVA. Chip Internal
VDD
Adjust Contrast
BIAS
VR1 50kΩ
SW4-1
VCL2
VR1
-
SW4-2
10kΩ × 3
VCL1
Adjust the proper position as well as
LCD display good.
SW4-3
VCL0
0.47uF × 3
VSS
External Resistor
and Capacitor
VR2
92
-
Reserved for other purpose.
Don’t care.
APR., 2001 Ver 2.01
APPENDIX
A. MASK ORDER SHEET
MASK ORDER & VERIFICATION SHEET
GMS81C7008
GMS81C7016 -LA
2. Device Information
Package
Company Name
Application
YYYY
MM
DD
Order Date
64MQFP
ROM Size
8K
16K
R C O SC O pt.
Crystal
RC
Mask Data File Name: (
Check Sum: (
Fax:
E-mail:
Internet
Name &
Signature:
.OTP file data
C000H
DFFFH
E000H
3. Marking Specification
(Please check mark into
)
.OTP)
)
GMS81C7008 (8K ROM)
Tel:
64SDIP
FFFFH
08 or 16
Customer’s logo
-LA
GMS81C70
YYWW
Hynix ROM Code
Number
-LA
GMS81C70
YYWW
KOREA
KOREA
Lot Number
Customer logo is not required.
If the customer logo must be used in the special mark, please submit a clean original of the logo.
Customer’s part number
4. Delivery Schedule
Quantity
Date
YYYY
MM
DD
Customer Sample
pcs
YYYY
MM
DD
pcs
Risk Order
5. ROM Code Verification
YYYY
This box is written after “5.Verification”.
MM
Please confirm our verification data.
Check Sum:
01-APR-2001
DD
Approval Date:
Verification D ate:
Tel:
E-mail:
Name &
Signature:
Hynix Confirmation
MM
DD
I agree with your verification data and confirm
you to m ake m ask set.
Tel:
Fax:
YYYY
Name &
Signature:
Fax:
GMS81C7016 (16K ROM)
Customer should write inside thick line box.
1. Customer Information
GMS81C71XX LCD MCU APPENDIX
B. INSTRUCTION
B.1 Terminology List
Terminology
Description
A
Accumulator
X
X - register
Y
Y - register
PSW
Program Status Word
#imm
8-bit Immediate data
dp
!abs
Direct Page Offset Address
Absolute Address
[]
Indirect expression
{}
Register Indirect expression
{ }+
Register Indirect expression, after that, Register auto-increment
.bit
Bit Position
A.bit
Bit Position of Accumulator
dp.bit
Bit Position of Direct Page Memory
M.bit
Bit Position of Memory Data (000H~0FFFH)
rel
upage
Relative Addressing Data
U-page (0FF00H~0FFFFH) Offset Address
n
Table CALL Number (0~15)
+
Addition
Upper Nibble Expression in Opcode
0
x
Bit Position
Upper Nibble Expression in Opcode
1
y
Bit Position
−
Subtraction
×
Multiplication
/
Division
()
Contents Expression
∧
AND
∨
OR
⊕
Exclusive OR
~
NOT
←
Assignment / Transfer / Shift Left
→
Shift Right
↔
Exchange
=
Equal
≠
Not Equal
APR. 2001 Ver 2.01
ii
GMS81C71XX LCD MCU APPENDIX
B.2 Instruction Map
LOW 00000
HIGH
00
SET1
dp.bit
00010
02
00011
03
BBS
BBS
A.bit,rel dp.bit,rel
00100
04
00101
05
00110
06
00111
07
01000
08
01001
09
ADC
#imm
ADC
dp
ADC
dp+X
ADC
!abs
ASL
A
ASL
dp
01010
0A
01011
0B
01100
0C
01101
0D
01110
0E
01111
0F
TCALL SETA1
0
.bit
BIT
dp
POP
A
PUSH
A
BRK
000
-
001
CLRC
SBC
#imm
SBC
dp
SBC
dp+X
SBC
!abs
ROL
A
ROL
dp
TCALL CLRA1
2
.bit
COM
dp
POP
X
PUSH
X
BRA
rel
010
CLRG
CMP
#imm
CMP
dp
CMP
dp+X
CMP
!abs
LSR
A
LSR
dp
TCALL
4
NOT1
M.bit
TST
dp
POP
Y
PUSH
Y
PCALL
Upage
011
DI
OR
#imm
OR
dp
OR
dp+X
OR
!abs
ROR
A
ROR
dp
TCALL
6
OR1
OR1B
CMPX
dp
POP
PSW
PUSH
PSW
RET
100
CLRV
AND
#imm
AND
dp
AND
dp+X
AND
!abs
INC
A
INC
dp
TCALL AND1
8
AND1B
CMPY
dp
CBNE
dp+X
TXSP
INC
X
101
SETC
EOR
#imm
EOR
dp
EOR
dp+X
EOR
!abs
DEC
A
DEC
dp
TCALL EOR1
10
EOR1B
DBNE
dp
XMA
dp+X
TSPX
DEC
X
110
SETG
LDA
#imm
LDA
dp
LDA
dp+X
LDA
!abs
TXA
LDY
dp
TCALL
12
LDC
LDCB
LDX
dp
LDX
dp+Y
XCN
DAS
111
EI
LDM
dp,#imm
STA
dp
STA
dp+X
STA
!abs
TAX
STY
dp
TCALL
14
STC
M.bit
STX
dp
STX
dp+Y
XAX
STOP
10011
13
10100
14
10101
15
10110
16
10111
17
11000
18
11001
19
11010
1A
11011
1B
11100
1C
11101
1D
11110
1E
11111
1F
ADC
{X}
ADC
!abs+Y
ADC
[dp+X]
ADC
[dp]+Y
ASL
!abs
ASL
dp+X
TCALL
1
JMP
!abs
BIT
!abs
ADDW
dp
LDX
#imm
JMP
[!abs]
TEST
!abs
SUBW
dp
LDY
#imm
JMP
[dp]
TCLR1 CMPW
!abs
dp
CMPX
#imm
CALL
[dp]
LOW 10000
HIGH
iii
00001
01
10
10001
11
10010
12
000
BPL
rel
001
BVC
rel
SBC
{X}
SBC
!abs+Y
SBC
[dp+X]
SBC
[dp]+Y
ROL
!abs
ROL
dp+X
TCALL
3
CALL
!abs
010
BCC
rel
CMP
{X}
CMP
!abs+Y
CMP
[dp+X]
CMP
[dp]+Y
LSR
!abs
LSR
dp+X
TCALL
5
MUL
011
BNE
rel
OR
{X}
OR
!abs+Y
OR
[dp+X]
OR
[dp]+Y
ROR
!abs
ROR
dp+X
TCALL
7
DBNE
Y
CMPX
!abs
LDYA
dp
CMPY
#imm
RETI
100
BMI
rel
AND
{X}
AND
!abs+Y
AND
[dp+X]
AND
[dp]+Y
INC
!abs
INC
dp+X
TCALL
9
DIV
CMPY
!abs
INCW
dp
INC
Y
TAY
101
BVS
rel
EOR
{X}
EOR
!abs+Y
EOR
[dp+X]
EOR
[dp]+Y
DEC
!abs
DEC
dp+X
TCALL
11
XMA
{X}
XMA
dp
DECW
dp
DEC
Y
TYA
110
BCS
rel
LDA
{X}
LDA
!abs+Y
LDA
[dp+X]
LDA
[dp]+Y
LDY
!abs
LDY
dp+X
TCALL
13
LDA
{X}+
LDX
!abs
STYA
dp
XAY
DAA
111
BEQ
rel
STA
{X}
STA
!abs+Y
STA
[dp+X]
STA
[dp]+Y
STY
!abs
STY
dp+X
TCALL
15
STA
{X}+
STX
!abs
CBNE
dp
XYX
NOP
CLR1
BBC
BBC
dp.bit
A.bit,rel
dp.bit,rel
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
B.3 Instruction Set
Arithmetic / Logic Operation
No.
Mnemonic
Op
Code
Byte
No
Cycle
No
Operation
1
ADC #imm
04
2
2
Add with carry.
2
ADC dp
05
2
3
A←(A)+(M)+C
3
ADC dp + X
06
2
4
4
ADC !abs
07
3
4
5
ADC !abs + Y
15
3
5
NV--H-ZC
6
ADC [ dp + X ]
16
2
6
7
ADC [ dp ] + Y
17
2
6
8
ADC { X }
14
1
3
9
AND #imm
84
2
2
Logical AND
10
AND dp
85
2
3
A← (A)∧(M)
11
AND dp + X
86
2
4
12
AND !abs
87
3
4
13
AND !abs + Y
95
3
5
14
AND [ dp + X ]
96
2
6
15
AND [ dp ] + Y
97
2
6
16
AND { X }
94
1
3
17
ASL A
08
1
2
18
ASL dp
09
2
4
19
ASL dp + X
19
2
5
20
ASL !abs
18
3
5
21
CMP #imm
44
2
2
22
CMP dp
45
2
3
23
CMP dp + X
46
2
4
24
CMP !abs
47
3
4
25
CMP !abs + Y
55
3
5
26
CMP [ dp + X ]
56
2
6
27
CMP [ dp ] + Y
57
2
6
28
CMP { X }
54
1
3
29
CMPX #imm
5E
2
2
30
CMPX dp
6C
2
3
31
CMPX !abs
7C
3
4
Flag
NVGBHIZC
N-----Z-
Arithmetic shift left
C
7 6 5 4 3 2 1 0
← ←←←←←←←←
N-----ZC
← “0”
Compare accumulator contents with memory contents
(A) -(M)
N-----ZC
Compare X contents with memory contents
(X)-(M)
N-----ZC
32
CMPY #imm
7E
2
2
33
CMPY dp
8C
2
3
Compare Y contents with memory contents
34
CMPY !abs
9C
3
4
35
COM dp
2C
2
4
1’S Complement : ( dp ) ← ~( dp )
N-----Z-
36
DAA
DF
1
3
Decimal adjust for addition
N-----ZC
37
DAS
CF
1
3
Decimal adjust for subtraction
N-----ZC
Decrement
N-----Z-
(Y)-(M)
N-----ZC
38
DEC A
A8
1
2
39
DEC dp
A9
2
4
40
DEC dp + X
B9
2
5
N-----Z-
41
DEC !abs
B8
3
5
N-----Z-
42
DEC X
AF
1
2
N-----Z-
43
DEC Y
BE
1
2
N-----Z-
APR. 2001 Ver 2.01
M← (M)-1
N-----Z-
iv
GMS81C71XX LCD MCU APPENDIX
No.
Op
Code
Byte
No
Cycle
No
Flag
Operation
44
DIV
9B
1
12
Divide : YA / X Q: A, R: Y
45
EOR #imm
A4
2
2
Exclusive OR
NVGBHIZC
NV--H-Z-
A← (A)⊕(M)
46
EOR dp
A5
2
3
47
EOR dp + X
A6
2
4
48
EOR !abs
A7
3
4
49
EOR !abs + Y
B5
3
5
50
EOR [ dp + X ]
B6
2
6
51
EOR [ dp ] + Y
B7
2
6
52
EOR { X }
B4
1
3
53
INC A
88
1
2
54
INC dp
89
2
4
55
INC dp + X
99
2
5
N-----Z-
56
INC !abs
98
3
5
N-----Z-
57
INC X
8F
1
2
N-----Z-
58
INC Y
9E
1
2
N-----Z-
59
LSR A
48
1
2
60
LSR dp
49
2
4
61
LSR dp + X
59
2
5
62
LSR !abs
58
3
5
63
MUL
5B
1
9
Multiply : YA ← Y × A
64
OR #imm
64
2
2
Logical OR
65
OR dp
65
2
3
66
OR dp + X
66
2
4
67
OR !abs
67
3
4
68
OR !abs + Y
75
3
5
69
OR [ dp + X ]
76
2
6
70
OR [ dp ] + Y
77
2
6
71
OR { X }
74
1
3
72
ROL A
28
1
2
73
ROL dp
29
2
4
74
ROL dp + X
39
2
5
75
ROL !abs
38
3
5
76
ROR A
68
1
2
Rotate right through Carry
77
ROR dp
69
2
4
78
ROR dp + X
79
2
5
7 6 5 4 3 2 1 0
→→→→→→→→
79
ROR !abs
78
3
5
80
SBC #imm
24
2
2
81
SBC dp
25
2
3
82
SBC dp + X
26
2
4
83
SBC !abs
27
3
4
84
SBC !abs + Y
35
3
5
85
SBC [ dp + X ]
36
2
6
86
SBC [ dp ] + Y
37
2
6
87
SBC { X }
34
1
3
88
TST dp
4C
2
3
Test memory contents for negative or zero, ( dp ) - 00H
N-----Z-
5
Exchange nibbles within the accumulator
A7~A4 ↔ A3~A0
N-----Z-
89
v
Mnemonic
XCN
CE
1
N-----Z-
Increment
N-----ZC
M← (M)+1
N-----Z-
Logical shift right
N-----ZC
7 6 5 4 3 2 1 0
C
“0” → → → → → → → → → →
N-----Z-
A ← (A)∨(M)
N-----Z-
Rotate left through Carry
C
N-----ZC
7 6 5 4 3 2 1 0
←←←←←←←←
N-----ZC
C
Subtract with Carry
A ← ( A ) - ( M ) - ~( C )
NV--HZC
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
Register / Memory Operation
No.
Mnemonic
Op
Code
Byte
No
Cycle
No
1
LDA #imm
C4
2
2
2
LDA dp
C5
2
3
3
LDA dp + X
C6
2
4
4
LDA !abs
C7
3
4
5
LDA !abs + Y
D5
3
5
6
LDA [ dp + X ]
D6
2
6
7
LDA [ dp ] + Y
D7
2
6
8
LDA { X }
D4
1
3
Operation
Load accumulator
A←(M)
N-----Z-
9
LDA { X }+
DB
1
4
X- register auto-increment : A ← ( M ) , X ← X + 1
10
LDM dp,#imm
E4
3
5
Load memory with immediate data : ( M ) ← imm
11
LDX #imm
1E
2
2
Load X-register
12
LDX dp
CC
2
3
13
LDX dp + Y
CD
2
4
14
LDX !abs
DC
3
4
15
LDY #imm
3E
2
2
16
LDY dp
C9
2
3
17
LDY dp + X
D9
2
4
18
LDY !abs
D8
3
4
19
STA dp
E5
2
4
20
STA dp + X
E6
2
5
21
STA !abs
E7
3
5
22
STA !abs + Y
F5
3
6
23
STA [ dp + X ]
F6
2
7
24
STA [ dp ] + Y
F7
2
7
Flag
NVGBHIZC
X ←(M)
-------N-----Z-
Load Y-register
Y←(M)
N-----Z-
Store accumulator contents in memory
(M)←A
--------
25
STA { X }
F4
1
4
26
STA { X }+
FB
1
4
X- register auto-increment : ( M ) ← A, X ← X + 1
27
STX dp
EC
2
4
Store X-register contents in memory
28
STX dp + Y
ED
2
5
29
STX !abs
FC
3
5
30
STY dp
E9
2
4
31
STY dp + X
F9
2
5
32
STY !abs
F8
3
5
33
TAX
E8
1
2
Transfer accumulator contents to X-register : X ← A
N-----Z-
34
TAY
9F
1
2
Transfer accumulator contents to Y-register : Y ← A
N-----Z-
35
TSPX
AE
1
2
Transfer stack-pointer contents to X-register : X ← sp
N-----Z-
36
TXA
C8
1
2
Transfer X-register contents to accumulator: A ← X
N-----Z-
37
TXSP
8E
1
2
Transfer X-register contents to stack-pointer: sp ← X
N-----Z-
38
TYA
BF
1
2
Transfer Y-register contents to accumulator: A ← Y
N-----Z-
39
XAX
EE
1
4
Exchange X-register contents with accumulator :X ↔ A
--------
40
XAY
DE
1
4
Exchange Y-register contents with accumulator :Y ↔ A
--------
41
XMA dp
BC
2
5
Exchange memory contents with accumulator
42
XMA dp+X
AD
2
6
43
XMA {X}
BB
1
5
44
XYX
FE
1
4
APR. 2001 Ver 2.01
(M)← X
--------
Store Y-register contents in memory
(M)← Y
(M)↔A
Exchange X-register contents with Y-register : X ↔ Y
--------
N-----Z--------
vi
GMS81C71XX LCD MCU APPENDIX
16-BIT operation
No.
Mnemonic
Op
Code
Byte
No
Cycle
No
Flag
Operation
NVGBHIZC
1
ADDW dp
1D
2
5
16-Bits add without Carry
YA ← ( YA ) ( dp +1 ) ( dp )
NV--H-ZC
2
CMPW dp
5D
2
4
Compare YA contents with memory pair contents :
(YA) − (dp+1)(dp)
N-----ZC
3
DECW dp
BD
2
6
Decrement memory pair
( dp+1)( dp) ← ( dp+1) ( dp) - 1
N-----Z-
4
INCW dp
9D
2
6
Increment memory pair
( dp+1) ( dp) ← ( dp+1) ( dp ) + 1
N-----Z-
5
LDYA dp
7D
2
5
Load YA
YA ← ( dp +1 ) ( dp )
N-----Z-
6
STYA dp
DD
2
5
Store YA
( dp +1 ) ( dp ) ← YA
--------
7
SUBW dp
3D
2
5
16-Bits subtract without carry
YA ← ( YA ) - ( dp +1) ( dp)
NV--H-ZC
Op
Code
Byte
No
Cycle
No
Bit Manipulation
No.
vii
Mnemonic
Flag
Operation
NVGBHIZC
1
AND1 M.bit
8B
3
4
Bit AND C-flag : C ← ( C ) ∧ ( M .bit )
-------C
2
AND1B M.bit
8B
3
4
Bit AND C-flag and NOT : C ← ( C ) ∧ ~( M .bit )
-------C
3
BIT dp
0C
2
4
Bit test A with memory :
MM----Z-
4
BIT !abs
1C
3
5
Z ← ( A ) ∧ ( M ) , N ← ( M 7 ) , V ← ( M6 )
5
CLR1 dp.bit
y1
2
4
Clear bit : ( M.bit ) ← “0”
--------
6
CLRA1 A.bit
2B
2
2
Clear A bit : ( A.bit ) ← “0”
--------
7
CLRC
20
1
2
Clear C-flag : C ← “0”
-------0
8
CLRG
40
1
2
Clear G-flag : G ← “0”
--0-----
9
CLRV
80
1
2
Clear V-flag : V ← “0”
-0--0---
10
EOR1 M.bit
AB
3
5
Bit exclusive-OR C-flag : C ← ( C ) ⊕ ( M .bit )
-------C
11
EOR1B M.bit
AB
3
5
Bit exclusive-OR C-flag and NOT : C ← ( C ) ⊕ ~(M .bit)
-------C
12
LDC M.bit
CB
3
4
Load C-flag : C ← ( M .bit )
-------C
13
LDCB M.bit
CB
3
4
Load C-flag with NOT : C ← ~( M .bit )
-------C
14
NOT1 M.bit
4B
3
5
Bit complement : ( M .bit ) ← ~( M .bit )
--------
15
OR1 M.bit
6B
3
5
Bit OR C-flag : C ← ( C ) ∨ ( M .bit )
-------C
16
OR1B M.bit
6B
3
5
Bit OR C-flag and NOT : C ← ( C ) ∨ ~( M .bit )
-------C
17
SET1 dp.bit
x1
2
4
Set bit : ( M.bit ) ← “1”
--------
18
SETA1 A.bit
0B
2
2
Set A bit : ( A.bit ) ← “1”
--------
19
SETC
A0
1
2
Set C-flag : C ← “1”
-------1
20
SETG
C0
1
2
Set G-flag : G ← “1”
--1-----
21
STC M.bit
EB
3
6
Store C-flag : ( M .bit ) ← C
--------
22
TCLR1 !abs
5C
3
6
Test and clear bits with A :
A - ( M ) , ( M ) ← ( M ) ∧ ~( A )
N-----Z-
23
TSET1 !abs
3C
3
6
Test and set bits with A :
A-(M), (M)← (M)∨(A)
N-----Z-
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
Branch / Jump Operation
No.
Mnemonic
Op
Code
Byte
No
Cycle
No
Operation
Flag
NVGBHIZC
1
BBC A.bit,rel
y2
2
4/6
Branch if bit clear :
2
BBC dp.bit,rel
y3
3
5/7
if ( bit ) = 0 , then pc ← ( pc ) + rel
3
BBS A.bit,rel
x2
2
4/6
Branch if bit set :
4
BBS dp.bit,rel
x3
3
5/7
if ( bit ) = 1 , then pc ← ( pc ) + rel
5
BCC rel
50
2
2/4
Branch if carry bit clear
if ( C ) = 0 , then pc ← ( pc ) + rel
--------
6
BCS rel
D0
2
2/4
Branch if carry bit set
if ( C ) = 1 , then pc ← ( pc ) + rel
--------
7
BEQ rel
F0
2
2/4
Branch if equal
if ( Z ) = 1 , then pc ← ( pc ) + rel
--------
8
BMI rel
90
2
2/4
Branch if minus
if ( N ) = 1 , then pc ← ( pc ) + rel
--------
9
BNE rel
70
2
2/4
Branch if not equal
if ( Z ) = 0 , then pc ← ( pc ) + rel
--------
10
BPL rel
10
2
2/4
Branch if plus
if ( N ) = 0 , then pc ← ( pc ) + rel
--------
11
BRA rel
2F
2
4
Branch always
pc ← ( pc ) + rel
--------
12
BVC rel
30
2
2/4
Branch if overflow bit clear
if (V) = 0 , then pc ← ( pc) + rel
--------
13
BVS rel
B0
2
2/4
Branch if overflow bit set
if (V) = 1 , then pc ← ( pc ) + rel
--------
14
CALL !abs
3B
3
8
Subroutine call
15
CALL [dp]
5F
2
8
M( sp)←( pcH ), sp←sp - 1, M(sp)← (pcL), sp ←sp - 1,
if !abs, pc← abs ; if [dp], pcL← ( dp ), pcH← ( dp+1 ) .
--------
16
CBNE dp,rel
FD
3
5/7
Compare and branch if not equal :
--------
17
CBNE dp+X,rel
8D
3
6/8
18
DBNE dp,rel
AC
3
5/7
Decrement and branch if not equal :
19
DBNE Y,rel
7B
2
4/6
if ( M ) ≠ 0 , then pc ← ( pc ) + rel.
20
JMP !abs
1B
3
3
21
JMP [!abs]
1F
3
5
22
JMP [dp]
3F
2
4
23
PCALL upage
4F
2
6
U-page call
M(sp) ←( pcH ), sp ←sp - 1, M(sp) ← ( pcL ),
sp ← sp - 1, pcL ← ( upage ), pcH ← ”0FFH” .
--------
24
TCALL n
nA
1
8
Table call : (sp) ←( pcH ), sp ← sp - 1,
M(sp) ← ( pcL ),sp ← sp - 1,
pcL ← (Table vector L), pcH ← (Table vector H)
--------
APR. 2001 Ver 2.01
---------------
if ( A ) ≠ ( M ) , then pc ← ( pc ) + rel.
--------
Unconditional jump
pc ← jump address
--------
viii
GMS81C71XX LCD MCU APPENDIX
Control Operation & Etc.
No.
1
ix
Mnemonic
BRK
Op
Code
Byte
No
Cycle
No
Operation
0F
1
8
Software interrupt : B ← ”1”, M(sp) ← (pcH), sp ←sp-1,
M(s) ← (pcL), sp ← sp - 1, M(sp) ← (PSW), sp ← sp -1,
pcL ← ( 0FFDE H ) , pcH ← ( 0FFDFH) .
---1-0--
Flag
NVGBHIZC
2
DI
60
1
3
Disable all interrupts : I ← “0”
-----0--
3
EI
E0
1
3
Enable all interrupt : I ← “1”
-----1--
4
NOP
FF
1
2
No operation
--------
5
POP A
0D
1
4
sp ← sp + 1, A ← M( sp )
6
POP X
2D
1
4
sp ← sp + 1, X ← M( sp )
7
POP Y
4D
1
4
sp ← sp + 1, Y ← M( sp )
8
POP PSW
6D
1
4
sp ← sp + 1, PSW ← M( sp )
-------restored
9
PUSH A
0E
1
4
M( sp ) ← A , sp ← sp - 1
10
PUSH X
2E
1
4
M( sp ) ← X , sp ← sp - 1
11
PUSH Y
4E
1
4
M( sp ) ← Y , sp ← sp - 1
12
PUSH PSW
6E
1
4
M( sp ) ← PSW , sp ← sp - 1
13
RET
6F
1
5
Return from subroutine
sp ← sp +1, pcL ← M( sp ), sp ← sp +1, pcH ← M( sp )
--------
14
RETI
7F
1
6
Return from interrupt
sp ← sp +1, PSW ← M( sp ), sp ← sp + 1,
pcL ← M( sp ), sp ← sp + 1, pcH ← M( sp )
restored
15
STOP
EF
1
3
Stop mode ( halt CPU, stop oscillator )
--------
--------
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
C. SOFTWARE EXAMPLE
;*****************************************************************************
; Title:
GMS81C7016 (GMS800 Series) Demonstration Program
*
; Company:
Hynix semiconductor Inc.
*
; Contents:
LCD DISPLAY & DUAL THERMOMETER
*
;*****************************************************************************
;
;******** DEFINE
I/O PORT & FUNCTION REGISTER ADDRESS *********
;
R0
EQU
0C0H
;port R0 register
R1
EQU
0C1H
;port R1 register
R2
EQU
0C2H
;port R2 register
R3
EQU
0C3H
;port R3 register
R4
EQU
0C4H
;port R4 register
R5
EQU
0C5H
;port R5 register
;
R0DD
EQU
0C8H
;port R0 data I/O direction register
R1DD
EQU
0C9H
;port R1 data I/O direction register
R2DD
EQU
0CAH
;port R2 data I/O direction register
R3DD
EQU
0CBH
;port R3 data I/O direction register
R4DD
EQU
0CCH
;port R4 data I/O direction register
R5DD
EQU
0CDH
;port R5 data I/O direction register
;
R0PU
EQU
0D0H
;port R0 Pull-up selection register
R1PU
EQU
0D1H
;port R1 Pull-up selection register
R2PU
EQU
0D2H
;port R2 Pull-up selection register
R3PU
EQU
0D3H
;port R3 Pull-up selection register
;
R0CR
EQU
0D4H
;port R0 Type selection register
R1CR
EQU
0D5H
;port R1 Type selection register
R2CR
EQU
0D6H
;port R2 Type selection register
R3CR
EQU
0D7H
;port R3 Type selection register
;
IEDS
EQU
0D8H
;External interrupt edge selection register
PMR
EQU
0D9H
;Alternative port mode register
IENL
EQU
0DAH
;int. enable register low
IENH
EQU
0DBH
;int. enable register high
IRQL
EQU
0DCH
;int. request flag register low
IRQH
EQU
0DDH
;int. request flag register high
SLPR
WDTR
EQU
EQU
0DEH
0DFH
;sleep mode register
;Watchdog timer register
TM0
TDR0
TM1
TDR1
T1PPR
T1PDR
PWM0HR
TM2
TDR2
TM3
TDR3
T3PPR
T3PDR
PWM1HR
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
0E0H
0E1H
0E2H
0E3H
0E3H
0E4H
0E5H
0E6H
0E7H
0E8H
0E9H
0E9H
0EAH
0EBH
;Timer 0 mode register
;Timer 0 data register
;Timer 1 mode register
;Timer 1 data register
;PWM0 period register
;Timer 1 pulse duty register
;PWM0 high register
;Timer 2 mode register
;Timer 2 data register
;Timer 3 mode register
;Timer 3 data register
;PWM1 period register
;Timer 3 pulse duty register
;PWM1 high register
ADCM
ADR
WTMR
EQU
EQU
EQU
0ECH
0EDH
0EFH
;ADC mode register
;ADC result data register
;Watch timer mode register
KSMR
LCDM
LCDPM
RPR
BITR
CKCTLR
SCMR
PFDR
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
0F0H
0F1H
0F2H
0F3H
0F4H
0F4H
0F5H
0FBH
;Key scan mode register
;LCD mode register
;LCD port mode register
;RAM paging register
;Basic interval timer data register
;Clock control register
;System clock mode register
;Power fail detector
BUR
EQU
0FDH
SMR
EQU
0FEH
SIOD
EQU
0FFH
;
;*********** MACRO
DEFINITION
;
R_SAVEMACRO
APR. 2001 Ver 2.01
;buzzer data register
;Serial mode register
;Serial data buffer register
************
;Save Registers to Stacks
x
GMS81C71XX LCD MCU APPENDIX
PUSH
A
PUSH
Y
X
PUSH
ENDM
;
R_RSTRMACRO
;Restore Register from Stacks
POP
Y
POP
X
POP
A
ENDM
;
;*********** CONSTANT DEFINITION ***********
;
;
;
;**************************************************************************
;
RAM
ALLOCATION
*
;**************************************************************************
TEMP0
DS
1
TEMP1
DS
1
TEMP2
DS
1
FLAG1
DS
1
RPTEN
KEYONF
ACTKEY
TOGMO3
DUAL_T
OUTSIDE
EQU
EQU
EQU
EQU
EQU
EQU
1,FLAG1
2,FLAG1
3,FLAG1
4,FLAG1
5,FLAG1
6,FLAG1
;SET RPTEN(REPEAT KEY ENABLE) AFTER 1 SEC.
;KEYSCAN
;AT ONCE, KEY VALID
;MODE 3 (PORT TOGGLE)
;INSIDE & OUTSIDE TEMP. DUAL DISPLAY
;INSIDE TEMP or OUTSIDE TEMP.
FLAG2
F200MS
F20MS
F_1MIN
LPM
RPM
DS
EQU
EQU
EQU
EQU
EQU
1
0,FLAG2
1,FLAG2
2,FLAG2
3,FLAG2
4,FLAG2
;WTIMER
;LEFT TIME PM FLAG
;RIGHT TIME PM FLAG
STATUS
RPTKEY
F_CLOCK
F_ON
DS
EQU
EQU
EQU
1
7,STATUS
6,STATUS
0,STATUS
DISPSIGN
DISPRAM
DISPRAM1
DS
DS
DS
1
1
4
ONDO
LHOUR
LMINUTE
RHOUR
RMINUTE
TIMESET
TSFLAG
TSLPM
TSRPM
BLINKCNT
;
NEWKY
OLDKY
PORTDT
KEYNM
KEYDT
TOTLKY
CHATFL
R0BUF
DS
DS
DS
DS
DS
DS
DS
EQU
EQU
DS
2
1
1
1
1
4
1
0,TSFLAG
1,TSFLAG
1
DS
DS
DS
DS
DS
DS
DS
DS
1
1
1
1
1
1
1
1
DGTCNT
MODE
SUBMODE
BSCTIME
DS
DS
DS
DS
1
1
1
1
TEMPCNT
HZCNT
DS
DS
1
1
;TEMP.
;LEFT TIME, RIGHT TIME
;LEFT WATCH COUNT
;RIGHT WATCH COUNT BUF.
;WATCH SET BUFFER
;TIME SET LEFT PM
;TIME SET RIGHT PM
;BLINK COUNTER 0~250 LOOP
PWMF
DS
1
PERIOD
EQU
0,PWMF
;
;**************************************************************************
;
INTERRUPT
VECTOR
TABLE
*
;**************************************************************************
xi
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
;
ORG
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
0FFE0H
NOT_USED
; Timer-3
NOT_USED
; Timer-2
WTIMER
; Watch Timer
INT_AD
; A/D CON.
NOT_USED
; Serial I/O
NOT_USED
; Not used
NOT_USED
; Not used
NOT_USED
; Int.2
TIMER1
; Timer-1
TIMER0
; Timer-0
INT1
; Int.1
INT0
; Int.0
NOT_USED; Watch Dog Timer
NOT_USED; BIT
INT_KEY
; Key Scan
RESET
; Reset
;
;**************************************************************************
;
MAIN
PROGRAM
*
;**************************************************************************
;
ORG
0C000H
;Program Start Address
;ORG
0E000H
; 8K ROM VERSION
;
RESET:
LDM
WDTR,#0
LDM
RPR,#1
;
CLRG
LDX
#0
RAMCLR:
LDA
#0
;RAM Clear(!0000H->!00BFH)
STA
{X}+
;M(X) <- A, then X <- X+1
CMPX
#0C0H
;X = #0C0H ?
BNE
RAMCLR
SETG
LDX
#0
RAMCLR1:
LDA
#0
;RAM Clear(!0100H->!011AH)
STA
{X}+
;M(X) <- A, then X <- X+1
CMPX
#1BH
;X = #01BH ?
BNE
RAMCLR1
CLRG
;
LDX
#0FFH
;Stack Pointer Initial
TXSP
;SP. <- #0FFH
;
;******** USER RAM INITIALIZE **********
;
; LDM
MODE,#4
; LDM
SUBMODE,#1
SET1
LPM
;KST PM 12:00 JUST NOON
LDM
LHOUR,#12H
LDM
LMINUTE,#00H
LDM
RHOUR,#03H
;UTC AM 03:00
LDM
RMINUTE,#00H
SET1
OUTSIDE
SET1
F_ON
;POWER ON
;
;********** PORT INITIALIZE ************
;
LDM
LCDPM,#0
;SEG0~SEG23 are used
LDM
R0,#0
;I/O Port Data Clea
LDM
R1,#0
;I/O Port Data Clear
LDM
R2,#0
LDM
R3,#0
LDM
R0DD,#1111_0001B
;R05,R06,R07: output for Keyscan
LDM
R1DD,#0000_0000B
LDM
R2DD,#0000_0000B
;R20~R23: input for keyscan
LDM
R3DD,#0000_0100B
LDM
R2PU,#0000_1111B
;R20~R23 pull-up active
;
;***** CONTROL REGISTER INITIALIZE *****
;
LDM
CKCTLR,#0
;WAKE UP TIME = 0.0625 sec
;(1/32768)*8*256 = 0.0625sec
LDM
TDR0,#249
;8us x (249+1) = 2ms
LDM
TM0,#0000_1111B
;8BIT Timer,8us,Start Count-up
LDM
TDR1,#249
;2us x (249+1) = 500us
LDM
TM1,#0000_1111B
;Timer1(8bit),32us,Start Count-up
LDM
TM3,#1010_1011B
APR. 2001 Ver 2.01
xii
GMS81C71XX LCD MCU APPENDIX
LOOP:
LDM
LDM
LDM
LDM
T3PPR,#99
T3PDR,#50
PWM1HR,#00H
PMR,#80H
LDM
LDM
LDM
LDM
LDM
LDM
LDM
LDM
LDM
IRQH,#0
IRQL,#0
IENL,#1111_1111B
IENH,#1111_1111B
IEDS,#0001_0101B
KSMR,#0000_0001B
WTMR,#48H
LCDM,#70H
SCMR,#0
EI
;
BBC
CALL
CLR1
;Clear All Interrupts Requeat Flags
;INT2,ADC,WT,T2,T3
;BIT,WDT,INT0,INT1,T0,T1
;External Int. Falling edge select
;R10 KEY INTERRUPT
;ENABLE WT COUNTER, 2Hz, SELECT SUBCLOCK
;CLK=fsub/64, 1/4duty, internal Bias
;1/2, MAIN OSC.
;Enable Interrupts
KEYONF,EXE1
KEYDECODE
KEYONF
;TEST IF KEY IS PRESSED
;CLEAR KEY FLAG
EXE1:
BBC
F20MS,NEXT1
CLR1
F20MS
;
;*****EVERY 20MS*****
;
CALL
MODEEXE
CALL
MODE1EXE
CALL
MODE3EXE
CALL
LCDDGT
CALL
LCDDOT
CALL
ADCEXE
CALL
LKEYSCAN
;SETTING DISPLAY MEMORY
;DURING CLOCK,
;7-Segments Display
;Dot Display
;ADC execution
NEXT1:
BBC
F200MS,ELOOP
CLR1
F200MS
;
;*****EVERY 200MS*****
;
CALL
WIND
ELOOP:
BBS
F_ON,EXE2
CLR1
R0.7
CLR1
R0.6
CLR1
R0.5
CLR1
R0.4
STOP
NOP
NOP
IF
[F_1MIN]
CLR1
F_1MIN
CALL
MODEEXE
CALL
LCDDGT
CALL
LCDDOT
ENDIF
CALL
LKEYSCAN
;FOR
;FOR
;FOR
;FOR
WAKE-UP
WAKE-UP
WAKE-UP
WAKE-UP
BY
BY
BY
BY
NEXT
NEXT
NEXT
NEXT
KEY
KEY
KEY
KEY
;7-Segments Display
;Dot Display
EXE2:
JMP
LOOP
;
;**************************************************************************
;
TIMER0,INTERRUPT ROUTINE(2ms)
*
;**************************************************************************
;
TIMER0:
R_SAVE
;Save Registers to Stacks
CLRG
CALL
MAKE10MS
;SET every 10ms
R_RSTR
;Restore Registers from Stacks
RETI
;
;**************************************************************************
;
TIMER1
*
;**************************************************************************
;
TIMER1:
R_SAVE
CLRG
R_RSTR
xiii
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
RETI
;
;**************************************************************************
;
WATCH TIMER 4Hz
*
;**************************************************************************
;
WTIMER:
R_SAVE
CLRG
NOT1
R0.0
INC
LDA
CMP
BNE
LDM
SET1
CALL
WT5:
HZCNT
HZCNT
#120
WT5
HZCNT,#0
F_1MIN
INC1MIN
R_RSTR
RETI
;
;**************************************************************************
;
PORT INTERRUPT
*
;**************************************************************************
;
INT_KEY:
R_SAVE
CLRG
BBS
CHATFL.7,IK8
BBS
F_ON,IK8
LDX
#3
LDM
KSMR,#0
;MAKE R10 TO BE NORMAL INPUT
WW:
WW2:
WW3:
IK8:
LDY
LDA
DEC
BNE
DEC
BNE
#2
#8
A
WW3
Y
WW2
;24ms wait
LDA
ROR
BCS
DEC
BNE
R1
A
IK8
X
WW
;READ R10
LDM
SET1
SET1
LDM
LDM
R_RSTR
RETI
SCMR,#0
F_ON
CHATFL.7
OLDKY,#0CH
KSMR,#1
;MAIN OSC.
;
;**************************************************************************
;
EXTERNAL INTERRUPT 0
*
;**************************************************************************
;
INT0:
R_SAVE
CLRG
R_RSTR
RETI
;
;**************************************************************************
;
EXTERNAL INTERRUPT 1
*
;**************************************************************************
;
INT1:
CLRG
RETI
;
;**************************************************************************
;
ADC INTERRUPT
*
;**************************************************************************
;
INT_AD:
RETI
;
;***********************************************************************
APR. 2001 Ver 2.01
xiv
GMS81C71XX LCD MCU APPENDIX
; Subject:
LCDDGT
;
LCD 7-SEG. DIGIT DISPLAY (TMEP,LTIME,RTIME
*
;***********************************************************************
; Entry:
DGTCNT (DIGIT COUNTER)
*
;
X (START ADDRESS)
*
; Output:
Output SEG_PORT (SEG0~SEG23)
*
;
Output COM_PORT (COM0~COM3)
*
;***********************************************************************
; EXAMPLE)
_ _
_ _
_ _
_ _
*
; DGTCNT=9
|
| |
|
|
| |
|
*
; X=LMINUTE
|---| |---|
|---| |---|
*
;
|___| |___|
|___| |___|
*
;
LMINUTE+1
LMINUTE
*
;***********************************************************************
;
LCDDGT: LDM
DGTCNT,#9
LDX
#DISPRAM
GOLCD:
LDA
{X}
PUSH
X
if [DGTCNT.0]
;WHEN DIGIT IS EVEN NUMBER,
AND
#0F0H
;WHEN DIGIT IS ODD NUMBER,
XCN
CALL
LCDDSP
;HIGHER 4 NIBBLE IS DISPLAYED
POP
X
else
AND
#0FH
;LOWER 4 NIBBLE IS DISPLAYED
CALL
LCDDSP
POP
X
INC
X
endif
DEC
DGTCNT
BPL
GOLCD
RET
;
;********* ONE DIGIT DISPLAY **********
;
LCDDSP:
TAY
;
;****** ZERO SURPRESS TO BLANK ******
;
BNE
GOCONT
;IF A=0 THEN SURPRESS
LDA
DGTCNT
CMP
#9
BEQ
BLNK
CMP
#7
BEQ
BLNK
CMP
#3
BEQ
BLNK
BRA
GOCONT
BLNK:
LDY
#0AH
;
GOCONT:
LDA
!FONT+Y
;LOAD FONT DATA
STA
TEMP0
;STORE 7-SEG FONT
LDM
TEMP2,#7
;SHIFT COUNTER INITIALIZE
LDY
DGTCNT
;GET OFFSET LCD ADDRESS FOR DGTCNT
LDA
#14
MUL
TAY
DPL1:
LDA
!FONTD0+Y
;GET LCD RAM ADDRESS
TAX
;STORE LCD RAM ADDRESS
INC
Y
;INCREMENT POINTER
LDA
!FONTD0+Y
;GET BIT POSITION
STA
TEMP1
;STORE BIT POSITION
ROR
TEMP0
BCS
DPL3
LDA
#0FFH
;CLEAR BIT DISPLAY RAM
ROL
A
DEC
TEMP1
BPL
$-3
SETG
AND
{X}
BRA
DPL5
DPL3:
LDA
#00H
;SET BIT DISPLAY RAM
ROL
A
DEC
TEMP1
BPL
$-3
SETG
OR
{X}
DPL5:
STA
{X}
xv
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
CLRG
INC
DBNE
RET
Y
TEMP2,DPL1
FONTD0
DB
13H,1H,13H,2H,13H,0H,13H,3H,0CH,3H,0CH,2H,0CH,0H
;RMINUTE0
FONTD1
DB
12H,1H,12H,2H,12H,0H,12H,3H,05H,3H,05H,2H,05H,0H
;RMINUTE1
FONTD2
DB
06H,1H,06H,2H,06H,0H,06H,3H,01H,3H,01H,2H,01H,0H
;RHOUR0
FONTD3
DB
80H,0H,01H,1H,01H,1H,80H,0H,80H,0H,80H,0H,80H,0H
;RHOUR1
FONTD4
DB
02H,1H,02H,2H,02H,0H,02H,3H,15H,3H,15H,2H,15H,0H
;LMINUTE0
FONTD5
DB
09H,1H,15H,1H,09H,0H,09H,3H,16H,0H,16H,1H,09H,2H
;LMINUTE1
FONTD6
DB
14H,1H,14H,2H,14H,0H,14H,3H,00H,3H,00H,2H,00H,0H
;LHOUR0
FONTD7
DB
80H,0H,08H,2H,08H,2H,80H,0H,80H,0H,80H,0H,80H,0H
;LHOUR1
FONTD8
DB
0BH,2H,0BH,0H,0BH,3H,0BH,1H,17H,1H,17H,0H,17H,3H
;ONDO0
FONTD9
DB
0FH,2H,0FH,0H,0FH,3H,0FH,1H,10H,1H,10H,0H,10H,3H
;ONDO1
;
;**************************************************************************
;
7-SEGMENT PATTERN DATA
*
;
_a_
*
;
f | g |b
*
;
|---|
*
;
e |___|c
*
;
d
.h
*
;**************************************************************************
;
Segment:
FONT
_LCOLON
_RCOLON
_ONDO
_C
_RAM
_RPM
_LAM
_LPM
_OUTSIDE
_INSIDE
_S1
_SNOW
_SAVE
;
LCDDOT:
hgfe dcba
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
0011_1111B
0000_0110B
0101_1011B
0100_1111B
0110_0110B
0110_1101B
0111_1101B
0000_0111B
0111_1111B
0110_1111B
0000_0000B
0100_0000B
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
EQU
2,116H
2,10EH
2,107H
0,111H
1,10EH
0,10EH
1,108H
3,108H
1,104H
0,107H
2,10AH
3,10AH
3,104H
SETC
STC
STC
STC
STC
_LCOLON
_S1
_ONDO
_C
LDCB
STC
LDCB
STC
F_ON
_SAVE
DUAL_T
_RCOLON
LDC
STC
LDCB
STC
IF
ldc
stc
ldcb
stc
ELSE
LDCB
STC
To be displayed Digit Number
;
;
;
;
;
;
;
;
;
;
;
;
0
1
2
3
4
5
6
7
8
9
A
B
"0"
"8"
"9"
"BLANK"
"BAR"
LPM
_LPM
LPM
_LAM
[DUAL_T]==0
RPM
_RPM
RPM
_RAM
DUAL_T
_RPM
APR. 2001 Ver 2.01
;AM,PM SETTING
;TURN OFF THE AM, PM
xvi
GMS81C71XX LCD MCU APPENDIX
STC
ENDIF
_RAM
LDC
STC
LDCB
STC
OUTSIDE
_OUTSIDE
OUTSIDE
_INSIDE
RET
;
;***********************************************
; Subject:
ANY
EXECUTION
*
;***********************************************
; DESCRIPTION: EVERY 20MS
*
;
*
;***********************************************
;
MODEEXE:
IF
[OUTSIDE]
LDX
#0
ELSE
LDX
#1
ENDIF
LDA
STA
LDA
STA
ONDO+X
DISPRAM
SIGN+X
DISPSIGN
IF
;COPY ONDO DATA TO DISPRAM
[DISPSIGN.0]
[DISPRAM] < #10
LDA
#0B0H
OR
DISPRAM
STA
DISPRAM
CLRC
STC
_SNOW
ELSE
SETC
STC
_SNOW
ENDIF
ELSE
CLRC
STC
_SNOW
ENDIF
;IF MINUS ONDO, THEN "-" DISPLAY
LDX
LDA
STA
DEC
BPL
#3
LHOUR+X
DISPRAM1+X
X
MX1
;MOVE TIME_BUF. TO DISP_BUF.
BBC
LDA
STA
DUAL_T,MX2
#0AAH
DISPRAM1+2
;IF SINGLE TEMP. MODE, SKIP
;MAKE ERASE DISP BUF. WITCH
;WILL BE DISPLAYED TEMP.
IF
MX1:
IF
LDX
ELSE
LDX
ENDIF
[OUTSIDE]
#1
#0
LDA
STA
ONDO+X
DISPRAM1+3
LDA
ROR
SIGN+X
A
IF
C
[DISPRAM1+3] < #10
LDA
#0B0H
OR
DISPRAM1+3
STA
DISPRAM1+3
ELSE
LDM
DISPRAM1+2,#0ABH
ENDIF
ELSE
IF
[DISPRAM1+3] < #10
LDA
#0A0H
OR
DISPRAM1+3
STA
DISPRAM1+3
ENDIF
;IF DUAL TEMP. MODE
;IF MAIN=OUSIDE, THEN SELECT INSIDE
;IF MAIN=INSIDE, THEN SELECT OUTSIDE
;GET BIT0 OF SIGN
;COPY SIGN TO CARRY
;IF MINUS ONDO, THEN "-" DISPLAY
IF
xvii
;EXE) BB-4
;EXE) B-14
;EXE) BB-4
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
ENDIF
MX2:
RET
;
;***********************************************
; Subject:
MODE 1 EXECUTION
*
;***********************************************
; DESCRIPTION: CLOCK SET
*
;
*
;***********************************************
;
MODE1EXE: LDA
MODE
AND
#0F0H
CMP
#10H
;IF MODE=1x
BNE
MB3
LDX
#3
MB1:
LDA
TIMESET+X
;TIMESET BUF. COPIED TO DISP BUF.
STA
DISPRAM1+X
;4BYTE & 2 BIT
DEC
X
BPL
MB1
LDC
TSLPM
STC
LPM
LDC
TSRPM
STC
RPM
;
LDA
MODE
CMP
#10H
;TEST IF LEFT TIME SET MODE ?
BEQ
MO10
CMP
#11H
BEQ
MO11
;TEST IF RIGHT TIME SET MODE ?
BRA
MB3
MO10:
MB3:
MO11:
LDA
CMP
BCS
LDA
STA
STA
RET
BLINKCNT
#125
MB3
#0AAH
DISPRAM1
DISPRAM1+1
LDA
CMP
BCS
LDA
STA
STA
BRA
BLINKCNT
#125
MB3
#0AAH
DISPRAM1+2
DISPRAM1+3
MB3
;IF LESS THAN 124, OFF
;IF LESS THAN 124, OFF
;
;***********************************************
; Subject:
MODE 3 EXECUTION
*
;***********************************************
; DESCRIPTION: All pin goes low and high
*
; repeatly every 20ms, rectangle wave output
*
;
*
;***********************************************
;
MODE3EXE: LDA
MODE
CMP
#3
BNE
MO2
LDA
SUBMODE
DEC
A
;BECAUSE INITIAL NO.=1
ROL
A
;EIGHT TIMES
ROL
A
ROL
A
NOT1
TOGMO3
BBC
TOGMO3,MO1
CLRC
ADC
#4
;ADD OFFSET
MO1:
TAY
LDA
!PPORT+Y
AND
#0001_1111B
OR
R0BUF
STA
R0BUF
STA
R0
LDA
!PPORT+1+Y
STA
R1
LDA
!PPORT+2+Y
STA
R2
APR. 2001 Ver 2.01
xviii
GMS81C71XX LCD MCU APPENDIX
MO2:
PPORT
LDA
STA
RET
!PPORT+3+Y
R3
DB
DB
00H,00H,00H,00H
00H,00H,00H,00H
DB
DB
0FFH,0FFH,0FFH,0FFH
0FFH,0FFH,0FFH,0FFH
DB
DB
00H,00H,00H,00H
0FFH,0FFH,0FFH,0FFH
DB
DB
00H,00H,00H,00H
0FFH,00H,0FFH,00H
DB
DB
00H,0FFH,00H,0FFH
00H,00H,00H,00H
DB
DB
00H,0FFH,00H,0FFH
0FFH,00H,0FFH,00H
DB
DB
55H,55H,55H,55H
0AAH,0AAH,0AAH,0AAH
;
;***********************************************
; Subject:
Set falg at every 20ms
*
;***********************************************
;
MAKE10MS: SETC
LDA
#0
ADC
BSCTIME
DAA
STA
BSCTIME
BNE
$+4
SET1
F200MS
;SET F200MS EVERY 200ms
AND
#0FH
BNE
$+4
SET1
F20MS
;SET F20MS EVERY 20ms
;
INC
BLINKCNT
;USED IN MODE0(CLOCK SET)
LDA
BLINKCNT
CMP
#250
BNE
MZ1
LDM
BLINKCNT,#0
MZ1:
RET
;
;***********************************************
; Subject:
Analog to Digital Conversion
*
;***********************************************
; It is called in main routine every 20ms
ADCNT
DS
2
ADR_AVR
DS
2
ADTTL
DS
4
ADFLAG
DS
1
AD_CH
EQU
0,ADFLAG
SIGN
DS
2
DIVISOR
EQU
250
;
;
:-------: :-------:
;
:ADR_AVR: :ADR_AVR:
;
:
: :
:
;
:OUTSIDE: :INSIDE :
;
:CH4
: :CH5
:
;
:-------: :-------:
;
ADCEXE:
IF
[AD_CH]== 0
LDM
ADCM,#52H
;AD START CH4
LDX
#0
;SET TO 0 INDEX POINTER
ELSE
LDM
ADCM,#56H
;AD START CH5
LDX
#1
;SET TO 1 INDEX POINTER
ENDIF
ADWAIT:
xix
LDY
DEC
BBS
CMPY
BNE
#20
Y
ADCM.0,GOGET
#0
ADWAIT
;WAIT ADC END
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
GOGET:
CLRC
LDA
ADR
ADC
ADTTL+X
STA
ADTTL+X
LDA
#0
ADC
ADTTL+2+X
STA
ADTTL+2+X
;
INC
ADCNT+X
LDA
ADCNT+X
IF A == #DIVISOR
LDA
#0
STA
ADCNT+X
LDY
ADTTL+2+X
LDA
ADTTL+X
PUSH
X
LDX
#DIVISOR
DIV
POP
X
STA
ADR_AVR+X
LDA
#0
STA
ADTTL+X
STA
ADTTL+2+X
LDA
IF
LDA
ENDIF
IF
LDA
ENDIF
CMP
ROL
SETC
SBC
TAY
LDA
STA
ENDIF
ADCQUIT:
;
;
ADTABLE
ADTABLE1
ADR_AVR+X
A < #65
#65
;UP8
LO8
;ADTTL2|ADTTL0 = CH4 DATA
;ADTTL3|ADTTL1 = CH5 DATA
;GET AVERAGE VALUE
;DIVIDE BY DIVISOR
;CLEAR SUM BUF.
;IGNORE BELOW 65
A > #240
#240
;MAX. 240
#181
SIGN+X
;MAKE SIGN
;COPY TO MINUS OR PLUS
#65
!ADTABLE1+Y
ONDO+X
NOT1
RET
AD_CH
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
50H,49H,49H,48H,48H,47H
47H,46H,46H,45H,45H,44H,44H,43H,43H,42H
41H,41H,40H,40H,40H,39H,39H,38H,38H,37H
37H,36H,36H,35H,35H,34H,34H,33H,33H,32H
32H,31H,31H,30H,30H,30H,29H,29H,28H,28H
27H,27H,26H,26H,25H,25H,24H,24H,24H,23H
23H,22H,22H,22H,21H,21H,20H,20H,20H,20H
19H,19H,18H,18H,17H,17H,16H,16H,15H,15H
15H,14H,14H,14H,13H,13H,13H,12H,12H,12H
11H,11H,11H,10H,10H,10H,09H,09H,09H,08H
08H,07H,07H,07H,06H,05H,05H,04H,04H,04H
03H,03H,02H,02H,01H,01H,00H,00H,00H,01H
01H,02H,02H,03H,03H,04H,04H,05H,05H,06H
06H,07H,07H,08H,08H,09H,09H,10H,10H,11H
11H,12H,12H,13H,13H,14H,15H,15H,16H,17H
17H,18H,18H,19H,19H,20H,20H,21H,21H,22H
23H,23H,24H,24H,25H,25H,26H,27H,28H,29H
30H,31H,32H,33H,34H,35H,36H,37H,38H,39H
40H,41H,42H
50H,50H,50H,49H,49H,48H
48H,47H,47H,46H,46H,45H,45H,44H,44H,43H
43H,42H,41H,40H,39H,38H,37H,36H,35H,34H
35H,35H,34H,34H,33H,33H,32H,32H,31H,31H
30H,30H,29H,29H,28H,28H,27H,27H,26H,26H
26H,25H,25H,25H,24H,24H,24H,23H,23H,23H
22H,22H,22H,21H,21H,21H,20H,20H,20H,20H
19H,18H,18H,18H,17H,17H,17H,16H,16H,16H
15H,15H,15H,14H,14H,14H,13H,13H,13H,12H
12H,11H,11H,10H,10H,09H,09H,09H,08H,08H
07H,07H,06H,06H,05H,05H,04H,04H,04H,03H
03H,03H,02H,02H,02H,01H,01H,01H,00H,00H
01H,01h,02H,02H,03H,03H,04H,04H,05H,05H
06H,06H,07H,07H,08H,08H,09H,09H,10H,10H
11H,11H,12H,12H,13H,13H,14H,15H,15H,16H
16H,16H,17H,18H,18H,19H,19H,20H,20H,21H
APR. 2001 Ver 2.01
; 65~ 70
; 71~ 80
; 81~ 90
; 91~100
;101~110
;111~120
;121~130
;131~140
;141~150
;151~160
;161~170
;171~180
;181~190
;191~200
;201~210
;211~220
;221~230
;231~240
; 65~ 70
; 71~ 80
; 81~ 90
; 91~100
;101~110
;111~120
;121~130
;131~140
;141~150
;151~160
;161~170
;171~180
;181~190
;191~200
;201~210
;211~220
65->+50’C
83->+40'C
105->+30'C
129->+20'C
154->+10'C
178->
0'C
199->-10'C
217->-20'C
231->-30'C
65->+50’C
83->+40'C
105->+30'C
129->+20'C
154->+10'C
178->
0'C
199->-10'C
217->-20'C
xx
GMS81C71XX LCD MCU APPENDIX
DB
DB
DB
21H,22H,23H,23H,24H,24H,25H,25H,26H,27H ;221~230
28H,29H,30H,31H,32H,33H,34H,35H,36H,37H ;231~240 231->-30'C
38H,39H,40H
;
;***********************************************
; Subject:
KEYDECODE
*
;***********************************************
;
*
;***********************************************
;
REPEAT
EQU
#1000_0000B
CLOCK
EQU
#0100_0000B
PWRON
EQU
#0000_0001B
KEYDECODE: LDA
LDY
MUL
TAY
LDA
STA
LDA
STA
LDA
STA
CALL
BCC
JMP
;
KEY:
DW
DB
DW
DB
DW
DB
DW
DB
DW
DB
DW
DB
DW
DB
DW
DB
DW
DB
DW
DB
DW
DB
DW
DB
DW
DB
DW
DB
DW
DB
DW
DB
DW
DB
DW
DB
DW
DB
QUIT:
NOKEY:
RET
KEYDT
#3
CONDICHK:
TEMP2
STATUS
TEMP2
CDC9
CDC10
CDC9:
CDC10:
LDA
OR
SBC
BEQ
BCS
SETC
RET
CLRC
RET
!KEY+Y
TEMP0
!KEY+1+Y
TEMP1
!KEY+2+Y
TEMP2
CONDICHK
QUIT
[TEMP0]
NOKEY
0
NOKEY
0
NOKEY
0
NOKEY
0
NOKEY
0
NOKEY
0
NOKEY
0
DOWNKEY
PWRON+REPEAT
NOKEY
0
DUALKEY
PWRON
SWAPKEY
PWRON
NOKEY
0
POWERKEY
PWRON
CLOCKKEY
PWRON+CLOCK
HOURKEY
PWRON+REPEAT+CLOCK
MINUTEKEY
PWRON+REPEAT+CLOCK
NOKEY
0
UPKEY
PWRON+REPEAT
NOKEY
0
;0
;1
;2
;3
;4
;5
;6
;7
;8
;9
;A
;B
;C
;D
;E
;F
;10
;11
;12
;PASS
;SKIP
;
xxi
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
;***********************************************************
;
DISPLAY SWAP KEY (TEMP. DISPLAY SWAP)
*
;***********************************************************
;
SWAPKEY:
NOT1
OUTSIDE
RET
;
;***********************************************************
;
DUAL KEY
*
;***********************************************************
;
DUALKEY:
NOT1
DUAL_T
RET
;
;***********************************************************
;
POWER KEY
*
;***********************************************************
;
POWERKEY: CLR1
F_ON
IF
[F_ON]
ELSE
LDM
SCMR,#2
CLR1
DUAL_T
LDM
MODE,#0
SET1
F20MS
ENDIF
RET
;
;***********************************************************
;
CLOCK KEY
*
;***********************************************************
;
CLOCKKEY: SET1 F_CLOCK
LDM
BLINKCNT,#0
LDA
MODE
; 10->11
CMP
#10H
; 11->00
BNE
CL1
; ETC. -> 10
LDM
MODE,#11H
BRA
QUIT
CL1:
CMP
#11H
BNE
CL2
LDM
MODE,#0
CLR1 F_CLOCK
CALL SETTO_CNT
LDC
TSLPM
STC
LPM
LDC
TSRPM
STC
RPM
LDM
HZCNT,#0
CLR1 F_1MIN
BRA
CLQ
CL2:
LDM
CLR1
CALL
LDC
STC
LDC
STC
RET
MODE,#10H
DUAL_T
CNTTO_SET
LPM
TSLPM
RPM
TSRPM
CLQ:
;
SETTO_CNT: LDX
#3
CL11:
LDA
TIMESET+X
STA
LHOUR+X
DEC
X
BPL
CL11
RET
;
CNTTO_SET: LDX
#3
CL3:
LDA
LHOUR+X
STA
TIMESET+X
DEC
X
BPL
CL3
RET
;
;***********************************************************
;
HOUR/MINUTE KEY
*
;***********************************************************
;
HOURKEY:
LDA
MODE
APR. 2001 Ver 2.01
xxii
GMS81C71XX LCD MCU APPENDIX
HO1:
HO2:
AND
#0F0H
CMP
#10H
BNE
HO1
LDM
BLINKCNT,#125
LDA
MODE
CMP
#10H
BNE
HO2
SETC
LDA
#0
ADC
TIMESET
DAA
IF
A==#12H
NOT1 TSLPM
ENDIF
IF
A==#13H
LDA
#1
ENDIF
STA
TIMESET
RET
CMP
#11H
BNE
HO1
SETC
LDA
#0
ADC
TIMESET+2
DAA
IF
A==#12H
NOT1 TSRPM
ENDIF
IF
A==#13H
LDA
#1
ENDIF
STA
TIMESET+2
BRA
HO1
MINUTEKEY: LDA
AND
CMP
BNE
MT1:
LDM
LDX
LDA
CMP
BNE
LDX
SETC
LDA
ADC
DAA
CMP
BNE
LDA
STA
RET
;IF MODE=10H, THEN LEFT TIME SET
;INC. LEFT HOUR 1UP
;ADJUST AM,PM FLAG
;INC. RIGHT HOUR 1UP
;ADJUST AM,PM FLAG
MODE
#0F0H
#10H
MT3
BLINKCNT,#125
#3
MODE
#10H
MT1
#1
#0
TIMESET+X
#60H
MT2
#0
TIMESET+X
MT2:
MT3:
;
;***********************************************
;
UP /DOWN KEY
*
;***********************************************
;
UPKEY:
BBS
PERIOD,PRU
LDA
PWM1HR
AND
#0000_0011B
CMP
#3
BNE
UPK1
LDA
T3PDR
CMP
#0FFH
BNE
UPK1
UPK0:
RET
UPK1:
INC
BNE
INC
BRA
T3PDR
UPK0
PWM1HR
UPK0
BBS
LDA
AND
CMP
PERIOD,PRD
PWM1HR
#0000_0011B
#0
PRU:
DOWNKEY:
xxiii
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
DNK1:
DNK2:
BNE
LDA
CMP
BEQ
DEC
LDA
CMP
BNE
DEC
RET
DNK1
T3PDR
#0
UPK0
T3PDR
T3PDR
#0FFH
DNK2
PWM1HR
PRD:
PWMMODE:
;
;***********************************************************
;
PLUS KEY
*
;
*
; When MODE=3, PRESS PULS KEY, SUBMODE IS INCRESED
*
; When MODE=3, PRESS MINUS KEY, SUBMODE IS DECRESED
*
;
*
;***********************************************************
;
;
;***********************************************
; Subject:
KEYSCAN
*
;***********************************************
; STROBE OUT: R05,R06,R07
*
; READ PORT : R20,R21,R22,R23
*
;
*
;***********************************************
;
LKEYSCAN: BBS
KEYONF,KS7
LDM
KEYNM,#1
LDM
TOTLKY,#0
LDM
NEWKY,#0
LDY
#3
;INITIALIZE STROBE LINE
KS1:
CMPY
#3
BNE
$+4
CLR1
R0.4
;OUTPUT STROBE SIGNAL
CMPY
#2
BNE
$+4
CLR1
R0.5
;OUTPUT STROBE SIGNAL
CMPY
#1
BNE
$+4
CLR1
R0.6
;OUTPUT STROBE SIGNAL
CMPY
#0
BNE
$+4
CLR1
R0.7
;OUTPUT STROBE SIGNAL
;
NOP
NOP
LDA
R2
STA
PORTDT
;READ KEY IN PORT
AND
#0FH
CMP
#0FH
;IF KEY IS PRESSED ?
BNE
KS2
CLRC
;KEYNM + 4 -> KEYNM
LDA
#4
ADC
KEYNM
STA
KEYNM
BRA
KS5
;
KS2:
LDX
#3
;INITIALIZE SHIFT COUNTER
KS3:
ROR
PORTDT
BCS
KS4
INC
TOTLKY
;IF TOTLKY IS ABOVE 2, THEN QUIT
LDA
TOTLKY
CMP
#20
BEQ
KS7
LDA
KEYNM
;KEYNM -> NEWKY
STA
NEWKY
KS4:
INC
KEYNM
DEC
X
BPL
KS3
KS5:
SET1
R0.4
SET1
R0.5
APR. 2001 Ver 2.01
xxiv
GMS81C71XX LCD MCU APPENDIX
KS6:
KS7:
KS8:
KS81:
KS9:
KS10:
KS11:
SET1
SET1
DEC
BPL
LDA
CMP
BNE
LDA
STA
LDM
CLR1
CLR1
CLR1
RET
LDA
CMP
BNE
BBS
LDA
AND
CMP
BCC
LDA
STA
SET1
LDM
SET1
BRA
INC
BRA
R0.6
R0.7
Y
KS1
NEWKY
#0
KS8
NEWKY
OLDKY
CHATFL,#0
RPTKEY
ACTKEY
RPTEN
LDA
AND
BBS
CMP
BCC
SET1
BRA
CMP
BCC
BBC
SET1
BRA
CHATFL
#0111_1111B
RPTEN,KS11
#25
KS9
RPTEN
KS81
#3
KS9
ACTKEY,KS7
RPTKEY
KS81
NEWKY
OLDKY
KS6
CHATFL.7,KS10
CHATFL
#0111_1111B
#5
KS9
NEWKY
KEYDT
ACTKEY
CHATFL,#80H
KEYONF
KS7
CHATFL
KS7
;TEST NEXT LINE
;WHEN NO KEY IS PRESSED,
;INITIALIZE NEWKY,OLDKY,CHATFL
;SET1 CHATFL.7 & SET TO 0
;REPEAT KEY
;
;***********************************************
; Subject:
Increase 1 minute
*
;***********************************************
;
INC1MIN:
LDX
#LMINUTE
CALL
MIN1UP
LDX
#RMINUTE
CALL
MIN1UP
RET
;
MIN1UP:
SETC
LDA
#0
; LMINUTE <- LMINUTE + 1
ADC
{X}
DAA
IF
A ==#60H
SETC
LDA
#0
ENDIF
STA
{X}
BCC
INC1
DEC
X
LDA
#0
ADC
{X}
DAA
IF
A==#12H
IF X==#LHOUR
NOT1
LPM
ELSE
NOT1
RPM
ENDIF
ENDIF
IF
A==#13H
LDA
#1
ENDIF
STA
{X}
INC1:
RET
xxv
APR. 2001 Ver 2.01
GMS81C71XX LCD MCU APPENDIX
;
;***********************************************
; Subject:
WIND DISPLAY
*
;***********************************************
;
WIND:
LDA
TEMPCNT
CLRC
STC
10DH.0
STC
10DH.1
STC
10DH.2
STC
10DH.3
CMP
#0
BEQ
LLL3
CMP
#1
BEQ
LLL2
CMP
#2
BEQ
LLL1
CMP
#3
BEQ
LLL0
CMP
#4
BEQ
LLL1
CMP
#5
BEQ
LLL2
CMP
#6
BEQ
LLL3
CMP
#7
BEQ
LLL4
LLL0:
STC
10DH.1
LLL1:
STC
10DH.2
LLL2:
STC
10DH.3
LLL3:
STC
10DH.0
LLL4:
STC
111H.1
INC
TEMPCNT
IF
[TEMPCNT]==#8
LDM
TEMPCNT,#0
ENDIF
RET
;
;
;**************************************************************************
;
NOT_USED: nop
;Discard Unexpected Interrupts
reti
;
END
;Notice Program End
APR. 2001 Ver 2.01
xxvi
Similar pages