HYNIX HMS87C1204A

Apr. 2001
Ver 1.0
8-BIT SINGLE-CHIP MICROCONTROLLERS
HMS87C1304(2)A
HMS87C1204(2)A
HMS87C1104(2)A
User’s Manual
HMS87C130XA/120XA/110XA
1. OVERVIEW ....................................................................................................................... 1
1.1
1.2
1.3
1.4
Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Ordering Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2. BLOCK DIAGRAM ........................................................................................................... 4
3. PIN ASSIGNMENT ........................................................................................................... 5
4. PACKAGE DIAGRAM ...................................................................................................... 6
5. PIN FUNCTION ................................................................................................................. 9
6. PORT STRUCTURES ..................................................................................................... 11
7. ELECTRICAL CHARACTERISTICS .............................................................................. 16
7.1
7.2
7.3
7.4
7.5
7.6
Absolute Maximum Ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Recommended Operating Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
A/D Converter Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
DC Electrical Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
AC Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Typical Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
8. MEMORY ORGANIZATION ........................................................................................... 22
8.1
8.2
8.3
8.4
Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Program Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Data Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Addressing Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
9. I/O PORTS ...................................................................................................................... 34
9.1
9.2
9.3
9.4
RA and RAIO registers
RB and RBIO registers
RC and RCIO registers
RD and RDIO registers
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
10. CLOCK GENERATOR ................................................................................................. 38
10.1 Oscillation Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
11. BASIC INTERVAL TIMER ............................................................................................ 40
12. TIMER / COUNTER ...................................................................................................... 41
12.1 8-bit Timer/Counter Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Apr. 2001 ver1.0
HMS87C130XA/120XA/110XA
12.2
12.3
12.4
12.5
12.6
16-bit Timer/Counter Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
8-bit Compare Output (16-bit) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
8-bit Capture Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
16-bit Capture Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
PWM Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
13. BUZZER OUTPUT FUNCTION .................................................................................... 50
14. ANALOG TO DIGITAL CONVERTER .......................................................................... 51
15. INTERRUPTS ............................................................................................................... 54
15.1 Interrupt Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
15.2 External Interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
16. WATCHDOG TIMER .................................................................................................... 59
17. POWER SAVING MODE .............................................................................................. 60
17.1 Minimizing Current Consumption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
18. RESET .......................................................................................................................... 66
19. POWER FAIL PROCESSOR ........................................................................................ 68
20. OTP PROGRAMMING .................................................................................................. 70
20.1 DEVICE CONFIGURATION AREA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
APPENDIX
Instruction Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i
Instruction Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
HMS87C1304A / HMS87C1302A
HMS87C1204A / HMS87C1202A
HMS87C1104A / HMS87C1102A
CMOS SINGLE-CHIP 8-BIT MICROCONTROLLER
1. OVERVIEW
1.1 Description
The HMS87C1X0XA is an advanced CMOS 8-bit microcontroller with 4K/2K bytes of EPROM. The Hynix
HMS87C1X0XA is a powerful microcontroller which provide a highly flexible and cost effective solution to many small
applications such as controller for battery charger. The HMS87C1X0XA provides the following standard features: 4K/2K
bytes of EPROM, 128bytes of RAM, 8-bit timer/counter, 8-bit A/D converter, 10-bit high speed PWM output, programmable
buzzer driving port, power-on reset circuit, on-chip oscillator and clock circuitry. In addition, the HMS87C1X0XA supports
power saving modes to reduce power consumption.
This document is only explained for the base of HMS87C1304A, the other’s eliminated functions are same as below.
Device name
EPROM
RAM
EXT.INT
BUZ
I/O
Operating
Voltage
Package
HMS87C1304A
4K bytes
128bytes
2
O
19
2.0 ~ 5.5V
24 SKDIP or SOP
HMS87C1302A
2K bytes
128bytes
2
O
19
2.0 ~ 5.5V
24 SKDIP or SOP
HMS87C1204A
4K bytes
128bytes
2
O
15
2.0 ~ 5.5V
20 PDIP or SOP
HMS87C1202A
2K bytes
128bytes
2
O
15
2.0 ~ 5.5V
20 PDIP or SOP
HMS87C1104A
4K bytes
128bytes
1
X
11
2.0 ~ 5.5V
16 PDIP or SOP
HMS87C1102A
2K bytes
128bytes
1
X
11
2.0 ~ 5.5V
16 PDIP or SOP
1.2 Features
• 4K/2K Bytes On-chip Program Memory
• One 8-bit Basic Interval Timer
• 128 Bytes of On-chip Data RAM
(Included stack memory)
• Two 8-bit Timer / Counters
• One 10-bit High Speed PWM Outputs
• Instruction Cycle Time:
- 250nS at 8MHz
• Programmable I/O pins
(LED direct driving can be source and sink)
- HMS87C1304A/1302A : 19
- HMS87C1204A/1202A : 15
- HMS87C1104A/1102A : 11
• 2.0V to 5.5V Wide Operating Range
• Watchdog timer
• Seven Interrupt sources
- External input: 2 ( 1 for HMS87C1104/2A )
- A/D Conversion: 1
- Timer: 4
• One Programmable Buzzer Driving port
( except HMS87C1104/2A )
- 500Hz ~ 130kHz
• 8-bit A/D Converter
- 8 channels
Apr. 2001 ver1.0
1
HMS87C130XA/120XA/110XA
• Oscillator Type
- Crystal
- Ceramic Resonator
- RC-oscillation ( C can be omitted )
• Power-On Reset
• Noise Immunity Circuit
- Power Fail Processor
• Power Down Mode
- STOP mode
- Wake-up Timer mode
- Internal RC-WDT mode
1.3 Development Tools
The HMS87C1X0XA is supported by a full-featured macro assembler, an in-circuit emulator CHOICE-DrTM and
OTP programmers.
The marco assembler operates under the MS-Windows 95/
98TM.
The OTP programmer can be supplied three types of programmer such as emulator add-on board type single programmer (Dr.WriterTM), univeral stand-alone type single
programmer (CHOICE-SIGMATM) and gang type programmer (CHOICE-SIGMATM). .
In Circuit
Emulators
CHOICE-Dr. TM
Assembler
Hynix Macro Assembler
Single Programmer : Dr. WriterTM
Universal Programmer : CHOICEOTP
Programmer SIGMATM
Gang Programmer : CHOICE-GANG4TM
Figure 1-2 OTP Single Programmer Dr.WriterTM
Figure 1-3 OTP Gang Programmer CHOICE-GANG4TM
Figure 1-1 In Circuit Emulator CHOICE-Dr.TM
2
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
1.4 Ordering Information
ROM Size
4K bytes (OTP)
2K bytes (OTP)
Apr. 2001 ver1.0
Package Type
Ordering Device Code
24 SKDIP
HMS87C1304A SK
24 SOP
HMS87C1304A D
20 PDIP
HMS87C1204A
20 SOP
HMS87C1204A D
16 PDIP
HMS87C1104A
16 SOP
HMS87C1104A D
24 SKDIP
HMS87C1302A SK
24 SOP
HMS87C1302A D
20 PDIP
HMS87C1202A
20 SOP
HMS87C1202A D
16 PDIP
HMS87C1102A
16 SOP
HMS87C1102A D
Operating Temperature
-20 ~ +85°C
3
HMS87C130XA/120XA/110XA
2. BLOCK DIAGRAM
PSW
Accumulator
ALU
PC
Stack Pointer
Data
Memory
RESET
System
Clock Controller
Timing generator
XIN
XOUT
Program
Memory
System controller
8-bit Basic
Interval
Timer
Data Table
Inte rrupt C ontroller
Clock Generator
Instruction
Decoder
Watch-dog
Timer
8-bit
A/D
Converter
8-bit
Timer/
Counter
High
Speed
PWM
B uzzer ‡
D river
VDD
RA
VSS
RB
RC
RD
RC0 ‡
RC1 ‡
RD0 †, ‡
RD1 †, ‡
RD2 †, ‡
RD3 †, ‡
Power
Supply
RA0 / EC0
RA1 / AN1
RA2 / AN2
RA3 / AN3
RA4 / AN4
RA5 / AN5
RA6 / AN6
RA7 / AN7
Note
4
†
‡
RB0 / AN0 / AVREF
RB1 / BUZ ‡
RB2 / INT0
RB3 / INT1 ‡
RB4 / CMP0 / PWM0
These pins are not available in HMS87C1204(2)A.
These pins are not available in HMS87C1104(2)A.
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
3. PIN ASSIGNMENT
HMS87C1304(2)A SK
HMS87C1304(2)A D
24 SKDIP
24 SOP
AN4 / RA4
1
24
RA3 / AN3
AN4 / RA4
1
24
RA3 / AN3
AN5 / RA5
2
23
RA2 / AN2
AN5 / RA5
2
23
RA2 / AN2
AN6 / RA6
3
22
RA1 / AN1
AN6 / RA6
3
22
RA1 / AN1
AN7 / RA7
4
21
RA0 / EC0
AN7 / RA7
4
21
RA0 / EC0
5
20
RC1
VDD
5
20
RC1
VDD
RD0
6
19
RC0
RD0
6
19
RC0
RD1
7
18
VSS
RD1
7
18
VSS
AN0 / AVREF / RB0
8
17
RESET
AN0 / AVREF/ RB0
8
17
RESET
BUZ / RB1
9
16
XOUT
BUZ / RB1
9
16
XOUT
INT0 / RB2
10
15
XIN
INT1 / RB3
11
14
RD3
PWM0 / COMP0 / RB4
12
13
RD2
INT0 / RB2
10
15
XIN
INT1 / RB3
11
14
RD3
PWM0 / COMP0 / RB4
12
13
RD2
HMS87C1204(2)A
HMS87C1204(2)A D
20 PDIP
20 SOP
AN4 / RA4
1
20
RA3 / AN3
AN4 / RA4
1
20
RA3 / AN3
AN5 / RA5
2
19
RA2 / AN2
AN5 / RA5
2
19
RA2 / AN2
AN6 / RA6
3
18
RA1 / AN1
AN6 / RA6
3
18
RA1 / AN1
AN7 / RA7
4
17
RA0 / EC0
AN7 / RA7
4
17
RA0 / EC0
5
16
RC1
VDD
5
16
RC1
VDD
AN0 / AVREF / RB0
6
15
RC0
AN0 / AVREF / RB0
6
15
RC0
BUZ / RB1
7
14
VSS
BUZ / RB1
7
14
VSS
INT0 / RB2
8
13
RESET
INT0 / RB2
8
13
RESET
INT1 / RB3
9
12
XOUT
INT1 / RB3
9
12
XOUT
10
11
XIN
10
11
XIN
PWM0 / COMP0 / RB4
HMS87C1104(2)A
PWM0 / COMP0 / RB4
HMS87C1104(2)A D
16 PDIP
16 SOP
AN4 / RA4
1
16
RA3 / AN3
AN4 / RA4
1
16
RA3 / AN3
AN5 / RA5
2
15
RA2 / AN2
AN5 / RA5
2
15
RA2 / AN2
AN6 / RA6
3
14
RA1 / AN1
AN6 / RA6
3
14
RA1 / AN1
AN7 / RA7
4
13
RA0 / EC0
AN7 / RA7
4
13
RA0 / EC0
5
12
VDD
5
12
VSS
VDD
VSS
AN0 / AVREF / RB0
6
11
RESET
AN0 / AVREF / RB0
6
11
RESET
INT0 / RB2
7
10
XOUT
INT0 / RB2
7
10
XOUT
PWM0 / COMP0 / RB4
8
9
PWM0 / COMP0 / RB4
8
9
Apr. 2001 ver1.0
XIN
XIN
5
HMS87C130XA/120XA/110XA
4. PACKAGE DIAGRAM
24 SKDIP
unit: inch
MAX
MIN
TYP 0.300
1.265
0.300
0.250
0.120
0.140
MAX 0.180
MIN 0.015
1.160
4
0.01
8
0.00
0.021
0.065
0.015
0 ~ 15°
TYP 0.100
0.045
6
0.419
0.398
0.292
0 ~ 8°
TYP 0.050
0.0125
0.019
0.0138
0.009
0.104
0.093
0.614
0.593
0.0118
0.004
0.299
24 SOP
0.042
0.016
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
20 PDIP
unit: inch
MAX
MIN
TYP 0.300
1.043
0.270
0.245
0.120
0.140
MAX 0.180
MIN 0.015
1.010
4
0.01
8
0
0
.
0
0.021
0.065
0.015
0 ~ 15°
TYP 0.100
0.050
Apr. 2001 ver1.0
0.419
0.398
0.291
0 ~ 8°
TYP 0.050
0.0091
0.020
0.013
0.0125
0.104
0.093
0.5118
0.4961
0.0118
0.004
0.299
20 SOP
0.042
0.016
7
HMS87C130XA/120XA/110XA
16 PDIP
unit: inch
MAX
MIN
TYP 0.300
0.765
0.260
MIN 0.015
0.240
0.120
0.140
MAX 0.180
0.745
4
0.01
8
0
0
.
0
0.022
0.065
0.015
0 ~ 15°
TYP 0.100
0.050
8
0.416
0.398
0.292
0 ~ 8°
TYP 0.050
0.0091
0.019
0.014
0.0125
0.104
0.094
0.412
0.402
0.0118
0.004
0.299
16 SOP
0.040
0.016
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
5. PIN FUNCTION
RB serves the functions of the various following special
features in Table 5-2.
VDD: Supply voltage.
VSS: Circuit ground.
RESET: Reset the MCU.
Port pin
XIN: Input to the inverting oscillator amplifier and input to
the internal main clock operating circuit.
RB0
XOUT: Output from the inverting oscillator amplifier.
RA0~RA7: RA is an 8-bit, CMOS, bidirectional I/O port.
RA pins can be used as outputs or inputs according to “1”
or “0” written the their Port Direction Register(RAIO).
Port pin
Alternate function
RA0
RA1
RA2
RA3
RA4
RA5
RA6
RA7
EC0 ( Event Counter Input Source )
AN1 ( Analog Input Port 1 )
AN2 ( Analog Input Port 2 )
AN3 ( Analog Input Port 3 )
AN4 ( Analog Input Port 4 )
AN5 ( Analog Input Port 5 )
AN6 ( Analog Input Port 6 )
AN7 ( Analog Input Port 7 )
Table 5-1 RA Port
In addition, RA serves the functions of the various special
features in Table 5-1.
RB1 1
RB2
RB3 1
RB4
Alternate function
AN0 ( Analog Input Port 0 )
AVREF ( External Analog Reference Pin
)
BUZ ( Buzzer Driving Output Port )
INT0 ( External Interrupt Input Port 0 )
INT1 ( External Interrupt Input Port 1 )
PWM0 (PWM0 Output)
COMP0 (Timer1 Compare Output)
Table 5-2 RB Port
1. These pins are not available in HMS87C1104(2)A.
RC0, RC1: RC is a 2-bit, CMOS, bidirectional I/O port.
RC pins can be used as outputs or inputs according to “1”
or “0” written the their Port Direction Register(RCIO).
And these pins are not available in HMS87C1104(2)A.
RD0~RD3: RD is a 4-bit, CMOS, bidirectional I/O port.
RC pins can be used as outputs or inputs according to “1”
or “0” written the their Port Direction Register(RDIO).
And these pins are not available in HMS87C1204(2)A and
HMS87C1104(2)A.
RB0~RB4: RB is an 8-bit, CMOS, bidirectional I/O port.
RB pins can be used as outputs or inputs according to “1”
or “0” written the their Port Direction Register(RBIO).
Apr. 2001 ver1.0
9
HMS87C130XA/120XA/110XA
PIN NUMBER
Function
PIN NAME
In/Out
87C1304(2)A 87C1204(2)A 87C1104(2)A
Basic
Sencondary
VDD
5
5
5
-
Supply voltage
VSS
18
14
12
-
Circuit ground
RESET
17
13
11
I
Reset signal input
XIN
15
11
9
I
XOUT
16
12
10
O
RA0 (EC0)
21
17
13
I/O (Input)
External Event Counter input 0
RA1 (AN1)
22
18
14
I/O (Input)
Analog Input Port 1
RA2 (AN2)
23
19
15
I/O (Input)
Analog Input Port 2
RA3 (AN3)
24
20
16
I/O (Input)
RA4 (AN4)
1
1
1
I/O (Input)
RA5 (AN5)
2
2
2
I/O (Input)
Analog Input Port 5
RA6 (AN6)
3
3
3
I/O (Input)
Analog Input Port 6
RA7 (AN7)
4
4
4
I/O (Input)
Analog Input Port 7
RB0 (AVref/AN0)
8
6
6
I/O (Input)
Analog Input Port 0
/ Analog Reference
RB1 (BUZ)
9
7
RB2 (INT0)
10
8-bit general
I/O ports
I/O (Input)
Analog Input Port 3
Analog Input Port 4
Buzzer Driving Output
5-bit general
I/O ports
8
I/O (Input)
External Interrupt Input 1
PWM0 Output or Timer1
Compare Output
RB3 (INT1)
11
9
I/O (Output)
RB4 (PWM0/
COMP0)
12
10
I/O (Output/
Output)
RC0
19
15
I/O
RC1
20
16
I/O
RD0
6
I/O
RD1
7
I/O
RD2
13
I/O
RD3
14
I/O
External Interrupt Input 0
2-bit general
I/O ports
4-bit general
I/O ports
Table 5-3 Pin Description
10
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
6. PORT STRUCTURES
• RESET
Internal RESET
VSS
• Xin, Xout
Crystal or Ceramic
VDD
Xout
VSS
STOP
To System CLK
Xin
RC Oscillation (refer to Configuration Area)
VDD
Xout
STOP
VSS
To System CLK
Xin
Internal Capacitor 6 pF
Apr. 2001 ver1.0
11
HMS87C130XA/120XA/110XA
• RA0/EC0
Open Drain
Data Reg.
Data Bus
Direction Reg.
Data Bus
Data Bus
Read
EC0
Schmitt Trigger
• RA1/AN1 ~ RA7/AN7
VDD
Data Reg.
Data Bus
Direction Reg.
Data Bus
VSS
Data Bus
Read
To A/D Converter
Analog Input Mode
(ANSEL7 ~ 1)
Analog CH. Selection
(ADCM.4 ~ 2)
12
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
• RB0 / AN0 / AVref
VDD
Data Reg.
Data Bus
AVREFS
Direction Reg.
Data Bus
VSS
Data Bus
Read
To A/D Converter
Analog Input Mode
(ANSEL0)
Analog CH0 Selection
(ADCM.4 ~ 2)
Internal VDD
1
To Vref of A/D
0
AVREFS
• RB1/BUZ, RB4/PWM0/COMP0
PWM/COMP
BUZ
VDD
Data Reg.
1
0
Data Bus
Function
Select
Direction Reg.
Data Bus
VSS
Data Bus
Read
Note: RB1/BUZ pin is not available in HMS87C1104(2)A.
Apr. 2001 ver1.0
13
HMS87C130XA/120XA/110XA
• RB2/INT0, RB3/INT1
Open Drain
Pull-up
Select
Weak Pull-up
Data Reg.
VDD
Data Bus
Function
Select
Direction Reg.
Data Bus
VSS
Data Bus
Read
Schmitt Trigger
INT0, INT1
Note: RB3/INT1 pin is not available in HMS87C1104(2)A .
• RC0, RD2, RD3
Data Reg.
Data Bus
Direction Reg.
Data Bus
Data Bus
Read
Note: RC0, RD2, RD3 pins are not available in
HMS87C1104(2)A
Note: RD2, RD3 pins are not available in HMS87C1204(2)
14
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
• RC1
Open Drain
VDD
Data Reg.
Data Bus
Direction Reg.
Data Bus
VSS
Data Bus
Read
• RD0, RD1
Pull-up
Select
Weak Pull-up
Data Reg.
VDD
Data Bus
Direction Reg.
Data Bus
VSS
Data Bus
Read
Apr. 2001 ver1.0
15
HMS87C130XA/120XA/110XA
7. ELECTRICAL CHARACTERISTICS
7.1 Absolute Maximum Ratings
Supply voltage ........................................... -0.3 to +6.0 V
Storage Temperature ................................-40 to +125 °C
Voltage on any pin with respect to Ground (VSS)
............................................................... -0.3 to VDD+0.3
Maximum current out of VSS pin ........................200 mA
Maximum current into VDD pin ..........................150 mA
Maximum current sunk by (IOL per I/O Pin) ........25 mA
Maximum output current sourced by (IOH per I/O Pin)
...............................................................................15 mA
Maximum current (ΣIOL) ....................................150 mA
Maximum current (ΣIOH).................................... 100 mA
Note: Stresses above those listed under “Absolute Maximum Ratings” may cause permanent damage to the
device. This is a stress rating only and functional operation of the device at any other conditions above
those indicated in the operational sections of this
specification is not implied. Exposure to absolute
maximum rating conditions for extended periods
may affect device reliability.
7.2 Recommended Operating Conditions
Specifications
Parameter
Symbol
VDD
Supply Voltage
Operating Frequency
Operating Temperature
fXIN
Condition
Unit
Min.
Max.
fXIN=8MHz
4.5
5.5
V
fXIN=4.2MHz
2.0
5.5
V
VDD=4.5~5.5V
1
8
MHz
VDD=2.0~5.5V
1
4.2
MHz
-20
85
°C
TOPR
7.3 A/D Converter Characteristics
(TA=25°C, VSS=0V, VDD=5.12V @fXIN =8MHz, VDD=3.072V @fXIN =4MHz)
Specifications
Parameter
Analog Input Voltage Range
Analog Power Supply Input Voltage Range
Symbol
VAIN
VREF
Condition
Unit
Min.
Typ.
Max.
AVREFS=0
VSS
-
VDD
AVREFS=1
VSS
-
VREF
VDD=5V
3
-
VDD
V
VDD=3V
2.4
-
VDD
V
V
Overall Accuracy
NACC
-
±1.0
±1.5
LSB
Non-Linearity Error
NNLE
-
±1.0
±1.5
LSB
Differential Non-Linearity Error
NDNLE
-
±1.0
±1.5
LSB
Zero Offset Error
NZOE
-
±0.5
±1.5
LSB
Full Scale Error
NFSE
-
±0.25
±0.5
LSB
Gain Error
NNLE
-
±1.0
±1.5
LSB
fXIN=8MHz
-
-
10
fXIN=4MHz
-
-
20
AVREFS=1
-
0.5
1.0
Conversion Time
AVREF Input Current
16
TCONV
IREF
µS
mA
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
7.4 DC Electrical Characteristics
(TA=-20~85°C, VDD=2.0~5.5V, VSS=0V),
Specifications
Parameter
Symbol
Pin
Condition
Unit
Min.
Typ.
Max.
VIH1
RESET
0.8 VDD
-
VDD
VIH2
XIN, Hysteresis Input1
0.8 VDD
-
VDD
VIH3
Normal Input
0.7 VDD
-
VDD
VIL1
RESET
0
-
0.2 VDD
VIL2
XIN, Hysteresis Input1
0
-
0.2 VDD
VIL3
Normal Input
0
-
0.3 VDD
Output High Voltage
VOH
All Output Port
VDD=5V, IOH=-5mA
VDD -1
-
-
V
Output Low Voltage
VOL
All Output Port
VDD=5V, IOL=10mA
-
-
1
V
IP
RB2, RB3, RD0, RD1
VDD=5V
-450
-380
-300
µA
Input High
Leakage Current
IIH1
All Pins (except XIN)
VDD=5V
-
-
5
µA
IIH2
XIN
VDD=5V
-
-
15
µA
Input Low
Leakage Current
IIL1
All Pins (except XIN)
VDD=5V
-5
-
-
µA
IIL2
XIN
VDD=5V
-15
-
-
µA
| VT |
Hysteresis Input1
VDD=5V
0.5
-
-
V
VPFD1
VDD
PFD Level = 0, VDD=5V
2.0
2.5
3.0
VPFD2
VDD
PFD Level = 1, VDD=3V
1.5
1.7
1.9
VDD=5.0V, fXIN=8MHz
60
200
VDD=3.0V, fXIN=4MHz
150
300
VDD=5.5V, fXIN=8MHz
-
2
5
VDD=3.0V, fXIN=4MHz
-
1
2
VDD=5.5V, fXIN=8MHz
-
0.1
0.5
VDD=3.0V, fXIN=4MHz
-
0.03
0.1
VDD=5.5V
-
-
50
VDD=3.0V
-
-
30
VDD=5.5V, fXIN=8MHz
-
0.7
1.6
VDD=3.0V, fXIN=4MHz
-
0.2
0.8
VDD=5V,
R=10KΩ, C=20pF
3
5
VDD=5V,
R=10KΩ
5
9
Input High Voltage
Input Low Voltage
Input Pull-up Current2
Hysteresis
PFD Voltage
Internal RC WDT
Period
Operating Current3
TRCWDT
IDD
VDD
Wake-up Timer Mode
Current
IWKUP
VDD
RCWDT Mode
Current at STOP
Mode
IRCWDT
VDD
ISTOP
VDD
Stop Mode Current
External RC
Oscillator Frequency
FRC
XOUT
V
V
V
µS
mA
mA
µA
µA
MHz
1. Hysteresis Input: RA0, RB2, RB3
2. This parameter is valid when the bit PUPSELx is selected and set the input mode or interrupt input function.
3. This value is measured under NOP instruction execution.
Apr. 2001 ver1.0
17
HMS87C130XA/120XA/110XA
7.5 AC Characteristics
(TA=-20~+85°C, VDD=5V±10%, VSS=0V)
Specifications
Parameter
Symbol
Pins
Unit
Min.
Typ.
Max.
fCP
XIN
1
-
8
MHz
tCPW
XIN
80
-
-
nS
tRCP,tFCP
XIN
-
-
20
nS
Oscillation Stabilizing Time
tST
XIN, XOUT
-
-
20
mS
External Input Pulse Width
tEPW
INT0, INT1, EC0
2
-
-
tSYS
RESET Input Width
tRST
RESET
8
-
-
tSYS
Operating Frequency
External Clock Pulse Width
External Clock Transition Time
tCPW
1/fCP
tCPW
VDD-0.5V
XIN
0.5V
tSYS
tRCP
tFCP
tRST
RESET
0.2VDD
tEPW
tEPW
0.8VDD
INT0, INT1
EC0
0.2VDD
Figure 7-1 Timing Chart
18
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
7.6 Typical Characteristics
This graphs and tables provided in this section are for design guidance only and are not tested or guaranteed.
In some graphs or tables the data presented are outside specified operating range (e.g. outside specified
VDD range). This is for information only and devices
are guaranteed to operate properly only within the
specified range.
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
Operating Area
Normal Operation (NOP)
IDD−VDD
fXIN
(MHz)
IDD
(mA)
Ta= 25°C
10
Ta=25°C
4
8
3
fXIN = 8MHz
6
2
4
1
4MHz
2
0
0
2
3
4
5
2
VDD
(V)
6
STOP Mode
ISTOP−VDD
IDD
(µA)
3
4
5
VDD
6 (V)
Wake-up Timer Mode
IWKUP−VDD
fXIN = 8MHz
2.0
-25°C
IDD
(mA)
25°C
2.0
Ta=25°C
85°C
1.5
1.5
1.0
1.0
0.5
0.5
fXIN = 8MHz
0
2
3
4
5
VDD
6 (V)
4MHz
0
2
3
4
5
VDD
6 (V)
RC-WDT in Stop Mode
IRCWDT−VDD
IDD
(µA)
Ta=25°C
20
TRCWDT = 180uS
15
10
5
0
2
Apr. 2001 ver1.0
3
4
5
VDD
6 (V)
19
HMS87C130XA/120XA/110XA
IOL−VOL, VDD=5V
IOH−VOH, VDD=5V
IOL
(mA)
IOH
(mA)
-25°C
25°C
40
-25°C
25°C
-20
85°C
85°C
-15
30
-10
20
-5
10
0
0.5
VIH1
(V)
1
1.5
0
VOL
2.5 (V)
VDD−VIH1
XIN, RESET
2
VDD−VIH2
VIH2
(V)
fXIN=4MHz
Ta=25°C
Hysteresis input
f XIN =4M H z
Ta=25°C
3
4
VIH3
(V)
4
3
3
3
2
2
2
1
1
1
1
VIL1
(V)
2
3
4
5
VDD
6 (V)
VDD−VIL1
XIN, RESET
4
0
2
3
VDD−VIL2
VIL2
(V)
fXIN=4MHz
Ta=25°C
4
5
VDD
6 (V)
Hysteresis input
f XIN =4M H z
Ta=25°C
VIL3
(V)
3
3
2
2
2
1
1
1
3
4
5
VDD
6 (V)
4
0
2
3
4
5
VDD
6 (V)
3
VDD−VIL3
3
2
f XIN =4M H z
Ta=25°C
2
4
1
Normal input
0
4
0
VOH
6 (V)
5
VDD−VIH3
4
0
20
2
4
5
VDD
6 (V)
Normal input
f XIN =4M H z
Ta=25°C
0
2
3
4
5
VDD
6 (V)
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
With External Capacitor
REXT
10KΩ
30KΩ
50KΩ
CEXT
fOSC @
5V,25°C
fOSC @
3V,25°C
10pF
4.9MHz
3.94MHz
20pF
3.35MHz
2.72MHz
40pF
2.12MHz
1.74MHz
10pF
1.81MHz
1.57MHz
20pF
1.21MHz
1.04MHz
40pF
0.75MHz
0.65MHz
10pF
1.11MHz
0.98MHz
20pF
0.74MHz
0.65MHz
40pF
0.46MHz
0.40MHz
Without External Capcitor
fOSC @
5V,25°C
fOSC @
3V,25°C
7.29MHz
5.1MHz
2.96MHz
2.37MHz
1.85MHz
1.55MHz
Table 7-1 RC Oscillation Frequencies (with CEXT and without CEXT)
Apr. 2001 ver1.0
21
HMS87C130XA/120XA/110XA
8. MEMORY ORGANIZATION
The HMS87C1X0XA has separate address spaces for Program memory and Data Memory. Program memory can
only be read, not written to. It can be up to 2K/4K bytes of
Program memory. Data memory can be read and written to
up to 128 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.
A
ACCUMULATOR
X
X REGISTER
Y
Y REGISTER
SP
PCH
STACK POINTER
PCL
PROGRAM COUNTER
PSW
PROGRAM STATUS
WORD
Generally, SP is automatically updated when a subroutine
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 00H to 7FH
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 “7FH” is
used.
Stack Address (000H ~ 07FH)
15
8
0
Figure 8-1 Configuration of Registers
Accumulator: The Accumulator is an 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
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).
22
7
0
SP
Hardware fixed
Note: The Stack Pointer must be initialized by software because its value is undefined after RESET.
Example: To initialize the SP
LDX
#07FH
TXSP
; SP ← 7FH
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.
[Zero flag Z]
This flag is set when the result of an arithmetic operation
or data transfer is “0” and is cleared by any other result.
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
MSB
PSW
N
LSB
V
-
B
H
I
Z
C
RESET VALUE: 00H
CARRY FLAG RECEIVES
CARRY OUT
NEGATIVE FLAG
OVERFLOW FLAG
ZERO FLAG
BRK FLAG
INTERRUPT ENABLE FLAG
HALF CARRY FLAG RECEIVES
CARRY OUT FROM BIT 1 OF
ADDITION OPERLANDS
Figure 8-3 PSW (Program Status Word) Register
[Interrupt disable flag I]
dress.
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.
[Overflow flag V]
[Half carry flag H]
After operation, this is set when there is a carry from bit 3
of ALU or there is no borrow from bit 4 of ALU. This bit
can not be set or cleared except CLRV instruction with
Overflow flag (V).
[Break flag B]
This flag is set by software BRK instruction to distinguish
BRK from TCALL instruction with the same vector ad-
Apr. 2001 ver1.0
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.
23
HMS87C130XA/120XA/110XA
8.2 Program Memory
A 16-bit program counter is capable of addressing up to
64K bytes, but these devices have 4K/2K bytes program
memory space only physically implemented. Accessing a
location above FFFFH will cause a wrap-around to 0000H.
Example: Usage of TCALL
Figure 8-4, 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-5.
;
;TABLE CALL ROUTINE
;
FUNC_A: LDA
LRG0
RET
;
FUNC_B: LDA
LRG1
2
RET
;
;TABLE CALL ADD. AREA
;
ORG
0FFC0H
DW
FUNC_A
DW
FUNC_B
As shown in Figure 8-4, each area is assigned a fixed location in Program Memory. Program Memory area contains
the user program.
#5
TCALL 0FH
:
:
;1BYTE INSTR UCTIO N
;INSTEAD OF 3 BYTES
;NOR M AL C ALL
1
;TCALL ADDRESS AREA
F800H
HMS87C1302A
HMS87C1304A
F000H
LDA
PROGRAM
MEMORY
FEFFH
FF00H
FFC0H
FFDFH
FFE0H
FFFFH
TCALL
AREA
PCALL
AREA
INTERRUPT
VECTOR AREA
Figure 8-4 Program Memory Map
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.
As for the area from 0FF00H to 0FFFFH, if any area of
them is not going to be used, its service location is available as general purpose Program Memory.
Address
0FFE0H
Page Call (PCALL) area contains subroutine program to
reduce program byte length by using 2 bytes PCALL instead of 3 bytes CALL instruction. If it is frequently called,
it is more useful to save program byte length.
Table Call (TCALL) 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-6.
E2
Vector Area Memory
-
E4
-
E6
Basic Interval Interrupt Vector Area
E8
Watchdog Timer Interrupt Vector Area
EA
A/D Converter Interrupt Vector Area
EC
-
EE
-
F0
-
F2
-
F4
Timer/Counter 1 Interrupt Vector Area
F6
Timer/Counter 0 Interrupt Vector Area
F8
External Interrupt 1 Vector Area
FA
External Interrupt 0 Vector Area
FC
-
FE
RESET Vector Area
NOTE:
“-” means reserved area.
Figure 8-5 Interrupt Vector Area
24
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
Address
Address
Program Memory
0FFC0H
C1
TCALL 15
C2
C3
C4
C5
C6
C7
C8
C9
CA
CB
CC
CD
CE
CF
PCALL Area Memory
0FF00H
PCALL Area
(256 Bytes)
0FFFFH
TCALL 14
TCALL 13
TCALL 12
TCALL 11
TCALL 10
TCALL 9
TCALL 8
D0
D1
D2
D3
D4
D5
D6
D7
D8
D9
DA
DB
DC
DD
DE
DF
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-6 PCALL and TCALL Memory Area
PCALL→
→ rel
TCALL→
→n
4F35
4A
PCALL 35H
TCALL 4
4A
4F
35
~
~
~
~
~
~
0F125H
~
~
NEXT
0FF00H
0FF35H
0FFFFH
01001010
➊
PC: 11111111 11010110
FH FH
DH 6H
➌
NEXT
0FF00H
0FFD6H
25
0FFD7H
F1
Reverse
➋
0FFFFH
Apr. 2001 ver1.0
25
HMS87C130XA/120XA/110XA
Example: The usage software example of Vector address and the initialize part.
ORG
0FFE0H
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
DW
NOT_USED
NOT_USED
NOT_USED
BIT_INT
WDT_INT
AD_INT
NOT_USED
NOT_USED
NOT_USED
NOT_USED
TMR1_INT
TMR0_INT
INT1
INT0
NOT_USED
RESET
ORG
0F000H
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
(0FFE0)
(0FFE2)
(0FFE4)
(0FFE6)
(0FFE8)
(0FFEA)
(0FFEC)
(0FFEE)
(0FFF0)
(0FFF2)
(0FFF4)
(0FFF6)
(0FFF8)
(0FFFA)
(0FFFC)
(0FFFE)
Basic Interval Timer
Watchdog Timer
A/D
Timer-1
Timer-0
Int.1
Int.0
Reset
;********************************************
;
MAIN
PROGRAM
*
;*******************************************
;
RESET: DI
;Disable All Interrupts
LDX
#0
RAM_CLR: LDA
#0
;RAM Clear(!0000H->!007FH)
STA
{X}+
CMPX
#080H
BNE
RAM_CLR
;
LDX
#07FH
;Stack Pointer Initialize
TXSP
;
CALL
INITIAL
;
;
LDM
RA, #0
;Normal Port A
LDM
RAIO,#1000_0010B ;Normal Port Direction
LDM
RB, #0
;Normal Port B
LDM
RBIO,#0000_0010B ;Normal Port Direction
:
:
LDM
PFDR,#0
;Enable Power Fail Detector
:
:
26
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
8.3 Data Memory
Figure 8-7 shows the internal Data Memory space available. Data Memory is divided into two groups, a user RAM
(including Stack) and control registers.
0000H
USER
MEMORY
(including STACK)
007FH
PAGE0
0080H
00BFH
00C0H
CONTROL
REGISTERS
00FFH
Figure 8-7 Data Memory Map
User Memory
The HMS87C1X0XA has 128 × 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.
Note that unoccupied addresses may not be implemented
on the chip. Read accesses to these addresses will in general return random data, and write accesses will have an indeterminate effect.
More detailed informations of each register are explained
in each peripheral section.
Address
Symbol
R/W
RESET
Value
Addressing
m ode
0C0H
0C1H
0C2H
0C3H
0C4H
0C5H
0C6H
0C7H
0CAH
0CBH
0CCH
RA
RAIO
RB
RBIO
RC
RCIO
RD
RDIO
RAFUNC
RBFUNC
PUPSEL
R/W
W
R/W
W
R/W
W
R/W
W
W
W
W
Undefined
0000_0000
Undefined
0000_0000
Undefined
----_--00
Undefined
----_0000
0000_0000
0000_0000
----_0000
byte, bit1
byte2
byte, bit
byte
byte, bit
byte
byte, bit
byte
byte
byte
byte
0D0H
0D1H
0D1H
0D1H
0D2H
0D3H
0D3H
0D4H
0D4H
0D4H
0D5H
TM0
T0
TDR0
CDR0
TM1
TDR1
T1PPR
T1
CDR1
T1PDR
PWM0HR
R/W
R
W
R
R/W
W
W
R
R
R/W
W
--00_0000
0000_0000
1111_1111
0000_0000
0000_0000
1111_1111
1111_1111
0000_0000
0000_0000
0000_0000
----_0000
byte, bit
byte
byte
byte
byte, bit
byte
byte
byte
byte
byte, bit
byte
0DEH
BUR
W
1111_1111
byte
0E2H
0E3H
0E4H
0E5H
0E6H
0EAH
0EBH
0ECH
0ECH
0EDH
0EDH
0EFH
IENH
IENL
IRQH
IRQL
IEDS
ADCM
ADCR
BITR
CKCTLR
WDTR
WDTR
PFDR
R/W
R/W
R/W
R/W
R/W
R/W
R
R
W
R
W
R/W
0000_---000-_---0000_---000-_-------_0000
--00_0001
Undefined
0000_0000
-001_0111
0000_0000
0111_1111
----_0100
byte, bit
byte, bit
byte, bit
byte, bit
byte, bit
byte, bit
byte
byte
byte
byte
byte
byte, bit
Table 8-1 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.
1. “byte, bit” means that register can be addressed by not only bit
but byte manipulation instruction.
2. “byte” means that register can be addressed by only byte
manipulation instruction. On the other hand, do not use any
read-modify-write instruction such as bit manipulation for
clearing bit.
Example; To write at CKCTLR
LDM
CKCTLR,#09H ;Divide ratio ÷16
Apr. 2001 ver1.0
27
HMS87C130XA/120XA/110XA
Note: Several names are given at same address. Refer to
below table.
When read
When write
Addr.
Timer
Mode
Capture
Mode
PWM
Mode
Timer
Mode
PWM
Mode
D1H
T0
CDR0
-
TDR0
-
TDR1
T1PPR
-
T1PDR
D3H
D4H
ECH
T1
CDR1
BITR
T1PDR
CKCTLR
Table 8-2 Various Register Name in Same Address
28
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.
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
Address
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
C0H
RA
RA Port Data Register
C1H
RAIO
RA Port Direction Register
C2H
RB
RB Port Data Register
C3H
RBIO
RB Port Direction Register
C4H
RC
RC Port Data Register
C5H
RCIO
RC Port Direction Register
C6H
RD
RD Port Data Register
C7H
RDIO
RD Port Direction Register
CAH
RAFUNC
ANSEL7
ANSEL6
ANSEL5
ANSEL4
ANSEL3
ANSEL2
ANSEL1
ANSEL0
CBH
RBFUNC
TMR2OV
EC1I
PWM1O
PWM0O
INT1I
INT0I
BUZO
AVREFS
CCH
PUPSEL
-
-
-
-
D0H
TM0
-
-
CAP0
T0CK2
D1H
T0/TDR0/
CDR0
D2H
TM1
D3H
TDR1/
T1PPR
Timer1 Data Register / PWM0 Period Register
D4H
T1/CDR1/
T1PDR
Timer1 Register / Capture1 Data Register / PWM0 Duty Register
D5H
PWM0HR
PWM0 High Register
DEH
BUR
BUCK1
BUCK0
BUR5
BUR4
BUR3
E2H
IENH
INT0E
INT1E
T0E
T1E
E3H
IENL
ADE
WDTE
BITE
E4H
IRQH
INT0IF
INT1IF
E5H
IRQL
ADIF
E6H
IEDS
EAH
ADCM
EBH
ADCR
ADC Result Data Register
ECH
BITR1
Basic Interval Timer Data Register
ECH
CKCTLR1
EDH
WDTR
WDTCL
EFH
PFDR2
-
PUPSEL3 PUPSEL2 PUPSEL1 PUPSEL0
T0CK1
T0CK0
T0CN
T0ST
T1CN
T1ST
BUR2
BUR1
BUR0
-
-
-
-
-
-
-
-
-
T0IF
T1IF
-
-
-
-
WDTIF
BITIF
-
-
-
-
-
-
-
-
-
IED1H
IED1L
IED0H
IED0L
-
-
ADEN
ADS2
ADS1
ADS0
ADST
ADSF
WDTON
BTCL
BTS2
BTS1
BTS0
PFDOPR
PFDIS
PFDM
PFDS
Timer0 Register / Timer0 Data Register / Capture0 Data Register
POL
-
16BIT
WAKEUP
PWM0E
RCWDT
CAP1
T1CK1
T1CK0
7-bit Watchdog Counter Register
-
-
-
Table 8-3 Control Registers of HMS87C1X0XA
These registers of shaded area can not be accessed by bit manipulation instruction as “SET1, CLR1”, but should be accessed by
register operation instruction as “LDM dp,#imm”.
1.The register BITR and CKCTLR are located at same address. Address ECH is read as BITR, written to CKCTLR.
2.The register PFDR only be implemented on devices, not on In-circuit Emulator.
Apr. 2001 ver1.0
29
HMS87C130XA/120XA/110XA
8.4 Addressing Mode
The HMS87C1X0XA uses six addressing modes;
(3) Direct Page Addressing → dp
• Register addressing
In this mode, a address is specified within direct page.
Example;
• Immediate addressing
C535
LDA
;A ←RAM[35H]
35H
• Direct page addressing
• Absolute addressing
0035H
• Indexed addressing
data
➋
~
~
• Register-indirect addressing
~
~
0F550H
C5
0F551H
35
➊
data → A
(1) Register Addressing
Register addressing accesses the A, X, Y, C and PSW.
(2) Immediate Addressing → #imm
In this mode, second byte (operand) is accessed as a data
immediately.
Example:
0435
ADC
#35H
MEMORY
04
A+35H+C → A
35
(4) Absolute Addressing → !abs
Absolute addressing sets corresponding memory data to
Data, i.e. second byte(Operand I) of command becomes
lower level address and third byte (Operand II) becomes
upper level address.
With 3 bytes command, it is possible to access to whole
memory area.
ADC, AND, CMP, CMPX, CMPY, EOR, LDA, LDX,
LDY, OR, SBC, STA, STX, STY
Example;
0735F0
E45535
LDM
35H,#55H
ADC
data
0F035H
~
~
0F100H
➊
0F100H
30
data ← 55H
data
0035H
~
~
~
~
;A ←ROM[0F035H]
!0F035H
➋
~
~
➊
A+data+C → A
07
0F101H
35
0F102H
F0
address: 0F035
➋
E4
0F101H
55
0F102H
35
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
The operation within data memory (RAM)
ASL, BIT, DEC, INC, LSR, ROL, ROR
Example; Addressing accesses the address 0135H.
983500
INC
;A ←RAM[035H]
!0035H
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; X=35H
DB
data
0035H
~
~
LDA
{X}+
➌
~
~
➋
data+1 → data
0F100H
98
➊
0F101H
35
address: 0035
0F102H
00
35H
➋
data
~
~
~
~
data → A
➊
36H → X
DB
(5) Indexed Addressing
X indexed direct page (no offset) → {X}
In this mode, a address is specified by the X register.
ADC, AND, CMP, EOR, LDA, OR, SBC, STA, XMA
Example; X=15H
D4
LDA
{X}
;ACC←RAM[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; X=015H
15H
~
~
0F550H
C645
data
~
~
D4
LDA
45H+X
➋
data → A
➊
5AH
data
➌
~
~
Apr. 2001 ver1.0
➋
~
~
0F550H
C6
0F551H
45
data → A
➊
45H+15H=5AH
31
HMS87C130XA/120XA/110XA
Y indexed direct page (8 bit offset) → dp+Y
3F35
JMP
[35H]
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.
35H
0A
36H
F3
Y indexed absolute →!abs+Y
~
~
Sets the value of 16-bit absolute address plus Y-register
data as Memory. This addressing mode can specify memory in whole area.
Example; Y=55H
D500FA
LDA
~
~
D5
00
0F102H
FA
~
~
~
~
➊
3F
35
!0FA00H+Y
0F100H
➋ jump to address 0F30AH
NEXT
0FA00H
0F101H
0FA55H
0F30AH
~
~
➊
0FA00H+55H=0FA55H
~
~
➋
data
➌
data → A
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; X=10H
1625
ADC
[25H+X]
(6) Indirect Addressing
Direct page indirect → [dp]
Assigns data address to use for accomplishing command
which sets memory data(or pair memory) by Operand.
Also index can be used with Index register X,Y.
JMP, CALL
35H
05
36H
F4
0F405H
~
~ ➋
~
~
0F405H
~
~
Example;
0FA00H
~
~
16
25
32
➊ 25 + X(10) = 35H
data
➌ A + data + C → A
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
Y indexed indirect → [dp]+Y
Absolute indirect → [!abs]
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.
The program jumps to address specified by 16-bit absolute
address.
ADC, AND, CMP, EOR, LDA, OR, SBC, STA
Example; Y=10H
1725
ADC
JMP
Example;
1F25F0
JMP
[!0F025H]
[25H]+Y
PROGRAM MEMORY
25H
05
0F025H
25
26H
F7
0F026H
F8
~
~
0F715H
~
~
0FA00H
0F705H + Y(10) = 0F715H
➊
data
~
~
➋
~
~
➊
0F825H
0FA00H
17
Apr. 2001 ver1.0
➌ A + data + C → A
➋
jump to
address 0F80AH
NEXT
~
~
~
~
25
~
~
~
~
1F
25
F0
33
HMS87C130XA/120XA/110XA
9. I/O PORTS
The HMS87C1X0XA has four ports, RA, RB, RC and RD.
These ports pins may be multiplexed with an alternate
function for the peripheral features on the device. In general, when a initial reset state, all ports are used as a general
purpose input port.
All pins have data direction registers which can set these
ports as output or input. An “1” in the port direction register defines the corresponding port pin as output. Conversely, write “0” to the corresponding bit to specify as an input
pin. For example, to use the even numbered bit of RA as
output ports and the odd numbered bits as input ports, write
“55H” to address C1H (RA direction register) during initial
setting as shown in Figure 9-1.
Reading data register reads the status of the pins whereas
writing to it will write to the port latch.
WRITE “55H” TO PORT RA DIRECTION REGISTER
C0H
RA DATA
C1H
RA DIRECTION
C2H
RB DATA
C3H
RB DIRECTION
0 1 0 1 0 1 0 1
7 6 5 4 3 2 1 0
I O I
BIT
O I O I O
7 6 5 4 3 2 1 0 PORT
I: INPUT PORT
O: OUTPUT PORT
Figure 9-1 Example of port I/O assignment
9.1 RA and RAIO registers
RA is an 8-bit bidirectional I/O port (address C0H). Each
port can be set individually as input and output through the
RAIO register (address C1H).
RA1~RA7 ports are multiplexed with Analog Input Port
(AN1~AN7) and RA0 port is multiplexed with Event
Counter Input Port (EC0).
RA Data Register
RA
ADDRESS : C0H
RESET VALUE : Undefined
RA7 RA6 RA5 RA4 RA3 RA2 RA1 RA0
INPUT / OUTPUT DATA
RA Direction Register
select alternate function. After reset, this value is “0”, port
may be used as general I/O ports. To select alternate function such as Analog Input or External Event Counter Input,
write “1” to the corresponding bit of RAFUNC.Regardless
of the direction register RAIO, RAFUNC is selected to use
as alternate functions, port pin can be used as a corresponding alternate features (RA0/EC0 is controlled by RBFUNC)
PORT
RAFUNC.7~0
Description
0
RA7 (Normal I/O Port)
1
AN7 (ADS2~0=111)
0
RA6 (Normal I/O Port)
1
AN6 (ADS2~0=110)
0
RA5 (Normal I/O Port)
1
AN5 (ADS2~0=101)
0
RA4 (Normal I/O Port)
1
AN4 (ADS2~0=100)
0
RA3 (Normal I/O Port)
1
AN3 (ADS2~0=011)
0
RA2 (Normal I/O Port)
1
AN2 (ADS2~0=010)
0
RA1 (Normal I/O Port)
1
AN1 (ADS2~0=001)
RA7/AN7
ADDRESS : C1H
RESET VALUE : 00000000
RA6/AN6
RAIO
DIRECTION SELECT
0 : INPUT PORT
1 : OUTPUT PORT
RA5/AN5
RA4/AN4
RA Function Selection Register
RAFUNC
ADDRESS : CAH
RESET VALUE : 00000000
ANSEL7 ANSEL6 ANSEL5 ANSEL4 ANSEL3 ANSEL2 ANSEL1 ANSEL0
0 : RA4
1 : AN4
0 : RA5
1 : AN5
0 : RA6
1 : AN6
0 : RA7
1 : AN7
0 : RB0
1 : AN0
0 : RA1
1 : AN1
0 : RA2
1 : AN2
0 : RA3
1 : AN3
RA3/AN3
RA2/AN2
RA1/AN1
RA0/EC01
Figure 9-2 Registers of Port RA
The control register RAFUNC (address CAH) controls to
34
RA0 (Normal I/O Port)
EC0 (T0CK2~0=111)
1. This port is not an Analog Input port, but Event Counter clock
source input port. EC0 is controlled by setting TOCK2~0 = 111.
The bit RAFUNC.0 (ANSEL0) controls the RB0/AN0/AVref port
(Refer to Port RB).
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
9.2 RB and RBIO registers
sponding bit of RBFUNC.
RB is a 5-bit bidirectional I/O port (address C2H). Each pin
can be set individually as input and output through the
RBIO register (address C3H). In addition, Port RB is multiplexed with various special features. The control register
RBFUNC (address CBH) controls to select alternate function. After reset, this value is “0”, port may be used as general I/O ports. To select alternate function such as External
interrupt or Timer compare output, write “1” to the corre-
-
-
And RB2/INT0, RB3/INT1 have a function of pull-up
transistor by setting the PUPSEL0 and PUPSEL1 of
PUPSEL register.
Pull-up Selection Register
RB Data Register
RB
-
Regardless of the direction register RBIO, RBFUNC is selected to use as alternate functions, port pin can be used as
a corresponding alternate features.
ADDRESS : C2H
RESET VALUE : Undefined
ADDRESS : CCH
RESET VALUE : ----0000
PUPSEL
RB4 RB3 RB2 RB1 RB0
-
-
-
-
-
-
-
PUPSEL1 PUPSEL0
RB1 / INT1 Pull-up
0 : No Pull-up
1 : With Pull-up
INPUT / OUTPUT DATA
RB Direction Register
RBIO
-
RB0 / INT0 Pull-up
0 : No Pull-up
1 : With Pull-up
Interrupt Edge Selection Register
ADDRESS : C3H
RESET VALUE : ---00000
ADDRESS : E6H
RESET VALUE : ----0000
IEDS
-
-
-
-
-
IED1H
IED1L
IED0H
INT1
IED0L
INT0
External Interrupt Edge Select
DIRECTION SELECT
0 : INPUT PORT
1 : OUTPUT PORT
00 : Normal I/O port
01 : Falling (1-to-0 transition)
10 : Rising (0-to-1 transition)
11 : Both (Rising & Falling)
ADDRESS : CBH
RESET VALUE : ---00000
RB Function Selection Register
RBFUNC
-
-
-
PWM0O
INT1I
INT0I
BUZO AVREFS
0 : RB0 when ANSEL0 = 0
AN0 when ANSEL0 = 1
1 : AVREF
0 : RB4
1 : PWM0 Output or
Compare Output
0 : RB1
1 : BUZ Output
0 : RB2
1 : INT0
0 : RB3
1 : INT1
Figure 9-3 Registers of Port RB
Apr. 2001 ver1.0
35
HMS87C130XA/120XA/110XA
PORT
RBFUNC.4~0
RB4/
PWM0/
COMP0
0
RB4 (Normal I/O Port)
1
PWM0 Output /
Timer1 Compare Output
0
RB3 (Normal I/O Port)
1
External Interrupt Input 1
0
RB2 (Normal I/O Port)
1
External Interrupt Input 0
0
RB1 (Normal I/O Port)
1
Buzzer Output
01
RB0 (Normal I/O Port)/
AN0 (ANSEL0=1)
12
External Analog Reference
Voltage
RB3/INT1
RB2/INT0
RB1/BUZ
RB0/AN0/
AVREF
Description
1. When ANSEL0 = “0”, this port is defined for normal I/O port
(RB0).
When ANSEL0 = “1” and ADS2~0 = “000”, this port can be
used Analog Input Port (AN0).
2. When this bit set to “1”, this port defined for AVREF, so it can
not be used Analog Input Port AN0 and Normal I/O Port
RB0.
9.3 RC and RCIO registers
RC is a 2-bit bidirectional I/O port (address C4H). Each
pin can be set individually as input and output through the
ADDRESS : C4H
RESET VALUE : Undefined
RC Data Register
RC
-
-
-
-
-
-
RC1
RC0
RCIO register (address C5H).
ADDRESS : C5H
RESET VALUE : ------00
RC Direction Register
RCIO
-
INPUT / OUTPUT DATA
-
-
-
-
DIRECTION SELECT
0 : INPUT PORT
1 : OUTPUT PORT
Figure 9-4 Registers of Port RC
36
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
9.4 RD and RDIO registers
RD is a 4-bit bidirectional I/O port (address C6H). Each
pin can be set individually as input and output through the
RDIO register (address C7H)
-
-
-
ADDRESS : C6H
RESET VALUE : Undefined
PUPSEL
RD3 RD2 RD1 RD0
-
INPUT / OUTPUT DATA
RD Direction Register
RDIO
-
-
-
.
Pull-up Selection Register
RD Data Register
RD
-
And RD0, RD1 have a function of pull-up transistor by setting the PUPSEL2 and PUPSEL3 of PUPSEL register.
ADDRESS : CCH
RESET VALUE : ----0000
-
-
-
PUPSEL3 PUPSEL2
RD1 Pull-up
0 : No Pull-up
1 : With Pull-up
ADDRESS : C7H
RESET VALUE : -----0000
-
-
RD0 Pull-up
0 : No Pull-up
1 : With Pull-up
-
DIRECTION SELECT
0 : INPUT PORT
1 : OUTPUT PORT
Figure 9-5 Registers of Port RD
Apr. 2001 ver1.0
37
HMS87C130XA/120XA/110XA
10. CLOCK GENERATOR
Xin and Xout pins. External clocks can be input to the main
system clock oscillator. In this case, input a clock signal to
the Xin pin and open the Xout pin.
The clock generator produces the basic clock pulses which
provide the system clock to be supplied to the CPU and peripheral hardware. The main system clock oscillator oscillates
with a crystal resonator or a ceramic resonator connected to the
OSCILLATION
CIRCUIT
fXIN
CLOCK PULSE
GENERATOR
Internal system clock
PRESCALER
STOP
WAKEUP
÷1
÷2
÷4
÷8
÷16
÷32
÷64
÷128
÷256
÷512
÷1024 ÷2048
Peripheral clock
Figure 10-1 Block Diagram of Clock Pulse Generator
10.1 Oscillation Circuit
XIN and XOUT are the input and output, respectively, a inverting amplifier which can be set for use as an on-chip oscillator, as shown in Figure 10-2.
XOUT
C1
C2
R1
values of external components.
OPEN
External
Clock
Source
XOUT
XIN
Vss
XIN
Vss
Figure 10-3 External Clock Connections
Recommended: C1, C2 = 30pF±10pF for Crystals
R1 = 1MΩ
Figure 10-2 Oscillator Connections
To drive the device from an external clock source, Xout
should be left unconnected while Xin is driven as shown in
Figure 10-3. There are no requirements on the duty cycle
of the external clock signal, since the input to the internal
clocking circuitry is through a divide-by-two flip-flop, but
minimum and maximum high and low times specified on
the data sheet must be observed.
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
38
Note: When using a system clock oscillator, carry out wiring in the broken line area in Figure 10-2 to prevent
any effects from wiring capacities.
- Minimize the wiring length.
- Do not allow wiring to intersect with other signal
conductors.
- Do not allow 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 to
any ground pattern where high current is present.
- Do not fetch signals from the oscillator.
In addition, the HMS87C1X0XA has an ability for the external RC oscillated operation. It offers additional cost savings for timing insensitive applications. The RC
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
oscillator frequency is a function of the supply voltage, the
external resistor (REXT) and capacitor (CEXT) values, and
the operating temperature.
saving. However, the characteristics of external R only oscillation are more variable than external RC oscillation.
VDD
The user needs to take into account variation due to tolerance of external R and C components used.
REXT
XIN
Figure 10-4 shows how the RC combination is connected
to the HMS87C1X0XA.
CINT ≈ 6pF
Vdd
fXIN÷4
REXT
XOUT
XIN
Cint ≈ 6pF
CEXT
Figure 10-5 R Oscillator Connections
fXIN÷4
XOUT
The oscillator frequency, divided by 4, is output from the
Xout pin, and can be used for test purpose or to synchroze
other logic.
Figure 10-4 RC Oscillator Connections
External capacitor (CEXT) can be omitted for more cost
Apr. 2001 ver1.0
To set the RC oscillation, it should be programmed
RCOPT bit to "1" to CONFIG (707FH). ( Refer to Section
"20.1". )
39
HMS87C130XA/120XA/110XA
11. BASIC INTERVAL TIMER
If the STOP instruction executed after writing “1” to bit
RCWDT of CKCTLR, it goes into the internal RC oscillated watchdog timer mode. In this mode, all of the block is
halted except the internal RC oscillator, Basic Interval
Timer and Watchdog Timer. More detail informations are
explained in Power Saving Function. The bit WDTON decides Watchdog Timer or the normal 7-bit timer
The HMS87C1X0XA has one 8-bit Basic Interval Timer
that is free-run, can not stop. Block diagram is shown in
Figure 11-1.The 8-bit Basic interval timer register (BITR)
is increased every internal count pulse which is divided by
prescaler. Since prescaler has divided ratio by 8 to 1024,
the count rate is 1/8 to 1/1024 of the oscillator frequency.
As the count overflows from FF H to 00H, this overflow
causes to generate the Basic interval timer interrupt. The
BITF is interrupt request flag of Basic interval timer.
Note: All control bits of Basic interval timer are in CKCTLR
register which is located at same address of BITR
(address ECH). Address ECH is read as BITR, written to CKCTLR. Therefore, the CKCTLR can not be
accessed by bit manipulation instruction.
When write “1” to bit BTCL of CKCTLR, BITR register is
cleared to “0” and restart to count-up. The bit BTCL becomes “0” after one machine cycle by hardware.
If the STOP instruction executed after writing “1” to bit
WAKEUP of CKCTLR, it goes into the wake-up timer
mode. In this mode, all of the block is halted except the oscillator, prescaler (only fxin÷2048) and Timer0.
.
WAKEUP
RCWDT
STOP
fXIN
BTS[2:0]
÷8
÷ 16
÷ 32
÷ 64
÷ 128
÷ 256
÷ 512
÷ 1024
BTCL
3
To Watchdog Timer
Clear
8
MUX
0
BITIF
BITR (8BIT)
Basic Interval Timer
Interrupt
1
Internal RC OSC
Figure 11-1 Block Diagram of Basic Interval Timer
Clock Control Register
CKCTLR
-
WAKEUP RCWDT
WDTON
BTCL
BTS2
BTS1
BTS0
ADDRESS : ECH
RESET VALUE : -0010111
Bit Manipulation Not Available
Basic Interval Timer Clock Selection
Symbol
WAKEUP
Function Description
1 : Enables Wake-up Timer
0 : Disables Wake-up Timer
RCWDT
1 : Enables Internal RC Watchdog Timer
0 : Disables Internal RC Watchdog Time
WDTON
1 : Enables Watchdog Timer
0 : Operates as a 7-bit Timer
BTCL
1 : BITR is cleared and BTCL becomes “0” automatically
after one machine cycle, and BITR continue to count-up
000 : fXIN ÷ 8
001 : fXIN ÷ 16
010 : fXIN ÷ 32
011 : fXIN ÷ 64
100 : fXIN ÷ 128
101 : fXIN ÷ 256
110 : fXIN ÷ 512
111 : fXIN ÷ 1024
Figure 11-2 CKCTLR: Clock Control Register
40
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
12. TIMER / COUNTER
The HMS87C1X0XA has two Timer/Counter registers.
Each module can generate an interrupt to indicate that an
event has occurred (i.e. timer match).
Note: If changing the Timer value or starting again, it
should be stop the timer clock firstly, and then
set Timer register value.
Timer 0 and Timer 1 can be used either two 8-bit Timer/
Counter or the one 16-bit Timer/Counter by combining
them.
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 2 and
most clock consists of 2048 oscillator periods, the count
rate is 1/2 to 1/2048 of the oscillator frequency in Timer0.
And Timer1 can use the same clock source too. In addition,
Timer1 has more fast clock source (1/1 to 1/8).
In the “counter” function, the register is increased in response to a 0-to-1 (rising edge) transition at its corresponding external input pin, EC0(Timer 0).
Ex)
LDM
LDM
LDM
TM0,#00001100B
TDR,#7FH
TM0,#00010111B
In addition the “capture” function, the register is increased
in response external interrupt same with timer function.
When external interrupt edge input, the count register is
captured into capture data register CDRx.
Timer1 is shared with “PWM” function and “Compare
output” function
It has seven operating modes: “8-bit timer/counter”, “16bit timer/counter”, “8-bit capture”, “16-bit capture”, “8-bit
compare output”, “16-bit compare output” and “10-bit
PWM” which are selected by bit in Timer mode register
TMx as shown in Figure 12-1 and Table 12-1.
Timer 0 Mode Register
TM0
-
-
CAP0
T0CK2
T0CK1
T0CK0
T0CN
ADDRESS : D0H
RESET VALUE : --000000
T0ST
CAP0
Capture mode selection bit.
0 : Disables Capture
1 : Enables Capture
T0CN
Continue control bit
0 : Stop counting
1 : Start counting continuously
T0CK[2:0]
Input clock selection
000 : fXIN ÷ 2, 100 : fXIN ÷ 128
T0ST
Start control bit
0 : Stop counting
1 : Start counting
001 : fXIN ÷ 4,
010 : fXIN ÷ 8,
101 : fXIN ÷ 512
110 : fXIN ÷ 2048
011 : fXIN ÷ 32, 111 : External Event ( EC0 )
Timer 1 Mode Register
TM1
POL
POL
16BIT
PWM0E
CAP1
T1CK1
T1CK0
T1CN
ADDRESS : D2H
RESET VALUE : 00000000
T1ST
PWM Output Polarity
0 : Duty active low
1 : Duty active high
T1CK[2:0]
16BIT
16-bit mode selection
0 : 8-bit mode
1 : 16-bit mode
T1CN
Continue control bit
0 : Stop counting
1 : Start counting continuously
PWM0E
PWM enable bit
0 : Disables PWM
1 : Enables PWM
T1ST
Start control bit
0 : Stop counting
1 : Start counting
CAP1
Capture mode selection bit.
0 : Disables Capture
1 : Enables Capture
Input clock selection
00 : fXIN
10 : fXIN ÷ 8
01 : fXIN ÷ 2
11 : using the Timer 0 clock
Figure 12-1 Timer Mode Register (TM0, TM1)
Apr. 2001 ver1.0
41
HMS87C130XA/120XA/110XA
16BIT
CAP0
CAP1
PWME
T0CK[2:0]
T1CK[1:0]
PWMO
TIMER 0
TIMER1
0
0
0
0
XXX
XX
0
8-bit Timer
8-bit Timer
0
0
1
0
111
XX
0
8-bit Event Counter
8-bit Capture
0
1
0
0
XXX
XX
1
8-bit Capture
8-bit Compare output
0
X1
0
1
XXX
XX
1
8-bit Timer/Counter
10-bit PWM
1
0
0
0
XXX
11
0
16-bit Timer
1
0
0
0
111
11
0
16-bit Event Counter
1
1
X
0
XXX
11
0
16-bit Capture
1
0
0
0
XXX
11
1
16-bit Compare output
Table 12-1 Operating Modes of Timer 0 and Timer 1
1. X: The value “0” or “1” corresponding your operation.
12.1 8-bit Timer/Counter Mode
The HMS87C1X0XA has four 8-bit Timer/Counters, Timer 0 and Timer 1 as shown in Figure 12-2.
The “timer” or “counter” function is selected by mode registers TMx as shown in Figure 12-1 and Table 12-1. To use
TM0
TM1
as an 8-bit timer/counter mode, bit CAP0 of TM0 is
cleared to “0” and bits 16BIT of TM1 should be cleared to
“0”(Table 12-1).
-
-
CAP0
T0CK2
T0CK1
T0CK0
T0CN
T0ST
-
-
0
X
X
X
X
X
POL
16BIT
PWME
CAP1
T1CK1
T1CK0
T1CN
T1ST
X
0
0
0
X
X
X
X
ADDRESS : D0H
RESET VALUE : --000000
ADDRESS : D2H
RESET VALUE : 00000000
X: The value “0” or “1” corresponding your operation.
T0CK[2:0]
T0ST
Edge Detector
0 : Stop
1 : Start
1
EC0
fXIN
÷2
÷4
÷8
÷ 32
÷ 128
÷ 512
÷ 2048
÷1
÷2
÷8
CLEAR
T0 (8-bit)
MUX
TIMER 0
INTERRUPT
T0IF
COMPARATOR
T0CN
TDR0 (8-bit)
T1CK[1:0]
T1ST
0 : Stop
1 : Start
1
MUX
T1 (8-bit)
COMP0 PIN
CLEAR
F/F
T1IF
T1CN
TIMER 1
INTERRUPT
COMPARATOR
TDR1 (8-bit)
Figure 12-2 8-bit Timer / Counter Mode
42
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
(latched in T0F bit). As TDRx and Tx register are in same
address, when reading it as a Tx, written to TDRx.
These timers have each 8-bit count register and data register. The count register is increased by every internal or external clock input. The internal clock has a prescaler divide
ratio option of 2, 4, 8, 32,128, 512, 2048 (selected by control bits T0CK2, T0CK1 and T0CK0 of register TM0) and
1, 2, 8 (selected by control bits T1CK1 and T1CK0 of register TM1). In the Timer 0, timer register T0 increases
from 00H until it matches TDR0 and then reset to 00H. The
match output of Timer 0 generates Timer 0 interrupt
In counter function, the counter is increased every 0-to 1
(rising edge) transition of EC0 pin. In order to use counter
function, the bit RA0 of the RA Direction Register RAIO
is set to “0”. The Timer 0 can be used as a counter by pin
EC0 input, but Timer 1 can not.
TDR1
n
n-1
nt
-c
ou
~~
PCP
~~
9
8
~~
up
7
6
5
4
3
2
1
0
Timer 1 (T1IF)
Interrupt
TIME
Interrupt period
= PCP x (n+1)
Occur interrupt
Occur interrupt
Occur interrupt
Figure 12-3 Counting Example of Timer Data Registers
TDR1
disable
t
~~
clear & start
enable
up
-c
o
un
stop
~~
TIME
Timer 1 (T1IF)
Interrupt
Occur interrupt
T1ST
Start & Stop
T1ST = 0
Occur interrupt
T1ST = 1
T1CN
Control count
T1CN = 0
T1CN = 1
Figure 12-4 Timer Count Operation
Apr. 2001 ver1.0
43
HMS87C130XA/120XA/110XA
12.2 16-bit Timer/Counter Mode
The clock source of the Timer 0 is selected either internal
or external clock by bit T0CK2, T0CK1 and T0SL0.
The Timer register is being run with 16 bits. A 16-bit timer/
counter register T0, T1 are increased from 0000H until it
matches TDR0, TDR1 and then resets to 0000 H . The
match output generates Timer 0 interrupt not Timer 1 interrupt.
-
-
CAP0
T0CK2
T0CK1
T0CK0
T0CN
T0ST
-
-
0
X
X
X
X
X
POL
16BIT
PWME
CAP1
T1CK1
T1CK0
T1CN
T1ST
X
1
0
0
1
1
X
X
TM0
TM1
In 16-bit mode, the bits T1CK1,T1CK0 and 16BIT of TM1
should be set to “1” respectively.
ADDRESS : D0H
RESET VALUE : --000000
ADDRESS : D2H
RESET VALUE : 00000000
X: The value “0” or “1” corresponding your operation.
T0CK[2:0]
T0ST
0 : Stop
1 : Start
Edge Detector
1
EC0
fXIN
÷2
÷4
÷8
÷ 32
÷ 128
÷ 512
÷ 2048
T1 (8-bit)
MUX
T0 (8-bit)
CLEAR
T0IF
T0CN
TIMER 0
INTERRUPT
COMPARATOR
F/F
TDR1 (8-bit)
TDR0 (8-bit)
COMP0 PIN
Figure 12-5 16-bit Timer / Counter Mode
12.3 8-bit Compare Output (16-bit)
The HMS87C1X0XA has a function of Timer Compare
Output. To pulse out, the timer match can goes to port
pin(COMP0) as shown in Figure 12-2 and Figure 12-5.
Thus, pulse out is generated by the timer match. These operation is implemented to pin, RB4/COMP0/PWM.
This pin output the signal having a 50: 50 duty square
wave, and output frequency is same as below equation.
Oscillation Frequency
fCOMP = ------------------------------------------------------------------------------2 × Prescaler Value × ( TDR + 1 )
In this mode, the bit PWMO of RB function register (RBFUNC) should be set to “1”, and the bit PWME of timer1
mode register (TM1) should be set to “0”.
In addition, 16-bit Compare output mode is available, also.
12.4 8-bit Capture Mode
The Timer 0 capture mode is set by bit CAP0 of timer
mode register TM0 (bit CAP1 of timer mode register TM1
for Timer 1) as shown in Figure 12-6.
As mentioned above, not only Timer 0 but Timer 1 can also
be used as a capture mode.
44
The Timer/Counter register is increased in response internal or external input. This counting function is same with
normal timer mode, and Timer interrupt is generated when
timer register T0 (T1) increases and matches TDR0
(TDR1).
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
This timer interrupt in capture mode is very useful when
the pulse width of captured signal is more wider than the
maximum period of Timer.
For example, in Figure 12-8, the pulse width of captured
signal is wider than the timer data value (FFH) over 2
times. When external interrupt is occurred, the captured
value (13H) is more little than wanted value. It can be obtained correct value by counting the number of timer overflow occurrence.
Timer/Counter still does the above, but with the added feature that a edge transition at external input INTx pin causes
the current value in the Timer x register (T0,T1), to be captured into registers CDRx (CDR0, CDR1), respectively.
TM0
TM1
After captured, Timer x register is cleared and restarts by
hardware.
It has three transition modes: “falling edge”, “rising edge”,
“both edge” which are selected by interrupt edge selection
register IEDS (Refer to External interrupt section). In addition, the transition at INTx pin generate an interrupt.
Note: The CDRx, TDRx and Tx are in same address. In
the capture mode, reading operation is read the
CDRx, not Tx because path is opened to the CDRx,
and TDRx is only for writing operation.
-
-
CAP0
T0CK2
T0CK1
T0CK0
T0CN
T0ST
-
-
1
X
X
X
X
X
POL
16BIT
PWME
CAP1
T1CK1
T1CK0
T1CN
T1ST
X
0
0
1
X
X
X
X
T0CK[2:0]
ADDRESS : D0H
RESET VALUE : --000000
ADDRESS : D2H
RESET VALUE : 00000000
T0ST
0 : Stop
1 : Start
Edge Detector
1
EC0
fXIN
÷2
÷4
÷8
÷ 32
÷ 128
÷ 512
CLEAR
T0 (8-bit)
MUX
T0IF
T0CN
CAPTURE
TIMER 0
INTERRUPT
COMPARATOR
CDR0 (8-bit)
TDR0 (8-bit)
÷ 2048
INT0IF
INT0
INT 0
INTERRUPT
T0ST
0 : Stop
1 : Start
IEDS[1:0]
÷1
÷2
÷8
1
MUX
CLEAR
T1 (8-bit)
T1IF
T1CK[1:0]
T1CN
IEDS[3:2]
TIMER 1
INTERRUPT
COMPARATOR
CDR1 (8-bit)
TDR1 (8-bit)
CAPTURE
INT1IF
INT 1
INTERRUPT
INT1
Figure 12-6 8-bit Capture Mode
Apr. 2001 ver1.0
45
HMS87C130XA/120XA/110XA
This value is loaded to CDR0
n
T0
n-1
nt
ou
~~
~~
9
up
-c
8
7
6
5
4
~~
3
2
1
0
TIME
Ext. INT0 Pin
Interrupt Request
(INT0F)
Interrupt Interval Period
Ext. INT0 Pin
Interrupt Request
(INT0F)
Delay
Capture
(Timer Stop)
Clear & Start
Figure 12-7 Input Capture Operation
Ext. INT0 Pin
Interrupt Request
(INT0F)
Interrupt Interval Period = FFH + 01H + FFH +01H + 13H = 213H
Interrupt Request
(T0F)
FFH
FFH
T0
13H
00H
00H
Figure 12-8 Excess Timer Overflow in Capture Mode
46
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
12.5 16-bit Capture Mode
In 16-bit mode, the bits T1CK1,T1CK0 and 16BIT of TM1
should be set to “1” respectively.
16-bit capture mode is the same as 8-bit capture, except
that the Timer register is being run will 16 bits.
The clock source of the Timer 0 is selected either internal
or external clock by bit T0CK2, T0CK1 and T0CK0.
-
-
CAP0
T0CK2
T0CK1
T0CK0
T0CN
T0ST
-
-
1
X
X
X
X
X
POL
16BIT
PWME
CAP1
T1CK1
T1CK0
T1CN
T1ST
X
1
0
X
1
1
X
X
TM0
TM1
ADDRESS : D0H
RESET VALUE : --000000
ADDRESS : D2H
RESET VALUE : 00000000
X: The value “0” or “1” corresponding your operation.
T0CK[2:0]
T0ST
Edge Detector
0 : Stop
1 : Start
1
EC0
fXIN
÷2
÷4
÷8
÷ 32
÷ 128
÷ 512
÷ 2048
CLEAR
T0 + T1 (16-bit)
MUX
T0CN
T0IF
TIMER 0
INTERRUPT
COMPARATOR
CAPTURE
CDR1
(8-bit)
CDR0
(8-bit)
TDR1
(8-bit)
TDR0
(8-bit)
INT0IF
INT 0
INTERRUPT
INT0
IEDS[1:0]
Figure 12-9 16-bit Capture Mode
12.6 PWM Mode
The HMS87C1X0XA has a high speed PWM (Pulse
Width Modulation) functions which shared with Timer1.
And writes duty value to the T1PDR and the
PWM0HR[1:0] same way.
In PWM mode, pin RB4/COMP0/PWM0 outputs up to a
10-bit resolution PWM output. This pin should be configure as a PWM output by setting “1” bit PWM0O in RBFUNC register.
The T1PDR is configure as a double buffering for glitchless PWM output. In Figure 12-10, the duty data is transferred from the master to the slave when the period data
matched to the counted value. (i.e. at the beginning of next
duty cycle)
The period of the PWM output is determined by the
T1PPR (PWM0 Period Register) and PWM0HR[3:2]
(bit3,2 of PWM0 High Register) and the duty of the PWM
output is determined by the T1PDR (PWM0 Duty Register) and PWM0HR[1:0] (bit1,0 of PWM0 High Register).
The user writes the lower 8-bit period value to the T1PPR
and the higher 2-bit period value to the PWM0HR[3:2].
Apr. 2001 ver1.0
PWM Period = [PWM0HR[3:2]T1PPR] X Source Clock
PWM Duty = [PWM0HR[1:0]T1PDR] X Source Clock
The relation of frequency and resolution is in inverse proportion. Table 12-2 shows the relation of PWM frequency
vs. resolution.
47
HMS87C130XA/120XA/110XA
It can be changed duty value when the PWM output. However the changed duty value is output after the current period is over. And it can be maintained the duty value at
present output when changed only period value shown as
Figure 12-12. As it were, the absolute duty time is not
changed in varying frequency. But the changed period value must greater than the duty value.
If it needed more higher frequency of PWM, it should be
reduced resolution.
Frequency
Resolution
T1CK[1:0] =
00(125nS)
T1CK[1:0] =
01(250nS)
T1CK[1:0] =
10(1uS)
10-bit
7.8KHz
3.9KHz
0.98KHZ
9-bit
15.6KHz
7.8KHz
1.95KHz
8-bit
31.2KHz
15.6KHz
3.90KHz
7-bit
62.5KHz
31.2KHz
7.81KHz
Note: If changing the Timer1 to PWM function, it
should be stop the timer clock firstly, and then
set period and duty register value. If user
writes register values while timer is in operation, these register could be set with certain
values.
Table 12-2 PWM Frequency vs. Resolution at 8MHz
Ex)
LDM
LDM
LDM
LDM
LDM
LDM
The bit POL of TM1 decides the polarity of duty cycle.
If the duty value is set same to the period value, the PWM
output is determined by the bit POL (1: High, 0: Low). And
if the duty value is set to “00H”, the PWM output is determined by the bit POL (1: Low, 0: High).
TM1
PWM0HR
POL
16BIT
PW ME
C A P1
T1CK1
T1CK0
T 1C N
T 1S T
X
0
1
0
X
X
X
X
-
-
-
-
-
-
-
-
PW M 0HR3 PW M0HR2 PW M0HR1 PW M0HR0
X
X
X
Period High
T1ST
ADDRESS : D2H
RESET VALUE : 00000000
ADDRESS : D5H
RESET VALUE : ----0000
Bit Manipulation Not Available
X
Duty High
X: The value “0” or “1” corresponding your operation.
PWM0HR[3:2]
T0 clock source
TM1,#00H
T1PPR,#00H
T1PDR,#00H
PWM0HR,#00H
RBFUNC,#0001_1100B
TM1,#1010_1011B
T1PPR(8-bit)
0 : Stop
1 : Clear and Start
COMPARATOR
RB4/
PWM0
S Q
CLEAR
1
fXIN
÷1
÷2
÷8
MUX
COMPARATOR
T1CK[1:0]
R
T1 (8-bit)
PWM0O
[RBFUNC.4]
POL
T1CN
Slave
T1PDR(8-bit)
PWM0HR[1:0]
Master
T1PDR(8-bit)
Figure 12-10 PWM Mode
48
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
~
~
~
~
fXIN
02
03
04
05
80
81
3FF
00 01
02
03
~
~
~
~
PWM
POL=1
7F
~
~
~ ~
00 01
~ ~
~ ~
~
~
T1
~
~
PWM
POL=0
Duty Cycle [80H x 125nS = 16uS]
Period Cycle [3FFH x 125nS = 127.875uS, 7.8KHz]
T1CK[1:0] = 00 (fXIN)
PWM0HR = 0CH
Period
PWM0HR3 PWM0HR2
1
1
T1PPR (8-bit)
FFH
T1PPR = FFH
T1PDR = 80H
Duty
PWM0HR1 PWM0HR0
0
0
T1PDR (8-bit)
80H
Figure 12-11 Example of PWM at 8MHz
T 1 C K [1:0 ] = 10 (1 uS )
P W M 0 H R = 0 0H
T1PPR = 0EH
T 1 P D R = 0 5H
Write T1PPR to 0AH
Period changed
Source
clock
T1
01 02 03 04 05 06 07 08 09
0A 0B 0C 0D 0E
01 02 03 04 05 06 07 08 09 0A
01 02 03 04
05
PWM
POL=1
Duty Cycle
[05H x 1uS = 5uS]
Period Cycle [0EH x 1uS = 14uS, 71KHz]
Duty Cycle
[05H x 1uS = 5uS]
Duty Cycle
[05H x 1uS = 5uS]
Period Cycle [0AH x 1uS = 10uS, 100KHz]
Figure 12-12 Example of Changing the Period in Absolute Duty Cycle (@8MHz)
Apr. 2001 ver1.0
49
HMS87C130XA/120XA/110XA
13. BUZZER OUTPUT FUNCTION
The buzzer driver consists of 6-bit binary counter, the
buzzer register BUR and the clock selector. It generates
square-wave which is very wide range frequency (480
Hz~250 KHz at fXIN = 4 MHz) by user programmable
counter.
Also, it is cleared by counter overflow and count up to output the square wave pulse of duty 50%.
The bit 0 to 5 of BUR determines output frequency for
buzzer driving. Frequency calculation is following as
shown below.
Pin RB1 is assigned for output port of Buzzer driver by setting the bit BUZO of RBFUNC to “1”.
The 6-bit buzzer counter is cleared and start the counting
by writing signal to the register BUR. It is increased from
00H until it matches 6-bit register BUR.
BUR
BUCK1
BUCK0
Input clock selection
00 : fXIN ÷ 8
BUR5
BUR4
BUR3
Oscillator Frequency
f BUZ ( Hz ) = -----------------------------------------------------------------------------2 × Prescaler Ratio × ( BUR + 1 )
The bits BUCK1, BUCK0 of BUR selects the source clock
from prescaler output.
BUR2
BUR1
BUR0
ADDRESS : DEH
RESET VALUE : 11111111
Bit Manipulation Not Available
Buzzer Period Data
01 : fXIN ÷ 16
10 : fXIN ÷ 32
11 : fXIN ÷ 64
fXIN
÷8
÷ 16
÷ 32
÷ 64
MUX
COUNTER (6-bit)
F/F
COMPARATOR
BUCK[1:0]
RB1/BUZ PIN
BUR (6-bit)
BUZO
[RBFUNC.1]
Figure 13-1 Buzzer Driver
50
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
14. ANALOG TO DIGITAL CONVERTER
The analog-to-digital converter (A/D) allows conversion
of an analog input signal to a corresponding 8-bit digital
value. The A/D module has eight analog inputs, which are
multiplexed into one sample and hold. The output of the
sample and hold is the input into the converter, which generates the result via successive approximation.
The analog reference voltage is selected to VDD or AVREF
by setting of the bit AVREFS in RBFUNC register. If external analog reference AVREF is selected, the bit ANSEL0
should not be set to “1”, because this pin is used to an analog reference of A/D converter.
The A/D module has two registers which are the control
register ADCM and A/D result register ADCR. The
ADCM register, shown in Figure 14-2, controls the operation of the A/D converter module. The port pins can be
configure as analog inputs or digital I/O.
To use analog inputs, each port is assigned analog input
port by setting the bit ANSEL[7:0] in RAFUNC register.
And selected the corresponding channel to be converted by
setting ADS[2:0].
The processing of conversion is start when the start bit
ADST is set to “1”. After one cycle, it is cleared by hardware. The register ADCR contains the results of the A/D
conversion. When the conversion is completed, the result
is loaded into the ADCR, the A/D conversion status bit
ADSF is set to “1”, and the A/D interrupt flag ADIF is set.
The block diagram of the A/D module is shown in Figure
14-1. The A/D status bit ADSF is set automatically when
A/D conversion is completed, cleared when A/D conversion is in process. The conversion time takes maximum 10
uS (at fXIN=8 MHz).
ADS[2:0]
111
RA7/AN7
ANSEL7
110
RA6/AN6
A/D Result Register
ANSEL6
101
ADCR(8-bit)
RA5/AN5
ADDRESS : EBH
RESET VALUE : Undefined
ANSEL5
100
RA4/AN4
ANSEL4
Sample & Hold
S/H
Successive
Approximation
Circuit
011
RA3/AN3
A D IF
A/D Interrupt
ANSEL3
010
RA2/AN2
ANSEL2
001
RA1/AN1
Resistor
Ladder
Circuit
ANSEL1
000
RB0/AN0/AVREF
ANSEL0 (RAFUNC.0)
1
VDD Pin
0
ADEN
AVREFS (RBFUNC.0)
Figure 14-1 A/D Converter Block Diagram
Apr. 2001 ver1.0
51
HMS87C130XA/120XA/110XA
A/D Control Register
ADCM
-
-
ADEN
ADS2
ADS1
ADS0
ADST
ADSF
ADDRESS : EAH
RESET VALUE : --000001
Reserved
A/D Status bit
0 : A/D Conversion is in process
1 : A/D Conversion is completed
Analog Channel Select
000 : Channel 0 (RB0/AN0)
001 : Channel 1 (RA1/AN1)
010 : Channel 2 (RA2/AN2)
011 : Channel 3 (RA3/AN3)
100 : Channel 4 (RA4/AN4)
101 : Channel 5 (RA5/AN5)
110 : Channel 6 (RA6/AN6)
111 : Channel 7 (RA7/AN7)
A/D Start bit
1 : A/D Conversion is started
After 1 cycle, cleared to “0”
0 : Bit force to zero
A/D Enable bit
1 : A/D Conversion is enable
0 : A/D Converter module shut off
and consumes no operation current
A/D Result Data Register
ADCR
ADCR7
ADCR6
ADCR5
ADCR4
ADCR3
ADCR2
ADCR1
ADCR0
ADDRESS : EBH
RESET VALUE : Undefined
Figure 14-2 A/D Converter Registers
A/D Converter Cautions
ENABLE A/D CONVERTER
(1) Input range of AN0 to AN7
The input voltage of AN0 to AN7 should be within the
specification range. In particular, if a voltage above VDD
(or AVREF) or below VSS is input (even if within the absolute
maximum rating range), the conversion value for that channel can
not be indeterminate. The conversion values of the other channels
may also be affected.
A/D INPUT CHANNEL SELECT
ANALOG REFERENCE SELECT
(2) Noise countermeasures
In order to maintain 8-bit resolution, attention must be paid to
noise on pins AVREF (or VDD) and AN0 to AN7. Since the effect
A/D START (ADST = 1)
increases in proportion to the output impedance of the analog input source, it is recommended that a capacitor be connected externally as shown in Figure 14-4 in order to reduce
noise.
NOP
ADSF = 1
NO
YES
Analog
Input
AN0~AN7
100~1000pF
READ ADCR
Figure 14-3 A/D Converter Operation Flow
52
Figure 14-4 Analog Input Pin Connecting Capacitor
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
(3) Pins AN0/RB0 and AN1/RA1 to AN7/RA7
The analog input pins AN0 to AN7 also function as input/
output port (PORT RA and RB0) pins. When A/D conversion is performed with any of pins AN0 to AN7 selected,
be sure not to execute a PORT input instruction while conversion is in progress, as this may reduce the conversion
resolution.
Also, if digital pulses are applied to a pin adjacent to the
pin in the process of A/D conversion, the expected A/D
conversion value may not be obtainable due to coupling
Apr. 2001 ver1.0
noise. Therefore, avoid applying pulses to pins adjacent to
the pin undergoing A/D conversion.
(4) AVREF pin input impedance
A series resistor string of approximately 10KΩ is connected between the AVREF pin and the VSS pin.
Therefore, if the output impedance of the reference voltage
source is high, this will result in parallel connection to the
series resistor string between the AVREF pin and the VSS pin, and
there will be a large reference voltage error.
53
HMS87C130XA/120XA/110XA
15. INTERRUPTS
The HMS87C1X0XA interrupt circuits consist of Interrupt
enable register (IENH, IENL), Interrupt request flags of
IRQH, IRQL, Interrupt Edge Selection Register (IEDS),
priority circuit and Master enable flag(“I” flag of PSW).
The configuration of interrupt circuit is shown in Figure
15-1and Interrupt priority is shown in Table 15-1.
The External Interrupts INT0 and INT1 can each be transition-activated (1-to-0, 0-to-1 and both transition).
The flags that actually generate these interrupts are bit
INT0IF and INT1IF in Register IRQH. When an external
interrupt is generated, the flag that generated it is cleared
by the hardware when the service routine is vectored to
only if the interrupt was transition-activated.
The Timer 0 and Timer 1 Interrupts are generated by T0IF
and T1IF, which are set by a match in their respective timer/counter register. The AD converter Interrupt is generated by ADIF which is set by finishing the analog to digital
conversion. The Watch dog timer Interrupt is generated by
WDTIF which set by a match in Watch dog timer register
(when the bit WDTON is set to “0”). The Basic Interval
Timer Interrupt is generated by BITIF which is set by a
overflowing of the Basic Interval Timer Register(BITR).
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.
Internal bus line
IENH
IRQH
INT0IF
IEDS
External Int. 1
INT1IF
Timer 0
T0IF
Timer 1
T1IF
A/D Converter
ADIF
WDT
WDTIF
BIT
BITIF
IRQL
Release STOP
7
6
To CPU
5
Priority Control
External Int. 0
Interrupt Enable
Register (Higher byte)
4
7
6
5
IENL
I Flag
Interrupt Master
Enable Flag
Interrupt
Vector
Address
Generator
Interrupt Enable
Register (Lower byte)
Internal bus line
Figure 15-1 Block Diagram of Interrupt Function
54
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
The interrupts are controlled by the interrupt master enable
flag I-flag (bit 2 of PSW), the interrupt enable register
(IENH, IENL) and the interrupt request flags (in IRQH,
IRQL) except Power-on reset and software BRK interrupt.
Interrupt enable registers are shown in Figure 15-2. These
registers are composed of interrupt enable flags of each interrupt source, these flags determines whether an interrupt
will be accepted or not. When enable flag is “0”, a corresponding interrupt source is prohibited. Note that PSW
contains also a master enable bit, I-flag, which disables all
interrupts at once.
Reset/Interrupt
Symbol
Priority
Vector Addr.
Hardware Reset
External Interrupt 0
External Interrupt 1
Timer 0
Timer 1
A/D Converter
Watch Dog Timer
Basic Interval Timer
RESET
INT0
INT1
Timer 0
Timer 1
A/D C
WDT
BIT
1
2
3
4
5
6
7
FFFEH
FFFAH
FFF8H
FFF6H
FFF4H
FFEAH
FFE8H
FFE6H
Table 15-1 Interrupt Priority
Interrupt Enable Register High
IENH
INT0E
INT1E
T0E
T1E
-
-
-
-
ADDRESS : E2H
RESET VALUE : 0000----
-
-
-
-
-
ADDRESS : E3H
RESET VALUE : 000-----
Interrupt Enable Register Low
IENL
ADE
WDTE
BITE
Enables or disables the interrupt individually
If flag is cleared, the interrupt is disabled.
0 : Disable
1 : Enable
Interrupt Request Register High
IRQH
INT0IF
INT1IF
T0IF
T1IF
-
-
-
-
ADDRESS : E4H
RESET VALUE : 0000----
-
-
-
-
-
ADDRESS : E5H
RESET VALUE : 000-----
Interrupt Request Register Low
IRQL
ADIF
WDTIF
BITIF
Shows the interrupt occurrence
0 : Not occurred
1 : Interrupt request is occurred
Figure 15-2 Interrupt Enable Registers and Interrupt Request Registers
When an interrupt is occurred, the I-flag is cleared and disable any further interrupt, the return address and PSW are
pushed into the stack and the PC is vectored to. Once in the
interrupt service routine the source(s) of the interrupt can
be determined by polling the interrupt request flag bits.
Apr. 2001 ver1.0
The interrupt request flag bit(s) must be cleared by software before re-enabling interrupts to avoid recursive interrupts. The Interrupt Request flags are able to be read and
written.
55
HMS87C130XA/120XA/110XA
15.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 fOSC (2
µs at fXIN=4MHz) 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 15-3 Timing chart of Interrupt Acceptance and Interrupt Return Instruction
Basic Interval Timer
Vector Table Address
0FFE6H
0FFE7H
012H
0F3H
Entry Address
0F312H
0F313H
0EH
2FH
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.
56
When nested interrupt service is required, the I-flag should
be set to “1” by “EI” instruction in the interrupt service
program. In this case, acceptable interrupt sources are selectively enabled by the individual interrupt enable flags.
Saving/Restoring General-purpose Register
During interrupt acceptance processing, the program
counter and the program status word are automatically
saved on the stack, but accumulator and other registers are
not saved itself. These registers are saved by the software
if necessary. Also, when multiple interrupt services are
nested, it is necessary to avoid using the same data memory
area for saving registers.
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
The following method is used to save/restore the generalpurpose registers.
Example: Register save using push and pop instructions
INTxx:
PUSH
PUSH
PUSH
A
X
Y
;SAVE ACC.
;SAVE X REG.
;SAVE Y REG.
interrupt processing
POP
POP
POP
RETI
Y
X
A
;RESTORE Y REG.
;RESTORE X REG.
;RESTORE ACC.
;RETURN
General purpose register save/restore using push and pop
instructions;
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.
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.
Main Program
service
main task
acceptance of
interrupt
TIMER 1
service
enable INT0
disable other
interrupt
service task
INT0
service
EI
saving
registers
Occur
TIMER1 interrupt
Occur
INT0
restoring
registers
interrupt return
enable INT0
enable other
BRK Interrupt
Software interrupt can be invoked by BRK instruction,
which has the lowest priority order.
Interrupt vector address of BRK is shared with the vector
of TCALL 0 (Refer to Program Memory Section). When
BRK interrupt is generated, B-flag of PSW is set to distinguish BRK from TCALL 0.
Each processing step is determined by B-flag as shown in
Figure 15-4.
B-FLAG
BRK or
TCALL0
=0
=1
BRK
INTERRUPT
ROUTINE
TCALL0
ROUTINE
RETI
RET
Figure 15-4 Execution of BRK/TCALL0
Apr. 2001 ver1.0
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 15-5 Execution of Multi Interrupt
Example: Even though Timer1 interrupt is in progress,
INT0 interrupt serviced without any suspend.
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,#0F0H ;Enable all interrupts
IENL,#0E0H
Y
X
A
57
HMS87C130XA/120XA/110XA
15.2 External Interrupt
The external interrupt on INT0 and INT1 pins are edge
triggered depending on the edge selection register IEDS
(address 0E6H) as shown in Figure 15-6.
The edge detection of external interrupt has three transition
activated mode: rising edge, falling edge, and both edge.
INT0 pin
edge selection
INT1 pin
INT0IF
INT1IF
INT0 INTERRUPT
INT1 INTERRUPT
Ext. Interrupt Edge Selection
Register
W
W W
W
ADDRESS : 0E6H
RESET VALUE : ----0000
W
W
W
W
IEDS
INT1 edge select
00 : Int. disable
01 : falling
10 : rising
11 : both
INT0 edge select
00 : Int. disable
01 : falling
10 : rising
11 : both
LDM
RBIO,#1111_1011B
;
;**** Set port as an interrupt port
LDM
RBFUNC,#04H
;
;**** Set Falling-edge Detection
LDM
IEDS,#0000_0001B
:
Response Time
IEDS
[0E6H]
Figure 15-6 External Interrupt Block Diagram
Example: To use as an INT0 and INT1
:
:
;**** Set port as an input port RB2
Figure 15-7 shows interrupt response timings.
max. 12 fOSC
Interrupt Interrupt
goes
latched
active
The INT0 and INT1 edge are latched into INT0IF and
INT1IF at every machine cycle. The values are not actually
polled by the circuitry until the next machine cycle. If a request is active and conditions are right for it to be acknowledged, a hardware subroutine call to the 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.
8 fOSC
Interrupt
processing
Interrupt
routine
Figure 15-7 Interrupt Response Timing Diagram
58
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
16. WATCHDOG TIMER
The purpose of the watchdog timer is to detect the malfunction (runaway) of program due to external noise or
other causes and return the operation to the normal condition. The watchdog timer has two types of clock source.
The first type is an on-chip RC oscillator which does not
require any external components. This RC oscillator is separate from the external oscillator of the Xin pin. But the internal RC oscillated clock source should be activated by
execution of STOP instruction. It means that the watchdog
timer can not run even if the clock on the Xin pin of the
device has been stopped, for example, by entering the
STOP mode.
The other type is a prescaled system clock.
The watchdog timer consists of 7-bit binary counter and
the watchdog timer data register. The source clock of
WDT is overflow of Basic Interval Timer. When the value
of 7-bit binary counter is equal to the lower 7 bits of
WDTR, the interrupt request flag is generated. This can be
used as WDT interrupt or CPU reset signal in accordance
with the bit WDTON .
Note: Because the watchdog timer counter is enabled after clearing Basic Interval Timer and setting the
Watchdog Timer Register, maximum error of timer
is depend on prescaler ratio of Basic Interval Timer.
The 7-bit binary counter is cleared by setting WDTCL(bit7
of WDTR) and the WDTCL is cleared automatically after
1 machine cycle.
The RC oscillated watchdog timer is activated by setting
the bit RCWDT of CKCTLR and executing the STOP instruction as shown below.
:
LDM
LDM
STOP
NOP
NOP
:
CKCTLR,#3FH
WDTR,#0FFH
; enable the RC-osc WDT
; set the WDT period
; enter the STOP mode
; RC-osc WDT running
The RC oscillation period is variable according to the temperature, VDD and process variations from part to part (approximately, 120~180uS at 5V). The following equation
shows the RC oscillated watchdog timer time-out.
T R C W D T = C LK R C ×28×[W D T R .6~ 0 ]+ (C L K R C ×28)/2
w h ere, C L K R C = 1 20~ 1 80u S
In addition, this watchdog timer can be used as a simple 7bit timer by interrupt WDTIF. The interval of watchdog
timer interrupt is decided by Basic Interval Timer. Interval
equation is as below.
TWDT = [WDTR.6~0] × Interval of BIT
Clock Control Register
-
CKCTLR
WAKEUP RCWDT
Watchdog Timer Register
0
BTCL
BTS2
BTS1
BTS0
1
X
X
X
X
X
WDTCL
WDTR
WDTON
ADDRESS : ECH
RESET VALUE : -0010111
Bit Manipulation Not Available
ADDRESS : EDH
RESET VALUE : 01111111
Bit Manipulation Not Available
7-bit Watchdog Counter Register
WAKEUP
RCWDT
STOP
BTS[2:0]
fXIN
÷8
÷ 16
÷ 32
÷ 64
÷ 128
÷ 256
÷ 512
÷ 1024
WDTR (8-bit)
3
BTCL
WDTCL
WDTON
Clear
8
MUX
Internal RC OSC
0
1
BITR (8-bit)
7-bit Counter
CPU RESET
OFD
1
0
Overflow Detection
BITIF
Basic Interval Timer
Interrupt
Watchdog Timer
Interrupt Request
Figure 16-1 Block Diagram of Watchdog Timer
Apr. 2001 ver1.0
59
HMS87C130XA/120XA/110XA
17. POWER SAVING MODE
For applications where power consumption is a critical
factor, device provides three kinds of power saving functions, STOP mode, Wake-up Timer mode and internal RCoscillated watchdog timer mode.
The power saving function is activated by execution of
STOP instruction after setting the corresponding bit
(WAKEUP, RCWDT) of CKCTLR.
Note: Before executing STOP instruction, clear all interrupt request flag. Because if the interrupt request flag is set before STOP instruction, the MCU
runs as if it doesn’t perform STOP instruction, even
though the STOP instruction is completed. So insert
two lines to clear all interrupt request flags (IRQH,
IRQL) before STOP instruction as shown each example.
Table 17-1 shows the status of each Power Saving Mode
Peripheral
STOP
Wake-up Timer
Internal RC-WDT
RAM
Retain
Retain
Retain
Control Registers
Retain
Retain
Retain
I/O Ports
Retain
Retain
Retain
CPU
Stop
Stop
Stop
Timer0
Stop
Operation
Stop
Oscillation
Stop
Oscillation
Stop
Prescaler
Stop
÷ 2048 only
Stop
Internal RC oscillator
Stop
Stop
Oscillation
Entering Condition
CKCTLR[6,5]
00
1X
01
Power Saving Release
Source
RESET, INT0, INT1
RESET, INT0, INT1,
Timer0
RESET, INT0, INT1,
RC-WDT
Table 17-1 Power Saving Mode
17.1 Stop Mode
In the Stop mode, the on-chip oscillator is stopped. With
the clock frozen, all functions are stopped, but the on-chip
RAM and Control registers are held. The port pins out the
values held by their respective port data register, port direction registers. Oscillator stops and the systems internal
operations are all held up.
• The states of the RAM, registers, and latches valid
immediately before the system is put in the STOP
state are all held.
• The program counter stop the address of the
instruction to be executed after the instruction
“STOP” which starts the STOP operating mode.
The Stop mode is activated by execution of STOP instruction after setting the bit WAKEUP and RCWDT
of CKCTLR to “00”. (This register should be written
by byte operation. If this register is set by bit manipulation instruction, for example “set1” or “clr1” instruction, it may be undesired operation)
In the Stop mode of operation, VDD can be reduced to minimize power consumption. Care must be taken, however,
60
to ensure that VDD is not reduced before the Stop mode is
invoked, and that VDD is restored to its normal operating
level, before the Stop mode is terminated.
The reset should not be activated before VDD is restored to
its normal operating level, and must be held active long
enough to allow the oscillator to restart and stabilize.
Note: After STOP instruction, at least two or more NOP
instruction should be written
Ex) LDM CKCTLR,#0000_1110B
LDM IRQH,#0
LDM IRQL,#0
STOP
NOP
NOP
In the STOP operation, the dissipation of the power associated with the oscillator and the internal hardware is lowered; however, the power dissipation associated with the
pin interface (depending on the external circuitry and program) is not directly determined by the hardware operation
of the STOP feature. This point should be little current
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
flows when the input level is stable at the power voltage
level (VDD/VSS), however, when the input level gets higher than the power voltage level (by approximately 0.3 to
0.5V), a current begins to flow. Therefore, if cutting off the
output transistor at an I/O port puts the pin signal into the
high-impedance state, a current flow across the ports input
transistor, requiring to fix the level by pull-up or other
means.
the user should turn-off output drivers that are sourcing or
sinking current, if it is practical. Weak pull-ups on port
pins should be turned off, if possible. All inputs should be
either as VSS or at VDD (or as close to rail as possible).
An intermediate voltage on an input pin causes the input
buffer to draw a significant amount of current.
Release the STOP mode
The exit from STOP mode is hardware reset or external interrupt. Reset re-defines 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.
After releasing STOP mode, instruction execution is divided into two ways by I-flag(bit2 of PSW).
If I-flag = 1, the normal interrupt response takes place. If Iflag = 0, the chip will resume execution starting with the
instruction following the STOP instruction. It will not vector to interrupt service routine. (refer to Figure 17-1)
When exit from Stop mode by external interrupt, enough
oscillation stabilization time is required to normal operation. Figure 17-2 shows the timing diagram. When release
the Stop mode, the Basic interval timer is activated on
wake-up. It is increased from 00H until FFH. The count
overflow is set to start normal operation. Therefore, before
STOP instruction, user must be set its relevant prescaler divide ratio to have long enough time (more than 20msec).
This guarantees that oscillator has started and stabilized.
STOP
INSTRUCTION
STOP Mode
Interrupt Request
Corresponding Interrupt
Enable Bit (IENH, IENL)
=0
IEXX
=1
STOP Mode Release
Master Interrupt
Enable Bit PSW[2]
I-FLAG
=0
=1
Interrupt Service Routine
Next
INSTRUCTION
By reset, exit from Stop mode is shown in Figure 17-3.
Minimizing Current Consumption in Stop Mode
Figure 17-1 STOP Releasing Flow by Interrupts
The Stop mode is designed to reduce power consumption.
To minimize the current consumption during Stop mode,
~
~
~
~
Internal
Clock
~
~
External
Interrupt
~
~
STOP Instruction Execution
Clear Basic Interval Timer
~
~
N-2
N-1
N
N+1
N+2
00
01
FE
FF
00
01
~
~
BIT
Counter
~
~
~
~ ~
~
Oscillator
(XIN pin)
Normal Operation
STOP Mode
Stabilization Time
tST > 20mS
Normal Operation
Figure 17-2 Timing of STOP Mode Release by External Interrupt
Apr. 2001 ver1.0
61
HMS87C130XA/120XA/110XA
STOP Mode
~
~
~~
~ ~
~
~
Oscillator
(XIN pin)
~
~
~ ~
~
~
Internal
Clock
RESET
~
~
Internal
RESET
~
~
STOP Instruction Execution
Time can not be controlled by software
Stabilization Time
tST = 64mS @4MHz
Figure 17-3 Timing of STOP Mode Release by RESET
17.2 Wake-up Timer Mode
In the Wake-up Timer mode, the on-chip oscillator is not
stopped. Except the Prescaler (only 2048 divided ratio) and
Timer0, all functions are stopped, but the on-chip RAM
and Control registers are held. The port pins out the values
held by their respective port data register, port direction
registers.
In addition, the clock source of timer0 should be selected to 2048 divided ratio. Otherwise, the wake-up function can not work. And the timer0 can be operated as
16-bit timer with timer1 (refer to timer function). The
period of wake-up function is varied by setting the timer data register 0, TDR0.
The Wake-up Timer mode is activated by execution of
STOP instruction after setting the bit WAKEUP of
CKCTLR to “1”. (This register should be written by
byte operation. If this register is set by bit manipulation
instruction, for example “set1” or “clr1” instruction, it
may be undesired operation)
Release the Wake-up Timer mode
Note: After STOP instruction, at least two or more NOP instruction should be written
Ex) LDM TDR0,#0FFH
LDM TM0,#0001_1011B
LDM CKCTLR,#0100_1110B
LDM IRQH,#0
LDM IRQL,#0
STOP
NOP
NOP
If I-flag = 1, the normal interrupt response takes place. If Iflag = 0, the chip will resume execution starting with the
instruction following the STOP instruction. It will not vector to interrupt service routine (refer to Figure 17-1).
When exit from Wake-up Timer mode by external interrupt or timer0 overflow, the oscillation stabilization time is
not required to normal operation. Because this mode do not
stop the on-chip oscillator shown as Figure 17-4.
~
~
~
~ ~
~
Oscillator
(XIN pin)
CPU
Clock
STOP Instruction
Execution
~
~
Interrupt
Request
The exit from Wake-up Timer mode is hardware reset,
Timer0 overflow or external interrupt. Reset re-defines all
the Control registers but does not change the on-chip
RAM. External interrupts and Timer0 overflow allow both
on-chip RAM and Control registers to retain their values.
Normal Operation
Wake-up Timer Mode
(stop the CPU clock)
Normal Operation
Do not need Stabilization Time
Figure 17-4 Wake-up Timer Mode Releasing by External Interrupt or Timer0 Interrupt
62
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
17.3 Internal RC-Oscillated Watchdog Timer Mode
In the Internal RC-Oscillated Watchdog Timer mode, the
on-chip oscillator is stopped. But internal RC oscillation
circuit is oscillated in this mode. The on-chip RAM and
Control registers are held. The port pins out the values held
by their respective port data register, port direction registers.
The Internal RC-Oscillated Watchdog Timer mode is
activated by execution of STOP instruction after setting the bit WAKEUP and RCWDT of CKCTLR to
“01”. (This register should be written by byte operation. If this register is set by bit manipulation instruction, for example “set1” or “clr1” instruction, it may be
undesired operation)
Note: After STOP instruction, at least two or more NOP instruction should be written
Ex)
LDM
LDM
LDM
LDM
STOP
NOP
NOP
WDTR,#1111_1111B
CKCTLR,#0010_1110B
IRQH,#0
IRQL,#0
Release the Internal RC-Oscillated Watchdog Timer mode
The exit from Internal RC-Oscillated Watchdog Timer
mode is hardware reset or external interrupt. Reset re-defines all the Control registers but does not change the on-
chip RAM. External interrupts allow both on-chip RAM
and Control registers to retain their values.
If I-flag = 1, the normal interrupt response takes place. In
this case, if the bit WDTON of CKCTLR is set to “0” and
the bit WDTE of IENH is set to “1”, the device will execute the watchdog timer interrupt service routine.(Figure
17-5) However, if the bit WDTON of CKCTLR is set to
“1”, the device will generate the internal RESET signal
and execute the reset processing. (Figure 17-6)
If I-flag = 0, the chip will resume execution starting with
the instruction following the STOP instruction. It will not
vector to interrupt service routine (refer to Figure 17-1).
When exit from Internal RC-Oscillated Watchdog Timer
mode by external interrupt, the oscillation stabilization
time is required for normal operation. Figure 17-5 shows
the timing diagram. When release the Internal RC-Oscillated Watchdog Timer mode, the basic interval timer is activated on wake-up. It is increased from 00H until FFH. The
count overflow is set to start normal operation. Therefore,
before STOP instruction, user must be set its relevant prescaler divide ratio to have long enough time (more than
20msec). This guarantees that oscillator has started and
stabilized.
By reset, exit from internal RC-Oscillated Watchdog Timer mode is shown in Figure 17-6.
~
~
~
~
~
~
Oscillator
(XIN pin)
Internal
RC Clock
~
~
~
~
Internal
Clock
~
~
External
Interrupt
(or WDT Interrupt)
~
~
STOP Instruction Execution
~
~
N-2
N-1
N
N+1
N+2
00
01
FE
FF
00
00
~
~
BIT
Counter
Clear Basic Interval Timer
Normal Operation
RCWDT Mode
Stabilization Time
tST > 20mS
Normal Operation
Figure 17-5 Internal RCWDT Mode Releasing by External Interrupt or WDT Interrupt
Apr. 2001 ver1.0
63
HMS87C130XA/120XA/110XA
RCWDT Mode
~
~
~
~
~
~
Oscillator
(XIN pin)
Internal
RC Clock
~
~
~
~
Internal
Clock
~
~
~
~
RESET
RESET by WDT
~
~
STOP Instruction Execution
Time can not be controlled by software
~
~
Internal
RESET
Stabilization Time
tST = 64mS @4MHz
Figure 17-6 Internal RCWDT Mode Releasing by RESET
17.4 Minimizing Current Consumption
The Stop mode is designed to reduce power consumption.
To minimize current drawn during Stop mode, the user
should turn-off output drivers that are sourcing or sinking
current, if it is practical.
Note: In the STOP operation, the power dissipation 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 high-impedance state, a current flow across
the ports input transistor, requiring it to fix the level
by pull-up or other means.
64
It should be set properly that current flow through port
doesn't exist.
First conseider the setting to input mode. Be sure that there
is no current flow after considering its relationship with
external circuit. In 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 uncertain voltage level
(not VSS or 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
is external pull-down register, it is set to low.
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
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 17-7 Application Example of Unused Input Port
OUTPUT PIN
OUTPUT PIN
VDD
ON
OPEN
OFF
ON
OFF
ON
O
OFF
i
VDD
GND
X
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 17-8 Application Example of Unused Output Port
Apr. 2001 ver1.0
65
HMS87C130XA/120XA/110XA
18. RESET
The reset input is the RESET pin, which is the input to a
Schmitt Trigger. A reset in accomplished by holding the
RESET pin low for at least 8 oscillator periods, while the
oscillator running. After reset, 64ms (at 4 MHz) add with
7 oscillator periods are required to start execution as shown
in Figure 18-1.
Internal RAM is not affected by reset. When VDD is turned
on, the RAM content is indeterminate. Therefore, this
RAM should be initialized before reading or testing it.
Initial state of each register is shown as Table 8-1.
1
2
3
?
?
4
5
6
7
~
~
Oscillator
(XIN pin)
~
~
RESET
~
~
ADDRESS
BUS
?
?
FFFE FFFF Start
~
~ ~
~
DATA
BUS
?
?
?
?
FE
ADL
ADH
OP
~
~
MAIN PROGRAM
Stabilizing Time
tST = 64mS at 4MHz
RESET Process Step
Figure 18-1 Timing Diagram after RESET
• Power-On Reset (POR)
The HMS87C130XA incorporates on-chip Power-On Reset (POR) circuitry which provides an internal chip reset
for most power-up situations. To use this feature, the user
merely ties the RESET pin to VDD and setting the POREN
bit of CONFIG register ( refer to Figure 20-1).
A Power-on Reset pulse is generated on-chip when VDD
rise is detected approximately 1V. To take an advantage of
the Power-on Reset, just tie the RESET pin directly ( or
through the resistor ) to VDD.
VDD
RESET
Basic Interval Timer Start
INTERNAL RESET
Figure 18-2 Time-out Sequence On Power-up (RESET Tied To VDD): Fast VDD Rise Time
A power-up example where RESET is not tied to VDD is
shown in Figure 18-2. VDD is allowed to rise and stabilize
before bringing RESET high. The chip will actually come
out of reset and start the Basic Interval Timer after RESET
goes high.
66
In Figure 18-3, the on-chip Power-On Reset feature is being used (RESET and VDD are tied together). The VDD is
stable before the Basic interval timer times out and there is
no problem in getting a proper reset. However, Figure 184 depicts a problem situation where VDD rises too slowly.
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
The time between when the Basic interval timer senses a
high on the RESET pin, and when the RESET pin (and
VDD) actually reach their full value, is too long. In this situation, when the Basic interval timer times out, VDD has
not reached the VDD (min) value and the chip is, therefore,
not guaranteed to function correctly. For such situations,
we recommend that external R circuits be used to achieve
longer POR delay times ( Figure 18-5). The POR circuit
does not produce an internal reset when VDD declines
Note: When the device starts normal operation (exits the
reset condition), device operating parameters (voltage, frequency, temperature, etc.) must be meet to
ensure operation. If these conditions are not met,
the device must be held in reset until the operating
conditions are met..
VDD
RESET
INTERNAL POR
Basic Interval Timer Start
INTERNAL RESET
Figure 18-3 Time-out Sequence On Power-up (RESET Tied To VDD): Fast VDD Rise Time
VDD
RESET
INTERNAL POR
Basic Interval Timer Start
INTERNAL RESET
Figure 18-4 TIME-OUT SEQUENCE ON POWER-UP (RESET TIED TO VDD): SLOW VDD RISE TIME
VDD
VDD
D
- External Power-On Reset circuit is required only if VDD
power-up is too slow. The diode D helps discharge the
capacitor quickly when VDD powers down.
R
R1
RESET
C
- R < 40 kΩ is recommended to make sure that voltage
drop across R does not violate the device electrical specification.
- R1 = 100Ω to 1kΩ will limit any current flowing into
RESET from external capacitor C in the event of RESET
pin breakdown due to Electrostatic Discharge (ESD) or
Electrical Overstress (EOS).
Figure 18-5 EXTERNAL POWERON RESET CIRCUIT (FOR SLOW VDD POWER-UP)
Apr. 2001 ver1.0
67
HMS87C130XA/120XA/110XA
19. POWER FAIL PROCESSOR
The HMS87C1X0XA has an on-chip power fail detection
circuitry to immunize against power noise. A Power Fail
Detector Register, PFDR can enable (if clear/programmed) or disable (if set) the Power fail Detect circuitry.
If VDD falls below 2.4~2.6V(or 1.6~1.8V) range for longer
than 50 nS, the Power fail situation may reset MCU or halt
the system clock according to PFS bit of PFDR. And power fail detect level is selectable by programming the bit
PFDLEVEL of CONFIG register when program the OTP.
PFDIS
As below PFDR register is not implemented on the in-circuit emulator, user can not experiment with it. Therefore,
after final development of user program, this function may
be experimented.
Note: Power fail detect level is decided by setting the bit
PFDLEVEL of CONFIG register (refer to Figure 201.
PFDOPR
PFDM
to RESET circuit
Power
Fail
Detection
Circuit
Power Noise
System clock freeze
PFS
Power Fail Detector Register
PFDR
-
-
-
-
PFDOPR
PFDIS
PFDM
Reserved
PFS
ADDRESS : EFH
RESET VALUE : ----0100
Power Fail Status
0 : Normal Operate
1 : This bit force to “1” when
Power fail was detected
Operation Mode
0 : System Clock Freeze during power fail
1 : MCU will be reset during power fail
Disable Flag
0 : Power fail detection enable
1 : Power fail detection disable
PFD Operation Disable Flag
0 : Power fail detection enable
1 : Power fail detection disable
But can read PFS
Figure 19-1 Power Fail Detector
68
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
RESET VECTOR
YES
PFS =1
NO
RAM CLEAR
INITIALIZE RAM DATA
Skip the
initial routine
INITIALIZE ALL PORTS
INITIALIZE REGISTERS
FUNTION
EXECUTION
Figure 19-2 Example S/W of RESET by Power fail
VDD
PFVDDMAX
PFVDDMIN
64mS
Internal
RESET
VDD
When PFDM = 1
Internal
RESET
64mS
t < 64mS
VDD
Internal
RESET
PFVDDMAX
PFVDDMIN
PFVDDMAX
PFVDDMIN
64mS
VDD
PFVDDMAX
PFVDDMIN
System
Clock
When PFDM = 0
VDD
PFVDDMAX
PFVDDMIN
System
Clock
Figure 19-3 Power Fail Processor Situations
Apr. 2001 ver1.0
69
HMS87C130XA/120XA/110XA
20. OTP PROGRAMMING
The HMS87C130XA is one-time PROM(OTP) microcontroller with 4K/2K bytes electrically programmable read
only memory.
To programming the OTP device, user must use the universal programmer which is support Hynix microcontrollers.
20.1 DEVICE CONFIGURATION AREA
The Device Configuration Area can be programmed or left
unprogrammed to select device configuration such as security bit, power on reset, RC-oscillation, PFD level select
and open drain port selection .
This area is not accessible during normal execution but is
readable and writable during program / verify.
Configuration Register
CONFIG
-
-
POREN
OPDR1
OPDR0
LOCK
PFD
LEVEL
RC_OPT
ADDRESS : 707FH
RC Otion
0 : Normal Oscillator
1 : External RC Oscillator
PFD Level Select
0 : PFD Level High (2.4~2.6V)
1 : PFD Level Low (1.6~1.8V)
SECURITY BIT
0 : Allow Code Read Out
1 : Prohibit Code Read Out
Open Drain Port Selection
00 : Normal Port
01 : Open Drain RA0
10 : Open Drain RA0/RB2
11 : Open Drain RA0/RB2/RB3/RC0
Power on RESET
0 : Power on RESET Disable
1 : Power on RESET Enable
Figure 20-1 Device Configuration Area
70
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
A_D4
1
24
A_D3
A_D5
2
23
A_D2
A_D6
3
22
A_D1
A_D7
4
21
A_D0
5
20
CTL0
6
19
CTL1
7
18
VSS
CTL2
8
17
VPP
9
16
10
15
11
14
12
13
VDD
NC
EPROM Enable
Figure 20-2 Pin Assignment ( HMS1304/2A )
User Mode
EPROM MODE
Pin No.
Pin Name
Pin Name
Description
1
RA4 (AN4)
A_D4
2
RA5 (AN5)
A_D5
3
RA6 (AN6)
A_D6
4
RA7 (AN7)
A_D7
5
VDD
VDD
6
RD0
CTL0
7
RD1
CTL1
8
RBB0/AN0/AVref
CTL2
9~14
RB1~4, RD2~3
VDD
Connect to VDD (6.0V)
15
XIN
EPROM Enable
High Active, Latch Address in falling edge
16
XOUT
NC
No connection
17
RESET
VPP
Programming Power (0V, 12.75V)
18
VSS
VSS
Connect to VSS (0V)
Connect to VDD (6.0V)
RC0, 1
VDD
21
RA0 (EC0)
A_D0
22
RA1 (AN1)
A_D1
23
RA2 (AN2)
A_D2
24
RA3 (AN3)
A_D3
19,20
Address Input
Data Input/Output
A12
A4
D4
A13
A5
D5
A14
A6
D6
A15
A7
D7
A8
A0
D0
A9
A1
D1
A10
A2
D2
A11
A3
D3
Connect to VDD (6.0V)
Read/Write Control
Address/Data Control
Address Input
Data Input/Output
Table 20-1 Pin Description in EPROM Mode ( HMS1304/2A )
Apr. 2001 ver1.0
71
HMS87C130XA/120XA/110XA
A_D4
1
20
A_D3
A_D5
2
19
A_D2
A_D6
3
18
A_D1
A_D7
4
17
A_D0
5
16
CTL0
6
15
CTL1
7
14
VSS
CTL2
8
13
VPP
9
12
10
11
VDD
NC
EPROM Enable
Figure 20-3 Pin Assignment ( HMS1204/2A )
User Mode
EPROM MODE
Pin No.
Pin Name
Pin Name
Description
1
RA4 (AN4)
A_D4
A12
A4
D4
2
RA5 (AN5)
A_D5
A13
A5
D5
3
RA6 (AN6)
A_D6
A14
A6
D6
4
RA7 (AN7)
A_D7
A15
A7
D7
5
VDD
VDD
6
RB0/AN0/AVref
CTL0
7
RB1/BUZ
CTL1
8
RB2/INT0
CTL2
RB3~4
VDD
Connect to VDD (6.0V)
11
XIN
EPROM Enable
High Active, Latch Address in falling edge
12
XOUT
NC
No connection
13
RESET
VPP
Programming Power (0V, 12.75V)
14
VSS
VSS
Connect to VSS (0V)
RC0, 1
VDD
Connect to VDD (6.0V)
17
RA0 (EC0)
A_D0
A8
A0
D0
18
RA1 (AN1)
A_D1
A9
A1
D1
19
RA2 (AN2)
A_D2
A10
A2
D2
20
RA3 (AN3)
A_D3
A11
A3
D3
9,10
15,16
Address Input
Data Input/Output
Connect to VDD (6.0V)
Read/Write Control
Address/Data Control
Address Input
Data Input/Output
Table 20-2 Pin Description in EPROM Mode ( HMS1204/2A )
72
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
A_D4
1
16
A_D3
A_D5
2
15
A_D2
A_D6
3
14
A_D1
A_D7
4
13
A_D0
VDD
5
12
VSS
CTL0
6
11
VPP
CTL1
7
10
CTL2
8
9
NC
EPROM Enable
Figure 20-4 Pin Assignment ( HMS1104/2A )
User Mode
EPROM MODE
Pin No.
Pin Name
Pin Name
Description
1
RA4 (AN4)
A_D4
A12
A4
D4
2
RA5 (AN5)
A_D5
A13
A5
D5
3
RA6 (AN6)
A_D6
A14
A6
D6
4
RA7 (AN7)
A_D7
A15
A7
D7
5
VDD
VDD
6
RB0/AN0/AVref
CTL0
7
RB2/INT0
CTL1
8
RB4/PWM/COMP
CTL2
9
XIN
EPROM Enable
High Active, Latch Address in falling edge
10
XOUT
NC
No connection
11
RESET
VPP
Programming Power (0V, 12.75V)
12
VSS
VSS
Connect to VSS (0V)
13
RA0 (EC0)
A_D0
A8
A0
D0
14
RA1 (AN1)
A_D1
A9
A1
D1
15
RA2 (AN2)
A_D2
A10
A2
D2
16
RA3 (AN3)
A_D3
A11
A3
D3
Address Input
Data Input/Output
Connect to VDD (6.0V)
Read/Write Control
Address/Data Control
Address Input
Data Input/Output
Table 20-3 Pin Description in EPROM Mode ( HMS1104/2A )
Apr. 2001 ver1.0
73
HMS87C130XA/120XA/110XA
THLD1
TSET1
TDLY1
~
~ ~
~
0V
~
~
CTL0
TVPPR
~ ~
~
~
TVDDS
~
~
VPP
VIHP
~
~
TVPPS
VDD1H
TCD1
0V
0V
TCD1
HA
LA
LA
~~
DATA
OUT
DATA IN
~
~
DATA
OUT
DATA IN
~
~
~
~
A_D7~
A_D0
~
~
TCD1
TCD1
~
~
VDD1H
CTL2
TDLY2
~
~
EPROM
Enable
CTL1
THLD2
VDD1H
VDD
High 8bit
Address
Input
Low 8bit
Address
Input
Write Mode
Verify
Low 8bit
Address
Input
Write Mode
Verify
Figure 20-5 Timing Diagram in Program (Write & Verify) Mode
After input a high address,
output data following low address input
TSET1
THLD1
Another high address step
TDLY1
EPROM
Enable
TVPPS
VPP
TVDDS
CTL0
0V
VIHP
T VPPR
VDD2H
CTL1
0V
CTL2
0V
TCD2
VDD2H
A_D7~
A_D0
TCD1
TCD2
TCD1
HA
LA
DATA
LA
DATA
HA
LA
DATA
High 8bit
Address
Input
Low 8bit
Address
Input
DATA
Output
Low 8bit
Address
Input
DATA
Output
High 8bit
Address
Input
Low 8bit
Address
Input
DATA
Output
VDD2H
VDD
Figure 20-6 Timing Diagram in READ Mode
74
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
Parameter
Symbol
MIN
TYP
MAX
Unit
Programming Supply Current
IVPP
-
-
50
mA
Supply Current in EPROM Mode
IVDDP
-
-
20
mA
VPP Level during Programming
VIHP
12.5
12.75
13
V
VDD Level in Program Mode
VDD1H
5.5
6
6.6
V
VDD Level in Read Mode
VDD2H
-
2.7
-
V
CTL2~0 High Level in EPROM Mode
VIHC
0.8VDD
-
-
V
CTL2~0 Low Level in EPROM Mode
VILC
-
-
0.2VDD
V
A_D7~A_D0 High Level in EPROM Mode
VIHAD
0.9VDD
-
-
V
A_D7~A_D0 Low Level in EPROM Mode
VILAD
-
-
0.1VDD
V
VDD Saturation Time
TVDDS
1
-
-
mS
VPP Setup Time
TVPPR
-
-
1
mS
VPP Saturation Time
TVPPS
1
-
-
mS
EPROM Enable Setup Time after Data Input
TSET1
200
nS
EPROM Enable Hold Time after TSET1
THLD1
500
nS
EPROM Enable Delay Time after THLD1
TDLY1
200
nS
EPROM Enable Hold Time in Write Mode
THLD2
100
nS
EPROM Enable Delay Time after THLD2
TDLY2
200
nS
CTL2,1 Setup Time after Low Address input and Data input
TCD1
100
nS
CTL1 Setup Time before Data output in Read and Verify Mode
TCD2
100
nS
Table 20-4 AC/DC Requirements for Program/Read Mode
Apr. 2001 ver1.0
75
HMS87C130XA/120XA/110XA
START
Set VDD=VDD1H
Report
Programming failure
Set VPP=VIHP
Verify OK
NO
Verify blank
Report
Verify failure
Verify for all address
NO
YES
YES
Report
Programming OK
First Address Location
Next address location
Report
Programming failure
N=1
VDD=Vpp=0v
NO
END
YES
EPROM Write
100uS program time
N > 25
NO
Verify pass
YES
Apply 3N program cycle
NO
Last address
YES
Figure 20-7 Programming Flow Chart
76
Apr. 2001 ver 1.0
HMS87C130XA/120XA/110XA
START
Set VDD=VDD2H
Verify for all address
Set VPP=VIHP
First Address Location
Next address location
NO
Last address
YES
Report Read OK
VDD=0V
VPP=0V
END
Figure 20-8 Reading Flow Chart
Apr. 2001 ver1.0
77
APPENDIX
HMS871C130XA/120XA/110XA
APPENDIX
A. 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
CLR1
BBC
BBC
dp.bit
A.bit,rel
dp.bit,rel
Apr. 2001 Ver 1.0
i
HMS87C130XA/120XA/110XA
B. INSTRUCTION SET
1. ARITHMETIC/ LOGIC OPERATION
NO.
ii
MNEMONIC
OP BYTE CYCLE
CODE NO
NO
04
2
2
1
ADC #imm
2
ADC dp
05
2
3
3
ADC dp + X
06
2
4
4
ADC !abs
07
3
4
5
ADC !abs + Y
15
3
5
6
ADC [ dp + X ]
16
2
6
7
ADC [ dp ] + Y
17
2
6
8
ADC { X }
14
1
3
9
AND #imm
AND dp
84
2
2
10
85
2
3
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
19
ASL dp
ASL dp + X
09
19
2
2
4
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
32
CMPY #imm
7E
2
2
33
CMPY dp
8C
2
3
34
CMPY !abs
9C
3
4
FLAG
NVGBHIZC
OPERATION
Add with carry.
A←(A)+(M)+C
NV--H-ZC
Logical AND
A← (A)∧(M)
N-----Z-
Arithmetic shift left
C
7
6
5
4
3
2
1
N-----ZC
0
“0”
Compare accumulator contents with memory contents
(A) -(M)
N-----ZC
Compare X contents with memory contents
(X)-(M)
N-----ZC
Compare Y contents with memory contents
(Y)-(M)
N-----ZC
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
38
DEC A
A8
1
2
Decrement
N-----Z-
39
DEC dp
A9
2
4
40
DEC dp + X
B9
2
5
41
DEC !abs
B8
3
5
42
DEC X
AF
1
2
43
DEC Y
BE
1
2
44
DIV
9B
1
12
M← (M)-1
N-----Z-
Divide : YA / X Q: A, R: Y
NV--H-Z-
Apr. 2001 Ver 1.0
HMS871C130XA/120XA/110XA
NO.
MNEMONIC
OP BYTE CYCLE
OPERATION
CODE NO
NO
A4
2
2
Exclusive OR
A5
2
3
A← (A)⊕(M)
45
EOR #imm
46
EOR dp
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
N-----Z-
53
INC A
88
1
2
54
INC dp
89
2
4
55
INC dp + X
99
2
5
56
INC !abs
98
3
5
57
INC X
8F
1
2
58
INC Y
9E
1
2
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
77
ROR dp
69
2
4
78
ROR dp + X
79
2
5
79
ROR !abs
78
3
5
FLAG
NVGBHIZC
Increment
N-----Z-
M← (M)+1
N-----Z-
Logical shift right
7
6
5
4
3
2
1
0
C
N-----ZC
“0”
N-----Z-
A ← (A)∨(M)
N-----Z-
Rotate left through carry
C
7
6
5
4
3
2
1
0
N-----ZC
Rotate right through carry
7
6
5
4
3
2
1
0
C
N-----ZC
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-
89
XCN
CE
1
5
Exchange nibbles within the accumulator
A7~A4 ↔ A3~A0
N-----Z-
Apr. 2001 Ver 1.0
Subtract with carry
A ← ( A ) - ( M ) - ~( C )
NV--HZC
iii
HMS87C130XA/120XA/110XA
2. REGISTER / MEMORY OPERATION
NO.
iv
MNEMONIC
OP
BYTE CYCLE
CODE NO
NO
C4
2
2
1
LDA #imm
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
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
25
STA { X }
F4
1
4
FLAG
NVGBHIZC
OPERATION
--------
X ←(M)
N-----Z-
Load Y-register
Y←(M)
N-----Z-
Store accumulator contents in memory
(M)←A
--------
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
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-
(M)← X
--------
Store Y-register contents in memory
(M)← Y
-------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)↔A
N-----Z-
Exchange X-register contents with Y-register : X ↔ Y
--------
Apr. 2001 Ver 1.0
HMS871C130XA/120XA/110XA
3. 16-BIT OPERATION
NO.
MNEMONIC
OP BYTE CYCLE
CODE NO
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 substact without carry
YA ← ( YA ) - ( dp +1) ( dp)
NV--H-ZC
4. BIT MANIPULATION
NO.
MNEMONIC
OP BYTE CYCLE
OPERATION
CODE NO
NO
8B
3
4
Bit AND C-flag : C ← ( C ) ∧ ( M .bit )
FLAG
NVGBHIZC
-------C
1
AND1 M.bit
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 ← ( M7 ) , 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
-0--0---
CLRV
80
1
2
Clear V-flag : V ← “0”
10
EOR1 M.bit
AB
3
5
Bit exclusive-OR C-flag : C ← ( C ) ⊕ ( M .bit )
11
EOR1B M.bit
AB
3
5
4
-------C
Bit exclusive-OR C-flag and NOT : C ← ( C ) ⊕ ~(M .bit) -------C
Load C-flag : C ← ( M .bit )
-------C
12
LDC M.bit
CB
3
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
-------N-----ZN-----Z-
22
TCLR1 !abs
5C
3
6
Test and clear bits with A :
A - ( M ) , ( M ) ← ( M ) ∧ ~( A )
23
TSET1 !abs
3C
3
6
Test and set bits with A :
A-(M), (M)← (M)∨(A)
Apr. 2001 Ver 1.0
v
HMS87C130XA/120XA/110XA
5. BRANCH / JUMP OPERATION
NO.
vi
MNEMONIC
1
BBC A.bit,rel
2
BBC dp.bit,rel
OP BYTE CYCLE
OPERATION
CODE NO
NO
y2
2
4/6
Branch if bit clear :
y3
3
5/7
if ( bit ) = 0 , then pc ← ( pc ) + rel
FLAG
NVGBHIZC
--------
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
M( sp)←( pcH ), sp←sp - 1, M(sp)← (pcL), sp ←sp - 1,
-------if !abs, pc← abs ; if [dp], pc L← ( dp ), pcH← ( dp+1 ) .
15
CALL [dp]
5F
2
8
16
--------
CBNE dp,rel
FD
3
5/7
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)
--------
Compare and branch if not equal :
--------
if ( A ) ≠ ( M ) , then pc ← ( pc ) + rel.
--------
Unconditional jump
pc ← jump address
--------
Apr. 2001 Ver 1.0
HMS871C130XA/120XA/110XA
6. CONTROL OPERATION & etc.
NO.
MNEMONIC
OP BYTE CYCLE
CODE NO
NO
OPERATION
FLAG
NVGBHIZC
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, ---1-0-pcL ← ( 0FFDEH ) , pcH ← ( 0FFDFH) .
DI
60
1
3
Disable interrupts : I ← “0”
-----0--
EI
E0
1
3
Enable interrupts : I ← “1”
-----1---------
1
BRK
2
3
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
sp ← sp + 1, PSW ← M( sp )
POP PSW
6D
1
4
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
-------restored
--------
13
RET
6F
1
5
Return from subroutine
-------sp ← sp +1, pcL ← M( sp ), sp ← sp +1, pcH ← M( sp )
14
RETI
7F
1
6
Return from interrupt
sp ← sp +1, PSW ← M( sp ), sp ← sp + 1,
pcL ← M( sp ), sp ← sp + 1, pcH ← M( sp )
restored
15
STOP
EF
1
3
Stop mode ( halt CPU, stop oscillator )
--------
Apr. 2001 Ver 1.0
vii