Hynix GMS81524BK Hyundai micro electronics 8-bit single-chip microcontroller Datasheet

HYUNDAI MICRO ELECTRONICS
8-BIT SINGLE-CHIP MICROCONTROLLERS
GMS81508B
GMS81516B
GMS81524B
User’s Manual (Ver. 1.04)
+<81'$,
MicroElectronics
Semiconductor Group of Hyundai Electronics Industrial Co., Ltd.
Version 1.04
Published by
MCU Application Team
1999 HYUNDAI Micro Electronics All right reserved.
Additional information of this manual may be served by HYUNDAI Micro Electronics offices in Korea or Distributors and
Representatives listed at address directory.
HYUNDAI Micro Electronics reserves the right to make changes to any information here in at any time without notice.
The information, diagrams and other data in this manual are correct and reliable; however, HYUNDAI Micro Electronics is
in no way responsible for any violations of patents or other rights of the third party generated by the use of this manual.
HYUNDAI MicroElectronics
GMS81508B/16B/24B
Table of Contents
1. OVERVIEW............................................1
Transmission/Receiving Timing ...................... 50
The Serial I/O operation by SRDY pin ............ 50
The method of Serial I/O ................................. 51
The Method to Test Correct Transmission ...... 51
Description .........................................................1
Features .............................................................1
Development Tools ............................................2
Ordering Information ..........................................2
14. PWM OUTPUT ..................................52
2. BLOCK DIAGRAM .................................3
15. BUZZER FUNCTION .........................55
3. PIN ASSIGNMENT ................................4
16. INTERRUPTS ....................................57
4. PACKAGE DIAGRAM ............................6
6. PORT STRUCTURES..........................10
Interrupt Sequence .......................................... 59
BRK Interrupt .................................................. 60
Multi Interrupt .................................................. 61
External Interrupt ............................................. 61
7. ELECTRICAL CHARACTERISTICS ....12
17. WATCHDOG TIMER .........................64
Absolute Maximum Ratings .............................12
Recommended Operating Conditions ..............12
A/D Converter Characteristics .........................12
DC Electrical Characteristics ...........................13
AC Characteristics ...........................................14
Serial Interface Timing Characteristics ............15
Typical Characteristic Curves ..........................16
18. POWER DOWN OPERATION...........66
5. PIN FUNCTION......................................8
8. MEMORY ORGANIZATION.................18
Registers ..........................................................18
Program Memory .............................................21
Data Memory ...................................................24
Addressing Mode .............................................27
STOP Mode .................................................... 66
Minimizing Current Consumption .................... 67
19. OSCILLATOR CIRCUIT.....................69
20. RESET ...............................................70
External Reset Input ........................................ 70
Watchdog Timer Reset ................................... 70
21. POWER FAIL PROCESSOR.............71
22. OTP PROGRAMMING.......................73
9. I/O PORTS ...........................................31
How to Program .............................................. 73
Pin Function .................................................... 73
Programming Specification ............................. 76
10. BASIC INTERVAL TIMER..................34
A. CONTROL REGISTER LIST .................. i
11. TIMER/EVENT COUNTER ................36
B. SOFTWARE EXAMPLE ....................... iii
8-bit Timer / Counter Mode ..............................38
16-bit Timer / Counter Mode ............................42
8-bit Capture Mode ..........................................43
16-bit Capture Mode ........................................44
7-segment LED display .................................... iii
C. INSTRUCTION....................................viii
12. ANALOG DIGITAL CONVERTER......46
Terminology List .............................................. viii
Instruction Map ..................................................ix
Instruction Set ....................................................x
13. SERIAL COMMUNICATION ..............48
D. MASK ORDER SHEET ...................... xvi
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
GMS81508B/16B/24B
CMOS SINGLE-CHIP 8-BIT MICROCONTROLLER
WITH A/D CONVERTER
1. OVERVIEW
1.1 Description
The GMS81508B/16B/24B are advanced CMOS 8-bit microcontrollers with 8K/16K/24K bytes of ROM. The device is one
of GMS800 family. This device using the GMS800 family CPU includes several peripheral functions such as Timer, A/D
converter, Programmable buzzer driver, Serial I/O communication, Pulse Width Modulation function, etc. The RAM, ROM,
and I/O are placed on the same memory map in addition to simple instruction set.
The GMS815xxB is functionally 100% compatible with earier GMS81508/16 or GMS81508A/16A, however better characteristics have such as strong EMS, wide operating voltage, temperature, frequency and fast programming time for the OTP.
Device name
ROM Size
RAM Size
OTP
GMS81508B
8K bytes
448 bytes
GMS81516BT
GMS81516B
16K bytes
448 bytes
GMS81516BT
GMS81524B
24K bytes
448 bytes
GMS81524BT
Package
64SDIP, 64MQFP,
64LQFP
1.2 Features
• 8K/16K/24K Bytes On-chip Program Memory
• 52 I/O Ports, 4 Input Ports
• 448 Bytes of On-chip Data RAM
(Included stack memory)
• Twelve Interrupt sources
- Basic Interval Timer: 1
- External input: 4
- Timer/Event counter: 4
- ADC: 1
- Serial Interface: 1
- WDT: 1
• Minimum Instruction Execution Time
0.5µ
µs at 8MHz
• One 8-bit Basic Interval Timer
• Four 8-bit Timer/Event counter
or Two 16-bit Timer/Event counter
• One 6-bit Watchdog timer
• Eight channel 8-bit A/D converter
• Two channel 8-bit PWM
• One 8-bit Serial Communication Interface
• Four External Interrupt input ports
• Buzzer Driving port
- 500Hz ~ 250kHz@8MHz
• Built in Noise Immunity Circuit
- Noise filter
- Power fail processor
• Power Down Mode
- STOP mode
• 2.2V to 5.5V Wide Operating Range
• 1~10MHz Wide Operating Frequency
• 64SDIP, 64MQFP, 64LQFP package types
• Available 16K, 24K bytes OTP version
DEC. 1999 Ver 1.04
1
GMS81508B/16B/24B
HYUNDAI MicroElectronics
1.3 Development Tools
The GMS815xxB are supported by a full-featured macro
assembler, an in-circuit emulator CHOICE-Jr.TM and OTP
programmers. There are third different type programmers
such as emulator add-on board type, single type, gang
type. For mode detail, Refer to “22. OTP PROGRAMMING” on page 73. Macro assembler operates under the
MS-Windows 95/98TM.
Please contact sales part of Hyundai MicroElectronics.
1.4 Ordering Information
Device name
ROM Size
RAM size
Package
Mask version
GMS81508B K
GMS81508B Q
GMS81508B LQ
GMS81516B K
GMS81516B Q
GMS81516B LQ
GMS81524B K
GMS81524B Q
GMS81524B LQ
8K bytes
8K bytes
8K bytes
16K bytes
16K bytes
16K bytes
24K bytes
24K bytes
24K bytes
448 bytes
448 bytes
448 bytes
448 bytes
448 bytes
448 bytes
448 bytes
448 bytes
448 bytes
64SDIP
64MQFP
64LQFP
64SDIP
64MQFP
64LQFP
64SDIP
64MQFP
64LQFP
OTP version
GMS81516BT K
GMS81516BT Q
GMS81516BT LQ
GMS81524BT K
GMS81524BT Q
GMS81524BT LQ
16K bytes OTP
16K bytes OTP
16K bytes OTP
24K bytes OTP
24K bytes OTP
24K bytes OTP
448 bytes
448 bytes
448 bytes
448 bytes
448 bytes
448 bytes
64SDIP
64MQFP
64LQFP
64SDIP
64MQFP
64LQFP
2
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
2. BLOCK DIAGRAM
AVDD
AVSS
ADC Power
Supply
PSW
R00~R07
R10~R17
R20~R27
R30~R37
R0
R1
R2
R3
A
ALU
X
Y
Stack Pointer
PC
Data Memory
(448 bytes)
Program
Memory
Interrupt Controller
Data Table
System controller
System
Clock Controller
Timing generator
8-bit Basic
Interval
Timer
Watchdog
Timer
8-bit
Timer/
Counter
8-bit serial
Interface
8-bit PWM
PC
8-bit
ADC
Clock Generator
VDD
VSS
XIN
XOUT
RESET
TEST
R4
Power
Supply
DEC. 1999 Ver 1.04
R40 / INT0
R41 / INT1
R42 / INT2
R43 / INT3
R44 / EC0
R45 / EC2
R46 / T1O
R47 / T3O
Buzzer
Driver
R5
R50 / SIN
R51 / SOUT
R52 / SCLK
R53 / SRDY
R54 / WDTO
R55 / BUZ
R56 / PWM0
R57 / PWM1
R6
R60 / AN0
R61 / AN1
R62 / AN2
R63 / AN3
R64 / AN4
R65 / AN5
R66 / AN6
R67 / AN7
3
GMS81508B/16B/24B
HYUNDAI MicroElectronics
3. PIN ASSIGNMENT
64SDIP
(Top View)
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
R30
R31
R32
R33
R34
R35
R36
R37
R00
R01
R02
R03
R04
R05
R06
R07
R10
R11
R12
R13
R14
R15
R16
R17
R20
R21
R22
R23
R24
R25
R26
R27
51
50
49
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
52
53
54
55
56
57
58
59
60
61
62
63
64
GMS81508B/16B/24B
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
R36
R35
R34
R33
R32
R31
R30
VDD
TEST
AVSS
AVDD
R67
R66
32
31
30
29
28
27
26
25
24
23
22
21
20
R22
R23
R24
R25
R26
R27
VSS
XOUT
XIN
RESET
R40
INT0
R41
INT1
R42
INT2
AN5
AN4
AN3
AN2
AN1
AN0
PWM1
PWM0
BUZ
WDTO
SRDY
SCLK
SOUT
SIN
T3O
T1O
EC2
EC0
INT3
R65
R64
R63
R62
R61
R60
R57
R56
R55
R54
R53
R52
R51
R50
R47
R46
R45
R44
R43
AN7
AN6
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
R37
R00
R01
R02
R03
R04
R05
R06
R07
R10
R11
R12
R13
R14
R15
R16
R17
R20
R21
64MQFP
(Top View)
GMS81508B/16B/24B
AN7
AN6
AN5
AN4
AN3
AN2
AN1
AN0
PWM1
PWM0
BUZ
WDTO
SRDY
SCLK
SOUT
SIN
T3O
T1O
EC2
EC0
INT3
INT2
INT1
INT0
VDD
TEST
AVSS
AVDD
R67
R66
R65
R64
R63
R62
R61
R60
R57
R56
R55
R54
R53
R52
R51
R50
R47
R46
R45
R44
R43
R42
R41
R40
RESET
XIN
XOUT
VSS
4
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
R00
R01
R02
R03
R04
R05
R06
R07
R10
R11
R12
R13
R14
R15
R16
R17
64LQFP
(Top View)
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
GMS81508B/16B/24B
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
R20
R21
R22
R23
R24
R25
R26
R27
VSS
XOUT
XIN
RESET
R40
R41
R42
R43
INT0
INT1
INT2
INT3
AN3
AN2
AN1
AN0
PWM1
PWM0
BUZ
WDTO
SRDY
SCLK
SOUT
SIN
T3O
T1O
EC2
EC0
R63
R62
R61
R60
R57
R56
R55
R54
R53
R52
R51
R50
R47
R46
R45
R44
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
AN7
AN6
AN5
AN4
R37
R36
R35
R34
R33
R32
R31
R30
VDD
TEST
AVSS
AVDD
R67
R66
R65
R64
DEC. 1999 Ver 1.04
5
GMS81508B/16B/24B
HYUNDAI MicroElectronics
4. PACKAGE DIAGRAM
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
6
1.03
0.73
0.23
0.13
0-7°
1.00 Typ.
DETAIL “A”
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
64LQFP
GMS81508B/16B/24B
12.00 Typ.
10.00 Typ.
1.45
1.35
10.00 Typ.
12.00 Typ.
UNIT: MM
0-7°
0.15
0.05
SEE DETAIL “A”
1.60 max.
0.38
0.22
DEC. 1999 Ver 1.04
0.50 Typ.
0.75
0.45
1.00
REF
DETAIL “A”
7
GMS81508B/16B/24B
HYUNDAI MicroElectronics
5. PIN FUNCTION
VDD: Supply voltage.
used as outputs or inputs.
VSS: Circuit ground.
In addition, R5 serves the functions of the various following special features.
TEST: Used for Test Mode. For normal operation, it
should be connected to VDD.
RESET: Reset the MCU.
XIN: Input to the inverting oscillator amplifier and input to
the internal main clock operating circuit.
XOUT: Output from the inverting oscillator amplifier.
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 inputs.
Port pin
R50
R51
R52
R53
R54
R55
R56
R57
Alternate function
SIN (Serial data input)
SOUT (Serial data output)
SCLK (Serial clock)
SRDY (Serial ready)
WDTO (Watchdog Timer output)
BUZ (Buzzer driver output)
PWM0 (PWM output 0)
PWM1 (PWM output 1)
R10~R17: R1 is an 8-bit CMOS bidirectional I/O port. R1
pins 1 or 0 written to the Port Direction Register can be
used as outputs or inputs.
R60~R67: 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.
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.
In addition, R6 is shared with the ADC input.
R30~R37: R3 is an 8-bit CMOS bidirectional I/O port. R3
pins 1 or 0 written to the Port Direction Register can be
used as outputs or inputs.
R40~R47: 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 inputs.
In addition, R4 serves the functions of the various following special features.
Port pin
R40
R41
R42
R43
R44
R45
R46
R47
Alternate function
INT0 (External interrupt 0)
INT1 (External interrupt 1)
INT2 (External interrupt 2)
INT3 (External interrupt 3)
EC0 (Event counter input 0)
EC2 (Event counter input 2)
T1O (Timer/Counter 1 output)
T3O (Timer/Counter 3 output)
Port pin
R60
R61
R62
R63
R64
R66
R66
R67
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)
Note: On the MDS Choice, when the MCU is RESET, R60
can not be used digital input port. For more detail, refer to
"9. I/O PORTS" on page 31.
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.
R50~R57: R5 is an 8-bit CMOS bidirectional I/O port. R5
pins 1 or 0 written to the Port Direction Register can be
8
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
Function
PIN NAME
In/Out
Basic
Alternate
VDD
-
Supply voltage
VSS
-
Circuit ground
TEST
I
Controls test mode of the chip,
For normal operation, it should be connected at VDD.
RESET
I
Reset signal input
XIN
I
Oscillation input
XOUT
O
Oscillation output
R00~R07
I/O
8-bit general I/O ports
R10~R17
I/O
8-bit general I/O ports
R20~R27
I/O
8-bit general I/O ports
R30~R37
I/O
8-bit general I/O ports
R40 (INT0)
I/O (I)
External interrupt 0 input
R41 (INT1)
I/O (I)
External interrupt 1 input
R42 (INT2)
I/O (I)
External interrupt 2 input
R43 (INT3)
I/O (I)
R44 (EC0)
I/O (I)
R45 (EC2)
I/O (I)
Timer/Counter 2 external input
R46 (T1O)
I/O (O)
Timer/Counter 1 output
R47 (T3O)
I/O (O)
Timer/Counter 3 output
R50 (SIN)
I/O (I)
Serial data input
R51 (SOUT)
I/O (O)
Serial data output
R52 (SCLK)
I/O (I/O)
Serial clock I/O
R53 (SRDY)
I/O (I/O)
R54 (WDTO)
I/O (O)
R55 (BUZ)
I/O (O)
R56 (PWM0)
I/O (O)
R57 (PWM1)
I/O (O)
R60~R63 (AN0~AN3)
I (I)
R64~R67 (AN4~AN7)
I/O (I)
8-bit general I/O ports
8-bit general I/O ports
External interrupt 3 input
Timer/Counter 0 external input
Receive enable I/O
Watchdog timer overflow output
Buzzer driving output
PWM pulse output
General input ports
General I/O ports
AVSS
-
Ground level input pin for ADC
AVDD
-
Supply voltage input pin for ADC
Analog voltage input
Table 5-1 Port Function Description
DEC. 1999 Ver 1.04
9
GMS81508B/16B/24B
HYUNDAI MicroElectronics
6. PORT STRUCTURES
R52/SCLK
R00~R07, R10~R17, R20~R27, R30~37
VDD
Selection
VDD
Data Reg.
SCK Output
Data Bus
M UX
Pin
Dir.
Reg.
Pin
Data Reg.
VSS
Data Bus
MUX
Rd
Direction
Reg.
VSS
M UX
exck
MUX
R40/INT0, R41/INT1, R42/INT2, R43/INT3, R44/
EC0, R45/EC2, R50/SIN
Rd
SCK Input
PMR Selection
VDD
Data Bus
Data Reg.
S53/SRDY
Direction
Reg.
Pin
Selection
SRDY
VSS
M UX
VDD
SRDY Output
MUX
Rd
EX) INT0
Alternate Function
Pin
Data Bus
Data Reg.
R46/T1O, R47/T3O, R51/SOUT, R54/WDTO
R55BUZ, R56/PWM0, R57/PWM1
Direction
Reg.
VSS
MUX
Selection
VDD
Rd
Secondary function
M UX
SRDY Input
Pin
Data Bus
Data Reg.
VSS
Direction
Reg.
M UX
Rd
10
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
R60/AN0 ~ R63/AN3
RESET
VDD
VDD
RESET
Data bus
Rd
VSS
To A/D converter
VSS
R64/AN7 ~ R67/AN7
TEST
VDD
VDD
Data Bus
OTP version: disconnected
Mask version: connected
TEST
Data Reg.
Pin
Dir.
Reg.
VSS
VSS
MUX
Rd
To A/D converter
XIN, XOUT
VDD
XIN
VSS
XOUT
VSS
Stop
DEC. 1999 Ver 1.04
11
GMS81508B/16B/24B
HYUNDAI MicroElectronics
7. ELECTRICAL CHARACTERISTICS
7.1 Absolute Maximum Ratings
Supply voltage ............................................. -0.3 to +7.0 V
Maximum current (ΣIOL) ...................................... 100 mA
Storage Temperature .................................. -40 to +125 °C
Maximum current (ΣIOH)........................................ 50 mA
Voltage on any pin with respect to Ground (VSS)
..................................................................-0.3 to VDD+0.3
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 current out of VSS pin .......................... 150 mA
Maximum current into VDD pin .............................. 80 mA
Maximum current sunk by (IOL per I/O Pin) .......... 20 mA
Maximum output current sourced by (IOH per I/O Pin)
................................................................................... 8 mA
7.2 Recommended Operating Conditions
Specifications
Parameter
Supply Voltage
Operating Frequency
Operating Temperature
Symbol
Condition
VDD
fXIN=1 ~ 10 MHz
fXIN=1 ~ 8 MHz
fXIN=1 ~ 4 MHz
fXIN
VDD=4.5~5.5V
VDD=2.7~5.5V
VDD=2.2~5.5V
TOPR
Unit
Normal Version
Temperature Extention Version
Min.
Max.
4.5
2.7
2.2
5.5
5.5
5.5
V
1
1
1
10
8
4
MHz
-20
-40
85
85
°C
7.3 A/D Converter Characteristics
(TA=25°C, VSS=0V, VDD=5.12V@fXIN=8MHz, VDD=3.072V@fXIN=4MHz)
Specifications
Parameter
Max.
Symbol
Min.
Typ.1
Unit
fXIN=4MHz
fXIN=8MHz
Analog Input Voltage Range
VAIN
VSS
-
AVDD
AVDD
V
Non-linearity Error
NNLE
-
±1.0
±1.5
±1.5
LSB
Differential Non-linearity Error
NDNLE
-
±1.0
±1.5
±1.5
LSB
Zero Offset Error
NZOE
-
±0.5
±1.5
±1.5
LSB
Full Scale Error
NFSE
-
±0.35
±0.5
±0.5
LSB
Gain Error
NGE
-
±1.0
±1.5
±1.5
LSB
Overall Accuracy
NACC
-
±1.0
±1.5
±1.5
LSB
AVDD Input Current
IREF
-
0.5
1.0
1.0
mA
TCONV
-
-
40
20
µs
Conversion Time
12
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
Specifications
Parameter
Max.
Symbol
AVDD
Analog Power Supply Input Range
Min.
Typ.1
0.9VDD
VDD
fXIN=4MHz
Unit
fXIN=8MHz
1.1VDD
V
1. Data in “Typ” column is at 25°C unless otherwise stated. These parameters are for design guidance only and are not tested.
7.4 DC Electrical Characteristics
(TA=-20~85°C, VDD=2.7~5.5V, Ta= -20~85°C, fXIN=8MHz, VSS=0V),
Specifications
Parameter
Input High Voltage
Symbol
VIH1
VIH2
Input Low Voltage
VIL1
VIL2
Condition
VDD=4.5
VDD=2.7
VDD=4.5
VDD=2.7
Unit
Min.
Typ.1
Max.
XIN, RESET,
R4, R5, R6
0.8VDD
-
VDD+0.3
R0, R1, R2, R3
0.7VDD
-
VDD+0.3
XIN, RESET,
R4, R5, R6
-
0.2VDD
R0, R1, R2, R3
-
0.3VDD
VDD-1.0
-
-
V
-
-
1.0
V
1.1VPFD
V
V
V
Output High Voltage
VOH
VDD=4.5
R0,R1,R2,R3,R4,R5
VDD=2.7
R6
IOH1=-2mA
Output Low Voltage
VOL
VDD=4.5
VDD=2.7
IOL1=5mA
Power Fail Detect
Voltage
VPFD
VPFD=3.0V
@ TA=25°C
VPFD=2.4V
Input High
Leakage Current
IIH1
VIN=VDD
All input pins
-5.0
-
5.0
µA
Input Low
Leakage Current
IIL
VIN=VSS
All input pins
-5.0
-
5.0
µA
RESET, EC0, EC2,
SIN, SCLK, INT0~INT3
0.3
0.8
V
8
20
mA
4
10
mA
1
10
µA
Hysteresis
Power Current
VT+, VTIDD1
f XIN=8M H z
IDD2
f XIN=4M H z
ISTOP
R0,R1,R2,R3,R4,R5
R6
0.9VPFD
A ll input = V SS
C rystal O scillator,
C L1 =C L2 =30pF
-
A ll input = V SS
-
1. Data in “Typ.” column is at 4.5V, 25°C unless otherwise stated. These parameters are for design guidance only and are not tested.
DEC. 1999 Ver 1.04
13
GMS81508B/16B/24B
HYUNDAI MicroElectronics
7.5 AC Characteristics
(TA=-20~+85°C, VDD=5V±10%, VSS=0V)
Specifications
Parameter
Symbol
Pins
Unit
Min.
Typ.
Max.
Operating Frequency
fXIN
XIN
1.0
-
10.0
MHz
Oscillation Stabilizing
Time
tST
XIN, XOUT
-
-
20
ms
External Clock Pulse
Width
tCPW
XIN
40
-
-
ns
External Clock Transition Time
tRCP,tFCP
XIN
-
-
20
ns
Interrupt Pulse Width
tIW
INT0, INT1, INT2, INT3
2
-
-
tSYS
RESET Input Width
tRST
RESET
8
-
-
tSYS
Event Counter Input
Pulse Width
tECW
EC0, EC2
2
-
-
tSYS
tREC,tFEC
EC0, EC2
-
-
20
ns
Event Counter Transition Time
tSYS = 1/fXIN
tCPW
tCPW
VDD-0.5V
XIN
0.5V
tRCP
tIW
INT0~INT3
tFCP
tIW
0.8VDD
0.2VDD
tRST
RESET
0.2VDD
tECW
tECW
0.8VDD
EC1, EC2
0.2VDD
tREC
tFEC
Figure 7-1 Timing Chart
14
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
7.6 Serial Interface Timing Characteristics
(TA=-20~+85°C, VDD=5V±10%, VSS=0V, fXIN=8MHz)
Specifications
Parameter
Symbol
Pins
Unit
Min.
Typ.
Max.
Serial Input Clock Pulse
tSCYC
SCLK
2tSYS+200
-
8
ns
Serial Input Clock Pulse Width
tSCKW
SCLK
tSYS+70
-
8
ns
Serial Input Clock Pulse Transition
Time
tFSCK
tRSCK
SCLK
-
-
30
ns
SIN Input Pulse Transition Time
tFSIN
tRSIN
SIN
-
-
30
ns
SIN Input Setup Time (External SCLK)
tSUS
SIN
100
-
-
ns
SIN Input Setup Time (Internal SCLK)
tSUS
SIN
200
-
ns
SIN Input Hold Time
tHS
SIN
tSYS+70
-
ns
Serial Output Clock Cycle Time
tSCYC
SCLK
4tSYS
-
Serial Output Clock Pulse Width
tSCKW
SCLK
tSYS-30
Serial Output Clock Pulse Transition
Time
tFSCK
tRSCK
SCLK
30
ns
Serial Output Delay Time
sOUT
SOUT
100
ns
tSCKW
ns
tSCKW
0.8VDD
0.2VDD
tSUS
tHS
0.8VDD
0.2VDD
SIN
tDS
SOUT
ns
tSCYC
tRSCK
tFSCK
SCLK
16tSYS
tFSIN
tRSIN
0.8VDD
0.2VDD
Figure 7-2 Serial I/O Timing Chart
DEC. 1999 Ver 1.04
15
GMS81508B/16B/24B
HYUNDAI MicroElectronics
7.7 Typical Characteristic Curves
This graphs and tables provided in this section are for design guidance only and are not tested or guaranteed.
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
IOH
(mA) VDD=4.5V
Ta=25°C
-12
R0~R6 pins
-9
-9
-6
-6
-3
-3
0
0.6
0.9
IOL−VOL1
1.2 1.5 (V)
VDD-VOH
R0~R6 pins
IOL
(mA) VDD=4.5V
Ta=25°C
20
0.3
10
10
5
5
0.2
4
0.4
VDD−VIH1
0.6
0.8
VOL
1.0 (V)
0.2
VIH2
(V)
R0~R6 pins
0.4
VDD−VIH2
0.6
0.8
VOL
1.0 (V)
R0, R1, R2, R3 pins
fXIN=8MHz
Ta=25°C
4
3
3
2
2
1
1
0
2
1.2 1.5 (V)
VDD-VOH
0
XIN, RESET,
R4, R5, R6 pins
fXIN=8MHz
Ta=25°C
0.9
IOL−VOL2
15
0
0.6
IOL
(mA) VDD=3.0V
Ta=25°C
20
15
VIH1
(V)
R0~R6 pins
0
0.3
16
IOH−VOH
IOH
(mA) VDD=3.0V
Ta=25°C
-12
3
4
5
VDD
6 (V)
0
1
2
3
4
5
VDD
6 (V)
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
VIL2
(V)
4
XIN, RESET,
R4, R5, R6 pins
VDD−VIL1
fXIN=8MHz
Ta=25°C
GMS81508B/16B/24B
VIL2
(V)
3
2
2
1
1
0
3
IDD−VDD
IDD
(mA)
4
5
VDD
6 (V)
0
1
2
3
4
ISTOP−VDD
Normal Operation
5
VDD
6 (V)
Operating Area
Stop Mode
fXIN
(MHz) Ta= -20~85°C
IDD
(µA)
Ta=25°C
20
0.4
15
0.3
10
0.2
5
R0, R1, R2, R3 pins
fXIN=8MHz
Ta=25°C
4
3
2
VDD−VIL2
fXIN = 8MHz
10
8
0.1
85°C
6
25°C
-20°C
4
2
4MHz
0
2
3
4
DEC. 1999 Ver 1.04
5
VDD
6 (V)
0
2
3
4
5
VDD
6 (V)
0
2
3
4
5
VDD
6 (V)
17
GMS81508B/16B/24B
HYUNDAI MicroElectronics
8. MEMORY ORGANIZATION
The GMS81508B/16B/24B has separate address spaces
for Program memory and Data Memory. Program memory
can only be read, not written to. It can be up to 24K bytes
of Program memory. Data memory can be read and written
to up to 448 bytes including the stack 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
call is executed or an interrupt is accepted. However, if it
is used in excess of the stack area permitted by the data
memory allocating configuration, the user-processed data
may be lost.
The stack can be located at any position within 100H to
1FFH 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 “FEH” is
used.
Bit 15
Stack Address (100H ~ 1FEH)
8 7
Bit 0
01H
SP
00H~FEH
Hardware fixed
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
A
A
Note: The Stack Pointer must be initialized by software because its value is undefined after RESET.
Example: To initialize the SP
LDX
#0FEH
TXSP
; SP ← FEH
Address 01FFH can not be used as stack. Don not use
1FFH, or malfunction would be occurred.
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 accessed
(save or restore).
Generally, SP is automatically updated when a subroutine
18
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 borrow from the ALU of CPU
after an arithmetic operation and is also changed by the
Shift Instruction or Rotate Instruction.
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
[Zero flag Z]
or data transfer is “0” and is cleared by any other result.
This flag is set when the result of an arithmetic operation
PSW
MSB
N V G B H
NEGATIVE FLAG
OVERFLOW FLAG
SELECT DIRECT PAGE
when G=1, page is selected to “page 1”
BRK FLAG
I
Z
LSB
C RESET VALUE: 00H
CARRY FLAG RECEIVES
CARRY OUT
ZERO 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).
[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]
DEC. 1999 Ver 1.04
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 100H to 1FFH. It is set by
SETG instruction and cleared by CLRG.
[Overflow flag V]
This flag is set to “1” when an overflow occurs 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.
19
GMS81508B/16B/24B
HYUNDAI MicroElectronics
At execution of
a CALL/TCALL/PCALL
01FE
At acceptance
of interrupt
Push
down
01FE
PCH
01FD
PCL
01FC
01FC
PSW
01FB
01FB
01FD
PCH
PCL
At execution
of RET instruction
Push
down
01FE
PCH
01FD
PCL
At execution
of RET instruction
01FE
PCH
01FD
PCL
01FC
01FC
PSW
01FB
01FB
Pop
up
SP before
execution
01FE
01FE
01FC
01FB
SP after
execution
01FC
01FB
01FE
01FE
At execution
of PUSH instruction
PUSH A (X,Y,PSW)
01FE
A
01FD
Push
down
Pop
up
At execution
of POP instruction
POP A (X,Y,PSW)
01FE
A
01FD
01FC
01FC
01FB
01FB
Pop
up
0100H
Stack
depth
01FEH
SP before
execution
01FE
01FD
SP after
execution
01FD
01FE
Figure 8-4 Stack Operation
20
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
8.2 Program Memory
A 16-bit program counter is capable of addressing up to
64K bytes, but this device has 24K 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.
A000H
Interrupt
Vector Area
GMS815024B, 24K ROM
GMS815016B, 16K ROM
TCALL area
GMS81508B, 8K ROM
FEFFH
FF00H
PCALL area
E000H
FFFFH
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.
Any area from 0FF00H to 0FFFFH, if it is not going to be
used, its service location is available as general purpose
Program Memory.
C000H
FFC0H
FFDFH
FFE0H
it is more useful to save program byte length.
Figure 8-5 Program Memory Map
Page Call (PCALL) area contains subroutine program to
reduce program byte length by using 2 bytes PCALL instead of 3 bytes CALL instruction. If it is frequently called,
DEC. 1999 Ver 1.04
Address
Vector Area Memory
0FFE0H
-
E2
-
E4
Serial Communication Interface
E6
Basic Interval Timer
E8
Watchdog Timer Interrupt
EA
A/D Converter
EC
Timer/Counter
- 3 Interrupt
EE
Timer/Counter
- 2 Interrupt
F0
Timer/Counter 1 Interrupt
F2
Timer/Counter 0 Interrupt
F4
External Interrupt 3
F6
External Interrupt 2
F8
External Interrupt 1
FA
External Interrupt 0
FC
-
FE
RESET Vector Area
NOTE:
“-” means reserved area.
Figure 8-6 Interrupt Vector Area
21
GMS81508B/16B/24B
Address
0FF00H
HYUNDAI MicroElectronics
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
➊
~
~
NEXT
Reverse
PC: 11111111 11010110
FH FH
DH 6H
0FF00H
0FF35H
0FFFFH
22
NEXT
➌
0FF00H
0FFD6H
25
0FFD7H
D1
➋
0FFFFH
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
Example: The usage software example of Vector address for GMS81524B.
;
;
ORG
0FFE0H
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
NOT_USED
NOT_USED
SIO
BIT_TIMER
WD_TIMER
ADC
TIMER3
TIMER2
TIMER1
TIMER0
INT3
INT2
INT1
INT0
NOT_USED
RESET
;
;
;
;
;
;
;
;
;
;
;
;
;
;
ORG
ORG
ORG
0A000H
0C000H
0E000H
; 24K ROM Start address
; 16K ROM Start address
; 8K ROM Start address
Serial Interface
Basic Interval Timer
Watchdog Timer
ADC
Timer-3
Timer-2
Timer-1
Timer-0
Int.3
Int.2
Int.1
Int.0
Reset
;*******************************************
;
MAIN
PROGRAM
*
;*******************************************
;
RESET: DI
;Disable All Interrupts
CLRG
LDX
#0
RAM_CLR: LDA
#0
;RAM Clear(!0000H->!00BFH)
STA
{X}+
CMPX #0C0H
BNE
RAM_CLR
;
LDX
#0FEH
;Stack Pointer Initialize
TXSP
;
LDM
R0, #0
;Normal Port 0
LDM
R0DD,#82H
;Normal Port Direction
:
:
:
LDM
TDR0,#250
;8us x 250 = 2000us
LDM
TM0,#1FH
;Start Timer0, 8us at 8MHz
LDM
IRQH,#0
LDM
IRQL,#0
LDM
IENH,#0C8H ;Enable Timer0, INT0, INT1
LDM
IENL,#0
LDM
IEDS,#55H
;Select falling edge detect on INT pin
LDM
PMR4,#3H
;Set external interrupt pin(INT0, INT1)
EI
;Enable master interrupt
:
:
:
:
:
NOT_USED:NOP
RETI
DEC. 1999 Ver 1.04
23
GMS81508B/16B/24B
HYUNDAI MicroElectronics
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
More detailed informations of each register are explained
in each peripheral section.
User Memory
PAGE0
00BFH
00C0H
00FFH
0100H
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.
When “G-flag=0”,
this page is selected
Control
Registers
Note: Write only registers can not be accessed by bit manipulation instruction. Do not use read-modify-write instruction. Use byte manipulation instruction, for example “LDM”.
Example; To write at CKCTLR
LDM
User Memory
or Stack Area
PAGE1
When “G-flag=1”
01FFH
Figure 8-8 Data Memory Map
User Memory
The GMS815xxB has 448 × 8 bits for the user memory
(RAM).
Control Registers
The control registers are used by the CPU and Peripheral
function blocks for controlling the desired operation of the
device. Therefore these registers contain control and status
bits for the interrupt system, the timer/ counters, analog to
digital converters and I/O ports. The control registers are in
address range of 0C0H to 0FFH.
24
CLCTLR,#09H ;Divide ratio(÷32)
Stack Area
The stack provides the area where the return address is
saved before a jump is performed during the processing
routine at the execution of a subroutine call instruction or
the acceptance of an interrupt.
When returning from the processing routine, 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.
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
Address
GMS81508B/16B/24B
Register Name
Symbol
R/W
Initial Value
Page
7 6 5 4 3 2 1 0
00C0
R0 port data register
R0
R/W
Undefined
page 31
00C1
R0 port I/O direction register
R0DD
W
00000000
page 31
00C2
R1 port data register
R1
R/W
Undefined
page 31
00C3
R1 port I/O direction register
R1DD
W
00000000
page 31
00C4
R2 port data register
R2
R/W
Undefined
page 31
00C5
R2 port I/O direction register
R2DD
W
00000000
page 31
00C6
R3 port data register
R3
R/W
Undefined
page 32
00C7
R3 port I/O direction register
R3DD
W
00000000
page 32
00C8
R4 port data register
R4
R/W
Undefined
page 32
00C9
R4 port I/O direction register
R4DD
W
00000000
page 32
00CA
R5 port data register
R5
R/W
Undefined
page 33
00CB
R5 port I/O direction register
R5DD
W
00000000
page 33
00CC
R6 port data register
R6
R/W
Undefined
page 33
00CD
R6 port I/O direction register
R6DD
W
0000 - - - -
page 33
00D0
R4 port mode register
PMR4
W
00000000
page 32, page 63
00D1
R5 port mode register
PMR5
W
- - 00 - - - -
page 33, page 55
Basic interval timer mode register
BITR
R
Undefined
page 35
CKCTLR
W
- - 010111
page 35
WDTR
W
- 0111111
page 64
00D3
Clock control register
00E0
Watchdog Timer Register
00E2
Timer mode register 0
TM0
R/W
00000000
page 37
00E3
Timer mode register 2
TM2
R/W
00000000
page 37
Timer 0 data register
TDR0
W
Undefined
page 37
T0
R
Undefined
page 37
TDR1
W
Undefined
page 37
T1
R
Undefined
page 37
TDR2
W
Undefined
page 37
T2
R
Undefined
page 37
TDR3
W
Undefined
page 37
T3
R
Undefined
page 37
00E4
00E5
00E6
00E7
Timer 0 counter register
Timer 1 data register
Timer 1 counter register
Timer 2 data register
Timer 2 counter register
Timer 3 data register
Timer 3 counter register
00E8
A/D converter mode register
ADCM
R/W
- - 000001
page 47
00E9
A/D converter data register
ADR
R
Undefined
page 47
00EA
Serial I/O mode register
SIOM
R/W
- 0000001
page 49
00EB
Serial I/O register
SIOR
R/W
Undefined
page 49
00EC
Buzzer driver register
BUR
W
Undefined
page 55
00F0
PWM0 duty register
PWMR0
W
Undefined
page 53
Table 8-1 Control Registers
DEC. 1999 Ver 1.04
25
GMS81508B/16B/24B
Address
HYUNDAI MicroElectronics
Register Name
Symbol
R/W
Initial Value
Page
7 6 5 4 3 2 1 0
00F1
PWM1 duty register
PWMR1
W
Undefined
page 53
00F2
PWM control register
PWMCR
W
00000000
page 53
00F4
Interrupt enable register low
IENL
R/W
0000 - - - -
page 58
00F5
Interrupt request flag register low
IRQL
R/W
0000 - - - -
page 57
00F6
Interrupt enable register high
IENH
R/W
00000000
page 58
00F7
Interrupt request flag register high
IRQH
R/W
00000000
page 57
00F8
External interrupt edge selection register
IEDS
W
00000000
page 63
00F9
Power fail detection register
PFDR
R/W
- - - - 1100
page 71
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
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
8.4 Addressing Mode
The GMS800 series MCU uses six addressing modes;
Example: G=1
• Register addressing
E45535
LDM
35H,#55H
• Immediate addressing
• Direct page addressing
• Absolute addressing
data
0135H
• Indexed addressing
➊
• Register-indirect addressing
~
~
0F100H
(1) Register Addressing
data ¨ 55H
~
~
➋
E4
0F101H
55
0F102H
35
Register addressing accesses the A, X, Y, C and PSW.
(2) Immediate Addressing → #imm
In this mode, second byte (operand) is accessed as a data
immediately.
In this mode, a address is specified within direct page.
Example; G=0
Example:
0435
(3) Direct Page Addressing → dp
ADC
C535
#35H
LDA
;A ←RAM[35H]
35H
MEMORY
35H
04
35
data
➋
A+35H+C → A
~
~
~
~
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.
DEC. 1999 Ver 1.04
27
GMS81508B/16B/24B
HYUNDAI MicroElectronics
(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
LDA
115H
ADC, AND, CMP, CMPX, CMPY, EOR, LDA, LDX,
LDY, OR, SBC, STA, STX, STY
{X}
;ACC←RAM[X].
data
➋
~
~
~
~
Example;
0735F0
ADC
;A ←ROM[0F035H]
!0F035H
data
0F035H
~
~
➋
~
~
0F100H
A+data+C → A
➊
07
0F101H
35
0F102H
F0
address: 0F035
data → A
➊
D4
0E550H
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
DB
LDA
{X}+
The operation within data memory (RAM)
ASL, BIT, DEC, INC, LSR, ROL, ROR
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
(5) Indexed Addressing
X indexed direct page (no offset) → {X}
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
Example; G=0, X=0F5H
In this mode, a address is specified by the X register.
28
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
C645
LDA
GMS81508B/16B/24B
Example; G=0
45H+X
3F35
3AH
data
➌
~
~
➋
~
~
0E550H
C6
0E551H
45
JMP
35H
0A
36H
E3
data → A
➊
[35H]
~
~
~
~
0E30AH
➋
➊
NEXT
jump to
address 0E30AH
45H+0F5H=13AH
~
~
~
~
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 plusX-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
!0FA00H+Y
35H
05
36H
E0
0E005H
~
~ ➋
~
~
0F100H
D5
0F101H
00
0F102H
FA
~
~
➊
0E005H
0FA00H+55H=0FA55H
~
~
➋
~
~
0FA00H
➊ 25 + X(10) = 35H
data
~
~
16
25
0FA55H
data
➌
data → A
➌ A + data + C → A
Y indexed indirect → [dp]+Y
(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.
Processes memory data as Data, assigned by the data
[dp+1][dp] of 16-bit pair memory paired by Operand in Direct pageplus Y-register data.
ADC, AND, CMP, EOR, LDA, OR, SBC, STA
Example; G=0, Y=10H
JMP, CALL
DEC. 1999 Ver 1.04
29
GMS81508B/16B/24B
1725
ADC
HYUNDAI MicroElectronics
Example; G=0
[25H]+Y
1F25E0
25H
05
26H
E0
~
~
0E015H
0FA00H
[!0C025H]
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
30
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
9. I/O PORTS
The GMS815xxB has seven ports (R0, R1, R2, R4, R5, and
R6).These ports pins may be multiplexed with an alternate
function for the peripheral features on the device.
All pins have data direction registers which can define
these ports as output or input. A “1” in the port direction
register configure the corresponding port pin as output.
Conversely, write “0” to the corresponding bit to 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 0C1H (R0 port direction register) during initial setting as shown in Figure 9-1.
All the port direction registers in the GMS815xxB have 0
written to them by reset function. On the other hand, its initial status is input.
R1 and R1DD register: R1 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 R1DD register
(address 0C3H).
R1 Data Register
R1
R17 R16 R15 R14 R13 R12 R11 R10
Input / Output data
R1 Direction Register
0C0H
R0 data
R0 direction
0C2H
R1 data
0C3H
R1 direction
0 1 0 1 0 1 0 1
7 6 5 4 3 2 1 0
BIT
I O I O I O I O PORT
7 6 5 4 3 2 1 0
I: INPUT PORT
O: OUTPUT PORT
Port Direction
0: Input
1: Output
R2 and R2DD register: R2 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 R2DD register
(address 0C5H).
R2 Data Register
R2
R0 Data Register
R0
ADDRESS: 0C0H
RESET VALUE: Undefined
ADDRESS: 0C4H
RESET VALUE: Undefined
R27 R26 R25 R24 R23 R22 R21 R20
Figure 9-1 Example of port I/O assignment
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 0C1H).
ADDRESS: 0C3H
RESET VALUE: 00H
R1DD
WRITE “55H” TO PORT R0 DIRECTION REGISTER
0C1H
ADDRESS: 0C2H
RESET VALUE: Undefined
Input / Output data
R2 Direction Register
ADDRESS: 0C5H
RESET VALUE: 00H
R2DD
Port Direction
0: Input
1: Output
R07 R06 R05 R04 R03 R02 R01 R00
Input / Output data
R0 Direction Register
ADDRESS: 0C1H
RESET VALUE: 00H
R0DD
Port Direction
0: Input
1: Output
DEC. 1999 Ver 1.04
31
GMS81508B/16B/24B
HYUNDAI MicroElectronics
R3 and R3DD register: R3 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 R0DD register
(address 0C7H).
ADDRESS: 0C6H
RESET VALUE: Undefined
R3 Data Register
R3
R37 R36 R35 R34 R33 R32 R31 R30
Regardless of the direction register R4DD, PMR4 is selected to use as alternate functions, port pin can be used as a
corresponding alternate features.
ADDRESS: 0C8H
RESET VALUE: Undefined
R4 Data Register
R4
R47 R46 R45 R44 R43 R42 R41 R40
Input / Output data
R3 Direction Register
ADDRESS: 0C7H
RESET VALUE: 00H
R3DD
Input / Output data
ADDRESS: 0C9H
RESET VALUE: 00H
R4 Direction Register
R4DD
Port Direction
0: Input
1: Output
R4 and R4DD register: R4 is an 8-bit CMOS bidirectional I/O port (address 0C8H). Each I/O pin can independently
used as an input or an output through the R4DD register
(address 0C9H).
Port Direction
0: Input
1: Output
PMR4
7
R40
R41
R42
R43
R44
R45
R46
R47
32
6
5
4
3
2
1
0
0: R40
1: INT0
0: R44
1: EC0
In addition, Port R4 is multiplexed with various special
features. The control register PMR4 (address 0D0H) controls the selection of alternate function. After reset, this
value is “0”, port may be used as normal I/O port.
To use alternate function such as external interrupt, external counter input or timer clock out, write “1” in the corresponding bit of PMR4.
Port Pin
ADDRESS: 0D0H
RESET VALUE: 00H
R4 Port Mode Register
0: R41
1: INT1
0: R45
1: EC2
0: R46
1: T1O
0: R42
1: INT2
0: R43
1: INT3
0: R47
1: T3O
Alternate Function
INT0 (External Interrupt 0)
INT1 (External Interrupt 1)
INT2 (External Interrupt 2)
INT3 (External Interrupt 3)
EC0 (External count input to Timer/
Counter 0)
EC2 (External count input to Timer/
Counter 2)
T1O (Timer 1 Clock-out)
T3O (Timer 3 Clock-out)
ADDRESS: 0F8H
RESET VALUE: 00H
Edge Selection Register
IEDS
7
6
INT3
5
4
INT2
3
2
1
INT1
0
INT0
External Interrupt Edge Select
00: Reserved
01: Falling (1-to-0 transition)
10: Rising (0-to-1 transition)
11: Both (Rising & Falling)
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
R5 and R5DD register: R5 is an 8-bit CMOS bidirectional I/O port (address 0CAH). Each I/O pin can independently used as an input or an output through the R5DD register
(address 0CBH).
Alternate Function
Port Pin
R54
R55
WDTO (Watchdog timer output)
BUZ (Square-wave output for buzzer)
R6 and R6DD register: R6 is an 8-bit CMOS bidirectional I/O port (address 0CCH). Each I/O pin can independently used as an input or an output through the R6DD register
(address 0CDH).
R60
R61
R62
R63
R64
R65
R66
R67
The control register PMR5 (address D1H) controls the selection alternate function. After reset, this value is “0”, port
may be used as general I/O ports. To use buzzer function,
write “1” to the PMR5 and the pin R55 must be defined as
output mode (the bit 5 of R5DD=1)
ADDRESS: 0CAH
RESET VALUE: Undefined
R5 Data Register
R5
R57 R56 R55 R54 R53 R52 R51 R50
Input / Output data
ADDRESS: 0CBH
RESET VALUE: 00H
R5 Direction Register
R5DD
Alternate Function
Port Pin
AN0 (ADC input 0)
AN1 (ADC input 1)
AN2 (ADC input 2)
AN3 (ADC input 3)
AN4 (ADC input 4)
AN5 (ADC input 5)
AN6 (ADC input 6)
AN7 (ADC input 7)
R6DD (address CDH) controls the direction of the R6 pins,
even when they are being used as analog inputs. The user
must make sure to keep the pins configured as inputs when
using them as analog inputs.
Note: On the initial RESET, R60 can not be used digital input port, because this port is selected as an analog input
port by ADCM register. To use this port as a digital I/O port,
change the value of lower 4 bits of ADCM (address 0E8H).
On the other hand, R6 port, all eight pins can not be used
as digital I/O port simultaneously. At least one pin is used
as an analog input.
Port Direction
0: Input
1: Output
ADDRESS: 0D1H
RESET VALUE: --00----B
R5 Port Mode Register
PMR5
-
-
BUZ W DTO
-
-
-
-
R6
R54/WDTO Selection
0: R54
1: WDTO (Output)
R55/BUZ Selection
0: R55
1: BUZ (Output)
ADDRESS: 0CCH
RESET VALUE: Undefined
R6 Data Register
R67 R66 R65 R64 R63 R62 R61 R60
Input / Output data
Input data
ADDRESS: 0CDH
RESET VALUE: 0000----B
R6 Direction Register
R6DD
-
Port Direction
0: Input
1: Output
DEC. 1999 Ver 1.04
-
-
-
R60~R63 are input
only
33
GMS81508B/16B/24B
HYUNDAI MicroElectronics
10. BASIC INTERVAL TIMER
The GMS815xxB has one 8-bit Basic Interval Timer that
is free-run and can not stop. Block diagram is shown in
Figure 10-1.
In addition, the Basic Interval Timer generates the time
base for watchdog timer counting. It also provides a Basic
interval timer interrupt (BITIF). As the count overflow
from FFH to 00H, this overflow causes the interrupt to be
generated. The Basic Interval Timer is controlled by the
clock control register (CKCTLR) shown in Figure 10-2.
Source clock can be selected by lower 3 bits of CKCTLR.
BITR and CKCTLR are located at same address, and address 0F9H is read as a BITR, and written to CKCTLR.
÷16
÷32
XIN PIN
Prescaler
÷64
÷128
÷256
MUX
8-bit up-counter
source
clock
overflow
BITR
BITIF
Basic Interval Timer Interrupt
÷512
[0F9H]
÷1024
÷2048
To Watchdog timer (WDTCK)
clear
Select Input clock 3
BTS[2:0]
BTCL
CKCTLR
[0D3H]
Read
Basic Interval Timer
clock control register
Internal bus line
Figure 10-1 Block Diagram of Basic Interval Timer
CKCTLR
[2:0]
000
001
010
011
100
101
110
111
Source clock
fXIN÷16
fXIN÷32
fXIN÷64
fXIN÷128
fXIN÷256
fXIN÷512
fXIN÷1024
fXIN÷ 2048
Interrupt (overflow) Period (ms)
@ fXIN = 8MHz
0.512
1.024
2.048
4.096
8.192
16.384
32.768
65.536
Table 10-1 Basic Interval Timer Interrupt Time
34
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
CKCTLR
7
-
6
-
GMS81508B/16B/24B
5
4
WDTON
ENPCK
3
2
1
0
BTCL
BTCL BTS2 BTS1 BTS0
ADDRESS: 0D3H
INITIAL VALUE: --01 0111B
Basic Interval Timer source clock select
000: fXIN ÷ 16
001: fXIN ÷ 32
010: fXIN ÷ 64
011: fXIN ÷ 128
100: fXIN ÷ 256
101: fXIN ÷ 512
110: fXIN ÷ 1024
111: fXIN ÷ 2048
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”. This bit becomes 0 automatically
after one machine cycle, and starts counting.
Enable Peripheral clock
If this bit is 0, all peripherals are disabled such as Timer, ADC, PWM, etc.
0: Operate as a 6-bit general timer
1: Enable Watchdog Timer operation
See the section “Watchdog Timer”.
7
6
5
BITR
4
3
BTCL
2
1
0
ADDRESS: 0D3H
INITIAL VALUE: Undefined
8-BIT FREE-RUN BINARY COUNTER
Figure 10-2 BITR: Basic Interval Timer Mode Register
Example 1:
Interrupt request flag is generated every 8.192ms at 4MHz.
:
LDM
SET1
EI
:
CKCTLR,#1BH
BITE
Example 2:
Interrupt request flag is generated every 8.192ms at 8MHz.
:
LDM
SET1
EI
:
CKCTLR,#1CH
BITE
DEC. 1999 Ver 1.04
35
GMS81508B/16B/24B
HYUNDAI MicroElectronics
11. TIMER/EVENT COUNTER
The GMS815xxB has four Timer/Counter registers. Each
module can generate an interrupt to indicate that an event
has occurred (i.e. timer match).
Timer 0 and Timer 1 are can be used either two 8-bit Timer/Counter or one 16-bit Timer/Counter with combine
them. Also Timer 2 and Timer 3 are same.
In the “timer” function, the register is increased every internal clock input. Thus, one can think of it as counting internal clock input. Since a least clock consists of 4 and
most clock consists of 64 oscillator periods, the count rate
is 1/4 to 1/64 of the oscillator frequency.
In the “counter” function, the register is incremented in response to a 1-to-0 (falling edge) transition at its corre-
sponding external input pin, EC0 or EC2.
In addition the “capture” function, the register is incremented in response external or internal clock sources same
with timer or counter function. When external clock edge
input, the count register is captured into Timer data register
correspondingly.
It has four operating modes: “8-bit timer/counter”, “16-bit
timer/counter”, “8-bit capture”, “16-bit capture” which are
selected by bit in Timer mode register TM0 and TM2 as
shown in Table 11-1.
In operation of Timer 2, Timer 3, their operations are same
with Timer 0, Timer 1, respectively as shown in Table 112.
TM0
CAP
0
T1ST
0
X
T1SL
[1:0]
01 or
10 or
11
TIMER 0
T0ST T0CN
X
X
01 or 10 or 11
8-bit Timer
8-bit Timer
X
X
00
8-bit Event counter
8-bit Timer
X
X
01 or 10 or 11
8-bit Capture (internal clock)
8-bit Timer
8-bit Capture (external clock)
8-bit Timer
0
X
1
X
1
X
X
X
00
0
X
X
X
01 or 10 or 11
0
X
X
X
00
1
X
X
X
01 or 10 or 11
16-bit Capture (internal clock)
1
X
X
X
00
16-bit Capture (external clock)
00
TIMER 1
T0SL[1:0]
16-bit Timer
16-bit Event counter
Table 11-1 TM0 Timer Mode Register
TM2
CAP
2
T3ST
0
X
T3SL
[1:0]
01 or
10 or
11
TIMER 2
T2ST
T2CN
T2SL[1:0]
X
X
01 or 10 or 11
X
X
00
X
X
8-bit Timer
8-bit Timer
8-bit Event counter
8-bit Timer
01 or 10 or 11
8-bit Capture (internal clock)
8-bit Timer
8-bit Capture (external clock)
8-bit Timer
0
X
1
X
1
X
X
X
00
0
X
X
X
01 or 10 or 11
0
X
X
X
00
1
X
X
X
01 or 10 or 11
16-bit Capture (internal clock)
1
X
X
X
00
16-bit Capture (external clock)
00
TIMER 3
16-bit Timer
16-bit Event counter
Table 11-2 TM2 Timer Mode Register
36
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
TM0
TIMER 1
TIMER 0
R/W
7
R/W
6
CAP 0
T1ST
R/W
4
R/W
3
T1S L1 T1SL0 BTCL
T0ST
R/W
2
R/W
1
R/W
0
T0C N T0SL1 T0SL0
Bit Position
Description
CAP0
TM0.7
0: Timer/Counter mode
1: Capture mode selection flag
T1ST
TM0.6
0: When cleared, stop the counting.
1: When set, Timer 1 count register is cleared and start again.
T1SL1
T1SL0
TM0.5
TM0.4
00: 16-bit mode (Clock source is selected by T0SL1, T0SL0)
01: 8-bit mode, Clock source is fXIN ÷ 4
10: 8-bit mode, Clock source is fXIN ÷ 16
11: 8-bit mode, Clock source is fXIN ÷ 64
T0ST
TM0.3
0: When cleared, stop the counting.
1: When set, Timer 0 Count Register is cleared and start again.
T0CN
TM0.2
0: Stop the timer
1: A logic 1 starts the timer.
T0SL1
T0SL0
TM0.1
TM0.0
00: EC0 (External clock)
01: 8-bit Timer, Clock source is fXIN ÷ 4
10: 8-bit Timer, Clock source is fXIN ÷ 16
11: 8-bit Timer, Clock source is fXIN ÷ 64
R/W
6
R/W
5
R/W
4
R/W
3
R/W
2
R/W
1
R/W
0
CAP2 T3ST T3SL1 T3SL0 BTCL
T2ST T2CN T2SL1 T2SL0
TIMER 3
ADD RES S: 0E2 H
INITIAL V ALUE: 00 H
Bit Name
R/W
7
TM2
R/W
5
GMS81508B/16B/24B
ADDRESS: 0E3H
INITIAL VALUE: 00H
Bit Name
Bit Position
CAP2
TM2.7
0: Timer/Counter mode
1: Capture mode selection flag
T3ST
TM2.6
0: When cleared, stop the counting.
1: When set, Timer 3 count register is cleared and start again.
T3SL1
T3SL0
TM2.5
TM2.4
00: 16-bit mode (Clock source is selected by T2SL1, T2SL0)
01: 8-bit mode, Clock source is fXIN ÷ 4
10: 8-bit mode, Clock source is fXIN ÷ 16
11: 8-bit mode, Clock source is fXIN ÷ 64
T2ST
TM2.3
0: When cleared, stop the counting.
1: When set, Timer 2 Count Register is cleared and start again.
T2CN
TM2.2
0: Stop the timer
1: A logic 1 starts the timer.
T2SL1
T2SL0
TM2.1
TM2.0
00: EC0 (External clock)
01: 8-bit Timer, Clock source is fXIN ÷ 4
10: 8-bit Timer, Clock source is fXIN ÷ 16
11: 8-bit Timer, Clock source is fXIN ÷ 64
TIMER 2
Description
R/W R/W R/W R/W R/W R/W R/W R/W
7
6
5
4
3
2
1
0
TDR0~TDR3
ADDRESS: 0E4H ~ 0E7H
INITIAL VALUE: Undefined
Read: Count value read
Write: Compare data write
Figure 11-1 TM0, TM2 Registers
DEC. 1999 Ver 1.04
37
GMS81508B/16B/24B
HYUNDAI MicroElectronics
11.1 8-bit Timer / Counter Mode
T3SL1, T3SL0 of TM2 should not set to zero. 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 4, 16, 64 (selected by control bits TxSL1, TxSL0 of register TMx).
The GMS815xxB has four 8-bit Timer/Counters, Timer 0,
Timer 1, Timer 2, Timer 3. The Timer 0, Timer 1 are
shown in Figure .
The “timer” or “counter” function is selected by control
registers TM0, TM2 as shown in Table 11-1 and Table 112. To use as an 8-bit timer/counter mode, bit CAP0 of TM0
is cleared to “0” and bits T1SL1, T1SL0 of TM0 or bits
7
TM0
6
5
4
3
2
1
0
CAP0 T1ST T1SL1 T1SL0 BTCL
T0ST T0CN T0SL1 T0SL0
0
X
X
X
X
ADDRESS: 0E2H
INITIAL VALUE: 00H
X
01 or 10 or 11
X means don’t care
T0SL[1:0]
T0ST
EC0 PIN
Prescaler
XIN PIN
00
÷#4
÷#16
÷#64
0: Stop
1: Clear and start
01
T0 (8-bit)
clear
10
11
MUX
T0CN
TIMER 0
INTERRUPT
T0IF
Comparator
TIMER 0
TDR0 (8-bit)
T1SL[1:0]
T1ST
÷#4
÷#16
÷#64
0: Stop
1: Clear and start
01
T1 (8-bit)
10
clear
11
MUX
T1IF
Comparator
TIMER 1
INTERRUPT
TIMER 1
TDR1 (8-bit)
F/F
T1O PIN
Figure 11-2 8-bit Timer/Counter 0, 1
Example 1:
Example 2:
Timer0 = 4ms 8-bit timer mode at 4MHz
Timer1 = 1ms 8-bit timer mode at 4MHz
Timer0 = 8-bit event counter mode
Timer1 = 1ms 8-bit timer mode at 4MHz
LDM
LDM
LDM
SET1
SET1
EI
38
TDR0,#250
TDR1,#250
TM0,#0110_1111B
T0E
T1E
LDM
LDM
LDM
SET1
SET1
EI
TDR0,#250
TDR1,#250
TM0,#0110_1100B
T0E
T1E
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
ing it as a Tx, written to TDRx.
Note: The contents of Timer data register TDRx should be
initialized 1H~FFH, not 0H, because it is undefined after reset.
In counter function, the counter is increased every 1-to-0
(falling edge) transition of EC0 or EC2 pin. In order to use
counter function, the bit 4, bit 5 of the Port mode register
PMR4 are set to “1”. The Timer 0 can be used as a counter
by pin EC0 input, but Timer 1 can input by internal clock.
Similarly, Timer 2 can be used by pin EC2 input but Timer
3 can not.
In the Timer 0, timer register T0 increments from 00H until
it matches TDR0 and then reset to 00H. The match output
of Timer 0 generates Timer 0 interrupt (latched in T0IF bit)
As TDRx and Tx register are in same address, when read-
7
TM2
6
5
4
3
2
1
0
ADDRESS: 0E3H
INITIAL VALUE: 00H
CAP2 T3ST T3SL1 T3SL0 BTCL
T2ST T2CN T2SL1 T2SL0
0
X
X
X
X
X
01 or 10 or 11
X means don’t care
T2SL[1:0]
Edge Detector
T2ST
EC2 PIN
Prescaler
XIN PIN
00
÷#4
÷#16
÷#64
0: Stop
1: Clear and start
01
T2 (8-bit)
clear
10
11
MUX
T2CN
TIMER 2
INTERRUPT
T2IF
Comparator
TIMER 2
TDR2 (8-bit)
T3SL[1:0]
T3ST
÷#4
÷#16
÷#64
0: Stop
1: Clear and start
01
T3 (8-bit)
10
clear
11
MUX
T3IF
Comparator
TIMER 3
INTERRUPT
TIMER 3
TDR3 (8-bit)
F/F
T3O PIN
Figure 11-3 8-bit Timer/Counter 2, 3
Example 3:
Example 4:
Timer2 = 8-bit timer mode, 2ms interval at 8MHz
Timer3 = 8-bit timer mode, 500us interval at 8MHz
Timer2 = 8-bit event counter mode
Timer3 = 500us 8-bit timer mode at 8MHz
LDM
LDM
LDM
SET1
SET1
EI
TDR2,#250
TDR3,#250
TM2,#0110_1111B
T2E
T3E
DEC. 1999 Ver 1.04
LDM
LDM
LDM
SET1
SET1
EI
TDR2,#250
TDR3,#250
TM2,#0110_1100B
T2E
T3E
39
GMS81508B/16B/24B
HYUNDAI MicroElectronics
8-bit Timer Mode
In the timer mode, the internal clock is used for counting
up. Thus, you can think of it as counting internal clock input. The contents of TDRn are compared with the contents
of up-counter, Tn. If match is found, a timer 1 interrupt
(T1IF) is generated and the up-counter is cleared to 0.
Counting up is resumed after the up-counter is cleared.
Value of
TM[1:0]
Clock
Source
00
01
10
11
fEC1
fXIN ÷ 4
fXIN ÷ 16
fXIN ÷ 64
As the value of TDRn is changeable by software, time interval is set as you want
Resolution
(At fXIN=8 M Hz)
Maximum Time
Setting
(At fXIN=8 M Hz)
1/fEC1 sec
0.5 us
2 us
8 us
1/fEC1 × 256 sec
128 us
512 us
2048 us
Table 11-1 Timer Source clock Interrupt Time
Start count
~
~
Source clock
~
~
Up-counter
0
2
1
n-2
3
n-1
n
0
2
1
3
4
~
~
TDR1
n
~
~
Match
Detect
Counter
Clear
~
~
T1IF interrupt
Figure 11-4 Timer Mode Timing Chart
Example: Make 1msinterrupt using by Timer0 at 8MHz
LDM
LDM
SET1
EI
TM0,#1FH
TDR0,#125
T0E
;
;
;
;
divide by 64
8us x 125= 1ms
Enable Timer 0 Interrupt
Enable Master Interrupt
When
TM0 = 0001 1111B (8-bit Timer mode, Prescaler divide ratio = 64)
TDR0 = 125D = 7DH
fXIN = 8 MHz
1
INTERRUPT PERIOD =
× 64 × 125 = 1 ms
8 × 106 Hz
TDR1
MATCH
(TDR0 = T0)
un
t
co
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 11-5 Timer Count Example
40
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
8-bit Event Counter Mode
In order to use event counter function, the bit 4, 5 of the
Port Mode Register PMR4(address 0D0H) is required to be
set to “1”.
In this mode, counting up is started by an external trigger.
This trigger means falling edge of the EC0 or EC1 pin input. Source clock is used as an internal clock selected with
timer mode register TM0 or TM2. The contents of timer
data register TDRn (n = 0,1,2,3) are compared with the
contents of the up-counter Tn. If a match is found, an timer
interrupt request flag TnIF is generated, and the counter is
cleared to “0”. The counter is restart and count up continuously by every falling edge of the ECn pin input.
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.
1
Period (sec) = ----------- × 2 × Divide Ratio × TDRn
f XIN
The maximum frequency applied to the ECn pin is fXIN/2
[Hz].
Start count
~
~
ECn pin input
~
~
1
0
2
~
~
Up-counter
n-1
n
1
0
2
~
~
n
~
~
TDR1
~
~
T1IF interrupt
Figure 11-6 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 11-7 Count Operation of Timer / Event counter
DEC. 1999 Ver 1.04
41
GMS81508B/16B/24B
HYUNDAI MicroElectronics
11.2 16-bit Timer / Counter Mode
Even if the Timer 0 (including the Timer 1) is used as a 16bit timer, the Timer 2 and Timer 3 can still be used as either
two 8-bit timer or one 16-bit timer by setting the TM2. Reversely, even if the Timer 2 (including the Timer 3) is used
as a 16-bit timer, the Timer 0 and Timer 1 can still be used
as 8-bit timer independently.
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.
7
TM0
6
5
4
3
2
1
0
CAP0 T1ST T1SL1 T1SL0 BTCL
T0ST T0CN T0SL1 T0SL0
0
X
0
0
X
X
X
ADDRESS: 0E2H
INITIAL VALUE: 00H
X
X means don’t care
T0SL[1:0]
EDGE DETECTOR
EC0 PIN
T0ST
0: Stop
1: Clear and start
Prescaler
“00”
XIN PIN
0
÷4
TDR1 + TDR0
(16-bit)
“01”
÷ 16
1
clear
“10”
÷ 64
“11”
MUX
T0CN
TIMER 0
INTERRUPT
T0IF
Comparator
(Not Timer 1 interrupt)
TDR1 + TDR0
(16-bit)
TIMER 0 + TIMER 1 → TIMER 0 (16-bit)
Higher byte Lower byte
COMPARE DATA
7
TM2
6
5
4
3
2
1
0
CAP2 T3ST T3SL1 T3SL0 BTCL
T2ST T2CN T2SL1 T2SL0
0
X
0
0
X
X
X
ADDRESS: 0E3H
INITIAL VALUE: 00H
X
X means don’t care
T2SL[1:0]
EDGE DETECTOR
EC2 PIN
Prescaler
XIN PIN
T2ST
0: Stop
1: Clear and start
“00”
÷4
÷ 16
÷ 64
0
“01”
1
TDR3 + TDR2
(16-bit)
clear
“10”
“11”
MUX
T2CN
T2IF
Comparator
TIMER 2
INTERRUPT
(Not Timer 3 interrupt)
TIMER 2 + TIMER 3 → TIMER 2 (16-bit)
TDR3 + TDR2
(16-bit)
Higher byte Lower byte
COMPARE DATA
Figure 11-8 16-bit Timer/Counter
42
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
11.3 8-bit Capture Mode
causes the current value in the Timer counter register
(T0,T2), to be captured into registers CDRn (CDR0,
CDR2), respectively. After captured, Timer counter register is cleared and restarts by hardware.
The Timer 0 capture mode is set by bit CAP0 of timer
mode register TM0 (bit CAP2 of timer mode register TM2
for Timer 2) as shown in Figure 21. In this mode, Timer 1
still operates as an 8-bit timer/counter.
As mentioned above, not only Timer 0 but Timer 2 can also
be used as a capture mode.
Note: The CDRn and TDRn are in same address.In the
capture mode, reading operation is read the CDRn, not
TDRn because path is opened to the CDRn.
In 8-bit capture mode, Timer 1 and Timer 3 are can not be
used as a capture mode.
It has three transition modes: "falling edge", "rising edge",
"both edge" which are selected by interrupt edge selection
register IEDS. Refer to “16.4 External Interrupt” on page
61. In addition, the transition at INTn pin generate an interrupt.
The Timer/Counter register is incremented in response internal or external input. This counting function is same
with normal timer mode, but Timer interrupt is not generated. Timer/Counter still does the above, but with the added feature that a edge transition at external input INTn pin
7
TM0
6
5
4
3
2
1
0
CAP0 T1ST T1SL1 T1SL0 BTCL
T0ST T0CN T0SL1 T0SL0
1
X
X
X
X
ADDRESS: 0E2H
INITIAL VALUE: 00H
X
01 or 10 or 11
X means don’t care
T0SL[1:0]
Edge Detector
T0ST
EC0 PIN
Prescaler
XIN PIN
“00”
÷4
÷ 16
÷ 64
0: Stop
1: Clear and start
“01”
T0 (8-bit)
“10”
“11”
T0CN
MUX
Capture
To TIMER1
IEDS[1:0]
CDR0 (8-bit)
TIMER 0
“01”
INT0 PIN
“10”
INT0IF
INT0
INTERRUPT
“11”
This figure is a example of using the Timer0.
In the Timer2, operation is same like Timer0, each registers and
flags may be changed with for Timer2.
Figure 11-9 8-bit Capture Mode
DEC. 1999 Ver 1.04
43
GMS81508B/16B/24B
HYUNDAI MicroElectronics
11.4 16-bit Capture Mode
16-bit capture mode is the same as 8-bit capture, except
that the Timer register is being run will 16 bits.
7
TM0
6
5
4
3
2
1
0
CAP0 T1ST T1SL1 T1SL0 BTCL
T0ST T0CN T0SL1 T0SL0
1
0
X
0
X
X
X
ADDRESS: 0E2H
INITIAL VALUE: 00H
X
X means don’t care
T0SL[1:0]
Edge Detector
T0ST
EC0 PIN
Prescaler
XIN PIN
“00”
÷4
÷ 16
÷ 64
TDR1 + TDR0
(16-bit)
“01”
“10”
“11”
MUX
IEDS[1:0]
T0CN
Capture
TDR1 + TDR0
(16-bit)
“01”
INT0 PIN
0: Stop
1: Clear and start
“10”
Higher byte Lower byte
CAPTURE DATA
INT0IF
INT0
INTERRUPT
“11”
TIMER 0 + TIMER 1 → TIMER 0 (16-bit)
This figure is a example of using the Timer0, 1.
In the Timer2, 3, operation is same like Timer0,1, each registers and
flags may be changed with for Timer2,3.
Figure 11-10 16-bit Capture Mode
44
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
Example 1:
Timer0 = 16-bit timer mode, 0.5s at 8MHz
Timer2 = 2ms 8-bit timer mode at 8MHz
Timer3 = 250us 8-bit timer mode at 8MHz
LDM
LDM
LDM
LDM
LDM
LDM
SET1
SET1
SET1
EI
:
:
TDR0,#23H
TDR1,#0F4H
TM0,#0FH
TDR2,#249
TDR3,#124
TM2,#0110_1111B
T0E
T2E
T3E
LDM
LDM
SET1
LDM
LDM
LDM
SET1
LDM
LDM
SET1
EI
:
:
TDR0,#250
TM0,#0111_1111B
T0E
TDR2,#40H
TDR3,#2AH
TM2,#1111_1111B
T2E
IEDS,#XX11_XXXXB
PMR4,#XXXX_X1XXB
INT2E
X: don’t care.
Example 4:
Timer0 = 8-bit timer mode, 2ms interval at 8MHz
Timer2 = 16-bit capture mode
Example 2:
Timer0 = 8-bit timer mode, 2ms interval at 8MHz
Timer2 = 16-bit event counter mode
LDM
LDM
LDM
LDM
LDM
SET1
SET1
EI
:
:
GMS81508B/16B/24B
TDR0,#249
TM0,#0111_1111B
TDR2,#3FH
TDR3,#2AH
TM2,#0100_1100B
T0E
T2E
Example 3:
LDM
LDM
SET1
LDM
LDM
LDM
SET1
LDM
LDM
SET1
EI
:
:
TDR0,#249
TM0,#0111_1111B
T0E
TDR2,#40H
TDR3,#2AH
TM2,#1100_1111B
T2E
IEDS,#XX11_XXXXB
PMR4,#XXXX_X1XXB
INT2E
X: don’t care.
Timer0 = 8-bit timer mode, 2ms interval at 8MHz
Timer2 = 8-bit capture mode
DEC. 1999 Ver 1.04
45
GMS81508B/16B/24B
HYUNDAI MicroElectronics
12. 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 12-2, controls the operation of
the A/D converter module. The port pins can be configured
as analog inputs or digital I/O. To use analog inputs, I/O is
selected input mode by R6DD 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
12-1. The A/D status bit ADSF is set automatically when
A/D conversion is completed, cleared when A/D conversion is in process. The conversion time takes maximum 20
uS (at fXIN=8 MHz).
“0”
AVDD
ADS[2:0]
000
R60/AN0
8-bit DAC
ADEN
LADDER RESISTOR
“1”
001
R61/AN1
R62/AN2
R63/AN3
010
011
100
R64/AN4
S/H
SUCCESSIVE
APPROXIMATION
CIRCUIT
ADIF
A/D
INTERRUPT
101
R65/AN5
R66/AN6
R67/AN7
Sample & Hold
110
111
ADR
ADDRESS: E9H
RESET VALUE: Undefined
A/D result register
Figure 12-1 A/D Block Diagram
Note: On the initial RESET, R60 port is selected as an analog input by ADCM register. So it can not be used digital
input port. To use this port as a digital I/O port, change to
except “0” the value of ADCM. Finally all eight ports can not
be used as digital I/O port simultaneously. At least one port
must be in analog port.
46
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
ADCM
7
-
6
-
GMS81508B/16B/24B
R/W
5
R/W
4
R/W R/W R/W R
3
2
1
0
ADEN ADS2 BTCL
ADS1 ADS0 ADST ADSF
ADDRESS: 0E8H
INITIAL VALUE: --00 0001B
A/D status bit
0: A/D conversion is in progress
1: A/D conversion is completed
A/D start bit
Setting this bit starts an A/D conversion.
After one cycle, bit is cleared to “0” by hardware.
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: 0E9H
INITIAL VALUE: Undefined
A/D Conversion Data
Figure 12-2 A/D Converter Control Register
DEC. 1999 Ver 1.04
47
GMS81508B/16B/24B
HYUNDAI MicroElectronics
13. SERIAL COMMUNICATION
The serial iterface is used to transmit/receive 8-bit data serially. This consists of serial I/O data register, serial I/O
mode register, clock selection circuit octal counter and
control circuit as illustrated in Figure 13-1.Pin R50/SIN,
R51/SOUT, R52/SCLK and R53/SRDY pins are con-
SIOST
trolled by the Serial Mode Register. The contents of the Serial I/O data register can be written into or read out by
software. The data in the Serial Data Register can be shifted synchronously with the transfer clock signal.
SIOSF
SCK[1:0]
XIN PIN
Prescaler
Start
overflow
÷8
÷ 16
÷ 32
00
“11”
CONTROL CIRCUIT
01
10
11
SCLK PIN
Complete
Clock
SRDY In
Clock
Complete
Octal
Counter
SIOIF
Serial communication
Interrupt
MUX
not “11”
SCK[1:0]
SRDY PIN
SRDY Out
Q
R
S
SOUT PIN
Input shift register
SIN PIN
Shift
SIOR
[0EBH]
Internal bus line
Figure 13-1 SCI Block Diagram
48
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
Serial I/O Mode Register(SIOM) controls serial I/O function. According to SCK1 and SCK0, the internal clock or
external clock can be selected.
SIOM
7
-
R/W
6
R/W
5
SRDY SM1
R/W
4
Serial I/O Data Register(SIOR) is an 8-bit shift register.
First LSB is send or is received.
R/W R/W R/W R
3
2
1
0
SM0 BTCL
SCK1 SCK0 SIOST SIOSF
ADDRESS: 0EAH
INITIAL VALUE: -000 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: fXIN ÷ 32
11: External Clock
Serial transmission Operation Mode
00: Normal Port(R52,R51,R50)
01: Sending Mode(SCLK,SOUT,R50)
10: Receiving Mode(SCLK,R51,SIN)
11: Sending & Receiving Mode(SCLK,SOUT,SIN)
R53/SRDY Selection
0: R53
1: SRDY
SIOR
R/W R/W R/W R/W R/W R/W R/W R/W
7
6
5
4
3
2
1
0
BTCL
ADDRESS: 0EBH
INITIAL VALUE: Undefined
Sending Data at Sending Mode
Receiving Data at Receiving Mode
Figure 13-2 SCI Control Register
DEC. 1999 Ver 1.04
49
GMS81508B/16B/24B
HYUNDAI MicroElectronics
13.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(IFSIO) 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
Input Clock
SCLK PIN
SIOST FLAG
Output
SOUT PIN
D0
SIN PIN
D0
D1
D2
D3
D4
D5
D6
D7
D1
D2
D3
D4
D5
D6
D7
Latch
SIOIF
INTERRUPT SIGNAL
Figure 13-3 Timing Diagram of Serial I/O
13.2 The Serial I/O operation by SRDY pin
Transmission clock = external clock
The SRDY pin becomes “L” by SIOST = “1”. This signal
tells to the external system that this device is ready for se-
rial transmission. The external system detects the “L” signal and starts transmission. The SRDY pin becomes “H” at
the first rising edge of transmission clock.
SIOST
SRDY(Output)
Transmission clock = internal clock
The I/O of SRDY pin is input mode. When the external
system is ready for serial transmission, The “L” level is in-
putted at this pin. At this time this device starts serial transmission.
SIOST
SRDY(Input)
50
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
13.3 The method of Serial I/O
1. Select transmission/receiving mode.
Note: When external clock is used, the frequency should
be less than 1MHz and recommended duty is 50%. If both
transmission mode is selected and transmission is performed simultaneously it would be made error.
2. In case of sending mode, write data to be send to SIOR.
3. Set SIOST to “1” to start serial transmission.
4. The SIO interrupt is generated at the completion of SIO
and SIOSF is set to “1”. In SIO interrupt service routine,
correct transmission should be tested.
5. In case of receiving mode, the received data is acquired
by reading the SIOR.
13.4 The Method to Test Correct Transmission
Serial I/O Interrupt
Service Routine
SIOSF
0
1
Abnormal
SE = 0
Write SIOM
SR
0
1
Normal Operation
Overrun Error
- SE: Interrupt Enable Register Low IENL(Bit3)
- SR: Interrupt Request Flag Register Low IRQL(Bit3)
Figure 13-4 Serial Method to Test Transmission
DEC. 1999 Ver 1.04
51
GMS81508B/16B/24B
HYUNDAI MicroElectronics
14. PWM OUTPUT
The GMS815xxB have two channels of built-in pulse
width modulation outputs. PWM outputs data are multiplex to the R56 and R57 port. Bit 6 and bit 7 of R5DD
should be set to “1” when PWM is used as an output port.
The input clock is selected by PWM Control Register
(PWMCR, address F2H) and the width of pulse is determined by the PWM Register (PWMR, address F0H and
F1H).
P0CK[1:0]
fXIN ÷ 256
00
fXIN ÷ 512
01
fXIN ÷ 1024
10
fXIN ÷ 2048
11
F/F
1
0
8-bit Counter
Overflow
EN0
S
R
Q
PWM0
Comparator
MUX
PWMR0
POL0
[0F0H]
P1CK[1:0]
fXIN ÷ 256
00
fXIN ÷ 512
01
fXIN ÷ 1024
10
fXIN ÷ 2048
11
F/F
1
0
8-bit Counter
Overflow
EN1
S
R
Q
PWM1
Comparator
MUX
PWMR1
POL1
[0F1H]
Figure 14-1 PWM block diagram
The pulse period according to input clock are shown as below.
Input clock
fXIN ÷ 256
fXIN ÷ 512
fXIN ÷ 1024
fXIN ÷ 2048
Period of PWM
8.19 ms
16.38 ms
32.77 ms
65.54 ms
Bit 2 (EN0) and bit 3 (EN1) of PWMCR determine the operation channel of PWM. When EN0=0 and EN1=0, PWM
does not execute
52
It is a PWM output controlled by PWMCR, PWMR0 and
PWMR1.
PWMR + 1
Duty ratio = ---------------------------- × 100%
256
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
W
W
W
W
GMS81508B/16B/24B
ADDRESS: 0F0H
RESET VALUE: Undefined
W W
W
W
PWMR0
Duty data
W
W
W
W
ADDRESS: 0F1H
RESET VALUE: Undefined
W
W
W
W
PWMR1
Duty data
Figure 14-2 PWM Duty Register
W
7
PWMCR
W
6
W
5
W
4
W
3
P1CK1 P1CK0 P0CK1 P0CK0 BTCL
EN1
W
2
EN0
W
1
POL1
W
0
ADDRESS: 0F2H
INITIAL VALUE: 0000 0000B
POL0
PWM0 output polarity
0: Active low
1: Active high
PWM1 output polarity
0: Active low
1: Active high
PWM1 clock selection
PWM0 clock selection
00: fXIN ÷ 256
01: fXIN ÷ 512
10: fXIN ÷ 1024
11: fXIN ÷ 2048
00: fXIN ÷ 256
01: fXIN ÷ 512
10: fXIN ÷ 1024
11: fXIN ÷ 2048
PWM enable flag
00: Disable
01: PWM0
10: PWM1
11: Both (PWM0 and PWM1)
Figure 14-3 PWM Control Register
Example:
PWM0: Period = 16.384ms, Duty = 20%
PWM1: Period = 8.192ms, Duty = 70%
DEC. 1999 Ver 1.04
LDM
LDM
LDM
PWMCR,#0100_1111B
PWMR0,#0B3H
PWMR1,#33H
53
GMS81508B/16B/24B
HYUNDAI MicroElectronics
active high
enable
PWMCR
0
1
0
fXIN
fixed
8MHz ÷ 512 ÷ 256 = 61.035Hz
0
1
1
1
1
fXIN
fixed
8MHz ÷ 256 ÷ 256 = 122.07Hz
16.384ms
8.192ms
5.728ms
3.264ms
PWM1
PWM0
PWMR0
PWMR1
33 H
16.384 × ------------- = 3.264ms
100 H
B3 H
8.192 × ------------- = 5.728ms
100 H
Figure 14-4 Example of Register Setting
54
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
15. BUZZER FUNCTION
The buzzer driver block consists of 6-bit binary counter,
buzzer register, and clock source selector. It generates
square-wave which has very wide range frequency (500Hz
~ 250kHz at fXIN= 8MHz) by user software.
The bit 0 to 5 of BUR determines output frequency for
buzzer driving.
A 50% duty pulse can be output to R55/BUZ pin to use for
piezo-electric buzzer drive. Pin R55 is assigned for output port
f XIN
f BUZ = ------------------------------------------------------------2 × DivideRatio × BUR
Equation of frequency calculation is shown below.
of Buzzer driver by setting the bit 5 of PMR5 (address D1H) to
“1”. At this time, the pin R55 must be defined as output
fBUZ: Buzzer frequency
mode (the bit 5 of R5DD=1).
fXIN: Oscillator frequency
Example: 2.4kHz output at 8MHz.
Divide Ratio: Prescaler divide ratio by BUCK[1:0]
BUR: Lower 6-bit value of BUR. Buzzer period value.
LDM
LDM
R5DD,#XX1X_XXXXB
BUR,#9AH
LDM
PMR5,#XX1X_XXXXB
The frequency of output signal is controlled by the buzzer
control register BUR.The bit 0 to bit 5 of BUR determine
output frequency for buzzer driving.
X means don’t care
R55 port data
6-bit binary
Prescaler
÷16
XIN PIN
00
÷32
6-BIT COUNTER
01
÷64
÷128
0
÷2
10
R55/BUZ PIN
1
F/F
11
Comparator
MUX
2
Compare data
6
PMR5
BUR
Port selection
[0D1H]
[0ECH]
Internal bus line
Figure 15-1 Block Diagram of Buzzer Driver
ADDRESS: 0D1H
RESET VALUE: --00 ----B
W
PMR5
-
-
ADDRESS: 0ECH
RESET VALUE: Undefined
W
W
-
-
-
-
BUR
W
W
W
W
W
W
W
BUCK1 BUCK0
R54/WDTO Selection
0: R54
1: WDTO (Output)
R55/BUZ Selection
0: R55 port (Turn off buzzer)
1: BUZ port (Turn on buzzer)
BUR[5:0]
Buzzer Period Data
Source clock select
00: ÷16
01: ÷ 32
10: ÷ 64
11: ÷128
Figure 15-2 PMR5 and Buzzer Register
DEC. 1999 Ver 1.04
55
GMS81508B/16B/24B
HYUNDAI MicroElectronics
Note: BUR is undefined after reset, so it must be initialized
to between 1H and 3FH by software.
Note that BUR is a write-only register.
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-bit BUR value.
When main-frequency is 8MHz, buzzer frequency is
shown as below table.
BUR
[5:0]
BUR[7:6]
00
01
10
11
BUR
[5:0]
BUR[7:6]
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
125.000
62.500
41.667
31.250
25.000
20.833
17.857
62.500
31.250
20.833
15.625
12.500
10.417
8.929
31.250
15.625
10.417
7.813
6.250
5.208
4.464
20
21
22
23
24
25
26
27
7.813
7.576
7.353
7.143
6.944
6.757
6.579
6.410
3.906
3.788
3.676
3.571
3.472
3.378
3.289
3.205
1.953
1.894
1.838
1.786
1.736
1.689
1.645
1.603
0.977
0.947
0.919
0.893
0.868
0.845
0.822
0.801
08
09
0A
0B
0C
0D
0E
0F
31.250
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
28
29
2A
2B
2C
2D
2E
2F
6.250
6.098
5.952
5.814
5.682
5.556
5.435
5.319
3.125
3.049
2.976
2.907
2.841
2.778
2.717
2.660
1.563
1.524
1.488
1.453
1.420
1.389
1.359
1.330
0.781
0.762
0.744
0.727
0.710
0.694
0.679
0.665
10
11
12
13
14
15
16
17
15.625
14.706
13.889
13.158
12.500
11.905
11.364
10.870
7.813
7.353
6.944
6.579
6.250
5.952
5.682
5.435
3.906
3.676
3.472
3.289
3.125
2.976
2.841
2.717
1.953
1.838
1.736
1.645
1.563
1.488
1.420
1.359
30
31
32
33
34
35
36
37
5.208
5.102
5.000
4.902
4.808
4.717
4.630
4.545
2.604
2.551
2.500
2.451
2.404
2.358
2.315
2.273
1.302
1.276
1.250
1.225
1.202
1.179
1.157
1.136
0.651
0.638
0.625
0.613
0.601
0.590
0.579
0.568
18
19
1A
1B
1C
1D
1E
1F
10.417
10.000
9.615
9.259
8.929
8.621
8.333
8.065
5.208
5.000
4.808
4.630
4.464
4.310
4.167
4.032
2.604
2.500
2.404
2.315
2.232
2.155
2.083
2.016
1.302
1.250
1.202
1.157
1.116
1.078
1.042
1.008
38
39
3A
3B
3C
3D
3E
3F
4.464
4.386
4.310
4.237
4.167
4.098
4.032
3.968
2.232
2.193
2.155
2.119
2.083
2.049
2.016
1.984
1.116
1.096
1.078
1.059
1.042
1.025
1.008
0.992
0.558
0.548
0.539
0.530
0.521
0.512
0.504
0.496
Table 15-1 Buzzer Frequency
56
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
16. INTERRUPTS
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 GMS815xxB 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 16-2.
Reset/Interrupt
The External Interrupts INT0 ~ INT3 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
INT0F, INT1F, INT2F and INT3F in register IRQH. When
an external interrupt is generated, the flag that generated it
is cleared by the hardware when the service routine is vectored to only if the interrupt was transition-activated.
Hardware Reset
External Interrupt 0
External Interrupt 1
External Interrupt 2
External Interrupt 3
Timer/Counter 0
Timer/Counter 1
Timer/Counter 2
Timer/Counter 3
ADC Interrupt
Basic Interval Timer
Watchdog Timer
Serial Communication
The Timer 0 ~ Timer 3 Interrupts are generated by TxIF
which is set by a match in their respective timer/counter
register. The Basic Interval Timer Interrupt is generated by
BITIF which is set by an overflow in the timer register.
The AD converter Interrupt is generated by ADIF which is
set by finishing the analog to digital conversion.
The Watchdog timer Interrupt is generated by WDTIF
which set by a match in Watchdog timer register.
The Basic Interval Timer INterrupt is generated by BITIF
which are set by a overflow in the timer counter register.
R/W
R/W
R/W
R/W
INT0IF INT1IF INT2IF INT3IF
Priority
RESET
INT0
INT1
INT2
INT3
Timer 0
Timer 1
Timer 2
Timer 3
ADC
BIT
WDT
SCI
1
2
3
4
5
6
7
8
9
10
11
12
13
Vector addresses are shown in Figure 8-6 on page 21. Interrupt enable registers are shown in Figure 16-3. These
registers are composed of interrupt 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, I-flag, which disables all interrupts at once.
The interrupts are controlled by the interrupt master enable
flag I-flag (bit 2 of PSW on page 19), the interrupt enable
IRQH
Symbol
R/W
R/W
R/W
R/W
T0IF
T1IF
T2IF
T3IF
MSB
ADDRESS: 0F7H
INITIAL VALUE: 0000 0000B
LSB
Timer/Counter 3 interrupt request flag
Timer/Counter 2 interrupt request flag
Timer/Counter 1 interrupt request flag
Timer/Counter 0 interrupt request flag
External interrupt 3 request flag
External interrupt 3 request flag
External interrupt 3 request flag
External interrupt 3 request flag
R/W
IRQL
ADIF
MSB
R/W
R/W
-
-
-
-
WDTIF BITIF
SIOIF
-
-
-
-
R/W
ADDRESS: 0F5H
INITIAL VALUE: 0000 ----B
LSB
Serial Communication interrupt request flag
Basic Interval Timer interrupt request flag
Watchdog timer interrupt request flag
A/D Converter interrupt request flag
Figure 16-1 Interrupt Request Flag
DEC. 1999 Ver 1.04
57
GMS81508B/16B/24B
HYUNDAI MicroElectronics
.
Internal bus line
[0F6H]
Interrupt Enable
Register (Higher byte)
IENH
IRQH
[0F7H]
INT0IF
INT1
INT1IF
INT2
INT2IF
INT3
INT3IF
Timer 0
T0IF
Timer 1
T1IF
Timer 2
T2IF
Timer 3
T3IF
Release STOP
Priority Control
INT0
To CPU
I-flag
Interrupt Master
Enable Flag
IRQL
[0F5H]
A/D Converter
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.
ADIF
Watchdog Timer
Interrupt
Vector
Address
Generator
WDTIF
BIT
BITIF
Serial
Communication
SIOIF
[0F4H]
IENL
Interrupt Enable
Register (Lower byte)
Internal bus line
Figure 16-2 Block Diagram of Interrupt
R/W
IENH
INT0E
R/W
R/W
R/W
INT1E INT2E INT3E
R/W
R/W
R/W
R/W
T0E
T1E
T2E
T3E
MSB
ADDRESS: 0F6H
INITIAL VALUE: 0000 0000B
LSB
Timer/Counter 3 interrupt enable flag
Timer/Counter 2 interrupt enable flag
Timer/Counter 1 interrupt enable flag
Timer/Counter 0 interrupt enable flag
External interrupt 3 enable flag
External interrupt 2 enable flag
External interrupt 1 enable flag
External interrupt 0 enable flag
IENL
R/W
R/W
R/W
R/W
-
-
-
-
ADE
WDTE
BITE
SIOE
-
-
-
-
MSB
VALUE
0: Disable
1: Enable
ADDRESS: 0F4H
INITIAL VALUE: 0000 ----B
LSB
Serial Communication interrupt enable flag
Basic Interval Timer interrupt enable flag
Watchdog timer interrupt enable flag
A/D Converter interrupt enable flag
Figure 16-3 Interrupt Enable Flag
58
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
16.1 Interrupt Sequence
An interrupt request is held until the interrupt is accepted
or the interrupt latch is cleared to “0” by a reset or an instruction. Interrupt acceptance sequence requires 8 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 16-4 Timing chart of Interrupt Acceptance and Interrupt Return Instruction
Basic Interval Timer
Vector Table Address
0FFE6H
0FFE7H
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 BIT 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.
DEC. 1999 Ver 1.04
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
59
GMS81508B/16B/24B
HYUNDAI MicroElectronics
area for saving registers.
16.2 BRK Interrupt
The following method is used to save/restore the generalpurpose registers.
Software interrupt can be invoked by BRK instruction,
which has the lowest priority order.
Example: Register save using push and pop instructions
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.
INTxx:
PUSH
PUSH
PUSH
A
X
Y
;SAVE ACC.
;SAVE X REG.
;SAVE Y REG.
interrupt processing
POP
POP
POP
RETI
Y
X
A
Each processing step is determined by B-flag as shown in
Figure 16-5.
;RESTORE Y REG.
;RESTORE X REG.
;RESTORE ACC.
;RETURN
B-FLAG
General-purpose register save/restore using push and pop
instructions;
main task
acceptance of
interrupt
BRK or
TCALL0
=0
=1
BRK
INTERRUPT
ROUTINE
TCALL0
ROUTINE
RETI
RET
interrupt
service task
saving
registers
restoring
registers
Figure 16-5 Execution of BRK/TCALL0
interrupt return
60
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
16.3 Multi Interrupt
If two requests of different priority levels are received simultaneously, the request of higher priority level is serviced. If requests of the interrupt are received at the same
time simultaneously, an internal polling sequence determines by hardware which request is serviced.
Example: During Timer1 interrupt is in progress, INT0 interrupt serviced without any suspend.
Main Program
service
TIMER 1
service
enable INT0
disable other
INT0
service
EI
Occur
TIMER1 interrupt
However, multiple processing through software for special
features is possible. Generally when an interrupt is accepted, the I-flag is cleared to disable any further interrupt. But
as user sets I-flag in interrupt routine, some further interrupt can be serviced even if certain interrupt is in progress.
Occur
INT0
enable INT0
enable other
TIMER1: PUSH
PUSH
PUSH
LDM
LDM
EI
:
:
:
:
:
:
LDM
LDM
POP
POP
POP
RETI
A
X
Y
IENH,#80H
IENL,#0
;Enable INT0 only
;Disable other
;Enable Interrupt
IENH,#0FFH ;Enable all interrupts
IENL,#0F0H
Y
X
A
In this example, the INT0 interrupt can be serviced without any
pending, even TIMER1 is in progress.
Because of re-setting the interrupt enable registers IENH,IENL
and master enable “EI” in the TIMER1 routine.
Figure 16-6 Execution of Multi Interrupt
16.4 External Interrupt
The external interrupt on INT0, INT1, INT2 and INT3 pins
are edge triggered depending on the edge selection register
IEDS (address 0F8H) as shown in Figure 16-7.
DEC. 1999 Ver 1.04
The edge detection of external interrupt has three transition
61
GMS81508B/16B/24B
HYUNDAI MicroElectronics
activated mode: rising edge, falling edge, and both edge.
spondingly.
Example: To use as an INT0 and INT2
INT0 pin
INT0IF
INT0 INTERRUPT
INT1 pin
INT1IF
INT1 INTERRUPT
INT2 pin
INT2IF
:
:
;**** Set port as an input port R40,R42
LDM
R4DD,#1111_1010B
;
;**** Set port as an external interrupt port
LDM
PMR4,#05H
;
;**** Set Falling-edge Detection
LDM
IEDS,#0001_0001B
:
:
:
INT2 INTERRUPT
INT3 pin
Response Time
INT3IF
INT3 INTERRUPT
2
2
IEDS
2
2
Edge selection
Register
[0F8H]
Figure 16-7 External Interrupt Block Diagram
INT0 ~ INT3 are multiplexed with general I/O ports
(R40~R43). To use as an external interrupt pin, the bit of
R4 port mode register PMR4 should be set to “1” corre-
max. 12 fXIN
Interrupt Interrupt
goes
latched
active
The INT0 ~ INT3 edge are latched into INT1IF ~ INT3IF
at every machine cycle. The values are not actually polled
by the circuitry until the next machine cycle. If a request is
active and conditions are right for it to be acknowledged, a
hardware subroutine call to the requested service routine
will be the next instruction to be executed. The DIV itself
takes twelve cycles. Thus, a minimum of twelve complete
machine cycles elapse between activation of an external
interrupt request and the beginning of execution of the first
instruction of the service routine.
Figure 16-8shows interrupt response timings.
8 fXIN
Interrupt
processing
Interrupt
routine
Figure 16-8 Interrupt Response Timing Diagram
62
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
PMR4
GMS81508B/16B/24B
W
W
W
W
T3S
T1S
EC2S
W
W
W
W
ADDRESS: 0D0H
INITIAL VALUE: 00H
EC0S INT3S
BTCL INT2S INT1S INT0S
0: R47
1: T3O
MSB
LSB
0: R40
1: INT0
0: R46
1: T1O
0: R41
1: INT1
0: R45
1: EC2
0: R42
1: INT2
0: R44
0: R43
1: INT3
1: EC0
MSB
W
IEDS
W
W
W
W
W
W
LSB
W
BTCL IED1L IED0H IED0L
IED3H IED3L IED2H IED2L IED1H
INT3
INT2
INT1
ADDRESS: 0F8H
INITIAL VALUE: 00H
INT0
Edge selection register
00: Reserved
01: Falling (1-to-0 transition)
10: Rising (0-to-1 transition)
11: Both (Rising & Falling)
Figure 16-9 PMR4 and IEDS Registers
DEC. 1999 Ver 1.04
63
GMS81508B/16B/24B
HYUNDAI MicroElectronics
17. WATCHDOG TIMER
When the watchdog timer is not being used for malfunction detection, it can be used as a timer to generate an interrupt at fixed intervals.
The 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.
clear
BASIC INTERVAL TIMER
OVERFLOW
Watchdog
Counter (8-bit)
Count source
clear
“0”
to reset CPU
“1”
enable
comparator
WDTON in CKCTLR [0D3H]
6-bit compare data
WDTCL
WDTIF
6
Watchdog Timer interrupt
Watchdog Timer
Register
WDTR
[0E0H]
Internal bus line
Figure 17-1 Block Diagram of Watchdog Timer
Watchdog Timer Control
er output will become active at the rising overflow from
the binary counters unless the binary counter is cleared. At
this time, when WDTON=1, a reset is generated, which
drives the RESET pin to low to reset the internal hardware.
When WDTON=0, a watchdog timer interrupt (WDTIF) is
generated.
Figure 17-2 shows the watchdog timer control register.
The watchdog timer is automatically disabled after reset.
The CPU malfunction is detected during setting of the detection time, selecting of output, and clearing of the binary
counter. Clearing the binary counter is repeated within the
detection time.
The watchdog timer temporarily stops counting in the
STOP mode, and when the STOP mode is released, it automatically restarts (continues counting).
If the malfunction occurs for any cause, the watchdog timW
7
WDTR
-
W
6
W
5
W
4
W
3
W
2
W
1
W
0
W DTCL
ADDRESS: 0E0H
INITIAL VALUE: -011_1111B
6-bit compare data
Clear count flag
0: Free-run count
1: When the WDTCL is set to “1”, binary counter
is cleared to “0”. And the WDTCL becomes “0” automatically
after one machine cycle. Counter count up again.
NOTE:
The WDTON bit is in register CKCTLR.
Figure 17-2 WDTR: Watchdog Timer Data Register
64
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
Example: Sets the watchdog timer detection time to 0.5 sec at 4.19MHz
Within WDT
detection time
Within WDT
detection time
LDM
LDM
CKCTLR,#3FH
WDTR,#04FH
;Select 1/2048 clock source, WDTON ← 1, Clear Counter
LDM
:
:
:
:
LDM
:
:
:
:
LDM
WDTR,#04FH
;Clear counter
WDTR,#04FH
;Clear counter
WDTR,#04FH
;Clear counter
Enable and Disable Watchdog
Watchdog Timer Interrupt
Watchdog timer is enabled by setting WDTON (bit 5 in
CKCTLR) to “1”. WDTON is initialized to “0” during reset and it should be set to “1” to operate after reset is released.
The watchdog timer can be also used as a simple 6-bit timer by clearing bit5 of CKCTLR to “0”. The interval of
watchdog timer interrupt is decided by Basic Interval Timer. Interval equation is shown as below.
Example: Enables watchdog timer for Reset
:
LDM
:
:
T = WDTR × Interval of BIT
CKCTLR,#xx1x_xxxxB;WDTON ← 1
The stack pointer (SP) should be initialized before using
the watchdog timer output as an interrupt source.
Example: 6-bit timer interrupt set up.
The watchdog timer is disabled by clearing bit 5 (WDTON) of CKCTLR. The watchdog timer is halted in STOP
mode and restarts automatically after STOP mode is released.
LDM
LDM
CKCTLR,#xx0xxxxxB;WDTON ←0
WDTR,#7FH
;WDTCL ←1
:
Source clock
BIT overflow
Binary-counter
2
1
3
0
1
2
3
0
Counter
Clear
WDTR
3
n
Match
Detect
WDTIF interrupt
WDTR ← “0100_0011B”
WDT reset
reset
Figure 17-3 Watchdog timer Timing
If the watchdog timer output becomes active, a reset is generated, which drives the RESET pin low to reset the internal hardware.
DEC. 1999 Ver 1.04
The main clock oscillator also turns on when a watchdog
timer reset is generated in sub clock mode.
65
GMS81508B/16B/24B
HYUNDAI MicroElectronics
18. POWER DOWN OPERATION
GMS815xxB has a power-down mode. In power-down
mode, power consumption is reduced considerably that in
battery operation. Battery life can be extended a lot.
STOP Mode is entered by STOP instruction.
18.1 STOP Mode
For applications where power consumption is a critical
factor, device provides reduced power of STOP.
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.
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
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.
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.
CPU
All CPU operations are disabled
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.
RAM
Retain
Example:
XIN PIN
Low
XOUT PIN
High
Oscillation
Stop
I/O ports
Retain
Control Registers
Retain
Release method
by RESET, by External interrupt
Peripheral
STOP Mode
LDM
STOP
NOP
NOP
:
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.
~
~ ~
~
~
~
Oscillator
(XIN pin)
CKCTLR,#0000_1110B
~
~
~
~
Internal Clock
~
~
STOP Instruction
Executed
n+1 n+2
n+3
0
1
~
~ ~
~
n
~ ~
~
~
BIT Counter
~
~
External Interrupt
FE
FF
0
1
2
Clear
Normal Operation
Stop Operation
tST > 20ms
by software
Normal Operation
Before executing Stop instruction, Basic Interval Timer must be set
properly by software to get stabilization time which is longer than 20ms.
Figure 18-1 STOP Mode Release Timing by External Interrupt
66
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
Release the STOP mode
The exit from STOP mode is using hardware reset or external interrupt.
To release STOP mode, corresponding interrupt should be
enabled before STOP mode.
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.
Chip function after event
Event
MCU Status before event
PC
Oscillator Circuit
Don’t care
Vector
on
STOP instruction
Normal operation
N +1
off
External Interrupt
Normal operation
Vector
on
External Interrupt Wake up
STOP, I flag = 1
STOP, I flag = 0
Vector
N+1
on
on
RESET
Table 18-1 Wake-up and Reset Function Table
18.2 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
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.
DEC. 1999 Ver 1.04
It should be set properly in order that current flow through
port doesn't exist.
First conseider the setting to input mode. Be sure that there
is no current flow after considering its relationship with
external circuit. In input mode, the pin impedance viewing
from external MCU is very high that the current doesn’t
flow.
But input voltage level should be VSS or VDD. Be careful
that if unspecified voltage, i.e. if unfirmed voltage level
(not VSSor VDD) is applied to input pin, there can be little
current (max. 1mA at around 2V) 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
67
GMS81508B/16B/24B
HYUNDAI MicroElectronics
is external pull-down register, it is set to low.
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
O
OPEN
Weak pull-up current flows
GND
O
When port is configure as an input, input level should
be closed to 0V or 5V to avoid power consumption.
Figure 18-2 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 18-3 Application Example of Unused Output Port
68
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
19. OSCILLATOR CIRCUIT
The GMS815xxB has two oscillation circuits internally.
XIN and XOUT are input and output for frequency, respec-
tively, inverting amplifier which can be configured for being used as an on-chip oscillator, as shown in Figure 19-1.
C1
XOUT
Open
C2
8MHz
XOUT
XIN
External Clock
VSS
XIN
Recommend
Crystal Oscillator
External Oscillator
C1,C2 = 30pF±10pF
Crystal or Ceramic Oscillator
Figure 19-1 Oscillation Circuit
Oscillation circuit is designed to be used either with a ceramic resonator or crystal oscillator. Since each crystal and
ceramic resonator have their own characteristics, the user
should consult the crystal manufacturer for appropriate
values of external components.
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.
XOUT
XIN
In addition, see Figure 19-2 for the layout of the crystal.
Note: Minimize the wiring length. Do not allow the wiring to
intersect with other 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.
DEC. 1999 Ver 1.04
Figure 19-2 Layout of Oscillator PCB circuit
69
GMS81508B/16B/24B
HYUNDAI MicroElectronics
20. RESET
The GMS815xxB have two types of reset generation procedures; one is an external reset input, the other is a watchOn-chip Hardware
Program counter
G-flag
Initial Value
(PC)
dog timer reset. Table 20-1 shows on-chip hardware initialization by reset action.
On-chip Hardware
Initial Value
(FFFFH) - (FFFEH)
Watchdog timer
Disable
0
Control registers
Refer to Table 8-1 on page 25
(G)
Peripheral clock
Off
Power fail detector
Disable
Table 20-1 Initializing Internal Status by Reset Action
20.1 External Reset Input
The reset input is the RESET pin, which is the input to a
Schmitt Trigger. A reset in accomplished by holding the
RESET pin low for at least 8 oscillator periods, within the
operating voltage range and oscillation stable, it is applied,
and the internal state is initialized. After reset, 64ms (at 4
MHz) add with 7 oscillator periods are required to start execution as shown in Figure 20-2.
A connection for simple power-on-reset is shown in Figure
20-1.
VCC
10kΩ
Internal RAM is not affected by reset. When VDD is turned
on, the RAM content is indeterminate. Therefore, this
RAM should be initialized before read or tested it.
+
10uF
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.
Figure 20-1 Simple Power-on-Reset Circuit
1
3
?
?
4
5
6
7
~
~
RESET
~
~
?
?
FFFE FFFF Start
~
~ ~
~
?
?
?
?
FE
ADL
ADH
OP
~
~
DATA
BUS
2
~
~
Oscillator
(XIN pin)
ADDRESS
BUS
to the RESET pin
7036P
Stabilization Time
tST = 62.5mS at 4.19MHz
RESET Process Step
tST =
1
fMAIN ÷1024
MAIN PROGRAM
x 256
Figure 20-2 Timing Diagram after RESET
20.2 Watchdog Timer Reset
Refer to “17. WATCHDOG TIMER” on page 64.
70
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
21. POWER FAIL PROCESSOR
The GMS815xxB has an on-chip power fail detection circuitry to immunize against power noise. A configuration
register, PFDR, can enable or disable the power fail detect
circuitry. Whenever VDD falls close to or below power fail
voltage for 100ns, the power fail situation may reset or
freeze MCU according to PFR bit of PFDR. Refer to “7.4
DC Electrical Characteristics” on page 13.
Note: If power fail voltage is selected to 3.0V on 3V operation, MCU is freezed at all the times.
Power FailFunction
OTP
MASK
Enable/Disable
by PFD flag
by PFD flag
Level Selection
by PFV flag
by mask option
In the in-circuit emulator, power fail function is not implemented and user can not experiment with it. Therefore, after final development of user program, this function may
be experimented or evaluated.
Table 21-1 Power fail processor
Note: User can select power fail voltage level according to
PFV bit of PFDR at the OTP(GMS815xxBT) but must select
the power fail voltage level to define PFD option of “Mask
Order & Verification Sheet” at the mask chip(GMS815xxB).
Because the power fail voltage level of mask chip
(GMS815xxB) is determined according to mask option regardless of PFV bit of PFDR
7
PFDR
6
5
4
R/W
3
PFV
R/W
2
R/W
1
R/W
0
PFD
PFR
PFS
ADDRESS: 0F9H
INITIAL VALUE: ---- 1100B
Power Fail Status
0: Normal operate
1: Set to “1” if power fail is detected
Operation Mode
0: Normal operation regardless of power fail
1: MCU will be reset by power fail detection
Disable Flag
0: Power fail detection enable
1: Power fail detection disable
Power Fail Voltage Selection Flag
0: 2.4V
1: 3.0V
Figure 21-1 Power Fail Voltage Detector Register
DEC. 1999 Ver 1.04
71
GMS81508B/16B/24B
HYUNDAI MicroElectronics
RESET VECTOR
YES
PFS =1
NO
RAM CLEAR
INITIALIZE RAM DATA
PFS = 0
Skip the
initial routine
INITIALIZE ALL PORTS
INITIALIZE REGISTERS
FUNTION
EXECUTION
Figure 21-2 Example S/W of RESET flow by Power fail
VDD
VPFDMAX
VPFDMIN
64mS
Internal
RESET
VDD
When PFR = 1
Internal
RESET
64mS
t <64mS
VDD
Internal
RESET
VPFDMAX
VPFDMIN
64mS
VPFDMAX
VPFDMIN
Figure 21-3 Power Fail Processor Situations
72
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
22. OTP PROGRAMMING
The GMS81516BT/24BT are OTP (One Time Programmable) microcontrollers. Its internal user memory is constructed with EPROM (Electrically Programmable Read
Only Memory).
The OTP micorcontroller is generally used for chip evaluation, first production, small amount production, fast mass
production, etc.
Blank OTP’s internal EPROM is filled by 00H, not FFH.
Note: In any case, you have to use *.OTP file, not *.HEX
file. After assemble, both OTP and HEX file are generated
by automatically. The HEX file is used during porgram emulation on emulator.
22.1 How to Program
To program the OTP devices, user can use HME own programmer or third party universal programmer shown as
listed below.
HME own programmer list
Manufacturer: Hyundai MicroElectronics
Programmer: Choice-Dr Writer
Choice-Sigma, Choice-Gang4
The Choice-Dr Writer is single writer and physically addon adapter board type, it should be used with Choice-Dr
emulator. However, the Choice-Sigma is stand alone HME
universal single programmer for any HME OTP devices,
also the Choice-Gang4 can program four OTPs at once.
Ask to HME sales part which is listed on appendix of this
manual.
Third party programmer list
Manufacturer: Hi-Lo Systems
Programmer: ALL-11, ALL-07
Website : http: //www.hilosystems.com.tw
posed of Motorola-S1 format.
3. Set the programming address range as below table.
GMS81516BT
Address
Set Value
Bufferstart address
4000H
Buffer end address
7FFFH
Device start address
C000H
GMS81524BT
Address
Set Value
Bufferstart address
2000H
Buffer end address
7FFFH
Device start address
A000H
4. Mount the socket adapter on the programmer.
5. Start program/verify.
22.2 Pin Function
VPP (Program Voltage)
VPP is the input for the program voltage for programming
the EPROM.
CE (Chip Enable)
CE is the input for programming and verifying internal
EPROM.
OE (Output Enable)
OE is the input of data output control signal for verify.
A0~A15 (Address Bus)
A0~A15 are address input pins for internal EPROM.
O0~O7 (EPROM Data Bus)
These are data bus for internal EPROM.
Socket adapters are supported by third party programmer’s
manufacturer. The other third party will be registered and
being under development.
Programming Procedure
1. Select device GMS81516BT or GMS81524BT.
2. Load the *.OTP file to the programmer. The file is com-
DEC. 1999 Ver 1.04
73
GMS81508B/16B/24B
HYUNDAI MicroElectronics
VDD
VPP
64SDIP
VDD
CE
OE
OPEN
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
GMS81516BT/24BT
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
GND
O0
O1
O2
O3
O4
O5
O6
O7
A0
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
A11
A12
A13
A14
A15
O0
O1
O2
O3
O4
O5
O6
O7
A0
A1
A2
A3
A4
A5
A6
A7
A8
A9
GND
51
50
49
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
64MQFP
52
53
54
55
56
57
58
59
60
61
62
63
64
GMS815016BT/24BT
A10
A11
A12
A13
A14
A15
OPEN
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
VDD
VPP
32
31
30
29
28
27
26
25
24
23
22
21
20
VDD
CE
OE
GND
Table 22-1 Socket Adapter Pin Assignment
74
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
O0
O1
O2
O3
O4
O5
O6
O7
A0
A1
A2
A3
A4
A5
A6
A7
64LQFP
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
GMS81516BT/24BT
A8
A9
A10
A11
A12
A13
A14
A15
OPEN
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
VDD
VPP
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
VDD
CE
OE
GND
Table 22-2 Socket Adapter Pin Assignment
DEC. 1999 Ver 1.04
75
GMS81508B/16B/24B
HYUNDAI MicroElectronics
22.3 Programming Specification
DEVICE OPERATION MODE
(TA = 25°C ± 5°C)
Mode
CE
OE
A0~A15
VPP
VDD
O0~O7
X1
VDD2
5.0V
DOUT
Read Mode
X1
Output Disable Mode
VIH
VIH
X1
VDD2
5.0V
Hi-Z
Programming Mode
VIL
VIH
X1
VPP2
VDD2
DIN
Program Verify
X1
X1
VPP2
VDD2
DOUT
1. X = Either VIL or VIH.
2. See DC Characteristics Table for VDD and VPP voltage during programming.
DEVICE CHARACTERISTICS
(VSS=0V, TA = 25°C ± 5°C)
Symbol
Item
Min
Typ
Max
Unit
VPP
Quick Pulse Programming
11.50
11.75
12.0
V
VDD1
Quick Pulse Programming
5.75
6.0
6.25
V
IPP2
VPP supply current
50
mA
IDD2
VDD supply current
30
mA
VIH
Input high voltage
VIL
Input low voltage
VOH
Output high voltage
VOL
Output low voltage
IIL
Input leakage current
0.8VDD
Test condition
CE=VIL
V
0.2VDD
VDD-0.1
V
V
IOH= -2.5mA
0.4
V
IOL= 2.1mA
5
µA
1. VDD must be applied simultaneously or before VPP and removed simultaneously or after VPP.
2. The maximum current value is with outputs O0 to O7 unloaded.
76
DEC. 1999 Ver 1.04
HYUNDAI MicroElectronics
GMS81508B/16B/24B
SWITCHING WAVEFORMS
WAVEFORM
INPUTS
OUTPUTS
Must be steady
Will be steady
May change
from H to L
Will be changing
from H to L
May change
from L to H
Will be changing
from L to H
Do not care any
change permitted
Changing state
unknown
Does not apply
Center line is
high impedance “Off” state
READING WAVEFORMS
VIH
Addresses
Addresses Valid
VIL
See note (2)
VIH
OE
VIL
tAS
tOE
tDH
VIH
High-Z
Output
Valid Output
VIL
1. The input timing reference level is 1.0V for a VIL and 4.0V for a VIH at VDD=5.0V.
2. To read the output data, transition requires on the OE form the high to the low after address setup time tAS.
DEC. 1999 Ver 1.04
77
GMS81508B/16B/24B
HYUNDAI MicroElectronics
PROGRAMMING ALGORITHM WAVEFORMS
Program
Verify
Program
VIH
Addresses
Addresses Valid
VIL
tAS
tAH
VIH
Data In/Out
High-Z
Data in Stable
Data out valid
VIL
tDH
tDS
tDFP
12.75V
VPP
VDD
tVPS
6.25V
VDD
5.0V
tVDS
VIH
CE
VIL
tPW
tOES
tOE
VIH
OE
VIL
1. The input timing reference level is 1.0V for a VIL and 4.0V for a VIH at VDD=5.0V.
78
DEC. 1999 Ver 1.04
AC READING CHARACTERISTICS
(VSS=0V, TA = 25°C ± 5°C)
Symbol
Item
tAS
Address setup time
tOE
Quick Pulse Programming
tDH
VPP supply current
Min
Typ
Max
Unit
Test condition
µs
2
0
200
ns
50
ns
Note: VDD must be applied simultaneously or before VPP and removed simultaneously or after VPP.
AC PROGRAMMING CHARACTERISTICS
(VSS=0V, TA = 25°C ± 5°C)
Symbol
Item
Min
Typ
Max
Unit
Address setup time
2
µs
tOES
OE setup time
2
µs
tDS
Data setup time
2
µs
tAH
Address hold time
0
µs
tDH
Data hold time
2
µs
tDFP
Output delay disable time
0
tVPS
VPP setup time
2
µs
tVDS
VDD setup time
2
µs
tPW
Program pulse width
95
tOE
Data output delay time
tAS
130
100
* AC CONDITION OF TEST
Input Rise and Fall Times (10% to 90%) ........................... 20ns
Input Pulse Levels ............................................................. 0.45V to 4.55V
Input Timing Reference Level............................................ 1.0V to 4.0V
Output Timing Reference Level ......................................... 1.0V to 4.0V
VDD must be applied simultaneously or before VPP and removed simultaneously or after VPP.
ns
105
µs
150
ns
Test condition*
GMS81508B/16B/24B
HYUNDAI MicroElectronics
START
ADDRESS=FIRST LOCATION
VCC =6.0V
VPP=11.75
X=0
PROGRAM ONE 100µs PULSE
INCREMENT X
X=25?
YES
NO
FAIL
VERIFY
BYTE
VERIFY
ONE BYTE
FAIL
PASS
PASS
INCREMENT
ADDRESS
NO
LAST
ADDRESS?
YES
VCC=VPP=5.0V
COMPARE
ALL BYTES TO
ORIGINAL
DATA
FAIL
PASS
DEVICE
PASSED
DEVICE
FAILED
Table 22-1 Programming Algorithm
80
DEC. 1999 Ver 1.04
APPENDIX
HYUNDAI Micro Electronics
GMS800 Series
A. CONTROL REGISTER LIST
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
Undefined
31
00C1
R0 port I/O direction register
R0DD
W
00000000
31
00C2
R1 port data register
R1
R/W
Undefined
31
00C3
R1 port I/O direction register
R1DD
W
00000000
31
00C4
R2 port data register
R2
R/W
Undefined
31
00C5
R2 port I/O direction register
R2DD
W
00000000
31
00C6
R3 port data register
R3
R/W
Undefined
32
00C7
R3 port I/O direction register
R3DD
W
00000000
32
00C8
R4 port data register
R4
R/W
Undefined
32
00C9
R4 port I/O direction register
R4DD
W
00000000
32
00CA
R5 port data register
R5
R/W
Undefined
33
00CB
R5 port I/O direction register
R5DD
W
00000000
33
00CC
R6 port data register
R6
R/W
Undefined
33
00CD
R6 port I/O direction register
R6DD
W
0000 - - - -
33
00D0
R4 port mode register
PMR4
W
00000000
32, 63
00D1
R5 port mode register
PMR5
W
- - 00 - - - -
33, 55
Basic interval timer mode register
BITR
R
Undefined
35
CKCTLR
W
- - 010111
35
WDTR
W
- 0111111
64
00D3
Clock control register
00E0
Watchdog Timer Register
00E2
Timer mode register 0
TM0
R/W
00000000
37
00E3
Timer mode register 2
TM2
R/W
00000000
37
Timer 0 data register
TDR0
W
Undefined
37
T0
R
Undefined
37
TDR1
W
Undefined
37
T1
R
Undefined
37
TDR2
W
Undefined
37
T2
R
Undefined
37
TDR3
W
Undefined
37
T3
R
Undefined
37
00E4
00E5
00E6
00E7
Timer 0 counter register
Timer 1 data register
Timer 1 counter register
Timer 2 data register
Timer 2 counter register
Timer 3 data register
Timer 3 counter register
00E8
A/D converter mode register
ADCM
R/W
- - 000001
47
00E9
A/D converter data register
ADR
R
Undefined
47
00EA
Serial I/O mode register
SIOM
R/W
- 0000001
49
00EB
Serial I/O register
SIOR
R/W
Undefined
49
00EC
Buzzer driver register
BUR
W
Undefined
55
00F0
PWM0 duty register
PWMR0
W
Undefined
53
00F1
PWM1 duty register
PWMR1
W
Undefined
53
DEC. 1999
i
GMS800 Series
Address
HYUNDAI Micro Electronics
Register Name
Symbol
R/W
Initial Value
Page
7 6 5 4 3 2 1 0
ii
00F2
PWM control register
PWMCR
W
00000000
53
00F4
Interrupt enable register low
IENL
R/W
0000 - - - -
58
00F5
Interrupt request flag register low
IRQL
R/W
0000 - - - -
57
00F6
Interrupt enable register high
IENH
R/W
00000000
58
00F7
Interrupt request flag register high
IRQH
R/W
00000000
57
00F8
External interrupt edge selection register
IEDS
W
00000000
63
00F9
Power fail detection register
PFDR
R/W
- - - - 1100
71
DEC. 1999
HYUNDAI Micro Electronics
GMS800 Series
B. SOFTWARE EXAMPLE
B.1 7-segment LED display
VDD
330Ω × 7
10kΩ × 7
UP/DOWN S/W
R20/INT0
CLEAR S/W
R21/INT1
R00
R01
R02
R03
R04
R05
R06
a
b
c
d
e
f
g
LED Display
4.7kΩ
R23
2N2222
GND
4.7kΩ
R22
2N2222
GMS81516
;*****************************************************************************
; Title:
GMS81516 (GMS800 Series) Demonstration Program
*
; Company:
HYUNDAI Micro Electronics
*
; Contents:
Decimal Up/Down Counter
*
; Programmer:
HME MCU application team
*
;*****************************************************************************
;
;******** DEFINE
I/O PORT & FUNCTION REGISTER ADDRESS *********
;
R0
EQU
0C0H
;port R0 register
R0DD
EQU
0C1H
;port R0 data I/O direction register
;
R1
EQU
0C2H
;port R1 register
R1DD
EQU
0C3H
;port R1 data I/O direction register
;
R2
EQU
0C4H
;port R2 register
R2DD
EQU
0C5H
;port R2 data I/O direction register
;
R3
EQU
0C6H
;port R3 register
R3DD
EQU
0C7H
;port R3 data I/O direction register
;
R4
EQU
0C8H
;port R4 register
R4DD
EQU
0C9H
;port R4 data I/O direction register
;
R5
EQU
0CAH
;port R5 register
R5DD
EQU
0CBH
;port R5 data I/O direction register
;
R6
EQU
0CCH
;port R6 register
R6DD
EQU
0CDH
;port R6 data I/O direction register
;
PMR4
EQU
0D0H
;port R4 mode register
T3S
EQU
7,0D0H
;timer3 selection
DEC. 1999
iii
GMS800 Series
T1S
EQU
EC2S
EQU
EC0S
EQU
INT3S
EQU
INT2S
EQU
INT1S
EQU
INT0S
EQU
;
PMR5
EQU
BUZS
EQU
WDTS
EQU
;
TMR
EQU
;
CKCTLR
EQU
BITR
EQU
;
;WDTR
EQU
;
TM0
EQU
TM2
EQU
;
TDR0
EQU
TDR1
EQU
TDR2
EQU
TDR3
EQU
;
ADCM
EQU
ADR
EQU
;
SIOM
EQU
;SIOR
EQU
;
BUR
EQU
;
PWMR0
EQU
PWMR1
EQU
;
PWMCR
EQU
;
IMOD
EQU
IENL
EQU
AE
EQU
WDTE
EQU
BITE
EQU
SE
EQU
;
IRQL
EQU
AR
EQU
WDTRF
EQU
BITRF
EQU
SR
EQU
;
IENH
EQU
INT0E
EQU
INT1E
EQU
INT2E
EQU
INT3E
EQU
T0E
EQU
T1E
EQU
T2E
EQU
T3E
EQU
;
IRQH
EQU
INT0R
EQU
INT1R
EQU
INT2R
EQU
INT3R
EQU
T0R
EQU
T1R
EQU
T2R
EQU
T3R
EQU
;
IEDS
EQU
;
;*********** MACRO
;
REG_SAVE
MACRO
PUSH
PUSH
iv
HYUNDAI Micro Electronics
6,0D0H
5,0D0H
4,0D0H
3,0D0H
2,0D0H
1,0D0H
0,0D0H
;timer1 selection
;event counter 2 selection
;event counter 0 selection
;external int.3 selection
;external int.2 selection
;external int.1 selection
;external int.0 selection
0D1H
5,0D1H
4,0D1H
;port R5 mode register
;buzzer selection
;watch dog timer selection
0D2H
;test mode register
0D3H
0D3H
;clock control register
;basic interval timer register
0E0H
;watch dog timer register
0E2H
0E3H
;timer0 mode register
;timer2 mode register
0E4H
0E5H
0E6H
0E7H
;tomer0
;tomer1
;tomer2
;tomer3
0E8H
0E9H
;A/D Converter mode register
;A/D con. register
0EAH
0EBH
;serial I/O mode register
;serial I/O register
0ECH
;buzzer data register
0F0H
0F1H
;PWM0 data register
;PWM1 data register
0F2H
;PWM control register
0F3H
0F4H
7,0F4H
6,0F4H
5,0F4H
4,0F4H
;interrupt mode register
;int. enable register low
;A/D con. int. enable
;W.D.T. int. enable
;B.I.T. int. enable
;serial I/O int. enable
0F5H
7,0F5H
6,0F5H
5,0F5H
4,0F5H
;int. request flag register low
;A/D con. int. request flag
;W.D.T. int. request flag
;B.I.T. int. request flag
;serial I/O int. request flag
0F6H
7,0F6H
6,0F6H
5,0F6H
4,0F6H
3,0F6H
2,0F6H
1,0F6H
0,0F6H
;int. enable register high
;external int.0 enable
;external int.1 enable
;external int.2 enable
;external int.3 enable
;timer0 int. enable
;timer1 int. enable
;timer2 int. enable
;timer3 int. enable
0F7H
7,0F7H
6,0F7H
5,0F7H
4,0F7H
3,0F7H
2,0F7H
1,0F7H
0,0F7H
;int. request flag register high
;external int.0 request flag
;external int.1 request flag
;external int.2 request flag
;external int.3 request flag
;timer0 int. request flag
;timer1 int. request flag
;timer2 int. request flag
;timer3 int. request flag
0F8H
;external int. edge selection
data
data
data
data
register
register
register
register
DEFINITION ************
;Save Registers to Stacks
A
X
DEC. 1999
HYUNDAI Micro Electronics
;
REG_RESTORE
PUSH
ENDM
Y
MACRO
POP
POP
POP
ENDM
Y
X
A
GMS800 Series
;Restore Register from Stacks
;
;*********** CONSTANT DEFINITION ***********
;
SEG_PORT
EQU
R0
;7-Segment Output Port
STROBE_PORT
EQU
R2
;Strobe Signal Port
;
;**************************************************************************
;
RAM
ALLOCATION
*
;**************************************************************************
DIGIT10
DS
1
;DIG10 Display Data
DIGIT1
DS
1
;Seg1 Display Data
STROBE
DS
1
;Strobe Signal Data
TMR_500mS
DS
1
;500ms Time Counter
FLAGS
DS
1
;Function Flags
UP_F
EQU
0,FLAGS
;1=Down,0=Up
F_500ms
EQU
1,FLAGS
;
;
;**************************************************************************
;
INTERRUPT
VECTOR
TABLE *
;**************************************************************************
;
ORG0FFE4H
DW
NOT_USED
; Serial I/O
DW
NOT_USED
; Basic Interval Timer
DW
NOT_USED
; Watch Dog Timer
DW
NOT_USED
; A/D CON.
DW
NOT_USED
; Timer-3
DW
NOT_USED
; Timer-2
DW
NOT_USED
; Timer-1
DW
TMR0_INT
; Timer-0
DW
NOT_USED
; Int.3
DW
NOT_USED
; Int.2
DW
INT_1
; Int.1
DW
INT_0
; Int.0
DW
NOT_USED
;
DW
RESET
; Reset
;
;**************************************************************************
;
MAIN
PROGRAM
*
;**************************************************************************
;
ORG
0C000H
;Program Start Address
;
RESET:
DI
;Disable All Interrupts
LDX
#0
RAM_CLR:
LDA
#0
;RAM Clear(!0000H->!00BFH)
STA
{X}+
;M(X) <- A, then X <- X+1
CMPX
#0C0H
;X = #0C0H ?
BNE
RAM_CLR
;
LDX
#0FEH
;Stack Pointer Initial
TXSP
;SP. <- #0FEH
DEC. 1999
LDM
LDM
R0,#0
R2,#0
;I/O Port Data Clear
LDM
LDM
R0DD,#0FFH
R2DD,#00FH
;7-Seg. Data Output Mode
;7-Seg. Strobe Output Mode
LDM
LDM
LDM
LDM
LDM
LDM
LDM
LDM
LDM
SET1
EI
STROBE,#0000_1011B
TDR0,#250
TM0,#0001_1111B
IRQH,#0
IRQL,#0
IENH,#1100_1000B
IENL,#00H
IEDS,#0101_0101B
PMR4,#03H
UP_F
;8us x 250 = 2000us
;Timer0(8bit),8us,Start Count-up
;Clear All Interrupts Requeat Flags
;EnableT0,Int0,Int1,Interrupt
;External Int. Falling edge select
;General port OR Int?
;Enable Interrupts
v
GMS800 Series
Loop:
HYUNDAI Micro Electronics
;
nop
IF
F_500ms == 1
clr1
F_500ms
call
INC_DEC
ENDIF
jmp
Loop
;
;***********************************************
; Subject:
Inc. or Dec. two digits
*
;***********************************************
; Entry:
UP_F
*
; Return:
UP_F=1, Increment two digits
*
;
UP_F=0, Decrement two digits
*
;***********************************************
;
INC_DEC:
BBC
UP_F,DOWN
;Check Down mode or Up mode
;
;**************************
;*
Up Count
*
;**************************
;
SETC
LDA
#0
; DIGIT1 <- DIGIT1 + 1
ADC
DIGIT1
IF
A == #0AH
setc
lda
#0
ENDIF
STA
DIGIT1
; Store result into DIGIT1
;
LDA
#0
; When Overflow is set,
ADC
DIGIT10
; DIGIT10 <- DIGIT10 + 1
IF
A == #10
lda
#0
ENDIF
STA
DIGIT10
RET
;
;**************************
;*
Down Count
*
;**************************
;
DOWN:
clrc
lda
DIGIT1
; DIGIT1 <- DIGIT1 - 1
sbc
#0
IF
A == #0FFH
lda
#9
clrc
ELSE
setc
ENDIF
sta
DIGIT1
; Store result into DIGIT1
;
lda
DIGIT10
; When Overflow is set,
sbc
#0
; DIGIT10 <- DIGIT10 - 1
IF
A == #0FFH
lda
#9
ENDIF
STA
DIGIT10
RET
;
;**************************************************************************
;
TIMER0,INTERRUPT ROUTINE(2ms)& INT0,INT1
*
;**************************************************************************
;
TMR0_INT:
REG_SAVE
;Save Registers to Stacks
CALL
DSPLY
;Segments Data Port Output
CALL
Make_500msFalg
;250ms mesurement
REG_RESTORE
;Restore Registers from Stacks
RETI
;
;**************************************************************************
;
EXTERNAL INTERRUPT 0 (UP/DOWN KEY)
*
;**************************************************************************
;
INT_0:
NOT1
UP_F
;INT0 Service routine
RETI
;Toggle the Up/Down mode
;
vi
DEC. 1999
HYUNDAI Micro Electronics
GMS800 Series
;**************************************************************************
;
EXTERNAL INTERRUPT 1 (CLEAR KEY)
*
;**************************************************************************
;
INT_1:
LDM
DIGIT1,#0
;INT1 Service routine
LDM
DIGIT10,#0
LDM
TMR_500MS,#0
;0.5Sec Restart
RETI
;
;***********************************************************************
; Subject:
Seven Segment Display (DSPLY)
*
;***********************************************************************
; Entry:
DIGIT10 or DIGIT1
*
; Return:
Output SEG_PORT (R00~R07),
*
;
Strobe_port (R22,R23)
*
; Scratch:
STROBE
*
;***********************************************************************
; Description: After read internal RAM data, output data to the port *
;***********************************************************************
;
DSPLY:
LDM
STROBE_PORT,#03H
;Segment All Turn Off
NOT1
STROBE.2
;Toggle strobe0
NOT1
STROBE.3
;Toggle strobe1
IF
ldy
ELSE
ldy
ENDIF
LDA
STA
LDA
STA
RET
STROBE.3 = 1
DIGIT1
;Test if R23 is high.
DIGIT10
!FONT+Y
SEG_PORT
STROBE
STROBE_PORT
;Segment Data output
;Current Digit Turn On
;Quit
;
;***********************************************
; Subject:
Set falg at every 500ms
*
;***********************************************
; Entry:
None
*
; Return:
500ms flag (F_500ms)
*
;***********************************************
;
Make_500msFalg:
INC
TMR_500MS
;count up every 2ms
LDA
TMR_500MS
IF
A == #250
;Compare 0.5S
ldm
TMR_500MS,#0
;clear 0.5sec. counter
set1
F_500ms
;set 0.5sec. flag
ENDIF
RET
;
;**************************************************************************
;
7-SEGMENT PATTERN DATA
*
;
_a_
*
;
f | g |b
*
;
|---|
*
;
e |___|c
*
;
d
.h
*
;**************************************************************************
;
Segment:
FONT
DB
DB
DB
DB
DB
DB
DB
DB
DB
DB
hgfe dcba
0011_1111B
0000_0110B
0101_1011B
0100_1111B
0110_0110B
0110_1101B
0111_1100B
0000_0111B
0111_1111B
0110_0111B
To be displayed Digit Number
;
;
;
;
;
;
;
;
;
;
0
1
2
3
4
5
6
7
8
9
;
;**************************************************************************
;
NOT_USED:
nop
;Discard Unexpected Interrupts
reti
;
END
;Notice Program End
DEC. 1999
vii
GMS800 Series
HYUNDAI Micro Electronics
C. INSTRUCTION
C.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
−
viii
Subtraction
×
Multiplication
/
Division
()
Contents Expression
∧
AND
∨
OR
⊕
Exclusive OR
~
NOT
←
Assignment / Transfer / Shift Left
→
Shift Right
↔
Exchange
=
Equal
≠
Not Equal
DEC. 1999
HYUNDAI Micro Electronics
GMS800 Series
C.2 Instruction Map
LOW 00000
HIGH
00
00001
01
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
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
DEC. 1999
CLR1
BBC
BBC
dp.bit
A.bit,rel
dp.bit,rel
ix
GMS800 Series
HYUNDAI Micro Electronics
C.3 Instruction Set
Arithmetic / Logic Operation
No.
x
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-
M← (M)-1
N-----Z-
DEC. 1999
HYUNDAI Micro Electronics
No.
Mnemonic
Op
Code
GMS800 Series
Byte
No
Cycle
No
Operation
44
DIV
9B
1
12
Divide : YA / X Q: A, R: Y
45
EOR #imm
A4
2
2
Exclusive OR
Flag
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
XCN
DEC. 1999
CE
1
N-----Z-
Increment
N-----ZC
M← (M)+1
N-----Z-
Logical shift right
7 6 5 4 3 2 1 0
C
“0” → → → → → → → → → →
N-----ZC
N-----Z-
A ← (A)∨(M)
N-----Z-
Rotate left through Carry
C
7 6 5 4 3 2 1 0
←←←←←←←←
C
N-----ZC
N-----ZC
Subtract with Carry
A ← ( A ) - ( M ) - ~( C )
NV--HZC
xi
GMS800 Series
HYUNDAI Micro Electronics
Register / Memory Operation
No.
xii
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
(M)← X
--------
Store Y-register contents in memory
(M)← Y
(M)↔A
Exchange X-register contents with Y-register : X ↔ Y
--------
N-----Z--------
DEC. 1999
HYUNDAI Micro Electronics
GMS800 Series
16-BIT operation
No.
Mnemonic
Op
Code
Byte
No
Cycle
No
Operation
Flag
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.
Mnemonic
Operation
Flag
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-
DEC. 1999
xiii
GMS800 Series
HYUNDAI Micro Electronics
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 minus
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)
--------
xiv
---------------
if ( A ) ≠ ( M ) , then pc ← ( pc ) + rel.
--------
Unconditional jump
pc ← jump address
--------
DEC. 1999
HYUNDAI Micro Electronics
GMS800 Series
Control Operation & Etc.
No.
1
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 )
--------
DEC. 1999
--------
xv
D. MASK ORDER SHEET
MASK ORDER & VERIFICATION SHEET
GMS81508B
GMS81516B -HF
GMS81524B
Customer should write inside thick line box.
2. Device Information
1. Customer Information
Company Name
Package
YYYY
Order Date
Tel:
MM
Mask Data
Application
DD
Fax:
64SDIP
64MQFP
64LQFP
Internet
Hitel
Chollian
(
File Name
ROM Size (bytes)
Check Sum
8K
PFD Option
24K
)
(24K ) 2000 H
(16K ) 4000 H
(8K ) 6000 H
3.0V
.O TP file d ata
2.4V
S et “FF H” in blan ked area
Not use
7FFF H
(Please check mark√ into
3. Marking Specification
08 or 16 or 24
HME
GMS815XXB-HF
YYWW
16K
(
E-mail address:
Name &
Signature:
) .OTP
Customer’s logo
GMS815XXB-HF
YYWW
KOREA
KOREA
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
Date
YYYY
Customer sample
YYYY
Risk order
Quantity
MM
DD
MM
DD
HME Confirmation
pcs
pcs
5. ROM Code Verification
Please confirm out verification data.
YYYY
Verification date:
Check sum:
Tel:
E-mail address:
Name &
Signature:
DEC., 10. 1999
MM
DD
YYYY
Approval date:
MM
DD
I agree with your verification data and confirm you to
make mask set.
Fax:
Tel:
Fax:
E-mail address:
Name &
Signature:
+<81'$,#0LFUR(OHFWURQLFV
Semiconductor Group of Hyundai Electronics Industries Co., Ltd.
)
Similar pages