Professional Documents
Culture Documents
Datasheet 2
Datasheet 2
com
HMS87C1808B/16B
HMS87C1708B/16B
HMS87C1608B/16B
HMS87C1508B/16B
HMS87C1404B/08B/16B
DataSheet4U.com DataShee
DataSheet4U.com
DataSheet 4 U .com
www.DataSheet4U.com
REVISION HISTORY
VERSION 1.03 (SEP. 2004) This book
The company name, Hynix Semiconductor Inc. changed to MagnaChip Semiconductor Ltd.
Version 1.03
Published by
MCU Application Team
2004 MagnaChip Semiconductor Ltd. All right reserved.
Additional information of this manual may be served by MagnaChip Semiconductor offices in Korea or Distributors and Representatives.
MagnaChip Semiconductor reserves the right to make changes to any information here in at any time without notice.
The information, diagrams and other data in this manual are correct and reliable; however, MagnaChip Semiconductor is in no way re-
sponsible for any violations of patents or other rights of the third party generated by the use of this manual.
DataSheet4U.com
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
DataSheet4U.com
SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
DataSheet4U.com
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
HMS87C1808B / 16B
HMS87C1708B / 16B
HMS87C1608B / 16B
HMS87C1508B / 16B
HMS87C1404B / 08B / 16B
CMOS SINGLE-CHIP 8-BIT MICROCONTROLLER
1. OVERVIEW
1.1 Description
The HMS87C1X04B/08B/16B is an advanced CMOS 8-bit microcontroller with 4K/8K/16K bytes of ROM. The MagnaChip semicon-
ductor’s HMS87C1X04B/08B/16B is a powerful microcontroller which provides a highly flexible and cost effective solution to many em-
bedded control applications. The HMS87C1X04B/08B/16B provides the following standard features: 4K/8K/16K bytes of ROM, 448
bytes of RAM, 8-bit timer/counter, 8-bit A/D converter, 10-bit high speed PWM output, programmable buzzer driving port, 8-bit serial
communication port, on-chip oscillator and clock circuitry. In addition, the HMS87C1X04B/08B/16B support power saving modes to re-
duce power consumption.
This document is only explained for the base HMS87C1816B, the other’s eliminated functions are same as below.
Operating
Device name EPROM RAM EXT.INT BUZ I/O Package
DataSheet4U.com Voltage
et4U.com DataShee
HMS87C14XXB 4,8,16K bytes 23 28 SKDIP or SOP
HMS87C15XXB 27 32 PDIP
HMS87C16XXB 448bytes 4 O 2.3 ~ 5.5V 35 40 PDIP
8,16K bytes
HMS87C17XXB 37 42 SDIP
HMS87C18XXB 39 44 QFP
1.2 Features
• 4K/8K/16 Bytes On-chip Program Memory - 4.5V ~ 5.5V (at 1 ~ 8.0MHz)
DataSheet4U.com
SEP. 2004 Ver 1.03 1
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
In Circuit
et4U.com Emulators CHOICE-Dr. TM DataSheet4U.com DataShee
Assembler MagnaChip Macro Assembler
DataSheet4U.com
2 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
DataSheet4U.com
SEP. 2004 Ver 1.03 3
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
2. BLOCK DIAGRAM
Program
RESET System controller Memory
System 8-bit Basic
Clock Controller Interval Interrupt Controller Data Table
Timer
Timing generator
Xin
Clock Generator
Xout
Instruction
Decoder
8-bit 8-bit High Buzzer
Watch-dog A/D Timer/ Speed SPI
Converter Counter PWM Driver
Timer
Power
Supply
DataSheet4U.com
4 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
3. PIN ASSIGNMENT
HMS87C14XXB SK HMS87C14XXB D
28 SKDIP 28 SOP
AN4 / RA4 1 28 RA3 / AN3 AN4 / RA4 1 28 RA3 / AN3
AN5 / RA5 2 27 RA2 / AN2 AN5 / RA5 2 27 RA2 / AN2
HMS87C15XXB HMS87C16XXB
et4U.com 32 PDIP DataSheet4U.com 40 PDIP DataShee
RC0 17 24 RC7
RC1 18 23 RC6 / SOUT
DataSheet4U.com
SEP. 2004 Ver 1.03 5
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
HMS87C17XXB K 42 SDIP
AN4 / RA4 1 42 RA3 / AN3
AN5 / RA5 2 41 RA2 / AN2
AN6 / RA6 3 40 RA1 / AN1
AN7 / RA7 4 39 RA0 / EC0
VDD 5 38 VSS
AN0 / AVREF/ RB0 6 37 RESET
BUZ / RB1 7 36 XOUT
INT0 / RB2 8 35 XIN
INT1 / RB3 9 34 RD7
PWM0 / COMP0 / RB4 10 33 RD6
PWM1 / COMP1 / RB5 11 32 RD5
EC1 / RB6 12 31 RD4
TMR2OV / RB7 13 30 RD3
RE4 14 29 RD2
RE3 15 28 RD1 / INT3
RE2 16 27 RD0 / INT2
RE1 17 26 RC7
RE0 18 25 RC6 / SOUT
RC0 19 24 RC5 / SIN
RC1 20 23 RC4 / SCK
RC2 21 22 SRDYIN / SRDYOUT / RC3
HMS87C18XXB Q 44 MQFP
et4U.com DataSheet4U.com DataShee
RD1 / INT3
RD0 / INT2
RESET
XOUT
RD7
RD6
RD5
RD4
RD3
RD2
XIN
33
32
31
30
29
28
27
26
25
24
23
VSS 34 22 RC7
RA0 / EC0 35 21 RC6 / SOUT
RA1 / AN1 36 20 RC5 / SIN
RA2 / AN2 37 19 RC4 / SCK
RA3 / AN3 38 18 SRDYIN / SRDYOUT / RC3
AN4 / RA4 39 17 RC2
AN5 / RA5 40 RC1
16
AN6 / RA6 41 RC0
15
AN7 / RA7 42 RE0
14
VDD 43 RE1
13
AN0 / AVREF/ RB0 44 RE2
12
10
11
1
2
3
4
5
6
7
8
9
INT0 / RB2
INT1 / RB3
PWM0 / COMP0 / RB4
PWM1 / COMP1 / RB5
BUZ / RB1
EC1 / RB6
TMR2OV / RB7
RE6
RE5
RE4
RE3
DataSheet4U.com
6 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
4. PACKAGE DRAWING
TYP 0.300
1.375
1.355 0.300
MIN 0.020
0.275
MAX 0.180
0.140
0.120 4
0.01
8
0.021 0.00
0.015 0.055 0 ~ 15°
TYP 0.100
0.045
DataSheet4U.com
et4U.com DataShee
28 SOP
0.299
0.292
0.419
0.398
0.713
0.697
0.0118
0.004
0.104
0.093
0.020 0 ~ 8°
0.042
0.0125
0.0138
0.009
DataSheet4U.com
SEP. 2004 Ver 1.03 7
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
32 PDIP
unit: inch
MAX
MIN
TYP 0.600
1.665
1.645 0.550
MIN 0.015
0.530
MAX 0.190
0.140
0.120
2
0.01
0.022 0 08
0.
0.015 0.065 0 ~ 15°
TYP 0.100
0.045
40 PDIP
TYP 0.600
2.075
2.045 0.550
MIN 0.015
0.530
MAX 0.200
0.140
0.120
2
0.01
0.022 0 08
0.
0.015 0.065 0 ~ 15°
TYP 0.100
0.045
DataSheet4U.com
8 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
42 SDIP
unit: inch
MAX
MIN
TYP 0.600
1.470
1.450 0.550
MIN 0.015
0.530
MAX 0.190
0.140
0.120
2
0.01
0.020 0 08
0.
0.016 0.045 0 ~ 15°
TYP 0.070
0.035
13.45
12.95 unit: mm
10.10
09.90 MAX
MIN
13.45
12.95
10.10
09.90
0-7°
REF
1.03
0.25
0.10
0.73
DataSheet4U.com
SEP. 2004 Ver 1.03 9
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
5. PIN FUNCTION
VDD: Supply voltage. RC0~RC7: RC is an 8-bit, CMOS, bidirectional I/O port. RC
pins can be used as outputs or inputs according to “1” or “0” writ-
VSS: Circuit ground.
ten the their Port Direction Register (RCIO).
RESET: Reset the MCU.
RC serves the functions of the serial interface following special
XIN: Input to the inverting oscillator amplifier and input to the in- features in Table 5-3 .
ternal main clock operating circuit.
XOUT: Output from the inverting oscillator amplifier. Port pin Alternate function
RA0~RA7: RA is an 8-bit, CMOS, bidirectional I/O port. RA RC0
pins can be used as outputs or inputs according to “1” or “0” writ- RC1
ten the their Port Direction Register(RAIO). RC2
RC3 SRDYIN (SPI Ready Input)
Port pin Alternate function SRDYOUT (SPI Ready Output)
RC4 SCKI (SPI CLK Input)
RA0 EC0 ( Event Counter Input Source ) SCKO (SPI CLK Output)
RA1 AN1 ( Analog Input Port 1 ) RC5 SIN (SPI Serial Data Input)
RA2 AN2 ( Analog Input Port 2 ) RC6 SOUT (SPI Serial Data Output)
RA3 AN3 ( Analog Input Port 3 ) RC7
RA4 AN4 ( Analog Input Port 4 )
RA5 AN5 ( Analog Input Port 5 ) Table 5-3 RC Port
RA6 AN6 ( Analog Input Port 6 )
RA7 AN7 ( Analog Input Port 7 ) RD0~RD7: RD is an 8-bit, CMOS, bidirectional I/O port. RC
pins can be used as outputs or inputs according to “1” or “0” writ-
Table 5-1 RA Port ten the their Port Direction Register (RDIO).
In addition, RA serves the functions of the various special fea- RD serves the functions of the external interrupt following spe-
et4U.com DataSheet4U.com
cial features in Table 5-4 DataShee
tures in Table 5-1 .
RB0~RB7: RB is an 8-bit, CMOS, bidirectional I/O port. RB
pins can be used as outputs or inputs according to “1” or “0” writ- Port pin Alternate function
ten the their Port Direction Register (RBIO). RD0 INT2 (External Interrupt Input Port 2)
RB serves the functions of the various following special features RD1 INT3 (External Interrupt Input Port 3)
in Table 5-2 RD2
RD3
RD4
Port pin Alternate function RD5
RB0 AN0 ( Analog Input Port 0 ) RD6
AVref ( External Analog Reference Pin ) RD7
RB1 BUZ ( Buzzer Driving Output Port )
RB2 INT0 ( External Interrupt Input Port 0 ) Table 5-4 RD Port
RB3 INT1 ( External Interrupt Input Port 1 )
RB4 PWM0 (PWM0 Output) RE0~RE6: RE is a 7-bit, CMOS, bidirectional I/O port. RC pins
COMP0 (Timer1 Compare Output) can be used as outputs or inputs according to “1” or “0” written
RB5 PWM1 (PWM1 Output) the their Port Direction Register (REIO).
COMP1 (Timer3 Compare Output)
RB6 EC1 (Event Counter Input Source)
RB7 TMR2OV (Timer2 Overflow Output)
DataSheet4U.com
10 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
RE0 ~ RE6 14 ~8
DataSheet4U.com
SEP. 2004 Ver 1.03 11
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
6. PORT STRUCTURES
• RESET
Internal RESET
VSS
VDD VDD
VDD
Xout
VSS
STOP
VDD VDD
VDD
RC
Xout
OSC
VSS
STOP
DataSheet4U.com
12 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
• RA0/EC0, RB6/EC1
Data Reg.
Data Bus
Direction Reg.
Data Bus
Data Bus
Read
EC0, EC1
• RA1/AN1 ~ RA7/AN7
VDD
Data Reg.
Data Bus
Direction Reg.
Data Bus
Read
To A/D Converter
DataSheet4U.com
SEP. 2004 Ver 1.03 13
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
PWM/COMP
BUZ,TMR2OV,SOUT VDD
1
Data Reg.
Data Bus 0
Function
Select Direction Reg.
Data Bus
VSS
Data Bus
Read
VDD
Data Reg.
Data Bus
AVREFS
Direction Reg.
et4U.com Data Bus
DataSheet4U.com DataShee
VSS
Data Bus
Read
To A/D Converter
To Vref of A/D
0
AVREFS
DataSheet4U.com
14 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
Pull-up
Select Weak Pull-up
Data Bus
Function
Select Direction Reg.
Data Bus
VSS
Data Bus
• RC5/SIN
Data Bus
Data Bus
VSS
Data Bus
SIN
DataSheet4U.com
SEP. 2004 Ver 1.03 15
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
VDD
Data Reg.
Data Bus
Direction Reg.
Data Bus
VSS
Data Bus
Read
SRDYOUT
SCKOUT VDD
1
Data Reg.
Data Bus 0
Function DataSheet4U.com
et4U.com Select Direction Reg.
DataShee
Data Bus
VSS
Data Bus
DataSheet4U.com
16 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
7. ELECTRICAL CHARACTERISTICS
Specifications
Parameter Symbol Condition Unit
Min. Max.
fXIN=8MHz 4.5 5.5 V
Supply Voltage VDD
fXIN=4.2MHz 2.3 5.5 V
VDD=4.5~5.5V 1 8 MHz
Operating Frequency fXIN
VDD=2.3~5.5V 1 4.2 MHz
et4U.com DataSheet4U.com DataShee
Operating Temperature TOPR -40 85 °C
Specifications
Parameter Symbol Condition Unit
Min. Typ. Max.
AVREFS=0 VSS - VDD
Analog Input Voltage Range VAIN V
AVREFS=1 VSS - VREF
VDD=5V 3 - VDD V
Analog Power Supply Input Voltage Range VREF
VDD=3V 2.4 - VDD V
Overall Accuracy NACC - ±0.7 ±1.5 LSB
Non-Linearity Error NNLE - ±0.8 ±1.5 LSB
Differential Non-Linearity Error NDNLE - ±1.0 ±1.5 LSB
Zero Offset Error NZOE - ±1.0 ±1.5 LSB
Full Scale Error NFSE - ±0.25 ±0.5 LSB
Gain Error NNLE - ±1.0 ±1.5 LSB
fXIN=8MHz - - 10
Conversion Time TCONV µS
fXIN=4MHz - - 20
AVREF Input Current IREF AVREFS=1 - 0.5 1.0 mA
DataSheet4U.com
SEP. 2004 Ver 1.03 17
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
Specifications
Parameter Symbol Pin Condition Unit
Min. Typ. Max.
VIH1 XIN, RESET 0.8 VDD - 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
Input Pull-up Current IP RB2, RB3, RD0, RD1 VDD=5V -150 - -70 µA
DataSheet4U.com
18 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
7.5 AC Characteristics
(TA=-40~+85°C, VDD=5V±10%, VSS=0V)
Specifications
Parameter Symbol Pins Unit
Min. Typ. Max.
Operating Frequency fCP XIN 1 - 8 MHz
External Clock Pulse Width tCPW XIN 50 - - nS
External Clock Transition Time tRCP,tFCP XIN - - 20 nS
Oscillation Stabilizing Time tST XIN, XOUT - - 20 mS
INT0, INT1, INT2, INT3
External Input Pulse Width tEPW 2 - - tSYS
EC0, EC1
RESET Input Width tRST RESET 8 - - tSYS
tCPW tCPW
1/fCP
VDD-0.5V
XIN 0.5V
tRCP tFCP
tSYS
tRST
RESET
0.2VDD
tEPW tEPW
0.8VDD
INT0, INT1 0.2VDD
INT2, INT3
EC0, EC1
DataSheet4U.com
SEP. 2004 Ver 1.03 19
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
8
6
6
4
fXIN = 8MHz
4
2 4MHz
2
0 VDD
2 3 4 5 6 (V)
0 VDD
2 3 4 5 6 (V)
0.2 0.5
4MHz
0 VDD 0 VDD
2 3 4 5 6 (V) 2 3 4 5 6 (V)
15
TRCWDT = 80uS
10
0 VDD
2 3 4 5 6 (V)
DataSheet4U.com
20 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
30 -15
-10
20
10 -5
0 0 VOH
VOL
1 2 3 4 5 (V) 2 3 4 5 6 (V)
2 2 2
1 1 1
3 3 3
2 2 2
1 1 1
DataSheet4U.com
SEP. 2004 Ver 1.03 21
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
4 4
R = 10K
3 3
R = 10K
R = 20K
2 2
R = 30K R = 20K
R = 30K
1 1
R = 51K R = 51K
0 VDD 0 VDD
2.5 3.0 3.5 4.0 4.5 5.0 5.5 (V) 2.5 3.0 3.5 4.0 4.5 5.0 5.5 (V)
4 4
3 3
R = 10K R = 10K
2 2
R = 20K R = 20K
1 R = 30K 1 R = 30K
0 R = 51K 0 R = 51K
VDD VDD
2.5 3.0 3.5 4.0 4.5 5.0 5.5 (V) 2.5 3.0 3.5 4.0 4.5 5.0 5.5 (V)
Note: The external RC oscillation frequencies shown in Note: The external RC oscillation frequencies of the
above are provided for design guidance only and not tested HMS87C1X04B/08B/16B may be different from that of the
or guaranteed. The user needs to take into account that the HMS81C1X04B/08B/16B. The user should modify the val-
external RC oscillation frequencies generated by the same ue of R and C components to get the proper frequency in
circuit design may be not the same. Because there are vari- exchanging OTP device to mask device.
ations in the resistance and capacitance due to the toler-
ance of external R and C components. The parasitic
capacitance difference due to the different wiring length
and layout may change the external RC oscillation frequen-
cies.
DataSheet4U.com
22 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
8. MEMORY ORGANIZATION
The HMS87C1X04B/08B/16B has separate address spaces for Program memory. The Data memory can be read and written to
Program memory and Data Memory. The Program memory can up to 448 bytes including the stack area.
only be read, not written to. It can be up to 4K /8K /16K bytes of
8.1 Registers
This device has six registers that are the Program Counter (PC), Generally, SP is automatically updated when a subroutine call is
a Accumulator (A), two index registers (X, Y), the Stack Pointer executed or an interrupt is accepted. However, if it is used in ex-
(SP), and the Program Status Word (PSW). The Program Counter cess of the stack area permitted by the data memory allocating
consists of 16-bit register. configuration, the user-processed data may be lost.
The stack can be located at any position within 00H to BFH of the
A ACCUMULATOR internal data memory. The SP is not initialized by hardware, re-
quiring to write the initial value (the location with which the use
X X REGISTER
of the stack starts) by using the initialization routine. Normally,
Y Y REGISTER the initial value of “BFH” is used.
DataSheet4U.com
SEP. 2004 Ver 1.03 23
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
MSB LSB
[Interrupt disable flag I] This flag assigned direct page for direct addressing mode. In the
direct addressing mode, addressing area is within zero page 00H
This flag enables/disables all interrupts except interrupt caused
to FFH when this flag is “0”. If it is set to “1”, addressing area is
by Reset or software BRK instruction. All interrupts are disabled
100H to 1FFH.
when cleared to “0”. This flag immediately becomes “0” when an
It is set by SETG instruction, and cleared by CLRG instruction.
interrupt is served. It is set by the EI instruction and cleared by
the DI instruction. [Overflow flag V]
[Half carry flag H] This flag is set to “1” when an overflow occurs as the result of an
arithmetic operation involving signs. An overflow occurs when
After operation, this is set when there is a carry from bit 3 of ALU
the result of an addition or subtraction exceeds +127(7FH) or -
et4U.com or there is no borrow from bit 4 of ALU. This bit can notDataSheet4U.com
be set DataShee
128(80H). The CLRV instruction clears the overflow flag. There
or cleared except CLRV instruction with Overflow flag (V).
is no set instruction. When the BIT instruction is executed, bit 6
[Break flag B] of memory is copied to this flag.
This flag is set by software BRK instruction to distinguish BRK [Negative flag N]
from TCALL instruction with the same vector address.
This flag is set to match the sign bit (bit 7) status of the result of
[Direct page select flag G] a data or arithmetic operation. When the BIT instruction is exe-
cuted, bit 7 of memory is copied to this flag.
DataSheet4U.com
24 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
HMS87C1X08B
The interrupt causes the CPU to jump to specific location, where
it commences the execution of the service routine. The External
F000H
interrupt 0, for example, is assigned to location 0FFFAH. The in-
terrupt service locations spaces 2-byte interval: 0FFF8H and
HMS87C1X04B PROGRAM
0FFF9H for External Interrupt 1, 0FFFAH and 0FFFBH for Exter-
MEMORY
FEFFH
nal Interrupt 0, etc.
FF00H As for the area from 0FF00H to 0FFFFH, if any area of them is not
et4U.com DataSheet4U.com DataShee
going to be used, its service location is available as general pur-
FFC0H TCALL PCALL pose Program Memory.
FFDFH AREA AREA
FFE0H INTERRUPT Address Vector Area Memory
FFFFH VECTOR AREA
0FFE0H -
E2 -
E4 Serial Peripheral Interface Interrupt Vector Area
Figure 8-4 Program Memory Map E6 Basic Interval Interrupt Vector Area
E8 Watchdog Timer Interrupt Vector Area
Page Call (PCALL) area contains subroutine program to reduce EA A/D Converter Interrupt Vector Area
program byte length by using 2 bytes PCALL instead of 3 bytes EC Timer/Counter 3 Interrupt Vector Area
CALL instruction. If it is frequently called, it is more useful to EE Timer/Counter 2 Interrupt Vector Area
save program byte length. F0 External Interrupt 3 Vector Area
Table Call (TCALL) causes the CPU to jump to each TCALL ad- F2 External Interrupt 2 Vector Area
dress, where it commences the execution of the service routine. F4 Timer/Counter 1 Interrupt Vector Area
The Table Call service area spaces 2-byte for every TCALL: F6 Timer/Counter 0 Interrupt Vector Area
0FFC0H for TCALL15, 0FFC2H for TCALL14, etc., as shown in F8 External Interrupt 1 Vector Area
Figure 8-6 . FA External Interrupt 0 Vector Area
FC -
FE RESET Vector Area
NOTE:
“-” means reserved area.
DataSheet4U.com
SEP. 2004 Ver 1.03 25
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
0FFC0H
TCALL 15
C1
C2
TCALL 14
C3
C4
TCALL 13
Address PCALL Area Memory C5
C6
0FF00H TCALL 12
C7
C8
TCALL 11
C9
PCALL Area CA
TCALL 10
(256 Bytes) CB
CC
TCALL 9
CD
CE
TCALL 8
0FFFFH CF
D0
TCALL 7
D1
D2
TCALL 6
D3
D4
TCALL 5
D5
D6
TCALL 4
D7
D8
TCALL 3
D9
DA
DataSheet4U.com TCALL 2
et4U.com DB DataShee
DC
TCALL 1
DD
DE
TCALL 0 / BRK *
DF
NOTE:
* means that the BRK software interrupt is using
same address with TCALL0.
4A 01001010
4F
Reverse
35 1
~
~ ~
~
PC: 11111111 11010110
~
~ ~
~ 0F125H NEXT FH FH DH 6 H
0FF00H
3
0FF35H NEXT 0FF00H 2
0FFD6H 25
0FFFFH 0FFD7H F1
0FFFFH
DataSheet4U.com
26 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
Example: The usage software example of Vector address and the initialize part.
ORG 0FFE0H
DW NOT_USED; (0FFEO)
DW NOT_USED; (0FFE2)
DW SPI_INT; (0FFE4) Serial Peripheral Interface
DW BIT_INT; (0FFE6) Basic Interval Timer
DW WDT_INT; (0FFE8) Watchdog Timer
DW AD_INT; (0FFEA) A/D
DW TMR3_INT; (0FFEC) Timer-3
DW TMR2_INT; (0FFEE) Timer-2
DW INT3; (0FFF0) Int.3
DW INT2; (0FFF2) Int.2
DW TMR1_INT; (0FFF4) Timer-1
DW TMR0_INT; (0FFF6) Timer-0
DW INT1; (0FFF8) Int.1
DW INT0; (0FFFA) Int.0
DW NOT_USED; (0FFFC)
DW RESET; (0FFFE) Reset
ORG 0F000H
;********************************************
; MAIN PROGRAM *
;*******************************************
;
RESET: DI ;Disable All Interrupts
LDX #0
RAM_CLR: LDA #0;RAM Clear(!0000H->!00BFH)
STA {X}+;0-page Clear
CMPX #0C0H
BNE RAM_CLR DataSheet4U.com
et4U.com DataShee
SETG
LDX #0
RAM_CL1: LDA #0;RAM Clear(!0100H->!01FFH)
STA {X}+;1-page Clear
CMPX #0
BNE RAM_CL1
CLRG
;
LDX #0BFH;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,#1000_0010B;Normal Port Direction
:
:
LDM PFDR,#0;Enable Power Fail Detector
:
DataSheet4U.com
SEP. 2004 Ver 1.03 27
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
DataSheet4U.com
28 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
below table.
0E2H IENH R/W 0000_0000 byte, bit
0E3H IENL R/W 0000_---- byte, bit
0E4H IRQH R/W 0000_0000 byte, bit
0E5H IRQL R/W 0000_---- byte, bit When read When write
0E6H IEDS R/W 0000_0000 byte, bit Addr. Timer Capture PWM Timer PWM
0EAH ADCM R/W --00_0001 byte, bit Mode Mode Mode Mode Mode
0EBH ADCR R Undefined byte D1H T0 CDR0 - TDR0 -
0ECH BITR R 0000_0000 byte
0ECH CKCTLR W -001_0111 byte D3H - TDR1 T1PPR
0EDH WDTR R 0000_0000 byte D4H T1 CDR1 T1PDR - T1PDR
0EDH WDTR W 0111_1111 byte
0EFH PFDR R/W ----_0100 byte, bit D7H T2 CDR2 - TDR2 -
D9H - TDR3 T3PPR
Table 8-1 Control Registers
DAH T3 CDR3 T3PDR - T3PDR
1. “byte, bit” means that register can be addressed by not only bit
but byte manipulation instruction. ECH BITR CKCTLR
2. “byte” means that register can be addressed by only byte
manipulation instruction. On the other hand, do not use any Table 8-2 Various Register Name in Same Address
read-modify-write instruction such as bit manipulation for
clearing bit.
Stack Area
The stack provides the area where the return address is saved be-
Note: Several names are given at same address. Refer to fore a jump is performed during the processing routine at the ex-
ecution of a subroutine call instruction or the acceptance of an
interrupt.
When returning from the processing routine, executing the sub-
routine return instruction [RET] restores the contents of the pro-
gram counter from the stack; executing the interrupt return
et4U.com DataSheet4U.com DataShee
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.
DataSheet4U.com
SEP. 2004 Ver 1.03 29
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
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
C8H RE RE Port Data Register
C9H REIO RE 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 - - - - PUPSEL3 PUPSEL2 PUPSEL1 PUPSEL0
CDH RDFUNC - - - - - - INT3I INT2I
D0H TM0 - - CAP0 T0CK2 T0CK1 T0CK0 T0CN T0ST
T0/TDR0/
D1H Timer0 Register / Timer0 Data Register / Capture0 Data Register
CDR0
D2H TM1 POL 16BIT PWM0E CAP1 T1CK1 T1CK0 T1CN T1ST
et4U.com TDR1/ DataSheet4U.com DataShee
D3H Timer1 Data Register / PWM0 Period Register
T1PPR
T1/CDR1/
D4H Timer1 Register / Capture1 Data Register / PWM0 Duty Register
T1PDR
D5H PWM0HR PWM0 High Register
D6H TM2 - - CAP2 T2CK2 T2CK1 T2CK0 T2CN T2ST
T2/TDR2/
D7H Timer2 Register / Timer2 Data Register / Capture2 Data Register
CDR2
D8H TM3 POL 16BIT PWM1E CAP3 T3CK1 T3CK0 T3CN T3ST
TDR3/
D9H Timer3 Data Register / PWM1 Period Register
T3PPR
T3/CDR3/
DAH Timer3 Register / Capture3 Data Register / PWM1Duty Register
T3PDR
DBH PWM1HR PWM1 High Register
DEH BUR BUCK1 BUCK0 BUR5 BUR4 BUR3 BUR2 BUR1 BUR0
E0H SIOM POL SRDY SM1 SM0 SCK1 SCK0 SIOST SIOSF
E1H SIOR SPI DATA REGISTER
E2H IENH INT0E INT1E T0E T1E INT2E INT3E T2E T3E
E3H IENL ADE WDTE BITE SPIE - - - -
E4H IRQH INT0IF INT1IF T0IF T1IF INT2IF INT3IF T2IF T3IF
DataSheet4U.com
30 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
DataSheet4U.com
SEP. 2004 Ver 1.03 31
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
0F035H data
2
~
~ ~
~ A+data+C → A
1
0035H data data ← 55H 0F100H 07
0F101H 35 address: 0F035
~
~ ~
~ 0F102H F0
1 2
0F100H E4
0F101H 55
0F102H 35
DataSheet4U.com
32 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
The operation within data memory (RAM) X indexed direct page, auto increment→ {X}+
ASL, BIT, DEC, INC, LSR, ROL, ROR In this mode, a address is specified within direct page by the X
Example; Addressing accesses the address 0035H. register and the content of X is increased by 1.
983500 INC !0035H ;A ←RAM[035H] LDA, STA
Example; X=35H
DB LDA {X}+
0035H data
3
~
~ ~
~ 2
data+1 → data 35H data 2
0F100H 98 1 ~ ~ data → A
0F101H 35 ~ ~
address: 0035
1 36H → X
0F102H 00
DB
X indexed direct page (no offset) → {X} X indexed direct page (8 bit offset) → dp+X
In this mode, a address is specified by the X register. This address value is the second byte (Operand) of command plus
ADC, AND, CMP, EOR, LDA, OR, SBC, STA, XMA the data of X-register. And it assigns the memory in Direct page.
Example; X=15H ADC, AND, CMP, EOR, LDA, LDY, OR, SBC, STA STY,
XMA, ASL, DEC, INC, LSR, ROL, ROR
et4U.com D4 LDA {X} ;ACC←RAM[X].DataSheet4U.com DataShee
Example; X=015H
C645 LDA 45H+X
15H data
2
~ ~ data → A 5AH
~ ~ data
1 3
0E550H D4 ~ ~ 2 data → A
~ ~
0E550H C6 1
0E551H 45
45H+15H=5AH
DataSheet4U.com
SEP. 2004 Ver 1.03 33
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
0F100H D5
0F101H 00
1
0F102H FA 0FA00H+55H=0FA55H
~
~ ~
~ 2 X indexed indirect → [dp+X]
Processes memory data as Data, assigned by 16-bit pair memory
0FA55H data
which is determined by pair data [dp+X+1][dp+X] Operand plus
data → A
3 X-register data in Direct page.
ADC, AND, CMP, EOR, LDA, OR, SBC, STA
et4U.com DataSheet4U.com DataShee
Example; X=10H
1625 ADC [25H+X]
(6) Indirect Addressing
~
~ ~
~
0FA00H 16
25
3 A + data + C → A
DataSheet4U.com
34 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
PROGRAM MEMORY
25H 05 0E025H 25
26H E0 0E026H E7
~
~ ~
~ ~
~ ~
~
0FA00H 17 0FA00H 1F
25 25
3 A + data + C → A E0
DataSheet4U.com
SEP. 2004 Ver 1.03 35
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
9. I/O PORTS
The HMS87C1816B has five ports, RA, RB, RC,RD and RE. to it will write to the port latch.
These ports pins may be multiplexed with an alternate function
WRITE “55H” TO PORT RA DIRECTION REGISTER
for the peripheral features on the device. In general, when initial
reset state, all ports are used as a general purpose input port.
0 1 0 1 0 1 0 1
All pins have data direction registers which can set these ports as C0H RA DATA 7 6 5 4 3 2 1 0 BIT
output or input. A “1” in the port direction register defines the C1H RA DIRECTION
corresponding port pin as output. Conversely, write “0” to the C2H RB DATA
corresponding bit to specify as an input pin. For example, to use I O I O I O I O
the even numbered bit of RA as output ports and the odd num- C3H RB DIRECTION
7 6 5 4 3 2 1 0 PORT
bered bits as input ports, write “55H” to address C1H (RA direc-
tion register) during initial setting as shown in Figure 9-1 . I: INPUT PORT
O: OUTPUT PORT
Reading data register reads the status of the pins whereas writing
Figure 9-1 Example of port I/O assignment
RA RA7 RA6 RA5 RA4 RA3 RA2 RA1 RA0 PORT RAFUNC.7~0 Description
et4U.com DataSheet4U.com DataShee
0 RA7 (Normal I/O Port)
INPUT / OUTPUT DATA RA7/AN7
1 AN7 (ADS2~0=111)
ADDRESS : C1H
RA Direction Register RESET VALUE : 0000_0000 0 RA6 (Normal I/O Port)
RA6/AN6
RAIO 1 AN6 (ADS2~0=110)
0 RA5 (Normal I/O Port)
RA5/AN5
DIRECTION SELECT
1 AN5 (ADS2~0=101)
0 : INPUT PORT
1 : OUTPUT PORT
0 RA4 (Normal I/O Port)
RA4/AN4
RA Function Selection Register 1 AN4 (ADS2~0=100)
ADDRESS : CAH
RAFUNC RESET VALUE : 0000_0000 0 RA3 (Normal I/O Port)
RA3/AN3
ANSEL7 ANSEL6 ANSEL5 ANSEL4 ANSEL3 ANSEL2 ANSEL1 ANSEL0 1 AN3 (ADS2~0=011)
0 : RA4 0 : RB0 0 RA2 (Normal I/O Port)
1 : AN4 1 : AN0 RA2/AN2
0 : RA5 0 : RA1 1 AN2 (ADS2~0=010)
1 : AN5 1 : AN1
0 : RA6 0 : RA2 0 RA1 (Normal I/O Port)
1 : AN6 1 : AN2 RA1/AN1
0 : RA7 0 : RA3 1 AN1 (ADS2~0=001)
1 : AN7 1 : AN3
RA0 (Normal I/O Port)
RA0/EC01
EC0 (T0CK2~0=111)
1. This port is not an Analog Input port, but Event Counter clock
Figure 9-2 Registers of Port RA source input port. ECO is controlled by setting TOCK2~0 =
111. The bit RAFUNC.0 (ANSEL0) controls the RB0/AN0/AVref
port (Refer to Port RB).
DataSheet4U.com
36 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0 - - - - PUP3 PUP2 PUP1 PUP0
Regardless of the direction register RBIO, RBFUNC is selected ing alternate features.
to use as alternate functions, port pin can be used as a correspond-
DataSheet4U.com
SEP. 2004 Ver 1.03 37
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
DataSheet4U.com
38 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
SIOM
PORT Function Description
SRDY SM [1:0] SCK [1:0]
DataSheet4U.com
SEP. 2004 Ver 1.03 39
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
RD7 RD6 RD5 RD4 RD3 RD2 RD1 RD0 - - - - PUP3 PUP2 PUP1 PUP0
INT3I INT2I
0 : RD1
1 : INT3
In addition, Port RD is multiplexed with external interrupt input Regardless of the direction register RDIO, RDFUNC is selected
function. The control register RDFUNC (address CDH) controls to use as external interrupt input function, port pin can be used as
to select alternate function. After reset, this value is “0”, port may a interrupt input feature.
be used as general I/O ports. To select alternate function, write
“1” to the corresponding bit of RDFUNC.
DataSheet4U.com
40 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
PRESCALER
STOP
WAKEUP
Peripheral clock
Xout External
C1 Xin
Clock
Source
C2
Vss
Xin
Vss
Figure 10-3 External Clock Connections
DataSheet4U.com
SEP. 2004 Ver 1.03 41
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
The user needs to take into account variation due to tolerance of The oscillator frequency, divided by 4, is output from the Xout
external R and C components used. pin, and can be used for test purpose or to synchronize other logic.
Figure 10-4 shows how the RC combination is connected to the To set the RC oscillation, it should be programmed RC_osc bit of
HMS87C1X04B/08B/16B. the configuration memory (CONFIG : 707Fh) to "1". ( Refer to
Section "21.3". )
Vdd
In addition to external crystal/resonator and external RC/R oscil-
REXT XIN lation, the HMS81C1X04B/08B/16B provides the internal 4MHz
oscillation. The internal 4MHz oscillation needs no external
parts.
CEXT Cint ≈ 6pF
Figure 10-6 shows the pin connections in case of using the inter-
nal 4MHz oscillation as the system clock.
fXIN÷4 XOUT
VDD
XIN
DataSheet4U.com
42 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
RCWDT
BTS[2:0]
÷8 3 BTCL To Watchdog Timer
÷ 16
÷ 32 Clear
fxin
÷ 64 8
0
MUX
÷ 128 Basic Interval Timer
÷ 256 BITR (8BIT) BITIF
Interrupt
et4U.com ÷ 512 1 DataSheet4U.com DataShee
÷ 1024
Internal RC OSC
DataSheet4U.com
SEP. 2004 Ver 1.03 43
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
DataSheet4U.com
44 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
ADDRESS : D0H
TM0 - - CAP0 T0CK2 T0CK1 T0CK0 T0CN T0ST RESET VALUE : --00_0000
et4U.com - - 0 X DataSheet4U.com
X X X X DataShee
ADDRESS : D2H
TM1 POL 16BIT PWME CAP1 T1CK1 T1CK0 T1CN T1ST RESET VALUE : 0000_0000
X 0 0 0 X X X X
These timers have each 8-bit count register and data register. The count register is increased by every internal or external clock in-
DataSheet4U.com
SEP. 2004 Ver 1.03 45
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
put. The internal clock has a prescaler divide ratio option of 2, 4, dress, when reading it as a Tx, written to TDRx.
8, 32,128, 512, 2048 (selected by control bits T0CK2, T0CK1
In counter function, the counter is increased every 0-to 1 (rising
and T0CK0 of register TM0) and 1, 2, 8 (selected by control bits
edge) transition of EC0 pin. In order to use counter function, the
T1CK1 and T1CK0 of register TM1). In the Timer 0, timer reg-
bit RA0 of the RA Direction Register RAIO is set to “0”. The
ister T0 increases from 00H until it matches TDR0 and then reset
Timer 0 can be used as a counter by pin EC0 input, but Timer 1
to 00H. The match output of Timer 0 generates Timer 0 interrupt
can not.
(latched in T0F bit). As TDRx and Tx register are in same ad-
TDR1
n
n-1
PCP
~~
~~
9
t
un
8
o
-c
7
up
~~
6
5
4
3
2
1
0
TIME
Interrupt period
= PCP x (n+1)
Timer 1 (T1IF)
Interrupt
Occur interrupt Occur interrupt Occur interrupt
TDR1
disable enable
stop
t
un
o
-c
up
~~
TIME
Timer 1 (T1IF)
Interrupt
Occur interrupt Occur interrupt
T1ST
Start & Stop
T1ST = 0 T1ST = 1
T1CN
Control count
T1CN = 0 T1CN = 1
DataSheet4U.com
46 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
TDR0, TDR1 and then resets to 0000H. The match output gener- In 16-bit mode, the bits T1CK1,T1CK0 and 16BIT of TM1
ates Timer 0 interrupt not Timer 1 interrupt. should be set to “1” respectively.
The clock source of the Timer 0 is selected either internal or ex-
ternal clock by bit T0CK2, T0CK1 and T0SL0.
ADDRESS : D0H
TM0 - - CAP0 T0CK2 T0CK1 T0CK0 T0CN T0ST RESET VALUE : --00_0000
- - 0 X X X X X
ADDRESS : D2H
TM1 POL 16BIT PWME CAP1 T1CK1 T1CK0 T1CN T1ST RESET VALUE : 0000_0000
X 1 0 0 1 1 X X
1
EC0 MUX T1 (8-bit) T0 (8-bit)
÷2 CLEAR
÷4
÷8
TIMER 0
fxin ÷ 32 T0CN T0IF
INTERRUPT
÷ 128 COMPARATOR
÷ 512
F/F
÷ 2048 TDR1 (8-bit) TDR0 (8-bit)
et4U.com DataSheet4U.com DataShee
COMP0 PIN
DataSheet4U.com
SEP. 2004 Ver 1.03 47
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
the number of timer overflow occurrence. tion at INTx pin generate an interrupt.
Timer/Counter still does the above, but with the added feature
that a edge transition at external input INTx pin causes the current Note: The CDRx, TDRx and Tx are in same address. In
value in the Timer x register (T0,T1), to be captured into registers the capture mode, reading operation read the CDRx, not Tx
CDRx (CDR0, CDR1), respectively. After captured, Timer x reg- because the reading path is opened to the CDRx, and
ister is cleared and restarts by hardware. TDRx is read while writing operation executed.
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 transi-
ADDRESS : D0H
TM0 - - CAP0 T0CK2 T0CK1 T0CK0 T0CN T0ST RESET VALUE : --00_0000
- - 1 X X X X X
ADDRESS : D2H
TM1 POL 16BIT PWME CAP1 T1CK1 T1CK0 T1CN T1ST RESET VALUE : 0000_0000
X 0 0 1 X X X X
T0CK[2:0] T0ST
Edge Detector 0 : Stop
1 : Clear and Start
1
CLEAR
EC0 MUX T0 (8-bit)
÷2
÷4
TIMER 0
÷8 T0IF
INTERRUPT
fxin ÷ 32 T0CN COMPARATOR
et4U.com ÷ 128 DataSheet4U.com DataShee
÷ 512 CAPTURE CDR0 (8-bit) TDR0 (8-bit)
÷ 2048
INT0IF INT 0
INTERRUPT
INT0 T0ST
0 : Stop
IEDS[1:0] 1 : Clear and Start
÷1 1
CLEAR
MUX
÷2 T1 (8-bit)
÷8
T1IF TIMER 1
INTERRUPT
T1CN COMPARATOR
T1CK[1:0]
CAPTURE
INT1IF INT 1
INTERRUPT
INT1
DataSheet4U.com
48 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
~~
~~
9
t
un
8
co
7
-
up
6
5
4
3
~~
2
1
0
TIME
Interrupt Request
(INT0F)
Interrupt Interval Period
Interrupt Request
et4U.com DataSheet4U.com DataShee
(INT0F)
Delay
Interrupt Request
(INT0F)
Interrupt Interval Period = FFH + 01H + FFH +01H + 13H = 213H
Interrupt Request
(T0F)
FFH FFH
T0
13H
00H 00H
DataSheet4U.com
SEP. 2004 Ver 1.03 49
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
ADDRESS : D0H
TM0 - - CAP0 T0CK2 T0CK1 T0CK0 T0CN T0ST RESET VALUE : --00_0000
- - 1 X X X X X
ADDRESS : D2H
TM1 POL 16BIT PWME CAP1 T1CK1 T1CK0 T1CN T1ST RESET VALUE : 0000_0000
X 1 0 X 1 1 X X
X: The value “0” or “1” corresponding your operation.
T0CK[2:0] T0ST
Edge Detector 0 : Stop
1 : Clear and Start
1
CLEAR
EC0 MUX T0 + T1 (16-bit)
÷2
÷4
T0CN TIMER 0
÷8 T0IF
INTERRUPT
fxin ÷ 32
COMPARATOR
÷ 128
÷ 512 CAPTURE CDR1 CDR0 TDR1 TDR0
÷ 2048 (8-bit) (8-bit) (8-bit) (8-bit)
IEDS[1:0]
DataSheet4U.com
50 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
If it needed more higher frequency of PWM, it should be reduced it can be maintained the duty value at present output when
resolution. 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.
Frequency
Resolution T1CK[1:0] = T1CK[1:0] = T1CK[1:0] =
Note: If changing the Timer1 to PWM function, the
00(125nS) 01(250nS) 10(1uS)
timer should be stop and set to PWM mode (PWME
10-bit 7.8KHz 3.9KHz 0.98KHZ = 1) firstly, and then set period and duty register val-
ue. When user writes register values while timer is in
9-bit 15.6KHz 7.8KHz 1.95KHz
operation, these register could be set with certain val-
8-bit 31.2KHz 15.6KHz 3.90KHz ues. If user sets the T1PPR, T1PDR register value
7-bit 62.5KHz 31.2KHz 7.81KHz with PWM mode being disabled, the T1PPR and
T1PDR can not be accessed because these registers
Table 12-1 PWM Frequency vs. Resolution at 8MHz act as TDR1 and T1/CDR1 register in non-PWM
mode.
Ex) LDM TM1,#0010_0000b
The bit POL of TM1 decides the polarity of duty cycle.
LDM T1PPR,#0EH
If the duty value is set same to the period value, the PWM output LDM T1PDR,#05H
is determined by the bit POL (1: High, 0: Low). And if the duty LDM PWM0HR,#00H
value is set to “00H”, the PWM output is determined by the bit LDM RBFUNC,#0001_1100B
POL (1: Low, 0: High). LDM TM1,#1010_1011B
It can be changed duty value when the PWM output. However the
changed duty value is output after the current period is over and
ADDRESS : D2H
TM1 POL 16BIT PWME CAP1 T1CK1 T1CK0 T1CN T1ST RESET VALUE : 0000_0000
et4U.com DataSheet4U.com DataShee
X 0 1 0 X X X X
ADDRESS : D5H
PWM0HR - - - - PWM0HR3 PWM0HR2 PWM0HR1 PWM0HR0 RESET VALUE : ----_0000
Bit Manipulation Not Available
- - - - X X X X
T1ST T1PPR(8-bit)
T0 clock source 0 : Stop
COMPARATOR
1 : Clear and Start
S Q RB4/
PWM0
CLEAR
1 R
MUX T1 (8-bit)
÷1 PWM0O
[RBFUNC.4]
fxin ÷2
÷8 COMPARATOR POL
T1CN
T1CK[1:0]
Slave T1PDR(8-bit)
PWM0HR[1:0]
Master T1PDR(8-bit)
DataSheet4U.com
SEP. 2004 Ver 1.03 51
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
~
~
~
~
fxin
~ ~
~
~
~ ~
T1 00 01 02 03 04 05 7F 80 81 3FF 00 01 02 03
~
~ ~
PWM
~
POL=1
~
~
~
~
PWM
POL=0
~
~
Duty Cycle [80H x 125nS = 16uS]
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
Period Cycle [0EH x 1uS = 14uS, 71KHz] Period Cycle [0AH x 1uS = 10uS, 100KHz]
Figure 12-12 Example of Changing the Period in Absolute Duty Cycle (@8MHz)
DataSheet4U.com
52 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
ADDRESS : E0H
SIOM POL SRDY SM1 SM0 SCK1 SCK0 SIOST SIOSF RESET VALUE : 0000_0001
POL Serial Clock Polarity Selection bit. SCK[1:0] Serial Clock Selection bits
0 : Data Transmission at falling edge 00 : fxin ÷ 4
(Received data latch at rising edge) 01 : fxin ÷ 16
1 : Data Transmission at rising edge 10 : TMR2OV (Overflow of Timer 2)
(Received data latch at falling edge) 11 : External Clock
SRDY Serial Ready Enable bit SIOST Serial Transmit Start bit
0 : Disable (RC3) 0 : Disable
1 : Enable (SRDYIN / SRDYOUT) 1 : Start (After one SCK, becomes “0”)
SM[1:0] Serial Operation Mode Selection bits SIOSF Serial Transmit Status bit
00 : Normal Port (RC4, RC5, RC6) 0 : During Transmission
01 : Transmit Mode (SCK, RC5, SOUT) 1 : Finished
10 : Receive Mode (SCK, SIN, RC6)
11 : Transmit & Receive Mode (SCK, SIN, SOUT)
ADDRESS : E1H
SIOR RESET VALUE : Undefined
SIN SIOR
SM1
POL
00 fxin ÷4
01 fxin ÷ 16
SCK Polarity
10 TMR2OV
11 External Clock
SCK1
SCK0
2
SCK[1:0]
SM1
SM0
SRDY
R SIOST
SRDY Q
S From Control Circuit
To Control Circuit
DataSheet4U.com
SEP. 2004 Ver 1.03 53
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
The SPI allows 8-bits of data to be synchronously transmitted and The serial data transfer operation mode is decided by setting the
received. To accomplish communication, typically three pins are SM1 and SM0 of SPI Mode Control Register, and the transfer
used: clock rate is decided by setting the SCK1 and SCK0 of SPI Mode
Control Register as shown in Figure 13-1 . And the polarity of
- Serial Data In RC5/SIN
transfer clock is selected by setting the POL.
- Serial Data Out RC6/SOUT
- Serial Clock RC4/SCK The bit SRDY is used for master / slave selection. If this bit is set
to “1” and SCK[1:0] is set to “11”, the controller is performed to
In addition to those pins, a fourth pin may be used when in a mas-
slave controller. As it were, the port RC3 is served for SRDY-
ter or a slave mode of operation:
OUT.
- Serial Transfer Ready RC3/SRDYIN/SRDYOUT
SIOST
SCK
(POL=1)
SCK
(POL=0)
SOUT D0 D1 D2 D3 D4 D5 D6 D7
SIN D0 D1 D2 D3 D4 D5 D6 D7
SPIF
(SPI Int. Req)
SRDY
SIOST
SCK
(POL=1)
SCK
(POL=0)
SOUT D0 D1 D2 D3 D4 D5 D6 D7
SIN D0 D1 D2 D3 D4 D5 D6 D7
SPIF
(SPI Int. Req)
DataSheet4U.com
54 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
ADDRESS : DEH
BUR BUCK1 BUCK0 BUR5 BUR4 BUR3 BUR2 BUR1 BUR0 RESET VALUE : 1111_1111
Bit Manipulation Not Available
Input clock selection Buzzer Period Data
00 : fxin ÷ 8
01 : fxin ÷ 16
10 : fxin ÷ 32
11 : fxin ÷ 64
÷8
÷ 16
fxin MUX COUNTER (6-bit)
et4U.com ÷ 32 DataSheet4U.com DataShee
÷ 64
F/F
COMPARATOR
BUCK[1:0]
RB1/BUZ PIN
BUZO
BUR (6-bit) [RBFUNC.1]
DataSheet4U.com
SEP. 2004 Ver 1.03 55
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
ADS[2:0]
111
RA7/AN7
ANSEL7
110
RA6/AN6
A/D Result Register
et4U.com ANSEL6 DataSheet4U.com DataShee
101 ADDRESS : EBH
RA5/AN5 ADCR(8-bit)
RESET VALUE : Undefined
ANSEL5
100
RA4/AN4 Sample & Hold
ANSEL2 Resistor
001 Ladder
RA1/AN1 Circuit
ANSEL1
000
RB0/AN0/AVref
ANSEL0 (RAFUNC.0)
VDD Pin 0
ADEN
AVREFS (RBFUNC.0)
DataSheet4U.com
56 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
Reserved
A/D Status bit
Analog Channel Select
0 : A/D Conversion is in process
000 : Channel 0 (RB0/AN0) 1 : A/D Conversion is completed
001 : Channel 1 (RA1/AN1)
A/D Start bit
010 : Channel 2 (RA2/AN2) 1 : A/D Conversion is started
011 : Channel 3 (RA3/AN3) After 1 cycle, cleared to “0”
100 : Channel 4 (RA4/AN4) 0 : Bit force to zero
101 : Channel 5 (RA5/AN5)
110 : Channel 6 (RA6/AN6)
111 : Channel 7 (RA7/AN7)
NOP
Analog
Input AN0~AN7
100~1000pF
ADSF = 1
NO
YES
READ ADCR
Figure 15-4 Analog Input Pin Connecting Capacitor
DataSheet4U.com
SEP. 2004 Ver 1.03 57
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
port (PORT RA and RB0) pins. When A/D conversion is per- (4) AVref pin input impedance
formed with any of pins AN0 to AN7 selected, be sure not to ex-
A series resistor string of approximately 10KΩ is connected be-
ecute a PORT input instruction while conversion is in progress,
tween the AVref pin and the VSS pin.
as this may reduce the conversion resolution.
Therefore, if the output impedance of the reference voltage
Also, if digital pulses are applied to a pin adjacent to the pin in the
source is high, this will result in parallel connection to the series
process of A/D conversion, the expected A/D conversion value
resistor string between the AVref pin and the VSS pin, and there
may not be obtainable due to coupling noise. Therefore, avoid ap-
will be a large reference voltage error.
plying pulses to pins adjacent to the pin undergoing A/D conver-
sion.
DataSheet4U.com
58 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
16. INTERRUPTS
The HMS87C1X04B/08B/16B interrupt circuits consist of Inter- the hardware when the service routine is vectored to only if the
rupt enable register (IENH, IENL), Interrupt request flags of interrupt was transition-activated.
IRQH, IRQL, Interrupt Edge Selection Register (IEDS), priority
The Timer 0, Timer 1, Timer 2 and Timer 3 Interrupts are gener-
circuit and Master enable flag(“I” flag of PSW). The configura-
ated by T0IF, T1IF, T2IF and T3IF, which are set by a match in
tion of interrupt circuit is shown in Figure 16-1 and Interrupt pri-
their respective timer/counter register. The AD converter Inter-
ority is shown in Table 16-1 .
rupt is generated by ADIF which is set by finishing the analog to
The External Interrupts INT0, INT1, INT2 and INT3 can each be digital conversion. The Watch dog timer Interrupt is generated by
transition-activated (1-to-0, 0-to-1 and both transition). WDTIF which set by a match in Watch dog timer register (when
the bit WDTON is set to “0”). The Basic Interval Timer Interrupt
The flags that actually generate these interrupts are bit INT0IF,
is generated by BITIF which is set by a overflowing of the Basic
INT1IF, INT2IF and INT3IF in Register IRQH. When an exter-
Interval Timer Register(BITR).
nal interrupt is generated, the flag that generated it is cleared by
7
External Int. 0 INT0IF
IEDS
External Int. 1 6
INT1IF
Timer 0 T0IF 5
et4U.com DataSheet4U.com Release STOP DataShee
Timer 1 4
T1IF
3
External Int. 2 INT2IF
IEDS
Priority Control
Timer 2 T2IF 1
I Flag
Timer 3 0
T3IF Interrupt Master
Enable Flag
ADIF 7 Interrupt
A/D Converter
Vector
WDT 6 Address
WDTIF
Generator
BIT 5
BITIF
SPI 5
SPIF
DataSheet4U.com
SEP. 2004 Ver 1.03 59
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
When an interrupt is occurred, the I-flag is cleared and disable The interrupt request flag bit(s) must be cleared by software be-
any further interrupt, the return address and PSW are pushed into fore re-enabling interrupts to avoid recursive interrupts. The In-
the stack and the PC is vectored to. Once in the interrupt service terrupt Request flags are able to be read and written.
routine the source(s) of the interrupt can be determined by polling
the interrupt request flag bits.
DataSheet4U.com
60 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
System clock
Instruction Fetch
Data Bus Not used PCH PCL PSW V.L. ADL ADH OP code
Internal Write
Figure 16-3 Timing chart of Interrupt Acceptance and Interrupt Return Instruction
DataSheet4U.com
SEP. 2004 Ver 1.03 61
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
DataSheet4U.com
62 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
DataSheet4U.com
SEP. 2004 Ver 1.03 63
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
IEDS
[0E6H]
et4U.com DataSheet4U.com DataShee
Figure 16-6 External Interrupt Block Diagram
:
:
;**** Set port as an input port RB2,RD0
Ext. Interrupt Edge Selection ADDRESS : 0E6H LDM RBIO,#1111_1011B
Register RESET VALUE : 0000_0000 LDM RDIO,#1111_1110B
W W W W W W W W ;
IESR ;**** Set port as an interrupt port
LDM RBFUNC,#04H
LDM RDFUNC,#01H
;
INT2 edge select INT0 edge select ;**** Set Falling-edge Detection
00 : Int. disable 00 : Int. disable LDM IEDS,#0001_0001B
01 : falling 01 : falling :
10 : rising 10 : rising :
11 : both 11 : both :
INT3 edge select INT1 edge select
00 : Int. disable 00 : Int. disable Response Time
01 : falling 01 : falling
10 : rising The INT0, INT1,INT2 and INT3 edge are latched into INT0IF,
10 : rising
11 : both 11 : both INT1IF, INT2IF and INT3IF at every machine cycle. The values
are not actually polled by the circuitry until the next machine cy-
cle. If a request is active and conditions are right for it to be ac-
knowledged, 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 ma-
chine cycles elapse between activation of an external interrupt re-
quest and the beginning of execution of the first instruction of the
service routine.
DataSheet4U.com
64 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
et4U.com DataSheet4U.com e
DataShe
DataSheet4U.com
SEP. 2004 Ver 1.03 65
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
et4U.com DataSheet4U.com e
Clock Control Register
DataShe
ADDRESS : ECH
CKCTLR - WAKEUP RCWDT WDTON BTCL BTS2 BTS1 BTS0 RESET VALUE : -001_0111
Bit Manipulation Not Available
- 0 X 1 X X X X
Watchdog Timer Register
ADDRESS : EDH
WDTR WDTCL 7-bit Watchdog Counter Register RESET VALUE : 0111_1111
Bit Manipulation Not Available
RCWDT
BTS[2:0]
÷8 3
WDTR (8-bit)
÷ 512 1 0
÷ 1024 Overflow Detection
Watchdog Timer
Interrupt Request
BITIF Basic Interval Timer
Internal RC OSC
Interrupt
DataSheet4U.com
66 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
DataSheet4U.com
SEP. 2004 Ver 1.03 67
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
Next
INSTRUCTION
et4U.com DataSheet4U.com
Figure 18-1 STOP Releasing Flow by Interrupts e
DataShe
~
~
Oscillator
(XIN pin)
~
~
~ ~
~ ~
Internal
Clock
~
~
External
~
~
Interrupt
~
~
BIT
N-2 N-1 N N+1 N+2 00 01 FE FF 00 00
Counter
~
~
DataSheet4U.com
68 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
STOP Mode
~
~
Oscillator
(XIN pin)
~
~
~ ~
~ ~
Internal
Clock
~ ~
~
~
~
~
RESET
Internal
~
~
RESET
~
~
STOP Instruction Execution
Stabilizing Time
Time can not be control by software tST = 64mS @4MHz
DataSheet4U.com
SEP. 2004 Ver 1.03 69
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
~
~
Oscillator
(XIN pin)
~
~
~
~
Internal
RC Clock
~
~
Internal
Clock
~
~
External
~
~
Interrupt
~
~
(or WDT Interrupt)
STOP Instruction Execution Clear Basic Interval Timer
~
~
BIT
N-2 N-1 N N+1 N+2 00 01 FE FF 00 00
Counter
~
~
Normal Operation STOP Mode Stabilizing Time Normal Operation
tST > 20mS
Figure 18-4 STOP Mode Releasing by External Interrupt or WDT Interrupt(using RCWDT)
et4U.com DataSheet4U.com e
DataShe
STOP Mode
~
~
Oscillator
(XIN pin)
~
~
~
~
Internal
RC Clock
~
~
Internal
Clock
~
~
RESET
~
~
~
~
RESET by WDT
Internal
~
~
RESET
~
~
DataSheet4U.com
70 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
Oscillator
(XIN pin)
~ ~
~ ~
CPU
Clock
STOP Instruction
Execution
Interrupt
~
~
Request
Normal Operation Wake-up Timer Mode Normal Operation
(stop the CPU clock) Do not need Stabilizing Time
et4U.com DataSheet4U.com e
DataShe
Figure 18-6 Wake-up Timer Mode Releasing by External Interrupt or Timer0(Timer2) Interrupt
DataSheet4U.com
SEP. 2004 Ver 1.03 71
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
VDD
INPUT PIN
INPUT PIN VDD VDD
internal
pull-up i=0
O
VDD
OPEN
O i
i
Very weak current flows
VDD
X
GND
i=0
X
GND
et4U.com
O DataSheet4U.comOFF ON i=0 e
OFF i i
DataShe
GND VDD GND GND
ON
X X O
OFF
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.
DataSheet4U.com
72 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
19. RESET
The reset input is the RESET pin, which is the input to a Schmitt Internal RAM is not affected by reset. When VDD is turned on,
Trigger. A reset is accomplished by holding the RESET pin low the RAM content is indeterminate. Therefore, this RAM should
for at least 8 oscillator periods, while the oscillator running. After be initialized before reading or testing it.
reset, 64ms (at 4 MHz) add with 7 oscillator periods are required
Initial state of each register is shown as Table 8-1 .
to start execution as shown in Figure 19-1 .
1 2 3 4 5 6 7
~
~
Oscillator
(XIN pin)
RESET ~
~
~
~
DATA
? ? ? ? FE ADL ADH OP
BUS
~
~
MAIN PROGRAM
RESET Process Step
Stabilizing Time
tST = 64mS at 4MHz
VDD
RESET
Stabilizing Time
INTERNAL
RESET Basic Interval Timer Start
DataSheet4U.com
SEP. 2004 Ver 1.03 73
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
Figure 19-3 EXTERNAL POWERON RESET CIRCUIT (FOR SLOW VDD POWER-UP)
• Address Fail Reset would be malfunction state. If the CPU fetch the instruction from
beyond area not in main user area address C000H~FFFFH, in that
The Address Fail Reset is the function to reset the system by
case the address fail reset is occurred.
checking abnormal address or unwished address cauased by ex-
ternal noise, which couldn’t be returned to normal operation and
External RESET
WDT RESET
et4U.com DataSheet4U.com e
WDT RESETen DataShe
PFD RESET
PFD RESETen
Execution
~
~
Internal RESET
~
~
DataSheet4U.com
74 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
Reserved
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 : PFD operation enable
1 : PFD operation disable
RESET VECTOR
YES
PFS =1
NO
RAM CLEAR
INITIALIZE RAM DATA Skip the
initial routine
FUNTION
EXECUTION
DataSheet4U.com
SEP. 2004 Ver 1.03 75
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
VDD
PFVDDMAX
PFVDDMIN
64mS
Internal
RESET
VDD PFVDDMAX
When PFDM = 1 PFVDDMIN
Internal 64mS
t < 64mS
RESET
VDD
PFVDDMAX
PFVDDMIN
64mS
Internal
RESET
VDD
PFVDDMAX
PFVDDMIN
System
Clock
When PFDM = 0
VDD PFVDDMAX
PFVDDMIN
et4U.com DataSheet4U.com e
System
DataShe
Clock
DataSheet4U.com
76 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
XIN OFP
1
XIN_NF
Mux 0
HF Noise CLK
HF Noise Canceller 0S
Internal Changer FINTERNAL
Observer OSC 1 S
en
INT_CLK
Xin_opt
LF Noise
Observer CLK_CHG
ONPb ONPb
en
LF_on IN_CLK
en
et4U.com DataSheet4U.com o/f e
OFP DataShe
PS10 CK
ONPb = 0
(8-Bit counter)
LF_on = 1
IN_CLK = 0
INT_CLK 8 periods PS10(INT_CLK/512) 256 periods
High Frq. Noise (250ns × 8 =2us) (250ns × 512 × 256 =33 ms)
~
~
XIN
~
~
Oscillation Fail
XIN_NF
~
~
INT_CLK reset
~
~
~
~
~
~
INT_CLK
~
~ ~
~
OFP_EN
CHG_END
~
~ ~
~
CLK_CHG
Clock Change Start(XIN to INT_CLK) Clock Change End(INT_CLK to XIN))
fINTERNAL
~
~
~
Figure 21-1 Block Diagram of ONP & OFP and Respective Wave Forms
DataSheet4U.com
SEP. 2004 Ver 1.03 77
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
ADDRESS
CONFIG AFR1 AFR0 ONPb IN_CLK LF_on Xin_opt Lock RC_osc 707FH
et4U.com DataSheet4U.com
Figure 21-2 Device Configuration Area e
DataShe
0 Use the Inter 4MHz clock as the Device Osc Disable Using the internal 4MHz clock
IN_CLK
1 Use the Inter 4MHz clock as the Device Osc Enable without external clock
0 ONP Low Pass Filter (clock changer) Disable Change the Inter clock when
CONFIG LF_on
1 ONP Low Pass Filter (clock changer) Enable oscillation failed
DataSheet4U.com
78 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
40ns noise canceller + change the clock source from external to internal
0 0 1 0 4MHz clock when oscillation failure occured.
80ns noise canceller + change the clock source from external to internal
0 0 1 1 4MHz clock when oscillation failure occured
1 X X X ONP disable
et4U.com DataSheet4U.com e
DataShe
DataSheet4U.com
SEP. 2004 Ver 1.03 79
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
Pin Description
Mode Remarks
EPROM
A_D7~A_D0 CTL0 CTL1 CTL2 VPP VDD
Enable
High Addr.
0 0 0 H 11.5V 5.0V
(A15~A8)
Low Addr.
Write 0 0 1 H 11.5V 5.0V
(A7~A0)
Program
Data In
0 1 1 H 11.5V 5.0V
(D7~D0)
Data Out
Verify 0 1 0 H 11.5V 5.0V
(D7~D0)
High Addr.
0 0 0 H 11.5V 5.0V
(A15~A8)
Low Addr.
Read 0 0 1 H 11.5V 5.0V
(A7~A0)
Data Out
0 1 0 H 11.5V 5.0V
(D7~D0)
et4U.com DataSheet4U.com e
DataShe
Table 22-1 Description of EPROM mode
A_D4 1 28 A_D3
A_D5 2 27 A_D2
A_D6 3 26 A_D1
A_D7 4 25 A_D0
VDD 5 24
CTL0 6 23
CTL1 7 22 VSS
CTL2 8 21 VPP
9 20 NC
10 19 EPROM Enable
11 18
12 17
13 16
14 15
DataSheet4U.com
80 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
DataSheet4U.com
SEP. 2004 Ver 1.03 81
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
EPROM
~
~
~
~
Enable
TVPPS VIHP
~
~
~
~
VPP TVPPR
TVDDS
CTL0 0V
~
~ ~
~ ~
~
VDD1H
~
0V TCD1 TCD1
CTL1
VDD1H
TCD1
~
~
~
~
TCD1
CTL2 0V
~
~
~
~
A_D7~ DATA DATA
HA LA DATA IN LA DATA IN
A_D0 OUT OUT
~
~
~
~
VDD1H
VDD
High 8bit Low 8bit Write Mode Verify Low 8bit Write Mode Verify
Address Address Address
Input Input Input
et4U.com DataSheet4U.com e
After input a high address, DataShe
output data following low address input Another high address step
EPROM
Enable
TVPPS VIHP
CTL0 0V
VDD2H
0V TCD2 TCD2
CTL1
VDD2H
TCD1
TCD1
CTL2 0V
A_D7~
HA LA DATA LA DATA HA LA DATA
A_D0
VDD2H
VDD
High 8bit Low 8bit DATA Low 8bit DATA High 8bit Low 8bit DATA
Address Address Output Address Output Address Address Output
Input Input Input Input Input
DataSheet4U.com
82 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
DataSheet4U.com
SEP. 2004 Ver 1.03 83
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
START
Set VDD=5.0VDD1H
Set VPP=11.5VIHP
NO
Verify blank
YES
First Address Location
Report
Next address location Programming failure
NO
N=1
YES
N≤5
EPROM Write
50uS program time
et4U.com DataSheet4U.com e
N=N+1 DataShe
NO
Verify pass
YES
NO
Last address
YES
EPROM Write
50uS program time
READ @VDD=3.0V
NO
READ pass
YES
END
DataSheet4U.com
84 SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
START
Set VPP=VIHP
NO
Last address
YES
Report Read OK
VDD=0V
VPP=0V
et4U.com DataSheet4U.com e
END DataShe
DataSheet4U.com
SEP. 2004 Ver 1.03 85
DataSheet 4 U .com
www.DataSheet4U.com
et4U.com DataSheet4U.com e
DataShe
DataSheet4U.com
DataSheet 4 U .com
www.DataSheet4U.com
APPENDIX
et4U.com DataSheet4U.com e
DataShe
DataSheet4U.com
DataSheet 4 U .com
www.DataSheet4U.com
et4U.com DataSheet4U.com e
DataShe
DataSheet4U.com
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
APPENDIX
A. INSTRUCTION MAP
LOW 00000 00001 00010 00011 00100 00101 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111
HIGH 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
SET1 BBS BBS ADC ADC ADC ADC ASL ASL TCALL SETA1 BIT POP PUSH
000 - BRK
dp.bit A.bit,rel dp.bit,rel #imm dp dp+X !abs A dp 0 .bit dp A A
SBC SBC SBC SBC ROL ROL TCALL CLRA1 COM POP PUSH BRA
001 CLRC
#imm dp dp+X !abs A dp 2 .bit dp X X rel
CMP CMP CMP CMP LSR LSR TCALL NOT1 TST POP PUSH PCALL
010 CLRG
#imm dp dp+X !abs A dp 4 M.bit dp Y Y Upage
OR OR OR OR ROR ROR TCALL OR1 CMPX POP PUSH
011 DI RET
#imm dp dp+X !abs A dp 6 OR1B dp PSW PSW
AND AND AND AND INC INC TCALL AND1 CMPY CBNE INC
100 CLRV TXSP
#imm dp dp+X !abs A dp 8 AND1B dp dp+X X
EOR EOR EOR EOR DEC DEC TCALL EOR1 DBNE XMA DEC
101 SETC TSPX
#imm dp dp+X !abs A dp 10 EOR1B dp dp+X X
LDA LDA LDA LDA LDY TCALL LDC LDX LDX
110 SETG TXA XCN DAS
#imm dp dp+X !abs dp 12 LDCB dp dp+Y
LDM STA STA STA STY TCALL STC STX STX
111 EI TAX XAX STOP
dp,#imm dp dp+X !abs dp 14 M.bit dp dp+Y
LOW 10000 10001 10010 10011 10100 10101 10110 10111 11000 11001 11010 11011 11100 11101 11110 11111
HIGH 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
BPL CLR1 BBC BBC ADC ADC ADC ADC ASL ASL TCALL JMP BIT ADDW LDX JMP
000
rel dp.bit A.bit,rel dp.bit,rel {X} !abs+Y [dp+X] [dp]+Y !abs dp+X 1 !abs !abs dp #imm [!abs]
et4U.com BVC SBC SBC DataSheet4U.com
SBC SBC ROL ROL TCALL CALL TEST SUBW LDY JMP e
001
rel {X} !abs+Y [dp+X] [dp]+Y !abs dp+X 3 !abs !abs dp #imm [dp] DataShe
BCC CMP CMP CMP CMP LSR LSR TCALL TCLR1 CMPW CMPX CALL
010 MUL
rel {X} !abs+Y [dp+X] [dp]+Y !abs dp+X 5 !abs dp #imm [dp]
BNE OR OR OR OR ROR ROR TCALL DBNE CMPX LDYA CMPY
011 RETI
rel {X} !abs+Y [dp+X] [dp]+Y !abs dp+X 7 Y !abs dp #imm
BMI AND AND AND AND INC INC TCALL CMPY INCW INC
100 DIV TAY
rel {X} !abs+Y [dp+X] [dp]+Y !abs dp+X 9 !abs dp Y
BVS EOR EOR EOR EOR DEC DEC TCALL XMA XMA DECW DEC
101 TYA
rel {X} !abs+Y [dp+X] [dp]+Y !abs dp+X 11 {X} dp dp Y
BCS LDA LDA LDA LDA LDY LDY TCALL LDA LDX STYA
110 XAY DAA
rel {X} !abs+Y [dp+X] [dp]+Y !abs dp+X 13 {X}+ !abs dp
BEQ STA STA STA STA STY STY TCALL STA STX CBNE
111 XYX NOP
rel {X} !abs+Y [dp+X] [dp]+Y !abs dp+X 15 {X}+ !abs dp
DataSheet4U.com
SEP. 2004 Ver 1.03 i
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
B. INSTRUCTION SET
1. ARITHMETIC/ LOGIC OPERATION
OP BYTE CYCLE FLAG
NO. MNEMONIC OPERATION
CODE NO NO NVGBHIZC
1 ADC #imm 04 2 2 Add with carry.
2 ADC dp 05 2 3 A←(A)+(M)+C
3 ADC dp + X 06 2 4
4 ADC !abs 07 3 4 NV--H-ZC
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 84 2 2 Logical AND
10 AND dp 85 2 3 A← (A)∧(M)
11 AND dp + X 86 2 4
12 AND !abs 87 3 4 N-----Z-
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 Arithmetic shift left
18 ASL dp 09 2 4 C 7 6 5 4 3 2 1 0 N-----ZC
19 ASL dp + X 19 2 5 “0”
20 ASL !abs 18 3 5
om
eet4U.c 21 CMP #imm 44 2 2D a t aCompare
S h e e taccumulator
4 U . c o m contents with memory contents e
DataSh
22 CMP dp 45 2 3 (A) -(M)
23 CMP dp + X 46 2 4
24 CMP !abs 47 3 4 N-----ZC
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 Compare X contents with memory contents
30 CMPX dp 6C 2 3 (X)-(M) N-----ZC
31 CMPX !abs 7C 3 4
32 CMPY #imm 7E 2 2 Compare Y contents with memory contents
33 CMPY dp 8C 2 3 (Y)-(M) N-----ZC
34 CMPY !abs 9C 3 4
35 COM dp 2C 2 4 1’S Complement : ( dp ) ← ~( dp ) N-----Z-
36 DAA DF 1 3 Decimal adjust for addition N-----ZC
37 DAS CF 1 3 Decimal adjust for subtraction N-----ZC
38 DEC A A8 1 2 Decrement N-----Z-
39 DEC dp A9 2 4 M← (M)-1
40 DEC dp + X B9 2 5 N-----Z-
41 DEC !abs B8 3 5
42 DEC X AF 1 2
43 DEC Y BE 1 2
44 DIV 9B 1 12 Divide : YA / X Q: A, R: Y NV--H-Z-
DataSheet4U.com
ii SEP. 2004 Ver 1.03
D a t a S h e e4t U . c o m
www.DataSheet4U.com
HMS87C1X04B/08B/16B
DataSheet4U.com
SEP. 2004 Ver 1.03 iii
D a t a S h e e4t U . c o m
www.DataSheet4U.com
HMS87C1X04B/08B/16B
DataSheet4U.com
iv SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
3. 16-BIT OPERATION
OP BYTE CYCLE FLAG
NO. MNEMONIC OPERATION NVGBHIZC
CODE NO NO
16-Bits add without carry
1 ADDW dp 1D 2 5 NV--H-ZC
YA ← ( YA ) + ( dp +1 ) ( dp )
Compare YA contents with memory pair contents :
2 CMPW dp 5D 2 4 N-----ZC
(YA) − (dp+1)(dp)
Decrement memory pair
3 DECW dp BD 2 6 N-----Z-
( dp+1)( dp) ← ( dp+1) ( dp) - 1
Increment memory pair
4 INCW dp 9D 2 6 N-----Z-
( dp+1) ( dp) ← ( dp+1) ( dp ) + 1
Load YA
5 LDYA dp 7D 2 5 N-----Z-
YA ← ( dp +1 ) ( dp )
Store YA
6 STYA dp DD 2 5 --------
( dp +1 ) ( dp ) ← YA
16-Bits substact without carry
7 SUBW dp 3D 2 5 NV--H-ZC
YA ← ( YA ) - ( dp +1) ( dp)
4. BIT MANIPULATION
OP BYTE CYCLE FLAG
NO. MNEMONIC OPERATION
CODE NO NO NVGBHIZC
1 AND1 M.bit 8B 3 4 Bit AND C-flag : C ← ( C ) ∧ ( M .bit ) -------C
2 AND1B M.bit 8B 3 4 Bit AND C-flag and NOT : C ← ( C ) ∧ ~( M .bit ) -------C
3 BIT dp 0C 2 4 Bit test A with memory : MM----Z-
4 BIT !abs 1C 3 5 Z ← ( A ) ∧ ( M ) , N ← ( M7 ) , V ← ( M 6 )
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” --------
et4U.com DataSheet4U.com e
7 CLRC 20 1 2 Clear C-flag : C ← “0” -------0 DataShe
8 CLRG 40 1 2 Clear G-flag : G ← “0” --0-----
9 CLRV 80 1 2 Clear V-flag : V ← “0” -0--0---
10 EOR1 M.bit AB 3 5 Bit exclusive-OR C-flag : C ← ( C ) ⊕ ( M .bit ) -------C
11 EOR1B M.bit AB 3 5 Bit exclusive-OR C-flag and NOT : C ← ( C ) ⊕ ~(M .bit) -------C
12 LDC M.bit CB 3 4 Load C-flag : C ← ( M .bit ) -------C
13 LDCB M.bit CB 3 4 Load C-flag with NOT : C ← ~( M .bit ) -------C
14 NOT1 M.bit 4B 3 5 Bit complement : ( M .bit ) ← ~( M .bit ) --------
15 OR1 M.bit 6B 3 5 Bit OR C-flag : C ← ( C ) ∨ ( M .bit ) -------C
16 OR1B M.bit 6B 3 5 Bit OR C-flag and NOT : C ← ( C ) ∨ ~( M .bit ) -------C
17 SET1 dp.bit x1 2 4 Set bit : ( M.bit ) ← “1” --------
18 SETA1 A.bit 0B 2 2 Set A bit : ( A.bit ) ← “1” --------
19 SETC A0 1 2 Set C-flag : C ← “1” -------1
20 SETG C0 1 2 Set G-flag : G ← “1” --1-----
21 STC M.bit EB 3 6 Store C-flag : ( M .bit ) ← C --------
Test and clear bits with A :
22 TCLR1 !abs 5C 3 6 N-----Z-
A - ( M ) , ( M ) ← ( M ) ∧ ~( A )
Test and set bits with A :
23 TSET1 !abs 3C 3 6 N-----Z-
A-(M), (M)← (M)∨(A)
DataSheet4U.com
SEP. 2004 Ver 1.03 v
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
11 2F 2 4 Branch always
BRA rel --------
pc ← ( pc ) + rel
DataSheet4U.com
vi SEP. 2004 Ver 1.03
DataSheet 4 U .com
www.DataSheet4U.com
HMS87C1X04B/08B/16B
et4U.com DataSheet4U.com
DataSheet4U.com
SEP. 2004 Ver 1.03 vii
DataSheet 4 U .com