ETC MC80F0504

ABOV SEMICONDUCTOR CO., LTD.
8-BIT SINGLE-CHIP MICROCONTROLLERS
MC80F0504/0604
User’s Manual (Ver. 1.46)
REVISION HISTORY
VERSION 1.46 (MAY.2008) This book
Change POR and Internal OSC characteristics on chapter ‘7.Electrical Characteristics’.
VERSION 1.45 (MAR.2008) This book
Add POR characteristic on chapter ‘7.Electrical Characteristics’.
VERSION 1.44 (FEB.2008)
Repalce ‘TBD’ with real data in ‘7.Electrical Characteristics’.
Amend the contents of ‘21.Device Configuration Area’ chapter.
VERSION 1.43 (DEC.2007)
Add 20 SSOP package info
VERSION 1.42 (NOV.2007)
Add ‘16 SOP( 153 mil)’ package info
VERSION 1.41 (APL.2007)
Add TVDD parameter specification and change TPOR in DC Electrical Characteristics.
Note for configuration option is added and fix some errata.
VERSION 1.4 (MAR.2007)
Add TVDD parameter specification and change TPOR in DC Electrical Characteristics.
Note for configuration option is added and fix some errata.
VERSION 1.3 (JUL.2006)
Version 1.46
Published by
FAE Team
©2006 ABOV semiconductor Ltd. All right reserved.
Additional information of this manual may be served by ABOV semiconductor offices in Korea or Distributors and Representatives.
ABOV 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, ABOV semiconductor is in no way responsible
for any violations of patents or other rights of the third party generated by the use of this manual.
MC80F0504/0604
1. OVERVIEW ...................................................................................................................................................... 1
Description ...................................................................................................................................................... 1
Features .......................................................................................................................................................... 1
Development Tools ......................................................................................................................................... 2
Ordering Information ................................................................................................................................. 3
2. BLOCK DIAGRAM .......................................................................................................................................... 4
3. PIN ASSIGNMENT .......................................................................................................................................... 5
4. PACKAGE DRAWING ..................................................................................................................................... 6
5. PIN FUNCTION .............................................................................................................................................. 10
6. PORT STRUCTURES .................................................................................................................................... 12
7. ELECTRICAL CHARACTERISTICS ............................................................................................................. 15
Absolute Maximum Ratings .......................................................................................................................... 15
Recommended Operating Conditions ........................................................................................................... 15
A/D Converter Characteristics ...................................................................................................................... 15
DC Electrical Characteristics ........................................................................................................................ 16
AC Characteristics ........................................................................................................................................ 17
Typical Characteristics .................................................................................................................................. 18
8. MEMORY ORGANIZATION .......................................................................................................................... 22
Registers ....................................................................................................................................................... 22
Program Memory .......................................................................................................................................... 25
Data Memory ................................................................................................................................................ 28
Addressing Mode .......................................................................................................................................... 33
9. I/O PORTS ..................................................................................................................................................... 37
R0 and R0IO register .................................................................................................................................... 37
R1 and R1IO register .................................................................................................................................... 38
R3 and R3IO register .................................................................................................................................... 40
10. CLOCK GENERATOR ................................................................................................................................ 41
Oscillation Circuit ......................................................................................................................................... 41
11. BASIC INTERVAL TIMER ........................................................................................................................... 43
12. WATCHDOG TIMER ................................................................................................................................... 45
13. TIMER/EVENT COUNTER .......................................................................................................................... 48
8-bit Timer / Counter Mode ........................................................................................................................... 50
16-bit Timer / Counter Mode ......................................................................................................................... 54
8-bit (16-bit) Compare Output ....................................................................................................................... 54
8-bit Capture Mode ....................................................................................................................................... 55
16-bit Capture Mode ..................................................................................................................................... 58
PWM Mode ................................................................................................................................................... 59
14. ANALOG TO DIGITAL CONVERTER ......................................................................................................... 62
15. BUZZER FUNCTION ................................................................................................................................... 65
16. INTERRUPTS .............................................................................................................................................. 67
Interrupt Sequence ....................................................................................................................................... 69
BRK Interrupt ................................................................................................................................................ 71
Multi Interrupt ................................................................................................................................................ 71
MAY.2008 Ver 1.46
MC80F0504/0604
External Interrupt .......................................................................................................................................... 73
17. POWER SAVING OPERATION .................................................................................................................. 75
Sleep Mode ................................................................................................................................................... 75
Stop Mode ..................................................................................................................................................... 76
Stop Mode at Internal RC-Oscillated Watchdog Timer Mode ....................................................................... 79
Minimizing Current Consumption .................................................................................................................. 81
18. RESET ......................................................................................................................................................... 83
19. POWER FAIL PROCESSOR ....................................................................................................................... 85
20. COUNTERMEASURE OF NOISE ............................................................................................................... 87
Oscillation Noise Protector ............................................................................................................................ 87
Oscillation Fail Processor ............................................................................................................................. 88
21. Device Configuration Area ........................................................................................................................ 89
22. Emulator EVA. Board Setting .................................................................................................................. 90
23. A. INSTRUCTION MAP .................................................................................................................................. i
24. B. INSTRUCTION SET .................................................................................................................................. ii
MAY.2008 Ver 1.46
MC80F0504/0604
MC80F0504/0604
CMOS SINGLE-CHIP 8-BIT MICROCONTROLLER
WITH 10-BIT A/D CONVERTER
1. OVERVIEW
1.1 Description
The MC80F0504/0604 is advanced CMOS 8-bit microcontroller with 4K bytes of FLASH. This is a powerful microcontroller which provides a highly flexible and cost effective solution to many embedded control applications. This provides the
following features : 4K bytes of FLASH (MTP), 256 bytes of RAM, 8/16-bit timer/counter, watchdog timer, on-chip POR,
10-bit A/D converter, buzzer driving port, 10-bit PWM output and on-chip oscillator and clock circuitry. It also has ONP,
noise filter, PFD for improving noise immunity. In addition, the MC80F0504/0604 supports power saving modes to reduce
power consumption.
This document explains the base MC80F0604, the other’s eliminated functions are same as below table.
Device Name
FLASH (ROM)
Size
RAM
4KB
256B
MC80F0604
MC80F0504
ADC
I/O PORT
Package
10 channel
18 port
20 PDIP, 20SOP, 20 SSOP
8 channel
14 port
16 PDIP, 16 SOP,
16 SOP(153 mil), 16 TSSOP
Note : The DAA, DAS decimal adjust instructions are not provided in these devices.
1.2 Features
• 4K Bytes On-chip FLASH (MTP)
- Endurance : 100 times
- Retention time : 10 years
• 256 Bytes On-chip Data RAM
(Included stack memory)
• Minimum Instruction Execution Time:
- 333ns at 12MHz (NOP instruction)
• Programmable I/O pins
(LED direct driving can be a source and sink)
- MC80F0604 : 18(17)
- MC80F0504 : 14(13)
• One 8-bit Basic Interval Timer
• Two 8-bit Timer/counters
(or one 16-bit Timer/counter)
• One Watchdog timer
• One 10-bit High Speed PWM Outputs
• 10-bit A/D converter
- MC80F0604 : 10 channels
- MC80F0504 : 8 channels
• One Buzzer Driving port
- 488Hz ~ 250kHz@4MHz
MAY.2008 Ver 1.46
• Two External Interrupt input ports
• On-chip POR (Power on Reset)
• Seven Interrupt sources
- External input : 2
- Timer : 4
- A/D Conversion : 1
• Built in Noise Immunity Circuit
- Noise Canceller
- PFD (Power fail detector)
- ONP (Oscillation Noise Protector)
• Operating Voltage & Frequency
- 2.2V ~ 5.5V (at 1 ~ 4MHz)
- 2.7V ~ 5.5V (at 1 ~ 8MHz)
- 4.5V ~ 5.5V (at 1 ~ 12MHz)
• Operating Temperature : -40°C ~ 85°C
• Power Saving Modes
- STOP mode
- SLEEP mode
- RC-WDT mode
• Oscillator Type
- Crystal
- Ceramic resonator
MC80F0504/0604
- External RC Oscillator (C can be omitted)
- Internal Oscillator (4MHz/2MHz)
• Package
- 20 PDIP, SOP or SSOP
- 16 PDIP, SOP, SOP(153 mil) or TSSOP
- Available Pb free package
1.3 Development Tools
The MC80F0504/0604 is supported by a full-featured macro assembler, an in-circuit emulator CHOICE-Dr.TM and FLASH programmers. There are two different type of programmers such as
single type and gang type. For mode detail, Macro assembler operates under the MS-Windows 95 and upversioned Windows OS.
Please contact sales part of abov semiconductor.
Software
- MS-Windows based assembler
- MS-Windows based Debugger
- HMS800 C compiler
Hardware
(Emulator)
- CHOICE-Dr.
- CHOICE-Dr. EVA80C0x B/D
Pod Name
- CHPOD80C01D-16PD
- CHPOD80C02D-20PD
FLASH Writer
- CHOICE - SIGMA I/II (Single writer)
- PGM Plus III (Single writer)
- Standalone GANG4 I/II (Gang writer)
PGMplus III ( Single Writer )
Standalone Gang4 II ( Gang Writer )
Choice-Dr. (Emulator)
2
MAY.2008 Ver 1.46
MC80F0504/0604
1.4 Ordering Information
Device name
MC80F0604B
MC80F0604D
MC80F0604S
MC80F0504B
MC80F0504D
MC80F0504M
MC80F0504R
ROM Size
4K bytes FLASH
RAM size
Package
256 bytes
20PDIP
20SOP
20SSOP
16PDIP
16SOP
16SOP(153 mil)
16TSSOP
Pb free package :
The “P” suffix will be added at the original part number.
For example; MC80F0604B (Normal package), MC80F0604B P (Pb free package)
MAY.2008 Ver 1.46
MC80F0504/0604
2. BLOCK DIAGRAM
PSW
ALU
Accumulator
PC
Stack Pointer
Data
Memory
RESET
Program
Memory
System controller
8-bit Basic
Interval
Timer
System
Clock Controller
Timing generator
Data Table
Interrupt Controller
Clock Generator
Instruction
Decoder
10-bit
A/D
Converter
Watch-dog
Timer
8-bit
Timer/
Counter
High
Speed
PWM
Buzzer
Driver
VDD
VSS
R3
R0
R1
Power
Supply
R31 / AN14
R32 / AN15
XIN / R33
XOUT / R34
4
R00
R01 / AN1
R02 / AN2
R03 / AN3
R04 / AN4 / EC0
R05 / AN5 / T0O
R06 / AN6
R07 / AN7
R10 / AN0 / AVREF / PWM1O
R11 / INT0
R12 / INT1 / BUZO
R13
R14
MAY.2008 Ver 1.46
MC80F0504/0604
3. PIN ASSIGNMENT
MC80F0604B/0604D
20 PDIP
20 SOP
1
20
R03 / AN3
R05 / AN5 / T0O
2
19
R02 / AN2
R06 / AN6
3
18
R01 / AN1
R07 / AN7
4
17
R00
VDD
5
16
VSS
R10 / AN0 / AVREF / PWM1O
6
15
RESET / R35
R11 / INT0
7
14
XOUT / R34
R12 / INT1 / BUZO
8
13
XIN / R33
R13
9
12
R32 / AN15
R14
10
11
R31 / AN14
MC80F0604B/D
R04 / AN4 / EC0
MC80F0504B/0504D/0504R
16 PDIP
16 SOP
16 TSSOP
1
16
R03 / AN3
R05 / AN5 / T0O
2
15
R02 / AN2
R06 / AN6
3
14
R01 / AN1
R07 / AN7
4
13
R00
VDD
5
12
VSS
R10 / AN0 / AVREF / PWM1O
6
11
RESET / R35
R11 / INT0
7
10
XOUT / R34
R12 / INT1 / BUZO
8
9
XIN / R33
MAY.2008 Ver 1.46
MC80F0504B/0/R
R04 / AN4 / EC0
MC80F0504/0604
4. PACKAGE DRAWING
20 PDIP
unit: inch
MAX
MIN
1.043
TYP 0.300
1.010
0.245
0.120
0.140
MAX 0.180
MIN 0.015
0.270
4
0.01
8
0
0
0.
0.021
0.065
0.015
0 ~ 15°
TYP 0.100
0.050
6
TYP 0.050
0.291
0.419
0.398
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 ~ 8°
0.042
0.016
MAY.2008 Ver 1.46
MC80F0504/0604
20 SSOP
unit: inch
MAX
MAY.2008 Ver 1.46
0.260
0.244
0.169
0 ~ 8°
TYP 0.026
0.004
0.013
0.008
0.008
0.057
0.264
0.248
0.008
0.002
0.177
MIN
0.030
0.018
MC80F0504/0604
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.00
0.022
0.065
0.015
0 ~ 15°
TYP 0.100
0.050
8
TYP 0.050
0.292
0.416
0.398
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 ~ 8°
0.040
0.016
MAY.2008 Ver 1.46
MC80F0504/0604
unit: inch
MAX
16 SOP (153 mil)
0.019
0.014
0.149
0.244
0.228
0 ~ 8°
TYP 0.0098
0.069
0.053
0.394
0.385
0.0098
0.0039
0.158
MIN
TYP 0.050
0.032
0.017
MAY.2008 Ver 1.46
0.201
0.193
0.012
0.007
0.258
0.246
0.169
0.006
0.002
0.047MAX
0.177
16 TSSOP
0 ~ 8°
0.026BSC
0.030
0.020
MC80F0504/0604
5. PIN FUNCTION
R1 serves the functions of the various following special
features in Table 5-2
VDD: Supply voltage.
VSS: Circuit ground.
RESET: Reset the MCU.
XIN: Input to the inverting oscillator amplifier and input to
the internal main clock operating circuit.
XOUT: Output from the inverting oscillator amplifier.
R00~R07: R0 is an 8-bit, CMOS, bidirectional I/O port.
RA pins can be used as outputs or inputs according to “1”
or “0” written the their Port Direction Register(R0IO).
Port pin
R00
R01
R02
R03
R04
R05
R06
R07
Alternate function
R10
AN0 ( Analog Input Port 0 )
AVref ( External Analog Reference Pin )
PWM1O ( PWM1 Output )
INT0 ( External Interrupt Input Port 0 )
INT1 ( External Interrupt Input Port 1 )
BUZ ( Buzzer Driving Output Port )
R11
R12
R13
R14
Alternate function
AN1 ( Analog Input Port 1 )
AN2 ( Analog Input Port 2 )
AN3 ( Analog Input Port 3 )
AN4 ( Analog Input Port 4 )
EC0 ( Event Counter Input Source 0 )
AN5 ( Analog Input Port 5 )
T0O (Timer0 Clock Output )
AN6 ( Analog Input Port 6 )
AN7 ( Analog Input Port 7 )
Table 5-1 R0 Port
In addition, R0 serves the functions of the various special
features in Table 5-1 .
R10~R14: R1 is a 5-bit, CMOS, bidirectional I/O port. R1
pins can be used as outputs or inputs according to “1” or
“0” written the their Port Direction Register (R1IO).
10
Port pin
Table 5-2 R1 Port
R31~R35: R3 is an 5-bit, CMOS, bidirectional I/O port.
R3 pins can be used as outputs or inputs according to “1”
or “0” written the their Port Direction Register (R3IO). In
R3 pins, R35 pin can be used as input port only.
R3 serves the functions of the following special features in
Table 5-3 .
Port pin
R31
R32
R33
R34
R35
Alternate function
AN14 ( Analog Input Port 14 )
AN15 ( Analog Input Port 15 )
XIN ( Oscillation Input )
XOUT ( Oscillation Output )
RESET ( Reset input port )
Table 5-3 R3 Port
MAY.2008 Ver 1.46
MC80F0504/0604
Pin No.
(20PDIP)
In/Out
VDD
5
-
Supply voltage
VSS
16
-
Circuit ground
RESET (R35)
15
I(I)
Reset signal input
Input only port
XIN (R33)
13
I (I/O)
Oscillation Input
Normal I/O Port
XOUT (R34)
14
O (I/O)
Oscillation Output
Normal I/O Port
R00
17
I/O
R01 (AN1)
18
I/O (Input)
Analog Input Port 1
R02 (AN2)
19
I/O (Input)
Analog Input Port 2
R03 (AN3)
20
I/O (Input)
Analog Input Port 3
R04 (AN4 / EC0)
1
I/O (Input/Input/Input)
R05 (AN5 / T0O)
2
I/O (Input/Output)
R06 (AN6)
3
I/O (Input)
R07 (AN7)
4
I/O (Input)
R10 (AN0 / AVREF /
PWM1O)
6
I/O (Input/Input/Output)
R11 (INT0)
7
I/O (Input)
R12 (INT1 / BUZO)
8
I/O (Input/Output)
External Interrupt Input 1 / Buzzer Driving Output
R13
9
I/O
-
PIN NAME
Function
-
Analog Input Port 4 / Event Counter Input 0
Analog Input Port 5 / Timer0 Output
Analog Input Port 6
Normal I/O Ports
Analog Input Port 7
Analog Input Port 0 / Analog Reference / PWM 1
output
External Interrupt Input 0
-
R14
10
I/O
R31 (AN14)
11
I/O (Input)
Analog Input Port 14
R32 (AN15)
12
I/O (Input)
Analog Input Port 15
Table 5-4 Pin Description
MAY.2008 Ver 1.46
MC80F0504/0604
6. PORT STRUCTURES
R04 (AN4 / EC0)
R00, R13, R14
VDD
VDD
Pull-up
Tr.
Pull-up
Reg.
Pull-up
Tr.
Pull-up
Reg.
Open Drain
Reg.
Open Drain
Reg.
VDD
VDD
VDD
VDD
Data Reg.
Data Reg.
Data Bus
VSS
VSS
Data Bus
Direction
Reg.
Pin
Direction
Reg.
Pin
MUX
VSS
VSS
RD
MUX
AN[1]
RD
ADEN & ADS[3:0]
(ADCM)
Noise
Filter
EC0
EC0E (PSR0)
R01(AN1)~R03(AN3), R06(AN6), R07(AN7),
R31 (AN14), R32 (AN15))
R11 (INT0)
VDD
VDD
Pull-up
Tr.
Pull-up
Reg.
Pull-up
Tr.
Pull-up
Reg.
Open Drain
Reg.
VDD
Open Drain
Reg.
VDD
VDD
VDD
Data Reg.
Data Reg.
Direction
Reg.
Pin
VSS
Data Bus
VSS
Direction
Reg.
Data Bus
MUX
VSS
VSS
RD
MUX
RD
INT0
AN[15:14]
AN[7:6]
AN[3:1]
Pin
Noise
Filter
INT0E (PSR0)
ADEN & ADS[3:0] (ADCM)
12
MAY.2008 Ver 1.46
MC80F0504/0604
R05 (AN5 / T0O)
R12 (INT1 / BUZO)
VDD
VDD
Pull-up
Reg.
Open Drain
Reg.
Open Drain
Reg.
Data Reg.
Pull-up
Tr.
Pull-up
Reg.
Pull-up
Tr.
VDD
VDD
Data Reg.
VDD
VDD
MUX
T0O
MUX
BUZO
Pin
Pin
T0OE(PSR1.0)
BUZOE(PSR1.2)
VSS
VSS
Direction
Reg.
VSS
Direction
Reg.
Data Bus
Data Bus
VSS
MUX
MUX
RD
RD
AN[5]
Noise
Filter
INT1
ADEN & ADS[3:0]
(ADCM)
INT1E(PSR0.1)
RESET(R35)
R10 (AN0 / AVREF / PWM1O)
VDD
Pull-up
Tr.
VDD
Pull-up
Tr.
Pull-up
Reg.
VDD
RD
Open Drain
Reg.
Data Reg.
Pull-up
Reg.
VDD
Mask only
VDD
Data Bus
MUX
PWM1O
Pin
Pin
Internal Reset
PWM1OE(PSR0.6)
VSS
Direction
Reg.
Data Bus
MUX
RD
AN[0]
ADEN & ADS[3:0]
(ADCM)
ADC Reference
Voltage Input
AVREFS(PSR1.3)
MAY.2008 Ver 1.46
VDD
MUX
VSS
Reset Disable
(Configuration option bit)
VSS
MC80F0504/0604
R33 (XIN), R34 (XOUT)
XIN, XOUT (Crystal or Ceramic Resonator)
VDD
VDD
VDD
XIN
STOP
Pull-up
Tr.
Pull-up
Reg.
Open Drain
Reg.
VDD
VDD
Data Reg.
VSS
Direction
Reg.
VDD
VDD
XIN
/ R33
VSS
MAIN
CLOCK
VSS
XOUT
Data Bus
VSS
IN4MCLK
IN2MCLK
IN4MCLKXO
IN2MCLKXO
CLOCK option
(Configuration
option bit)
XIN, XOUT (External RC or R oscillation)
MUX
RD
IN4MCLK
IN2MCLK
EXRC
VDD
Main Clock
(to ONP Block)
VDD
XIN
STOP
VDD
Pull-up
Tr.
Pull-up
Reg.
Open Drain
Reg.
VSS
VDD
VDD
Data Reg.
MAIN
CLOCK
VDD
Direction
Reg.
XOUT
/ R34
fXIN ÷ 16
XOUT
VSS
VSS
VSS
Data Bus
MUX
RD
System Clock ÷ 4
IN4MCLKXO
IN2MCLKCO
EXRCXO
CLOCK option
(Configuration option bit)
14
MAY.2008 Ver 1.46
MC80F0504/0604
7. ELECTRICAL CHARACTERISTICS
7.1 Absolute Maximum Ratings
Supply voltage ............................................. -0.3 to +6.5 V
................................................................................. 10 mA
Storage Temperature .................................. -65 to +150 °C
Maximum current (ΣIOL) ...................................... 160 mA
Voltage on any pin with respect to Ground (VSS)
...............................................................-0.3 to VDD+0.3V
Maximum current (ΣIOH)........................................ 80 mA
Maximum current out of VSS pin .......................... 200 mA
Note: Stresses above those listed under “Absolute Maximum
Ratings” may cause permanent damage to the device. This is a
stress rating only and functional operation of the device at any other conditions above those indicated in the operational sections of
this specification is not implied. Exposure to absolute maximum
rating conditions for extended periods may affect device reliability.
Maximum current into VDD pin ............................ 100 mA
Maximum current sunk by (IOL per I/O Pin) .......... 20 mA
Maximum output current sourced by (IOH per I/O Pin)
7.2 Recommended Operating Conditions
Parameter
Symbol
Condition
Min.
Max.
Unit
Supply Voltage
VDD
fXIN=1~12MHz
fXIN=1~8MHz
fXIN=1~8MHz
4.5
2.7
2.2
5.5
5.5
5.5
V
Operating Frequency
fXIN
VDD=4.5~5.5V
VDD=2.7~5.5V
VDD=2.2~5.5V
1
1
1
12
8
4
MHz
TOPR
VDD=2.2~5.5V
-40
85
°C
Operating Temperature
7.3 A/D Converter Characteristics
(Ta=-40~85°C, VSS=0V, VDD=2.7~5.5V @fXIN=8MHz)
Parameter
Symbol
Resolution
Overall Accuracy
CAIN
Non Linearity Error
NLE
Differential Non Linearity Error
DLE
Conditions
Min.
Typ.
Max.
Unit
-
-
10
-
BIT
-
-
-
±3
LSB
-
−
±3
LSB
-
−
±3
LSB
-
±1
±3
LSB
-
±0.5
±3
LSB
VDD = AVREF = 5V
CPU Clock = 4MHz
VSS = 0V
Zero Offset Error
NZOE
Full Scale Error
NFSE
Conversion Time
TCONV
-
13
-
-
μS
VAN
-
VSS
-
VDD(AVREF)
V
AVREF
-
2.7
-
VDD
V
RAIN
VDD = AVREF = 5V
5
100
-
ΜΩ
VDD = AVREF = 5V
VDD = AVREF = 3V
-
1
0.5
3
1.5
mA
VDD = AVREF = 5V
power down mode
-
100
500
nA
Analog Input Voltage Range
Analog Reference Voltage
Analog Input Impedance
Analog Block Current
MAY.2008 Ver 1.46
IAVDD
MC80F0504/0604
7.4 DC Electrical Characteristics
(TA=-40~85°C, VDD=5.0V, VSS=0V),
Specifications
Parameter
Symbol
Pin
Condition
Unit
Min.
Typ.
Max.
VIH1
XIN, RESET
0.8 VDD
-
VDD
VIH2
Hysteresis Input1
0.8 VDD
-
VDD
VIH3
Normal Input
0.7 VDD
-
VDD
VIL1
XIN, RESET
0
-
0.2 VDD
VIL2
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
Input Pull-up Current
IP
Normal Input
VDD=5V
-60
-
-150
μA
Input High Voltage
Input Low Voltage
V
V
Input High
Leakage Current
IIH1
All Pins (except XIN)
VDD=5V
-
-
5
μA
IIH2
XIN
VDD=5V
-
12
20
μA
Input Low
Leakage Current
IIL1
All Pins (except XIN)
VDD=5V
-5
-
-
μA
IIL2
XIN
VDD=5V
-20
-12
-
μA
VDD=5V
0.5
-
-
V
Input1
Hysteresis
| VT |
Hysteresis
PFD Voltage
VPFD
VDD
2.0
-
3.0
V
POR Voltage
VPOR
VDD
2.1
2.6
3.0
V
POR Start Voltage2
VSTART
VDD
0
1.9
V
POR Rising Time2
TPOR
VDD
40
ms/V
VDD Rising Time2
TVDD
VDD
Internal RC WDT
Period
TRCWDT
XOUT
VDD=5.5V
Operating Current
IDD
VDD
Sleep Mode Current
ISLEEP
RCWDT Mode Current at STOP Mode
-
-
40
ms/V
36
-
90
μS
VDD=5.5V, fXIN=12MHz
-
7
15
mA
VDD
VDD=5.5V, fXIN=12MHz
-
2
4.5
mA
IRCWDT
VDD
VDD=5.5V, fXIN=12MHz
-
20
55
μA
Stop Mode Current
ISTOP
VDD
VDD=5.5V, fXIN=12MHz
-
1
5
μA
Internal Oscillation
Frequency( 4MHz )
fIN_CLK
XOUT
VDD=5V, Temp=25°C
3.75
4.25
4.65
MHz
VDD=5V
1.5
1.8
μs
0.5
1.5
2.5
MHz
1
2
3
MHz
RESET Input Noise
Cancel Time
External RC
Oscillator Frequency
TRST_NC RESET
fRC-OSC
fXOUT = fRC-OSC ÷ 4
VDD=5.5V
R=30kΩ, C=10pF
fR-OSC
fXOUT = fR-OSC ÷ 4
VDD=5.5V, R=30kΩ
1. Hysteresis Input: INT0(R11),INT1(R12), EC0(R04)
2. These parameters are presented for design guidance only and not tested or guaranteed.
16
MAY.2008 Ver 1.46
MC80F0504/0604
7.5 AC Characteristics
(TA=-40~85°C, VDD=5V±10%, VSS=0V)
Parameter
Symbol
Pins
Operating Frequency
fXIN
System Clock Cycle
Time
Specifications
Unit
Min.
Typ.
Max.
XIN
1
-
12
MHz
tSYS
-
166
-
5000
nS
Oscillation Stabilizing
Time (4MHz)
tST
XIN, XOUT
-
-
20
mS
External Clock Pulse
Width
tCPW
XIN
35
-
-
nS
External Clock Transition Time
tRCP,tFCP
XIN
-
-
20
nS
Interrupt Pulse Width
tIW
INT0, INT1
2
-
-
tSYS
RESET Input Width
tRST
RESET
8
-
-
tSYS
Event Counter Input
Pulse Width
tECW
EC0
2
-
-
tSYS
tREC,tFEC
EC0
-
-
20
nS
Event Counter Transition Time
tSYS = 1/fXIN
tCPW
tCPW
VDD-0.5V
XIN
0.5V
tRCP
tIW
INT0, INT1
tFCP
tIW
0.8VDD
0.2VDD
tRST
RESET
0.2VDD
tECW
tECW
0.8VDD
EC0
0.2VDD
tREC
tFEC
Figure 7-1 Timing Chart
MAY.2008 Ver 1.46
MC80F0504/0604
7.6 Typical Characteristics
These 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
fXIN
(MHz)
Normal Operation
IDD−VDD
Ta=25°C
16
14
IDD
(mA)
12
12
10
10
8
8
6
6
4
4
2
2
Ta=25°C
fXIN=12MHz
4MHz
0
2
3
4
VDD
(V)
6
5
0
2
STOP Mode
ISTOP−VDD
IDD
(μA)
3
4
5
VDD
6 (V)
5
VDD
6 (V)
SLEEP Mode
ISLEEP−VDD
IDD
(mA)
Ta=25°C
2
2.0
1.5
1.5
1
1.0
0.5
0.5
Ta=25°C
fXIN = 12MHz
0
2
3
4
VDD
(V)
5
0
2
3
4
RC-WDT in Stop Mode
IRCWDT−VDD
IDD
(μA)
Ta=25°C
20
15
TRCWDT = 50uS
10
5
0
2
18
3
4
5
VDD
6 (V)
MAY.2008 Ver 1.46
MC80F0504/0604
IOL−VOL, VDD=5V
IOH−VOH, VDD=5V
IOL
(mA)
IOH
(mA)
-25°C
25°C
20
-25°C
25°C
-20
85°C
85°C
-15
15
-10
10
-5
5
0
0.5
VIH1
(V)
1
1.5
2
VDD−VIH1
XIN, RESET
0
VOL
(V)
3.5
VDD−VIH2
VIH2
(V)
fXIN=4MHz
Ta=25°C
4
4.5
VDD−VIH3
Hysteresis input
VIH3
(V)
fXIN=4kHz
Ta=25°C
4
4
3
3
3
2
2
2
1
1
1
0
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)
2
4
3
3
3
2
2
2
1
1
1
1
2
3
4
MAY.2008 Ver 1.46
5
VDD
6 (V)
4
0
2
3
4
5
VDD
6 (V)
3
VDD−VIL3
VIL3
(V)
4
0
Normal input
fXIN=4kHz
Ta=25°C
0
Hysteresis input
fXIN=4kHz
Ta=25°C
VOH
(V)
5
4
5
VDD
6 (V)
Normal input
fXIN=4kHz
Ta=25°C
0
2
3
4
5
VDD
6 (V)
MC80F0504/0604
Typical RC Oscillator
Frequency vs VDD
FOSC
(MHz)
10
Typical RC Oscillator
Frequency vs VDD
FOSC
(MHz)
No Cap
Ta = 25°C
10
CEXT = 10pF
Ta = 25°C
9
9
R = 4.7K
8
8
7
7
R = 4.7K
R = 10K
6
6
R = 10K
5
5
4
4
R = 20K
3
3
R = 20K
R = 30K
2
2
1
1
0
2.5
3.0
3.5
4.0
4.5
5.0
FOSC
(MHz)
7
0
VDD
5.5 (V)
Typical RC Oscillator
Frequency vs VDD
2.5
7
6
3.0
3.5
4.0
4.5
5.0
VDD
5.5 (V)
Typical RC Oscillator
Frequency vs VDD
FOSC
(MHz)
CEXT = 20pF
Ta = 25°C
R = 30K
CEXT = 30pF
Ta = 25°C
6
R = 4.7K
R = 4.7K
5
5
4
4
R = 10K
3
R = 10K
3
R = 20K
2
2
R = 30K
1
1
0
2.5
3.0
3.5
4.0
4.5
5.0
VDD
5.5 (V)
Note: The external RC oscillation frequencies shown in
above are provided for design guidance only and not tested
or guaranteed. The user needs to take into account that the
external RC oscillation frequencies generated by the same
circuit design may be not the same. Because there are variations in the resistance and capacitance due to the tolerance of external R and C components. The parasitic
capacitance difference due to the different wiring length
and layout may change the external RC oscillation frequencies.
20
R = 20K
R = 30K
0
2.5
3.0
3.5
4.0
4.5
5.0
VDD
5.5 (V)
Note: There may be the difference between package
types(PDIP, SOP, TSSOP). The user should modify the
value of R and C components to get the proper frequency
in exchanging MC80F0104/0204 to MC80F0504/0604 or
one package type to another package type.
MAY.2008 Ver 1.46
MC80F0504/0604
8. MEMORY ORGANIZATION
The MC80F0504/0604 has separate address spaces for
Program memory and Data Memory. 4K bytes program
memory can only be read, not written to.
Data memory can be read and written to up to 256 bytes including the stack area.
8.1 Registers
This device has six registers that are the Program Counter
(PC), a Accumulator (A), two index registers (X, Y), the
Stack Pointer (SP), and the Program Status Word (PSW).
The Program Counter consists of 16-bit register.
PCH
A
ACCUMULATOR
X
X REGISTER
Y
Y REGISTER
SP
STACK POINTER
PCL
PROGRAM COUNTER
PSW
PROGRAM STATUS WORD
call is executed or an interrupt is accepted. However, if it
is used in excess of the stack area permitted by the data
memory allocating configuration, the user-processed data
may be lost.
The stack can be located at any position within 1C0H to
1FFH of the internal data memory. The SP is not initialized
by hardware, requiring to write the initial value (the location with which the use of the stack starts) by using the initialization routine. Normally, the initial value of “FFH” is
used.
Bit 15
Stack Address (1C0H ~ 1FFH)
8 7
Bit 0
01H
SP
C0H~FFH
Hardware fixed
Figure 8-1 Configuration of Registers
Accumulator: The Accumulator is the 8-bit general purpose register, used for data operation such as transfer, temporary saving, and conditional judgement, etc.
Note: The Stack Pointer must be initialized by software because
The Accumulator can be used as a 16-bit register with Y
Register as shown below.
Example: To initialize the SP
LDX
#0FFH
TXSP
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).
Generally, SP is automatically updated when a subroutine
MAY.2008 Ver 1.46
its value is undefined after Reset.
; SP ← FFH
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.
MC80F0504/0604
PSW
MSB
N V G B H
NEGATIVE FLAG
OVERFLOW FLAG
SELECT DIRECT PAGE
when G=1, page is selected to “page 1”
BRK FLAG
I
Z
LSB
C RESET VALUE: 00H
CARRY FLAG RECEIVES
CARRY OUT
ZERO FLAG
INTERRUPT ENABLE FLAG
HALF CARRY FLAG RECEIVES
CARRY OUT FROM BIT 1 OF
ADDITION OPERLANDS
Figure 8-3 PSW (Program Status Word) Register
[Interrupt disable flag I]
This flag enables/disables all interrupts except interrupt
caused by Reset or software BRK instruction. All interrupts are disabled when cleared to “0”. This flag immediately becomes “0” when an interrupt is served. It is set by
the EI instruction and cleared by the DI instruction.
[Half carry flag H]
After operation, this is set when there is a carry from bit 3
of ALU or there is no borrow from bit 4 of ALU. This bit
can not be set or cleared except CLRV instruction with
Overflow flag (V).
[Break flag B]
This flag is set by software BRK instruction to distinguish
BRK from TCALL instruction with the same vector address.
[Direct page flag G]
22
This flag assigns RAM page for direct addressing mode. In
the direct addressing mode, addressing area is from zero
page 00H to 0FFH when this flag is "0". If it is set to "1",
addressing area is assigned 100H to 1FFH. It is set by
SETG instruction and cleared by CLRG.
[Overflow flag V]
This flag is set to “1” when an overflow occurs as the result
of an arithmetic operation involving signs. An overflow
occurs when the result of an addition or subtraction exceeds +127(7FH) or -128(80H). The CLRV instruction
clears the overflow flag. There is no set instruction. When
the BIT instruction is executed, bit 6 of memory is copied
to this flag.
[Negative flag N]
This flag is set to match the sign bit (bit 7) status of the result of a data or arithmetic operation. When the BIT instruction is executed, bit 7 of memory is copied to this flag.
MAY.2008 Ver 1.46
MC80F0504/0604
At acceptance
of interrupt
At execution of
a CALL/TCALL/PCALL
01FF
Push
down
01FF
PCH
01FE
PCL
01FD
01FD
PSW
01FC
01FC
01FE
PCH
PCL
At execution
of RET instruction
Push
down
01FF
PCH
01FE
PCL
At execution
of RET instruction
01FF
PCH
01FE
PCL
01FD
01FD
PSW
01FC
01FC
Pop
up
SP before
execution
01FF
01FF
01FD
01FC
SP after
execution
01FD
01FC
01FF
01FF
At execution
of PUSH instruction
PUSH A (X,Y,PSW)
01FF
A
01FE
Push
down
At execution
of POP instruction
POP A (X,Y,PSW)
01FF
A
01FE
01FD
01FD
01FC
01FC
Pop
up
01FFH
SP before
execution
01FF
01FE
SP after
execution
01FE
01FF
Figure 8-4 Stack Operation
MAY.2008 Ver 1.46
01C0H
Stack
depth
Pop
up
MC80F0504/0604
8.2 Program Memory
A 16-bit program counter is capable of addressing up to
64K bytes, but this device has 4K bytes program memory
space only physically implemented. Accessing a location
above FFFFH will cause a wrap-around to 0000H.
Figure 8-5 , shows a map of Program Memory. After reset,
the CPU begins execution from reset vector which is stored
in address FFFEH and FFFFH as shown in Figure 8-6 .
As shown in Figure 8-5 , each area is assigned a fixed location in Program Memory. Program Memory area contains the user program
FFC0H
FFDFH
FFE0H
FFFFH
TCALL area
Interrupt
Vector Area
MC80F0504/0604, 4K FLASH
FEFFH
FF00H
PCALL area
F000H
Example: Usage of TCALL
LDA
#5
TCALL 0FH
:
:
;1BYTE INSTRUCTION
;INSTEAD OF 3 BYTES
;NORMAL CALL
;
;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
1
;TCALL ADDRESS AREA
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 0FFFCH. The interrupt service locations spaces 2-byte
interval: 0FFFAH and 0FFFBH for External Interrupt 1,
0FFFCH and 0FFFDH for External Interrupt 0, etc.
Any area from 0FF00H to 0FFFFH, if it is not going to be
used, its service location is available as general purpose
Program Memory.
Figure 8-5 Program Memory Map
Page Call (PCALL) area contains subroutine program to
reduce program byte length by using 2 bytes PCALL instead of 3 bytes CALL instruction. If it is frequently called,
it is more useful to save program byte length.
Table Call (TCALL) causes the CPU to jump to each
TCALL address, where it commences the execution of the
service routine. The Table Call service area spaces 2-byte
for every TCALL: 0FFC0H for TCALL15, 0FFC2H for
TCALL14, etc., as shown in Figure 8-7 .
Address
0FFE0H
Vector Area Memory
Basic Interval Timer
E2
Watchdog Timer Interrupt
E4
A/D Converter
E6
-
E8
-
EA
-
EC
Timer/Counter 1 Interrupt
EE
Timer/Counter 0 Interrupt
F0
-
F2
-
F4
-
F6
-
F8
-
FA
External Interrupt 1
FC
External Interrupt 0
FE
RESET
Figure 8-6 Interrupt Vector Area
24
MAY.2008 Ver 1.46
MC80F0504/0604
Address
0FF00H
PCALL Area Memory
Address
PCALL Area
(256 Bytes)
0FFC0H
C1
C2
C3
C4
C5
C6
C7
C8
C9
CA
CB
CC
CD
CE
CF
D0
D1
D2
D3
D4
D5
D6
D7
D8
D9
DA
DB
DC
DD
DE
DF
0FFFFH
Program Memory
TCALL 15
TCALL 14
TCALL 13
TCALL 12
TCALL 11
TCALL 10
TCALL 9
TCALL 8
TCALL 7
TCALL 6
TCALL 5
TCALL 4
TCALL 3
TCALL 2
TCALL 1
TCALL 0 / BRK *
NOTE:
* means that the BRK software interrupt is using
same address with TCALL0.
Figure 8-7 PCALL and TCALL Memory Area
PCALL→ rel
TCALL→ n
4F35
4A
PCALL 35H
TCALL 4
4A
4F
01001010
35
~
~
~
~
~
~
0D125H
➊
~
~
NEXT
Reverse
PC: 11111111 11010110
FH
FH
DH 6H
0FF00H
0FF35H
NEXT
0FFFFH
MAY.2008 Ver 1.46
➌
0FF00H
0FFD6H
25
0FFD7H
D1
0FFFFH
➋
MC80F0504/0604
Example: The usage software example of Vector address
;Interrupt Vector Table
ORG
0FFE0H
DW
BIT_TIMER
DW
WDT
DW
ADC
DW
Noticed
DW
Noticed
DW
Noticed
DW
TIMER1
DW
TIMER0
DW
Noticed
DW
Noticed
DW
Noticed
DW
Noticed
DW
Noticed
DW
INT1
DW
INT0
DW
RESET
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
for MC80F0604.
BIT
WDT
AD Converter
Timer-1
Timer-0
Ext. Int.1
Ext. Int.0
Reset
ORG
0F000H
; 4K bytes ROM Start address
;*******************************************
;
MAIN
PROGRAM
*
;*******************************************
RESET:
DI
;Disable All Interrupt
;RAM Clear Routine
LDX
#0
RAM_Clear0:
LDA
#0
;Page0 RAM Clear(0000h ~ 00BFh)
STA
{X}+
CMPX
#0C0h
BNE
RAM_Clear0
LDM
SETG
RPR,#1
LDX
#0C0h
LDA
STA
CMPX
BNE
#0
{X}+
#00h
RAM_Clear1
;Page Select
RAM_Clear1:
RAM_Clear_Finish:
CLRG
LDX
TXSP
:
:
;Initialize IO
LDM
LDM
:
:
26
;Page0 Select
#0FFh
;Initial Stack Pointer
R0, #0
R0IO,#0FFH
;Normal Port R0
;Normal Port R0 Direction
MAY.2008 Ver 1.46
MC80F0504/0604
8.3 Data Memory
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.
Figure 8-8 shows the internal Data Memory space available. Data Memory is divided into three groups, a user
RAM, control registers, and Stack memory.
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.
0000H
User Memory
(192Bytes)
More detailed informations of each register are explained
in each peripheral section.
PAGE0
00BFH
00C0H
(When “G-flag=0”,
this page0 is selected)
Control
Registers
00FFH
0100H
Note: Write only registers can not be accessed by bit manipulation instruction. Do not use read-modify-write instruction. Use byte
manipulation instruction, for example “LDM”.
Not Available
PAGE1
01BFH
01C0H
Example; To write at CKCTLR
LDM
CKCTLR,#0AH ;Divide ratio(÷32)
User Memory
or Stack Area
(64Bytes)
01FFH
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.
Figure 8-8 Data Memory Map
User Memory
The MC80F0504/0604 has 256 × 8 bits for the user memory (RAM). RAM pages are selected by RPR (See Figure
8-9 ).
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.
Note: After setting RPR(RAM Page Select Register), be sure to
execute SETG instruction. When executing CLRG instruction, be
selected PAGE0 regardless of RPR.
The save/restore locations in the stack are determined by
the stack pointed (SP). The SP is automatically decreased
after the saving, and increased before the restoring. This
means the value of the SP indicates the stack location
number for the next save. Refer to Figure 8-4 .
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
RPR
7
6
5
4
3
R/W
2
R/W
1
R/W
0
-
-
-
-
-
RPR2 RPR1 RPR0
ADDRESS: 0E1H
INITIAL VALUE: ---- -000B
System clock source select
000 : PAGE0
001 : PAGE1
010 : Not used
011 : Not used
100 : Not used
others : Setting prohibited
Figure 8-9 RPR(RAM Page Select Register)
MAY.2008 Ver 1.46
MC80F0504/0604
Address
Register Name
Symbol
Initial Value
R/W
7 6 5 4 3 2 1 0
Addressing
Mode
R0
R/W
0 0 0 0 0 0 0 0
byte, bit1
R0IO
W
0 0 0 0 0 0 0 0
byte2
R1
R/W
-
-
- 0 0 0 0 0
byte, bit
R1IO
W
-
-
- 0 0 0 0 0
byte
R3
R/W
-
- 0 0 0 0 0 -
R3 port I/O direction register
R3IO
W
0 0 0 0 0 0 0 -
byte
00C8
Port 0 Open Drain Selection Register
R0OD
W
0 0 0 0 0 0 0 0
byte
00C9
Port 1 Open Drain Selection Register
R1OD
W
-
-
- 0 0 0 0 0
byte
00CB
Port 3 Open Drain Selection Register
R3OD
W
-
-
- 0 0 0 0 -
byte
00D0
Timer 0 mode control register
TM0
R/W
-
- 0 0 0 0 0 0
T0
R
0 0 0 0 0 0 0 0
Timer 0 data register
TDR0
W
1 1 1 1 1 1 1 1
Timer 0 capture data register
CDR0
R
0 0 0 0 0 0 0 0
Timer 1 mode control register
TM1
R/W
0 0 0 0 0 0 0 0
byte, bit
TDR1
W
1 1 1 1 1 1 1 1
byte
T1PPR
W
1 1 1 1 1 1 1 1
byte
T1
R
0 0 0 0 0 0 0 0
Timer 1 capture data register
CDR1
R
0 0 0 0 0 0 0 0
Timer 1 PWM duty register
T1PDR
R/W
0 0 0 0 0 0 0 0
byte
00D5
Timer 1 PWM high register
T1PWHR
W
-
- 0 0 0 0
byte
00E0
Buzzer driver register
BUZR
W
1 1 1 1 1 1 1 1
byte
00E1
RAM page selection register
RPR
R/W
-
-
-
- 0 0 0
byte, bit
00EA
Interrupt enable register high
IENH
R/W
0 0 -
-
-
- 0
byte, bit
00EB
Interrupt enable register low
IENL
R/W
0 -
- 0 0 - 0
byte, bit
00EC
Interrupt request register high
IRQH
R/W
0 0 -
-
- 0
byte, bit
00ED
Interrupt request register low
IRQL
R/W
0 -
-
- 0 0 - 0
byte, bit
00EE
Interrupt edge selection register
IEDS
R/W
-
-
- 0 0 0 0
byte, bit
00EF
A/D converter mode control register
ADCM
R/W
0 0 0 0 0 0 0 1
byte, bit
00F0
A/D converter result high register
ADCRH
R(W)
0 1 0
00F1
A/D converter result low register
ADCRL
R
Undefined
BITR
R
Undefined
CKCTLR
W
0 - 0 1 0 1 1 1
00C0
R0 port data register
00C1
R0 port I/O direction register
00C2
R1 port data register
00C3
R1 port I/O direction register
00C6
R3 port data register
00C7
Timer 0 register
00D1
00D2
Timer 1 data register
byte, bit
byte, bit
byte
00D3
Timer 1 PWM period register
Timer 1 register
byte
00D4
Basic interval timer register
-
-
-
-
-
-
-
-
Undefined
byte
byte
00F2
byte
Clock control register
Table 8-1 Control Registers
28
MAY.2008 Ver 1.46
MC80F0504/0604
Address
Register Name
Symbol
Initial Value
R/W
7 6 5 4 3 2 1 0
Watch dog timer register
WDTR
W
0 1 1 1 1 1 1 1
WDTDR
R
Undefined
0 0 0 0 0 0 0 0
Addressing
Mode
00F4
byte
Watch dog timer data register
00F5
Stop & sleep mode control register
SSCR
W
00F7
PFD control register
PFDR
R/W
00F8
Port selection register 0
PSR0
W
0 0 0 0 0 0 0 0
byte
00F9
Port selection register 1
PSR1
W
-
- 0 0 0 0
byte
00FC
Pull-up selection register 0
PU0
W
0 0 0 0 0 0 0 0
byte
00FD
Pull-up selection register 1
PU1
W
-
-
- 0 0 0 0 0
byte
00FF
Pull-up selection register 3
PU3
W
-
- 0 0 0 0 0 -
byte
-
-
-
-
-
-
- 0 0 0
Table 8-1 Control Registers
1.
The ‘byte, bit’ means registers are controlled by both bit and byte manipulation instruction.
Caution) The R/W registers except T1PDR are both can be byte and bit manipulated.
2.
The ‘byte’ means registers are controlled by only byte manipulation instruction. Do not use bit manipulation
instruction such as SET1, CLR1 etc. If bit manipulation instruction is used on these registers,
content of other seven bits are may varied to unwanted value.
*The mark of ‘-’ means this bit location is reserved.
MAY.2008 Ver 1.46
byte
byte, bit
MC80F0504/0604
Address
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
T0CK2
T0CK1
T0CK0
T0CN
T0ST
T1CN
T1ST
0C0H
R0
R0 Port Data Register
0C1H
R0IO
R0 Port Direction Register
0C2H
R1
R1 Port Data Register
0C3H
R1IO
R1 Port Direction Register
0C6H
R3
R3 Port Data Register
0C7H
R3IO
R3 Port Direction Register
0C8H
R0OD
R0 Open Drain Selection Register
0C9H
R1OD
R1 Open Drain Selection Register
0CBH
R3OD
R3 Open Drain Selection Register
0D0H
TM0
0D1H
T0/TDR0/
CDR0
0D2H
TM1
0D3H
TDR1/
T1PPR
0D4H
T1/CDR1/
Timer1 Register / Timer1 Capture Data Register /Timer1 PWM Duty Register
T1PDR
0D5H
PWM1HR
0E0H
BUZR
0E1H
-
-
CAP0
Timer0 Register / Timer0 Data Register / Timer0 Capture Data Register
POL
16BIT
PWM1E
CAP1
T1CK1
T1CK0
Timer1 Data Register / Timer1 PWM Period Register
-
-
-
-
BUCK1
BUCK0
BUR5
BUR4
BUR3
BUR2
BUR1
BUR0
RPR
-
-
-
-
-
RPR2
RPR1
RPR0
0EAH
IENH
INT0E
INT1E
-
-
-
-
-
T0E
0EBH
IENL
T1E
-
-
-
ADCE
WDTE
-
BITE
0ECH
IRQH
INT0IF
INT1IF
-
-
-
-
-
T0IF
0EDH
IRQL
T1IF
-
-
-
ADCIF
WDTIF
-
BITIF
0EEH
IEDS
-
-
-
-
IED1H
IED1L
IED0H
IED0L
0EFH
ADCM
ADEN
ADCK
ADS3
ADS2
ADS1
ADS0
ADST
ADSF
0F0H
ADCRH
PSSEL1
PSSEL0
ADC8
-
-
-
0F1H
ADCRL
ADC Result Register Low
BITR1
Basic Interval Timer Data Register
WDTON
BTCL
BTS2
BTS1
BTS0
0F2H
0F4H
CKCTLR1
ADRST
WDTR
WDTCL
-
RCWDT
Timer1 PWM High Register
ADC Result Reg. High
7-bit Watchdog Timer Register
WDTDR
Watchdog Timer Data Register (Counter Register)
0F5H
SSCR
Stop & Sleep Mode Control Register
0F7H
PFDR
-
-
-
-
-
PFDEN
PFDM
PFDS
0F8H
PSR0
-
PWM1OE
-
EC0E
-
-
INT1E
INT0E
0F9H
PSR1
-
-
-
-
AVREFS
BUZO
-
T0O
0FCH
PU0
R0 Pull-up Selection Register
Table 8-2 Control Register Function Description
30
MAY.2008 Ver 1.46
MC80F0504/0604
Address
Bit 7
Name
Bit 6
Bit 5
0FDH
PU1
R1 Pull-up Selection Register
0FFH
PU3
R3 Pull-up Selection Register
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Table 8-2 Control Register Function Description
1. The register BITR and CKCTLR are located at same address. Address ECH is read as BITR, written to CKCTLR.
Caution) The registers of dark-shaded area can not be accessed by bit manipulation instruction such as "SET1, CLR1", but should be
accessed by register operation instruction such as "LDM dp,#imm".
MAY.2008 Ver 1.46
MC80F0504/0604
8.4 Addressing Mode
The MC80 series MCU uses six addressing modes;
8.4.3 Direct Page Addressing→ dp
• Register addressing
In this mode, a address is specified within direct page.
• Immediate addressing
Example; G=0
• Direct page addressing
C535
LDA
;A ←RAM[35H]
35H
• Absolute addressing
• Indexed addressing
• Register-indirect addressing
35H
data
➋
~
~
~
~
8.4.1 Register Addressing
0E550H
C5
Register addressing accesses the A, X, Y, C and PSW.
0E551H
35
data → A
➊
8.4.2 Immediate Addressing → #imm
In this mode, second byte (operand) is accessed as a data
immediately.
8.4.4 Absolute Addressing → !abs
Example:
0435
ADC
#35H
MEMORY
04
A+35H+C → A
35
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;
When G-flag is 1, then RAM address is defined by 16-bit
address which is composed of 8-bit RAM paging register
(RPR) and 8-bit immediate data.
LDM
35H,#55H
➊
0F100H
32
data
~
~
E4
0F101H
55
0F102H
35
➋
~
~
➊
A+data+C → A
07
0F101H
35
0F102H
F0
address: 0F035
data ← 55H
data
~
~
;A ←ROM[0F035H]
!0F035H
~
~
0F100H
0135H
ADC
0F035H
Example: G=1
E45535
0735F0
➋
The operation within data memory (RAM)
ASL, BIT, DEC, INC, LSR, ROL, ROR
Example; Addressing accesses the address 0135H regardless of G-flag.
MAY.2008 Ver 1.46
MC80F0504/0604
983501
INC
;A ←ROM[135H]
!0135H
35H
data
135H
➌
~
~
➋
data
~
~
~
~
➋
~
~
data+1 → data
0F100H
98
➊
0F101H
35
address: 0135
0F102H
01
data → A
➊
36H → X
DB
X indexed direct page (8 bit offset) → dp+X
8.4.5 Indexed Addressing
X indexed direct page (no offset) → {X}
In this mode, a address is specified by the X register.
This address value is the second byte (Operand) of command plus the data of X-register. And it assigns the memory in Direct page.
ADC, AND, CMP, EOR, LDA, OR, SBC, STA, XMA
ADC, AND, CMP, EOR, LDA, LDY, OR, SBC, STA
STY, XMA, ASL, DEC, INC, LSR, ROL, ROR
Example; X=15H, G=1
Example; G=0, X=0F5H
D4
LDA
115H
{X}
;ACC←RAM[X].
data
~
~
45H+X
data
➌
data → A
➊
D4
0E550H
LDA
3AH
➋
~
~
C645
~
~
➋
~
~
0E550H
C6
0E551H
45
data → A
➊
45H+0F5H=13AH
X indexed direct page, auto increment→ {X}+
In this mode, a address is specified within direct page by
the X register and the content of X is increased by 1.
LDA, STA
Example; G=0, X=35H
DB
LDA
{X}+
Y indexed direct page (8 bit offset) → dp+Y
This address value is the second byte (Operand) of command plus the data of Y-register, which assigns Memory in
Direct page.
This is same with above (2). Use Y register instead of X.
Y indexed absolute → !abs+Y
Sets the value of 16-bit absolute address plus Y-register
data as Memory.This addressing mode can specify memory in whole area.
Example; Y=55H
MAY.2008 Ver 1.46
MC80F0504/0604
D500FA
LDA
!0FA00H+Y
0F100H
D5
0F101H
00
0F102H
FA
1625
➊
ADC
35H
05
36H
E0
~
~
➋
➋ 0E005H
~
~
~
~
0FA00H+55H=0FA55H
~
~
[25H+X]
0E005H
➊ 25 + X(10) = 35H
data
~
~
data
0FA55H
~
~
data → A
➌
0FA00H
16
25
➌ A + data + C → A
8.4.6 Indirect Addressing
Y indexed indirect → [dp]+Y
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.
ADC, AND, CMP, EOR, LDA, OR, SBC, STA
JMP, CALL
Example; G=0, Y=10H
Example; G=0
3F35
Processes memory data as Data, assigned by the data
[dp+1][dp] of 16-bit pair memory paired by Operand in Direct page plus Y-register data.
JMP
1725
[35H]
ADC
[25H]+Y
35H
0A
25H
05
36H
E3
26H
E0
~
~
0E30AH
~
~
~
~
➊
NEXT
~
~
0FA00H
➋
jump to
address 0E30AH
0E015H
~
~
3F
~
~
➋
~
~
0FA00H
35
➊
0E005H + Y(10)
= 0E015H
data
~
~
17
25
➌
A + data + C → A
X indexed indirect → [dp+X]
Absolute indirect → [!abs]
Processes memory data as Data, assigned by 16-bit pair
memory which is determined by pair data
[dp+X+1][dp+X] Operand plus X-register data in Direct
page.
The program jumps to address specified by 16-bit absolute
address.
ADC, AND, CMP, EOR, LDA, OR, SBC, STA
Example; G=0
JMP
Example; G=0, X=10H
34
MAY.2008 Ver 1.46
MC80F0504/0604
1F25E0
JMP
[!0C025H]
PROGRAM MEMORY
0E025H
25
0E026H
E7
~
~
➊
0E725H
~
~
NEXT
~
~
0FA00H
~
~
1F
25
E0
MAY.2008 Ver 1.46
➋
jump to
address 0E30AH
MC80F0504/0604
9. I/O PORTS
The MC80F0504/0604 has three ports (R0, R1 and R3).
These ports pins may be multiplexed with an alternate
function for the peripheral features on the device. All port
can drive maximum 20mA of high current in output low
state, so it can directly drive LED device.
All pins have data direction registers which can define
these ports as output or input. A “1” in the port direction
register configure the corresponding port pin as output.
Conversely, write “0” to the corresponding bit to specify it
as input pin. For example, to use the even numbered bit of
R0 as output ports and the odd numbered bits as input
ports, write “55H” to address 0C1H (R0 port direction register) during initial setting as shown in Figure 9-1 .
its initial status is input.
WRITE “55H” TO PORT R0 DIRECTION REGISTER
0C0H
R0 data
0C1H
R0 direction
0C2H
R1 data
0C3H
R1 direction
0 1 0 1 0 1 0 1
7 6 5 4 3 2 1 0
BIT
I O I O I O I O PORT
7 6 5 4 3 2 1 0
I: INPUT PORT
O: OUTPUT PORT
Figure 9-1 Example of port I/O assignment
All the port direction registers in the MC80F0504/0604
have 0 written to them by reset function. On the other hand,
9.1 R0 and R0IO register
R0 is an 8-bit CMOS bidirectional I/O port (address
0C0H). Each I/O pin can independently used as an input or
an output through the R0IO register (address 0C1H). When
R00 through R07 pins are used as input ports, an on-chip
pull-up resistor can be connected to them in 1-bit units
R0 Data Register
R0
with a pull-up selection register 0 (PU0). Each I/O pin of
R0 port can be used to open drain output port by setting the
corresponding bit of the open drain selection register 0
(R0OD).
ADDRESS: 0F8H
RESET VALUE: -0-0 --00B
ADDRESS: 0C0H
RESET VALUE: 00H
R07 R06 R05 R04 R03 R02 R01 R00
PSR0
-
PWM1OE
-
EC0E
Input / Output data
R0 Direction Register
ADDRESS: 0C1H
RESET VALUE: 00H
Port / PWM Selection
0: R10
1: PWM1O
ADDRESS: 0FCH
RESET VALUE: 00H
ADDRESS: 0F9H
RESET VALUE: ---- 0000B
PU0
Pull-up Resister Selection
0: Disable
1: Enable
ADDRESS: 0C8H
RESET VALUE: 00H
R0OD
Open Drain Resister Selection
0: Disable
1: Enable
36
INT1E INT0E
Port / EC Selection
0: R04
1: EC0
Port Direction
0: Input
1: Output
R0 Open Drain
Selection Register
-
Port / INT Selection
0: R11, R12
1: INT0, INT1
R0IO
R0 Pull-up
Selection Register
-
PSR1
-
-
-
-
AVREFS BUZOE
-
T0OE
Port / TO Selection
0: R05
1: Timer0 output
R12/BUZO Selection
0: R12 port (Turn off buzzer)
1: BUZO port (Turn on buzzer)
R10 / AVREF Selection
0: R10 port
1: AVREF port
MAY.2008 Ver 1.46
MC80F0504/0604
Figure 9-2 R0 Port Register
In addition, Port R0 is multiplexed with various alternate
functions. The port selection register PSR0 (address 0F8H)
and PSR1 (address 0F9H) control the selection of alternate
functions such as event counter input 0 (EC0) and timer 0
output (T0O). When the alternate function is selected by
writing “1” in the corresponding bit of PSR0 or PSR1, port
pin can be used as a corresponding alternate features regardless of the direction register R0IO.
The ADC input channel 1~7 (AN1~AN7) can be selected
by setting ADCM(00EFH) register to enable the corresponding peripheral operation and select operation mode.
Port Pin
R00
R01
R02
R03
R04
R05
R06
R07
Alternate Function
AN1(ADC Input channel 1)
AN2 (ADC Input channel 2)
AN3 (ADC Input channel 3)
AN4 (ADC Input channel 4)
EC0 (Event counter input 0)
AN5 (ADC Input channel 5)
T0O (Timer output 0)
AN6 (ADC Input channel 6)
AN7 (ADC Input channel 7)
9.2 R1 and R1IO register
R1 is a 5-bit CMOS bidirectional I/O port (address 0C2H).
Each I/O pin can independently used as an input or an output through the R1IO register (address 0C3H). When R10
through R14 pins are used as input ports, an on-chip pullup resistor can be connected to them in 1-bit units with a
pull-up selection register 1 (PU1). Each I/O pin of R0 port
can be used to open drain output port by setting the corresponding bit of the open drain selection register 1 (R1OD).
In addition, Port R1 is multiplexed with various alternate
functions. The port selection register PSR0 (address 0F8H)
and PSR1 (address 0F9H) control the selection of alternate
functions such as Analog reference voltage input (AVREF),
external interrupt 0 (INT0), external interrupt 1 (INT1),
PWM 1 output (PWM1O) and buzzer output (BUZO).
When the alternate function is selected by writing “1” in
the corresponding bit of PSR0 or PSR1, port pin can be
used as a corresponding alternate features regardless of the
direction register R1IO.
MAY.2008 Ver 1.46
The ADC input channel 0 (AN0) can be selected by setting
ADCM(00EFH) register to enable ADC and select channel
0.
Port Pin
R10
R11
R12
Alternate Function
AN0 (ADC input channel 0)
AVREF (Analog reference voltage)
PWM1O (PWM 1 output)
INT0 (External Interrupt 0)
INT1 (External Interrupt 1)
BUZO (Buzzer output)
MC80F0504/0604
ADDRESS: 0C2H
RESET VALUE: ---0 0000B
R1 Data Register
R1
-
-
-
R14 R13 R12 R11 R10
ADDRESS: 0F8H
RESET VALUE: -0-0 --00B
PSR0
-
PWM1OE
-
EC0E
Input / Output data
R1 Direction Register
R1IO
-
-
ADDRESS: 0C3H
RESET VALUE: ---0 0000B
-
-
Port / PWM Selection
0: R10
1: PWM1O
ADDRESS: 0FDH
RESET VALUE: ---0 0000B
ADDRESS: 0F9H
RESET VALUE: ---- 0000B
-
PSR1
Pull-up Resister Selection
0: Disable
1: Enable
R1 Open Drain
Selection Register
R1OD
-
-
INT1E INT0E
Port / EC Selection
0: R04
1: EC0
Port Direction
0: Input
1: Output
PU1
-
Port / INT Selection
0: R11, R12
1: INT0, INT1
-
R1 Pull-up
Selection Register
-
ADDRESS: 0C9H
RESET VALUE: ---0 0000B
-
Open Drain Resister Selection
0: Disable
1: Enable
-
-
-
-
AVREFS BUZOE
-
T0OE
Port / TO Selection
0: R05
1: Timer0 output
R12/BUZO Selection
0: R12 port (Turn off buzzer)
1: BUZO port (Turn on buzzer)
R10 / AVREF Selection
0: R10 port
1: AVREF port
Figure 9-3 R1 Port Register
38
MAY.2008 Ver 1.46
MC80F0504/0604
9.3 R3 and R3IO register
R3 is a 5-bit CMOS bidirectional I/O port (address 0C6H).
Each I/O pin (except R35) can independently used as an input or an output through the R3IO register (address 0C7H).
R35 is an input only port. When R31 through R35 pins are
used as input ports, an on-chip pull-up resistor can be connected to them in 1-bit units with a pull-up selection register 3 (PU3). R31 through R34 pins can be used to open
drain output port by setting the corresponding bit of the
open drain selection register 3 (R3OD).
In addition, Port R3 is multiplexed with alternate functions. R31 and R32 can be used as ADC input channel 14
and 15 by setting ADCM to enable ADC and select channel 14 and 15.
Port Pin
R31
R32
ADDRESS: 0C6H
RESET VALUE: --00 000-B
R3 Data Register
R3
-
-
R35 R34 R33 R32 R31
-
Input / Output data
Input data
R3 Direction Register
R3IO
-
-
-
ADDRESS: 0C7H
RESET VALUE: ---0 000-B
-
Port Direction
0: Input
1: Output
Alternate Function
AN14 (ADC input channel 14)
AN15 (ADC input channel 15)
R3 Pull-up
Selection Register
PU3
-
-
R33, R34 and R35 is multiplexed with XIN, XOUT, and
RESET pin. These pins can be used as general I/O pins by
setting writing option described in "21. Device Configuration Area" .
ADDRESS: 0FFH
RESET VALUE: --00 000-B
-
Pull-up Resister Selection
0: Disable
1: Enable
R3 Open Drain
Selection Register
ADDRESS: 0CBH
RESET VALUE: ---0 000-B
R3OD
Open Drain Resister Selection
0: Disable
1: Enable
MAY.2008 Ver 1.46
MC80F0504/0604
10. CLOCK GENERATOR
ry is through a divide-by-two flip-flop, but minimum and
maximum high and low times specified on the data sheet
must be observed.
As shown in Figure 10-1 , the clock generator produces the
basic clock pulses which provide the system clock to be
supplied to the CPU and the peripheral hardware. It contains main-frequency clock oscillator. The system clock
operation can be easily obtained by attaching a crystal or a
ceramic resonator between the XIN and XOUT pin, respectively. The system clock can also be obtained from the external oscillator. In this case, it is necessary to input a
external clock signal to the XIN pin and open the XOUT pin.
There are no requirements on the duty cycle of the external
clock signal, since the input to the internal clocking circuit-
To the peripheral block, the clock among the not-divided
original clock, clocks divided by 1, 2, 4,..., up to 4096 can
be provided. Peripheral clock is enabled or disabled by
STOP instruction. The peripheral clock is controlled by
clock control register (CKCTLR). See "11. BASIC INTERVAL TIMER" on page 43 for details.
STOP
INOSC
SLEEP
INOSC
Main OSC
Stop
XIN
OSC
Circuit
fXIN
ONP
Circuit
Clock Pulse
Generator
(÷2)
fEX
XOUT
MUX
Internal
system clock
INCLK
Int OSC
Circuit
INOSC
PRESCALER
PS0
INOSC (IN4MCLK/IN2MCLK/
IN4MCLKXO/IN2MCLKXO)
÷1
7~3
PS1
÷2
PS2
÷4
PS3
÷8
PS4
÷16
PS5
÷32
PS6
÷64
PS7
÷128
PS8
÷256
PS9
PS10
PS11
PS12
÷512 ÷1024 ÷2048 ÷4096
2~0
Configuration Option Register (20FFH)
fEX (Hz)
Peripheral clock
PS0
PS1
PS2
PS3
PS4
PS5
PS6
PS7
PS8
PS9
PS10
PS11
PS12
Frequency
4M
2M
1M
500K
250K
125K
62.5K
31.25K
15.63K
7.183K
3.906K
1.953K
976
period
250n
500n
1u
2u
4u
8u
16u
32u
64u
128u
256u
512u
1.024m
4M
Figure 10-1 Block Diagram of Clock 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 .
C1
Xout
C2
Xin
Vss
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.
Figure 10-2 Oscillator Connections
40
MAY.2008 Ver 1.46
MC80F0504/0604
n addition, see Figure 10-3 for the layout of the crystal.
omitted for more cost saving. However, the characteristics
of external R only oscillation are more variable than external RC oscillation.
Vdd
XOUT
REXT
XIN
XIN
Cint ≈ 6pF
CEXT
fXIN÷4
Figure 10-3 Layout of Oscillator PCB circuit
Figure 10-5 RC 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-4 . 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
values of external components.
OPEN
External
Clock
Source
Xout
Xin
Vss
Figure 10-4 External Clock Connections
In addition, the MC80F0504/0604 has an ability for the external RC oscillated operation. It offers additional cost savings for timing insensitive applications. The RC
oscillator frequency is a function of the supply voltage, the
external resistor (REXT) and capacitor (CEXT) values, and
the operating temperature.
The user needs to take into account variation due to tolerance of external R and C components used.
Figure 10-5 shows how the RC combination is connected
to the MC80F0504/0604. External capacitor (CEXT) can be
MAY.2008 Ver 1.46
XOUT
VDD
REXT
XIN
CINT ≈ 6pF
fXIN÷4
XOUT
Figure 10-6 R Oscillator Connections
To use the RC oscillation, the CLK option of the configuration bits (20FFH) should be set to “EXRC or EXRCXO”.
The oscillator frequency, divided by 4, is output from the
Xout pin, and can be used for test purpose or to synchronize other logic.
In addition to external crystal/resonator and external RC/R
oscillation, the MC80F0504/0604 provides the internal
4MHz or 2MHz oscillation. The internal 4MHz/2MHz oscillation needs no external parts.
To use the internal 4MHz/2MHz oscillation, the CLK option of the configuration bits should be set to “IN4MCLK”,
“IN2MCLK”, “IN4MCLKXO” or “IN2MCLKXO”. For
detail description on the configuration bits, refer to "21.
Device Configuration Area"
MC80F0504/0604
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.
Source clock can be selected by lower 3 bits of CKCTLR.
The MC80F0504/0604 has one 8-bit Basic Interval Timer
that is free-run and can not stop. Block diagram is shown
in Figure 11-1 . In addition, the Basic Interval Timer generates the time base for watchdog timer counting. It also
provides a Basic interval timer interrupt (BITIF).
The 8-bit Basic interval timer register (BITR) is increased
every internal count pulse which is divided by prescaler.
Since prescaler has divided ratio by 8 to 1024, the count
rate is 1/8 to 1/1024 of the oscillator frequency. As the
count overflow from FFH to 00H, this overflow causes the
interrupt to be generated.
BITR and CKCTLR are located at same address, and address 0F2H is read as a BITR, and written to CKCTLR.
Note: All control bits of Basic interval timer are in CKCTLR reg-
The Basic Interval Timer is controlled by the clock control
register (CKCTLR) shown in Figure 11-2. If the RCWDT
bit is set to “1”, the clock source of the BITR is changed to
the internal RC oscillation.
ister 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.
Internal RC OSC
XIN PIN
Prescaler
RCWDT
÷8
÷16
÷32
÷64
÷128
÷256
÷512
÷1024
1
source
clock
8-bit up-counter
overflow
BITR
Basic Interval
Timer Interrupt
BITIF
0
MUX
[0F2H]
To Watchdog timer (WDTCK)
clear
Select Input clock 3
BCK[2:0]
[0F2H]
RCWDT
BTCL
CKCTLR
Basic Interval Timer
clock control register
Read
Internal bus line
Figure 11-1 Block Diagram of Basic Interval Timer
42
MAY.2008 Ver 1.46
MC80F0504/0604
CKCTLR
[2:0]
Interrupt (overflow) Period (ms)
@ fXIN = 8MHz
Source clock
fXIN÷8
fXIN÷16
fXIN÷32
fXIN÷64
fXIN÷128
fXIN÷256
fXIN÷512
fXIN÷1024
000
001
010
011
100
101
110
111
0.256
0.512
1.024
2.048
4.096
8.192
16.384
32.768
Table 11-1 Basic Interval Timer Interrupt Period
7
CKCTLR
6
-
ADRST
5
4
3
RCWDT WDTONBTCL
BTCL
2
1
0
BTS2 BTS1 BTS0
ADDRESS: 0F2H
INITIAL VALUE: 0-01 0111B
Basic Interval Timer source clock select
000: fXIN ÷ 8
001: fXIN ÷ 16
010: fXIN ÷ 32
011: fXIN ÷ 64
100: fXIN ÷ 128
101: fXIN ÷ 256
110: fXIN ÷ 512
111: fXIN ÷ 1024
Caution:
Both register are in same address,
when write, to be a CKCTLR,
when read, to be a BITR.
Clear bit
0: Normal operation (free-run)
1: Clear 8-bit counter (BITR) to “0”. This bit becomes 0 automatically
after one machine cycle, and starts counting.
Watchdog timer Enable bit
0: Operate as 7-bit Timer
1: Enable Watchdog Timer operation
See the section “Watchdog Timer”.
RC Watchdog Selection bit
0: Disable Internal RC Watchdog Timer
1: Enable Internal RC Watchdog Timer
Address Trap Reset Selection
0: Enable Address Fail Reset
1: Disable Address Fail Reset
7
6
BITR
5
4
3
BTCL
2
1
0
ADDRESS: 0F2H
INITIAL VALUE: Undefined
8-BIT FREE-RUN BINARY COUNTER
Figure 11-2 BITR: Basic Interval Timer Mode Register
Example 1:
Example 2:
Interrupt request flag is generated every 8.192ms at 4MHz.
Interrupt request flag is generated every 8.192ms at 8MHz.
:
LDM
SET1
EI
:
CKCTLR,#1BH
BITE
MAY.2008 Ver 1.46
:
LDM
SET1
EI
:
CKCTLR,#1CH
BITE
MC80F0504/0604
12. WATCHDOG TIMER
The watchdog timer rapidly detects the CPU malfunction
such as endless looping caused by noise or the like, and resumes the CPU to the normal state. The watchdog timer
signal for detecting malfunction can be selected either a reset CPU or a interrupt request.
The RC oscillated watchdog timer is activated by setting
the bit RCWDT as shown below.
LDM
LDM
LDM
STOP
NOP
NOP
:
When the watchdog timer is not being used for malfunction detection, it can be used as a timer to generate an interrupt at fixed intervals.
The watchdog timer has two types of clock source. The
first type is an on-chip RC oscillator which does not require any external components. This RC oscillator is separate from the external oscillator of the XIN pin. It means
that the watchdog timer will run, even if the clock on the
XIN pin of the device has been stopped, for example, by entering the STOP mode. The other type is a prescaled system clock.
CKCTLR,#3FH; enable the RC-OSC WDT
WDTR,#0FFH ; set the WDT period
SSCR, #5AH ;ready for STOP mode
; enter the STOP mode
; RC-OSC WDT running
The RC-WDT oscillation period is vary with temperature,
VDD and process variations from part to part (approximately, 33~100uS). The following equation shows the
RCWDT oscillated watchdog timer time-out.
TRCWDT=CLKRCWDT×28×WDTR + (CLKRCWDT×28)/2
where, CLKRCWDT = 33~100uS
The watchdog timer consists of 7-bit binary counter and
the watchdog timer data register. When the value of 7-bit
binary counter is equal to the lower 7 bits of WDTR, the
interrupt request flag is generated. This can be used as
Watchdog timer interrupt or reset the CPU in accordance
with the bit WDTON.
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+1) × Interval of BIT
Note: Because the watchdog timer counter is enabled after clearing Basic Interval Timer, after the bit WDTON set to "1", maximum
error of timer is depend on prescaler ratio of Basic Interval Timer.
The 7-bit binary counter is cleared by setting WDTCL(bit7 of
WDTR) and the WDTCL is cleared automatically after 1 machine
cycle.
clear
BASIC INTERVAL TIMER
OVERFLOW
Watchdog
Counter (7-bit)
Count
source
clear
“0”
comparator
WDTCL
WDTON in CKCTLR [0F2H]
7-bit compare data
WDTIF
7
WDTR
to reset CPU
“1”
enable
Watchdog Timer interrupt
Watchdog Timer
Register
[0F4H]
Internal bus line
Figure 12-1 Block Diagram of Watchdog Timer
44
MAY.2008 Ver 1.46
MC80F0504/0604
Watchdog Timer Control
er output will become active at the rising overflow from
the binary counters unless the binary counter is cleared. At
this time, when WDTON=1, a reset is generated, which
drives the RESET pin to low to reset the internal hardware.
When WDTON=0, a watchdog timer interrupt (WDTIF) is
generated. The WDTON bit is in register CLKCTLR.
Figure 12-2 shows the watchdog timer control register.
The watchdog timer is automatically disabled after reset.
The CPU malfunction is detected during setting of the detection time, selecting of output, and clearing of the binary
counter. Clearing the binary counter is repeated within the
detection time.
The watchdog timer temporarily stops counting in the
STOP mode, and when the STOP mode is released, it automatically restarts (continues counting).
If the malfunction occurs for any cause, the watchdog timW
7
WDTR
W
6
W
5
W
4
W
3
W
2
W
1
W
0
ADDRESS: 0F4H
INITIAL VALUE: 0111 1111B
WDTCL
7-bit compare data
Clear count flag
0: Free-run count
1: When the WDTCL is set to “1”, binary counter
is cleared to “0”. And the WDTCL becomes “0” automatically
after one machine cycle. Counter count up again.
Figure 12-2 WDTR: Watchdog Timer Control Register
Example: Sets the watchdog timer detection time to 1 sec.
Within WDT
detection time
Within WDT
detection time
at 4.194304MHz
LDM
LDM
CKCTLR,#3FH
WDTR,#08FH
;Select 1/1024 clock source, WDTON ← 1, Clear Counter
LDM
:
:
:
:
LDM
:
:
:
:
LDM
WDTR,#08FH
;Clear counter
WDTR,#08FH
;Clear counter
WDTR,#08FH
;Clear counter
Enable and Disable Watchdog
Watchdog timer is enabled by setting WDTON (bit 4 in
CKCTLR) to “1”. WDTON is initialized to “0” during reset and it should be set to “1” to operate after reset is released.
Example: Enables watchdog timer for Reset
:
LDM
:
:
CKCTLR,#xxx1_xxxxB;WDTON ← 1
The watchdog timer is disabled by clearing bit 4 (WDTON) of CKCTLR. The watchdog timer is halted in STOP
mode and restarts automatically after STOP mode is released.
MAY.2008 Ver 1.46
Watchdog Timer Interrupt
The watchdog timer can be also used as a simple 7-bit timer by clearing bit4 of CKCTLR to “0”. The interval of
watchdog timer interrupt is decided by Basic Interval Timer. Interval equation is shown as below.
TWDT = (WDTR+1) × Interval of BIT
The stack pointer (SP) should be initialized before using
the watchdog timer output as an interrupt source.
Example: 7-bit timer interrupt set up.
LDM
LDM
CKCTLR,#xxx0_xxxxB;WDTON ←0
WDTR,#8FH
;WDTCL ←1
MC80F0504/0604
:
Source clock
BIT overflow
Binary-counter
2
1
3
0
1
2
3
Counter
Clear
WDTR
0
Counter
Clear
3
n
Match
Detect
WDTIF interrupt
WDTR ← “1000_0011B”
WDT reset
reset
Figure 12-3 Watchdog timer Timing
If the watchdog timer output becomes active, a reset is generated, which drives the RESET pin low to reset the internal hardware.
46
The main clock oscillator also turns on when a watchdog
timer reset is generated in sub clock mode.
MAY.2008 Ver 1.46
MC80F0504/0604
13. TIMER/EVENT COUNTER
ing external input pin, EC0.
The MC80F0504/0604 has two Timer/Counter. Each module can generate an interrupt to indicate that an event has
occurred (i.e. timer match).
In addition the “capture” function, the register is increased
in response external or internal clock sources same with
timer or counter function. When external clock edge input,
the count register is captured into Timer data register correspondingly. When external clock edge input, the count
register is captured into capture data register CDRx.
Timer 0 and Timer 1 are can be used either two 8-bit Timer/Counter or one 16-bit Timer/Counter with combine
them. Also Timer 2 and Timer 3 are same.
In the “timer” function, the register is increased every internal clock input. Thus, one can think of it as counting internal clock input. Since a least clock consists of 2 and
most clock consists of 2048 oscillator periods, the count
rate is 1/2 to 1/2048 of the oscillator frequency.
Timer 0 and Timer 1 is shared with "PWM" function and
"Compare output" function. It has six operating modes: "8bit timer/counter", "16-bit timer/counter", "8-bit capture",
"16-bit capture", "8-bit compare output", and "10-bit
PWM" which are selected by bit in Timer mode register
TM0 and TM1 as shown in Table 13-1, Figure 13-1 .
In the “counter” function, the register is increased in response to a 0-to-1 (rising edge) transition at its correspond-
16BIT
CAP0
CAP1
PWM1E
T0CK
[2:0]
T1CK
[1:0]
PWM1O
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 (internal clock)
8-bit Compare Output
0
X
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
1
0
XXX
11
0
16-bit Capture (internal clock)
TIMER 0
Table 13-1 Operation Modes of Timer 0, 1
1. X means the value of “0” or “1” corresponds to user operation.
MAY.2008 Ver 1.46
TIMER 1
MC80F0504/0604
R/W
5
TM0
TM1
-
-
R/W
4
R/W
3
R/W
2
R/W
1
R/W
0
CAP0 T0CK2 T0CK1
BTCL T0CK0 T0CN
T0ST
ADDRESS: 0D0H
INITIAL VALUE: --00 0000B
Bit Name
Bit Position
Description
CAP0
TM0.5
0: Timer/Counter mode
1: Capture mode selection flag
T0CK2
T0CK1
T0CK0
TM0.4
TM0.3
TM0.2
000: 8-bit Timer, Clock source is fXIN ÷ 2
001: 8-bit Timer, Clock source is fXIN ÷ 4
010: 8-bit Timer, Clock source is fXIN ÷ 8
011: 8-bit Timer, Clock source is fXIN ÷ 32
100: 8-bit Timer, Clock source is fXIN ÷ 128
101: 8-bit Timer, Clock source is fXIN ÷ 512
110: 8-bit Timer, Clock source is fXIN ÷ 2048
111: EC0 (External clock)
T0CN
TM0.1
0: Timer count pause
1: Timer count start
T0ST
TM0.0
0: When cleared, stop the counting.
1: When set, Timer 0 Count Register is cleared and start again.
R/W
7
R/W
6
R/W
5
R/W
4
R/W
3
R/W
2
R/W
1
R/W
0
POL
16BIT PWM1E CAP1 T1CK1
BTCL T1CK0 T1CN T1ST
ADDRESS: 0D2H
INITIAL VALUE: 00H
Bit Name
Bit Position
Description
POL
TM1.7
0: PWM Duty Active Low
1: PWM Duty Active High
16BIT
TM1.6
0: 8-bit Mode
1: 16-bit Mode
PWM1E
TM1.5
0: Disable PWM
1: Enable PWM
CAP1
TM1.4
0: Timer/Counter mode
1: Capture mode selection flag
T1CK1
T1CK0
TM1.3
TM1.2
00: 8-bit Timer, Clock source is fXIN
01: 8-bit Timer, Clock source is fXIN ÷ 2
10: 8-bit Timer, Clock source is fXIN ÷ 8
11: 8-bit Timer, Clock source is Using the Timer 0 Clock
T1CN
TM1.1
0: Timer count pause
1: Timer count start
T1ST
TM1.0
0: When cleared, stop the counting.
1: When set, Timer 0 Count Register is cleared and start again.
R/W R/W R/W R/W R/W R/W R/W R/W
7
6
5
4
3
2
1
0
TDR0
R/W R/W R/W R/W R/W R/W R/W R/W
7
6
5
4
3
2
1
0
TDR1
ADDRESS: 0D1H
INITIAL VALUE: 0FFH
ADDRESS: 0D3H
INITIAL VALUE: 0FFH
Read: Count value read
Write: Compare data write
Figure 13-1 TM0, TM1 Registers
48
MAY.2008 Ver 1.46
MC80F0504/0604
13.1 8-bit Timer / Counter Mode
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 1,
2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048 or external
clock (selected by control bits TxCK0, TxCK1, TxCK2 of
register TMx).
The MC80F0504/0604 has two 8-bit Timer/Counters,
Timer 0 and Timer 1, which are shown in Figure 13-2 .
The “timer” or “counter” function is selected by control
registers TM0, TM1 as shown in Figure 13-1 . To use as an
8-bit timer/counter mode, bit CAP0 or CAP1 of TMx
should be cleared to “0” and 16BIT and PWM1E of TM1
should be cleared to "0" (Figure 13-2 ). These timers have
TM0
7
6
-
-
-
-
5
4
3
2
1
0
ADDRESS: 0D0H
INITIAL VALUE: --00 0000B
CAP0 T0CK2 T0CK1
BTCL T0CK0 T0CN T0ST
0
X
X
X
X
X
X means don’t care
7
TM1
6
5
4
3
2
1
0
POL 16BIT PWM1E CAP1 T1CK1
BTCL T1CK0 T1CN T1ST
X
0
0
0
X
X
X
ADDRESS: 0D2H
INITIAL VALUE: 00H
X
X means don’t care
T0CK[2:0]
EDGE
DETECTOR
EC0 PIN
111
T0ST
÷2
000
XIN PIN
Prescaler
÷4
0: Stop
1: Clear and start
001
÷8
010
÷ 32
T0 (8-bit)
clear
011
÷ 128
100
÷ 512
÷ 2048
101
T0CN
T0IF
Comparator
TIMER 0
INTERRUPT
110
MUX
TIMER 0
TDR0 (8-bit)
F/F
R05 / T0O
T1CK[1:0]
T1ST
÷1
÷2
÷8
0: Stop
1: Clear and start
11
00
T1 (8-bit)
01
clear
10
T1CN
T1IF
MUX
Comparator
TIMER 1
TDR1 (8-bit)
Figure 13-2 8-bit Timer/Counter 0, 1
MAY.2008 Ver 1.46
TIMER 1
INTERRUPT
MC80F0504/0604
Example 1:
ratio option of 2, 4, 8, 32, 128, 512, 2048 selected by control bits T0CK[2:0] of register TM0 or 1, 2, 8 selected by
control bits T1CK[1:0] of register TM1. In the Timer 0,
timer register T0 increases from 00 H until it matches
TDR0 and then reset to 00H. The match output of Timer 0
generates Timer 0 interrupt (latched in T0IF bit).
Timer0 = 2ms 8-bit timer mode at 4MHz
Timer1 = 0.5ms 8-bit timer mode at 4MHz
LDM
LDM
LDM
LDM
SET1
SET1
EI
TDR0,#249
TDR1,#249
TM0,#0000_1111B
TM1,#0000_1011B
T0E
T1E
Example 2:
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 EC0 of the Port Selection Register
(PSR0.4) is set to "1". The Timer 0 can be used as a counter
by pin EC0 input, but Timer 1 can not.
Timer0 = 8-bit event counter mode
Timer1 = 0.5ms 8-bit timer mode at 4MHz
13.1.1 8-bit Timer Mode
LDM
LDM
LDM
LDM
SET1
SET1
EI
In the timer mode, the internal clock is used for counting
up. Thus, you can think of it as counting internal clock input. The contents of TDRn are compared with the contents
of up-counter, Tn. If match is found, a timer n interrupt
(TnIF) is generated and the up-counter is cleared to 0.
Counting up is resumed after the up-counter is cleared.
TDR0,#249
TDR1,#249
TM0,#0001_1111B
TM1,#0000_1011B
T0E
T1E
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
As the value of TDRn is changeable by software, time interval is set as you want.
Start count
~
~
Source clock
~
~
Up-counter
0
1
2
n-2
3
n-1
n
0
1
2
3
4
~
~
Match
Detect
Counter
Clear
~
~
T1IF interrupt
n
~
~
TDR1
Figure 13-3 Timer Mode Timing Chart
50
MAY.2008 Ver 1.46
MC80F0504/0604
Example: Make 1ms interrupt using by Timer0 at 4MHz
LDM
LDM
SET1
EI
TM0,#0FH
TDR0,#124
T0E
;
;
;
;
divide by 32
8us x (124+1)= 1ms
Enable Timer 0 Interrupt
Enable Master Interrupt
When
TM0 = 0000 1111B (8-bit Timer mode, Prescaler divide ratio = 32)
TDR0 = 124D = 7CH
fXIN = 4 MHz
1
INTERRUPT PERIOD =
× 32 × (124+1) = 1 ms
4 × 106 Hz
TDR0
MATCH
(TDR0 = T0)
Count Pulse
Period
7C
7C
8 μs
6
~~
~~
up
-c
ou
nt
~~
7B
7A
5
4
3
2
1
0
0
TIME
Interrupt period
= 8 μs x (124+1)
Timer 0 (T0IF)
Interrupt
Occur interrupt
Occur interrupt
Occur interrupt
Figure 13-4 Timer Count Example
13.1.2 8-bit Event Counter Mode
In order to use event counter function, the bit 4 of the Port
Selection Register PSR0(address 0F8H) is required to be
set to “1”.
In this mode, counting up is started by an external trigger.
This trigger means rising edge of the EC0 pin input. Source
clock is used as an internal clock selected with timer mode
register TM0. The contents of timer data register TDR0 are
compared with the contents of the up-counter T1. If a
match is found, an timer interrupt request flag T0IF is generated, and the counter is cleared to “0”. The counter is restart and count up continuously by every rising edge of the
EC0 pin input. The maximum frequency applied to the
EC0 pin is fXIN/2 [Hz].
After reset, the value of timer data register TDRn is initialized to "0", The interval period of Timer is calculated as
below equation.
1
Period (sec) = ----------- × 2 × Divide Ratio × (TDRn+1)
f XIN
~
~
Start count
EC0 pin input
~
~
1
0
2
~
~
Up-counter
n-1
n
0
~
~
~
~
T0IF interrupt
n
~
~
TDR0
Figure 13-5 Event Counter Mode Timing Chart
MAY.2008 Ver 1.46
1
2
MC80F0504/0604
TDR1
disable
~~
clear & start
enable
up
-c
o
un
t
stop
~~
TIME
Timer 1 (T1IF)
Interrupt
Occur interrupt
Occur interrupt
T1ST
Start & Stop
T1ST = 1
T1ST = 0
T1CN
Control count
T1CN = 1
T1CN = 0
Figure 13-6 Count Operation of Timer / Event counter
52
MAY.2008 Ver 1.46
MC80F0504/0604
13.2 16-bit Timer / Counter Mode
The clock source of the Timer 0 is selected either internal
or external clock by bit T0CK[2:0]. In 16-bit mode, the bits
T1CK[1:0] and 16BIT of TM1 should be set to "1" respectively as shown in Figure 13-7 .
The Timer register is being run with all 16 bits. A 16-bit
timer/counter register T0, T1 increments from 0000H until
it matches TDR0, TDR1 and then resets to 0000H. The
match output generates Timer 0 interrupt.
TM0
7
6
-
-
-
-
5
4
3
2
1
0
ADDRESS: 0D0H
INITIAL VALUE: --00 0000B
CAP0 T0CK2 T0CK1
BTCL T0CK0 T0CN T0ST
0
X
X
X
X
X
X means don’t care
7
TM1
6
5
4
3
2
1
0
ADDRESS: 0D2H
INITIAL VALUE: 00H
POL 16BIT PWM1E CAP1 T1CK1
BTCL T1CK0 T1CN T1ST
X
1
0
0
1
1
X
X
X means don’t care
T0CK[2:0]
EDGE
DETECTOR
EC0 PIN
111
÷2
÷4
Prescaler
XIN PIN
÷8
÷ 32
÷ 128
÷ 512
÷ 2048
T0ST
0: Stop
1: Clear and start
000
001
T1 + T0
(16-bit)
010
clear
011
100
101
T0CN
T0IF
Comparator
110
TIMER 0
INTERRUPT
(Not Timer 1 interrupt)
TDR1 + TDR0
(16-bit)
MUX
Higher byte Lower byte
COMPARE DATA
TIMER 0 + TIMER 1 → TIMER 0 (16-bit)
Figure 13-7 16-bit Timer/Counter for Timer 0, 1
13.3 8-bit (16-bit) Compare Output
TheMC80F0504/0604 has Timer Compare Output function. To pulse out, the timer match can goes to port pin (
T0O) as shown in Figure 13-2 . Thus, pulse out is generated by the timer match. These operation is implemented to
pin, R05/AN5//T0O.
In this mode, the bit T0OE bit of Port Selection register1
(PSR1.0) should be set to "1". This pin output the signal
MAY.2008 Ver 1.46
having a 50 : 50 duty square wave, and output frequency is
same as below equation.
Oscillation Frequency
f COMP = ------------------------------------------------------------------------------------------2 × Prescaler Value × ( TDR + 1 )
MC80F0504/0604
13.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 13-8 .
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).
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 13-10 , 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 ob-
54
tained 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.
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 “16.4 External Interrupt” on page 73. In addition, the transition at INTn pin
generate an interrupt.
Note: The CDRn and TDRn are in same address.In the capture
mode, reading operation is read the CDRn, not TDRn because
path is opened to the CDRn.
MAY.2008 Ver 1.46
MC80F0504/0604
TM0
7
6
-
-
-
-
5
4
3
2
1
0
ADDRESS: 0D0H
INITIAL VALUE: --00 0000B
CAP0 T0CK2 T0CK1
BTCL T0CK0 T0CN T0ST
1
X
X
X
X
X
X means don’t care
7
TM1
6
5
4
3
2
1
0
ADDRESS: 0D2H
INITIAL VALUE: 00H
POL 16BIT PWM1E CAP1 T1CK1
BTCL T1CK0 T1CN T1ST
X
0
0
1
X
X
X
X
X means don’t care
T0CK[2:0]
Edge
Detector
EC0 PIN
111
T0ST
÷2
000
÷4
Prescaler
XIN PIN
0: Stop
1: Clear and start
001
÷8
T0 (8-bit)
010
÷ 32
011
÷ 128
100
÷ 512
÷ 2048
101
clear
T0CN
Capture
110
CDR0 (8-bit)
MUX
IEDS[1:0]
“01”
“10”
INT0 PIN
INT0IF
T1CK[1:0]
INT0
INTERRUPT
“11”
T1ST
÷1
÷2
÷8
0: Stop
1: Clear and start
11
00
T1 (8-bit)
01
clear
10
MUX
T1CN
Capture
CDR1 (8-bit)
IEDS[3:2]
“01”
INT1 PIN
“10”
INT1IF
“11”
Figure 13-8 8-bit Capture Mode for Timer 0, 1
MAY.2008 Ver 1.46
INT1
INTERRUPT
MC80F0504/0604
This value is loaded to CDR0
n
T0
n-1
co
un
t
~~
~~
9
up
-
8
7
6
5
4
~~
3
2
1
0
TIME
Ext. INT0 Pin
Interrupt Request
( INT0IF )
Interrupt Interval Period
Ext. INT0 Pin
Interrupt Request
( INT0IF )
20nS
Capture
( Timer Stop )
5nS
Delay
Clear & Start
Figure 13-9 Input Capture Operation of Timer 0 Capture mode
Ext. INT0 Pin
Interrupt Request
( INT0IF )
Interrupt Interval Period=01H+FFH +01H+FFH +01H+13H=214H
Interrupt Request
( T0IF )
FFH
FFH
T0
13H
00H
00H
Figure 13-10 Excess Timer Overflow in Capture Mode
56
MAY.2008 Ver 1.46
MC80F0504/0604
13.5 16-bit Capture Mode
clock by bit T0CK[2:0]. In 16-bit mode, the bits T1CK1,
T1CK0, CAP1 and 16BIT of TM1 should be set to "1" respectively as shown in Figure 13-11 .
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
TM0
7
6
-
-
-
-
5
4
3
2
1
0
ADDRESS: 0D0H
INITIAL VALUE: --00 0000B
CAP0 T0CK2 T0CK1
BTCL T0CK0 T0CN T0ST
1
X
X
X
X
X
X means don’t care
7
TM1
6
5
4
3
2
1
0
ADDRESS: 0D2H
INITIAL VALUE: 00H
POL 16BIT PWM1E CAP1 T1CK1
BTCL T1CK0 T1CN T1ST
X
1
1
0
1
1
X
X
X means don’t care
T0CK[2:0]
Edge
Detector
EC0 PIN
111
T0ST
÷2
÷4
Prescaler
XIN PIN
÷8
÷ 32
÷ 128
÷ 512
÷ 2048
0: Stop
1: Clear and start
000
001
TDR1 + TDR0
(16-bit)
010
011
clear
100
T0CN
101
Capture
110
CDR1 + CDR0
(16-bit)
MUX
IEDS[1:0]
Higher byte Lower byte
CAPTURE DATA
“01”
“10”
INT0 PIN
INT0IF
INT0
INTERRUPT
“11”
Figure 13-11 16-bit Capture Mode of Timer 0, 1
Example 1:
Timer0 = 16-bit timer mode, 0.5s at 4MHz
LDM
LDM
LDM
LDM
SET1
EI
:
:
TM0,#0000_1111B;8uS
TM1,#0100_1100B;16bit Mode
TDR0,#<62499
;8uS X 62500
TDR1,#>62499
;=0.5s
T0E
Example 2:
Timer0 = 16-bit event counter mode
LDM
LDM
LDM
LDM
PSR0,#0001_0000B;EC0 Set
TM0,#0001_1111B;Counter Mode
TM1,#0100_1100B;16bit Mode
TDR0,#<0FFH
;
MAY.2008 Ver 1.46
LDM
SET1
EI
:
:
TDR1,#>0FFH
T0E
;
Example 3:
Timer0 = 16-bit capture mode
LDM
LDM
LDM
LDM
LDM
LDM
SET1
EI
:
:
PSR0,#0000_0001B;INT0 set
TM0,#0010_1111B;Capture Mode
TM1,#0100_1100B;16bit Mode
TDR0,#<0FFH
;
TDR1,#>0FFH
;
IEDS,#01H;Falling Edge
T0E
MC80F0504/0604
13.6 PWM Mode
The MC80F0504/0604 has high speed PWM (Pulse Width
Modulation) functions which shared with Timer1.
In PWM mode, R10 / PWM1O pin output up to a 10-bit
resolution PWM output. This pin should be configured as
a PWM output by setting "1" bit PWM1OE in PSR0 register.
The period of the PWM1 output is determined by the
T1PPR (T1 PWM Period Register) and T1PWHR[3:2]
(bit3,2 of T1 PWM High Register) and the duty of the
PWM output is determined by the T1PDR (T1 PWM Duty
Register) and T3PWHR[1:0] (bit1,0 of T1 PWM High
Register).
The user writes the lower 8-bit period value to the T1PPR
and the higher 2-bit period value to the T1PWHR[3:2].
And writes duty value to the T1PDR and the
T1PWHR[1:0] same way.
The T1PDR is configured as a double buffering for glitchless PWM output. In Figure 13-13 , 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)
PWM1 Period = [PWM1HR[3:2]T1PPR + 1] X
Source Clock
PWM1 Duty = [PWM1HR[1:0]T1PDR + 1] X
Source Clock
reduced resolution.
Frequency
Resolution
T1CK[1:0]
= 00(250nS)
T1CK[1:0]
= 01(500nS)
T1CK[1:0]
= 10(2uS)
10-bit
3.9kHz
0.98kHz
0.49kHz
9-bit
7.8kHz
1.95kHz
0.97kHz
8-bit
15.6kHz
3.90kHz
1.95kHz
7-bit
31.2kHz
7.81kHz
3.90kHz
Table 13-2 PWM Frequency vs. Resolution at 4MHz
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).
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 13-14 . As it were, the absolute duty time is not
changed in varying frequency. But the changed period value must greater than the duty value.
Note: If changing the Timer1 to PWM function, it should be stop
The relation of frequency and resolution is in inverse proportion. Table 13-2 shows the relation of PWM frequency
vs. resolution.
If it needed more higher frequency of PWM, it should be
58
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.
Ex) Sample Program @4MHz 2uS
LDM
LDM
LDM
LDM
LDM
TM1,#1010_1000b ; Set Clock & PWM1E
T1PPR,#199
; Period :400uS=2uSX(199+1)
T1PDR,#99
; Duty:200uS=2uSX(99+1)
PWM1HR,00H
TM1,#1010_1011b ; Start timer1
MAY.2008 Ver 1.46
MC80F0504/0604
R/W
7
TM1
R/W
6
R/W
5
R/W
4
R/W
3
R/W
2
R/W
1
R/W
0
ADDRESS: 0D2H
INITIAL VALUE: 00H
POL 16BIT PWM1E CAP1 T1CK1
BTCL T1CK0 T1CN T1ST
T1PWHR
X
0
1
0
X
X
X
X
7
6
5
4
W
3
W
2
W
1
W
0
-
-
-
-
-
-
-
-
X: The value "0" or "1" corresponding your operation.
ADDRESS: 0D5H
INITIAL VALUE: ---- 0000B
T1PWHR3
BTCL T1PWHR2 T1PWHR1 T1PWHR0
X
X
X
Bit Manipulation Not Available
X
X:The value "0" or "1" corresponding your operation.
Period High
W
7
W
6
W
5
W
4
T1PPR
W
3
Duty High
W
2
W
1
W
0
R/W
2
R/W
1
R/W
0
ADDRESS: 0D3H
INITIAL VALUE: 0FFH
BTCL
R/W
7
R/W
6
R/W
5
R/W
4
T1PDR
R/W
3
ADDRESS: 0D4H
INITIAL VALUE: 00H
BTCL
T1PWHR[3:2]
T0 clock source
[T0CK]
T1CK[1:0]
0 : Stop
1 : Clear and Start
Prescaler
XIN PIN
÷2
÷8
Clear
00
T1(8-bit)
10
POL
T1CN
Comparator
Slave
T1PDR(8-bit)
T1PWHR[1:0]
Master
T1PDR(8-bit)
Figure 13-12 PWM1 Mode
MAY.2008 Ver 1.46
R10 / PWM1O PIN
R
2-bit
01
MUX
S Q
Comparator
11
÷1
PWM1OE
[PSR0.6]
T1PPR(8-bit)
T1ST
MC80F0504/0604
~
~
~
~
Source
clock
01
02
03
04
PWM1E
7E
7F
~
~ ~
~
00
~
~ ~
~ ~
~
T1
80
00
3FF
01
02
~
~
T1ST
~
~
T1CN
~
~
~
~
~
~
PWM1O
[POL=1]
~
~
PWM1O
[POL=0]
Duty Cycle [ (1+7Fh) x 250nS = 32uS ]
Period Cycle [ (3FFh+1) x 250nS = 256uS, 3.9KHz ]
T1CK[1:0] = 00 ( XIN )
T1PWHR = 0CH
Period
T1PWHR3
1
T1PWHR2
T1PPR (8-bit)
1
FFH
T1PWHR0
T1PDR (8-bit)
0
7FH
T1PPR = FFH
T1PDR = 7FH
Duty
T1PWHR1
0
Figure 13-13 Example of PWM1 at 4MHz
T1CK[1:0] = 10 ( 1us )
PWM1HR = 00H
T1PPR = 0DH
Write T1PPR to 09H
T1PDR = 04H
Source
clock
T1
00 01 02 03 04 05 06 07 08
09 0A 0B 0C 0D
00 01 02 03 04 05 06 07 08 09
00 01 02 03
04
PWM1O
POL=1
Duty Cycle
[ (04h+1) x 2uS = 10uS ]
Period Cycle [ (1+0Dh) x 2uS = 28uS, 35.5KHz ]
Duty Cycle
[ (04h+1) x 2uS = 10uS ]
Duty Cycle
[ (04h+1) x 2uS = 10uS ]
Period Cycle [ (1+09h) x 2uS = 20uS, 50KHz ]
Figure 13-14 Example of Changing the PWM1 Period in Absolute Duty Cycle (@4MHz)
60
MAY.2008 Ver 1.46
MC80F0504/0604
14. ANALOG TO DIGITAL CONVERTER
The analog-to-digital converter (A/D) allows conversion
of an analog input signal to a corresponding 10-bit digital
value. The A/D module has ten (eight for MC80F0504) 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 PSR1 register. If external
analog reference AVref is selected, the analog input channel 0 (AN0) should not be selected to use. Because this pin
is used to an analog reference of A/D converter.
The A/D module has three registers which are the control
register ADCM and A/D result register ADCRH and ADCRL. The ADCRH[7:6] is used as ADC clock source selection bits too. The register ADCM, shown in Figure 144 , controls the operation of the A/D converter module. The
port pins can be configured as analog inputs or digital I/O.
It is selected for the corresponding channel to be converted
by setting ADS[3:0]. The A/D port is set to analog input
port by ADEN and ADS[3:0] regardless of port I/O direction register. The port unselected by ADS[3:0] operates as
normal port.
Enable A/D Converter
How to Use A/D Converter
The processing of conversion is start when the start bit
ADST is set to “1”. After one cycle, it is cleared by hardware. The register ADCRH and ADCRL contains the results of the A/D conversion. When the conversion is
completed, the result is loaded into the ADCRH and ADCRL, the A/D conversion status bit ADSF is set to “1”, and
the A/D interrupt flag ADCIF is set. See Figure 14-1 for
operation flow.
The block diagram of the A/D module is shown in Figure
14-3 . 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 13 times of
conversion source clock. The conversion source clock
should selected for the conversion time being more than
25μs.
A/D Converter Cautions
(1) Input range of AN0 ~ AN7, AN14 and AN15
The input voltage of A/D input pins 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 determinate. The conversion values of
the other channels may also be affected.
(2) Noise countermeasures
In order to maintain 10-bit resolution, attention must be
paid to noise on pins VDD (or AVref) and analog input pins
(AN0 ~ AN7, AN14, AN15). Since the effect increases in
proportion to the output impedance of the analog input
source, it is recommended in some cases that a capacitor be
connected externally as shown in Figure 14-2 in order to
reduce noise. The capacitance is user-selectable and appropriately determined according to the target system.
A/D Input Channel Select
Conversion Source Clock Select
A/D Start (ADST = 1)
Analog
Input
NOP
0~1000pF
User Selectable
AN0~AN7
AN14, AN15
ADSF = 1
NO
YES
Read ADCR
Figure 14-1 A/D Converter Operation Flow
MAY.2008 Ver 1.46
Figure 14-2 Analog Input Pin Connecting Capacitor
MC80F0504/0604
(3) I/O operation
the pin undergoing A/D conversion.
The analog input pins AN0 ~ AN7,AN14 and AN15 also
have function as input/output port pins. When A/D conversion is performed with any pin, be sure not to execute a
PORT input instruction with the selected pin while conversion is in progress, as this may reduce the conversion resolution.
(4) AVDD pin input impedance
A series resistor string of approximately 5KΩ is connected
between the AVREF pin and the VSS pin. Therefore, if the
output impedance of the analog power 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 analog supply voltage error
Also, if digital pulses are applied to a pin adjacent to the
pin in the process of A/D conversion, the expected A/D
conversion value may not be obtainable due to coupling
noise. Therefore, avoid applying pulses to pins adjacent to
AVREFS (PSR1.3)
ADEN
0
VDD
Resistor Ladder Circuit
1
AN0 / AVREF
AN1
Successive
MUX
Sample & Hold
ADC
INTERRUPT
ADCIF
Approximation
Circuit
AN7
AN14
ADC8
AN15
0
1
10-bit Mode
8-bit Mode
ADS[3:0] (ADCM[5:2])
98
98
ADCR
(10-bit)
10-bit ADCR
32
10-bit ADCR
0 0
ADCRH
ADCRL (8-bit)
1 0
ADC Result Register
ADCRH
ADCRL (8-bit)
1 0
ADC Result Register
Figure 14-3 A/D Block Diagram
62
MAY.2008 Ver 1.46
MC80F0504/0604
R/W R/W R/W
R
3
2
1
0
ADEN ADCK ADS3 ADS2 BTCL
ADS1 ADS0 ADST ADSF
R/W
7
ADCM
R/W
6
R/W
5
R/W
4
ADDRESS: 0EFH
INITIAL VALUE: 0000 0001B
A/D status bit
0: A/D conversion is in progress
1: A/D conversion is completed
A/D start bit
Setting this bit starts an A/D conversion.
After one cycle, bit is cleared to “0” by hardware.
Analog input channel select
0000: Channel 0 (AN0) 0110: Channel 6 (AN6)
0001: Channel 1 (AN1) 0111: Channel 7 (AN7)
0010: Channel 2 (AN2) 1000 ~ 1101: Not available
0011: Channel 3 (AN3) 1110: Channel 14 (AN14)
0100: Channel 4 (AN4) 1111: Channel 15 (AN15)
0101: Channel 5 (AN5)
A/D converter Clock Source Divide Ratio Selection bit
0: Clock Source fPS
1: Clock Source fPS ÷ 2
A/D converter Enable bit
0: A/D converter module turn off and current is not flow.
1: Enable A/D converter
ADCRH
W
W
7
6
W
5
PSSEL1 PSSEL0 ADC8
-
-
-
R
R
4
3
BTCL
-
2
1
0
-
ADDRESS: 0F0H
INITIAL VALUE: 010- ----B
-
A/D Conversion High Data
ADC 8-bit Mode select bit
0: 10-bit Mode
1: 8-bit Mode
A/D Conversion Clock (fPS) Source Selection
00: fXIN ÷ 4
01: fXIN ÷ 8
10: fXIN ÷ 16
11: fXIN ÷ 32
R
7
R
5
R
6
ADCRL
R
4
R
3
BTCL
R
2
R
1
R
0
ADDRESS: 0F1H
INITIAL VALUE: Undefined
A/D Conversion Low Data
ADCK
PSSEL1
PSSEL0
PS Clock Selection
0
0
0
PS = fXIN ÷ 4
0
0
1
PS = fXIN ÷ 8
0
0
0
PS = fXIN ÷ 16
0
0
1
PS = fXIN ÷ 32
1
1
0
PS = fXIN ÷ 8
1
1
1
PS = fXIN ÷ 16
1
1
0
PS = fXIN ÷ 32
1
1
1
PS = fXIN ÷ 64
PS : Conversion Clock
Figure 14-4 A/D Converter Control & Result Register
MAY.2008 Ver 1.46
MC80F0504/0604
15. BUZZER FUNCTION
The buzzer driver block consists of 6-bit binary counter,
buzzer register BUZR, and clock source selector. It generates square-wave which has very wide range frequency
(488Hz ~ 250kHz at fXIN= 4MHz) by user software.
The bit 0 to 5 of BUZR determines output frequency for
buzzer driving.
Equation of frequency calculation is shown below.
f XIN
f BUZ = -------------------------------------------------------------------------------2 × DivideRatio × ( BUR + 1 )
A 50% duty pulse can be output to R12 / BUZO pin to use
for piezo-electric buzzer drive. Pin R12 is assigned for output port of Buzzer driver by setting the bit 2 of PSR1(address 0F9H) to “1”. For PSR1 register, refer to Figure 15-2
.
fBUZ: Buzzer frequency
fXIN: Oscillator frequency
Divide Ratio: Prescaler divide ratio by BUCK[1:0]
BUR: Lower 6-bit value of BUZR. Buzzer period value.
Example: 5kHz output at 4MHz.
LDM
LDM
BUZR,#0011_0001B
PSR1,#XXXX_X1XXB
The frequency of output signal is controlled by the buzzer
control register BUZR. The bit 0 to bit 5 of BUZR determine output frequency for buzzer driving.
X means don’t care
R12 port data
Prescaler
÷8
XIN PIN
6-BIT BINARY
COUNTER
00
÷ 16
MUX
01
÷ 32
0
10
÷ 64
F/F
11
R12/BUZO PIN
1
Comparator
MUX
2
Compare data
BUZO
6
PSR1
BUR
Port selection register 1
[0F9H]
[0E0H]
Internal bus line
Figure 15-1 Block Diagram of Buzzer Driver
ADDRESS: 0E0H
RESET VALUE: 0FFH
W
BUZR
W
W
W
W
W
W
ADDRESS: 0F9H
RESET VALUE: ---- 0000B
W
PSR1
BUCK1 BUCK0
-
-
BUR[5:0]
Buzzer Period Data
Source clock select
00: fXIN ÷ 8
01: fXIN ÷ 16
10: fXIN ÷ 32
11: fXIN ÷ 64
-
-
-
BUZO
-
-
R12 / BUZO Selection
0: R12 port (Turn off buzzer)
1: BUZO port (Turn on buzzer)
Figure 15-2 Buzzer Register & PSR1
64
MAY.2008 Ver 1.46
MC80F0504/0604
The 6-bit counter is cleared and starts the counting by writing signal at BUZR register. It is incremental from 00H until it matches 6-bit BUR value.
BUR
[5:0]
BUR[7:6]
00
01
10
11
When main-frequency is 4MHz, buzzer frequency is
shown as below Table 15-1.
BUR
[5:0]
BUR[7:6]
00
01
10
11
00
01
02
03
04
05
06
07
250.000
125.000
83.333
62.500
50.000
41.667
35.714
31.250
125.000
62.500
41.667
31.250
25.000
20.833
17.857
15.625
62.500
31.250
20.833
15.625
12.500
10.417
8.929
7.813
31.250
15.625
10.417
7.813
6.250
5.208
4.464
3.906
20
21
22
23
24
25
26
27
7.576
7.353
7.143
6.944
6.757
6.579
6.410
6.250
3.788
3.676
3.571
3.472
3.378
3.289
3.205
3.125
1.894
1.838
1.786
1.736
1.689
1.645
1.603
1.563
0.947
0.919
0.893
0.868
0.845
0.822
0.801
0.781
08
09
0A
0B
0C
0D
0E
0F
27.778
25.000
22.727
20.833
19.231
17.857
16.667
15.625
13.889
12.500
11.364
10.417
9.615
8.929
8.333
7.813
6.944
6.250
5.682
5.208
4.808
4.464
4.167
3.906
3.472
3.125
2.841
2.604
2.404
2.232
2.083
1.953
28
29
2A
2B
2C
2D
2E
2F
6.098
5.952
5.814
5.682
5.556
5.435
5.319
5.208
3.049
2.976
2.907
2.841
2.778
2.717
2.660
2.604
1.524
1.488
1.453
1.420
1.389
1.359
1.330
1.302
0.762
0.744
0.727
0.710
0.694
0.679
0.665
0.651
10
11
12
13
14
15
16
17
14.706
13.889
13.158
12.500
11.905
11.364
10.870
10.417
7.353
6.944
6.579
6.250
5.952
5.682
5.435
5.208
3.676
3.472
3.289
3.125
2.976
2.841
2.717
2.604
1.838
1.736
1.645
1.563
1.488
1.420
1.359
1.302
30
31
32
33
34
35
36
37
5.102
5.000
4.902
4.808
4.717
4.630
4.545
4.464
2.551
2.500
2.451
2.404
2.358
2.315
2.273
2.232
1.276
1.250
1.225
1.202
1.179
1.157
1.136
1.116
0.638
0.625
0.613
0.601
0.590
0.579
0.568
0.558
18
19
1A
1B
1C
1D
1E
1F
10.000
9.615
9.259
8.929
8.621
8.333
8.065
7.813
5.000
4.808
4.630
4.464
4.310
4.167
4.032
3.906
2.500
2.404
2.315
2.232
2.155
2.083
2.016
1.953
1.250
1.202
1.157
1.116
1.078
1.042
1.008
0.977
38
39
3A
3B
3C
3D
3E
3F
4.386
4.310
4.237
4.167
4.098
4.032
3.968
3.907
2.193
2.155
2.119
2.083
2.049
2.016
1.984
1.953
1.096
1.078
1.059
1.042
1.025
1.008
0.992
0.977
0.548
0.539
0.530
0.521
0.512
0.504
0.496
0.488
Table 15-1 buzzer frequency (kHz unit)
MAY.2008 Ver 1.46
MC80F0504/0604
16. INTERRUPTS
interrupt was transition-activated.
TheMC80F0504/0604 interrupt circuits consist of Interrupt enable register (IENH, IENL), Interrupt request flags
of IRQH, IRQL, Priority circuit, and Master enable flag
(“I” flag of PSW). Fifteen interrupt sources are provided.
The configuration of interrupt circuit is shown in Figure
16-1 and interrupt priority is shown in Table 16-1.
The Timer 0 and Timer 1 Interrupts are generated by T0IF,
T1IF and T1IF which is set by a match in their respective
timer/counter register.
The Basic Interval Timer Interrupt is generated by BITIF
which is set by an overflow in the timer register.
The External Interrupts INT0 and INT1 each can be transition-activated (1-to-0 or 0-to-1 transition) by selection
IEDS register.
The flags that actually generate these interrupts are bit
INT0IF and INT1IF in register IRQH. When an external
interrupt is generated, the generated flag is cleared by the
hardware when the service routine is vectored to only if the
The AD converter Interrupt is generated by ADCIF which
is set by finishing the analog to digital conversion.
The Watchdog timer is generated by WDTIF and WTIF
which is set by a match in Watchdog timer register.
Internal bus line
[0EAH]
IENH
Interrupt Enable
Register (Higher byte)
IRQH
[0ECH]
INT0
INT0IF
INT1
INT1IF
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.
Timer 0
Priority Control
Release STOP/SLEEP
T0IF
IRQL
[0EDH]
Timer 1
I-flag
Interrupt Master
Enable Flag
Interrupt
Vector
Address
Generator
T1IF
A/D Converter
ADCIF
Watchdog Timer
WDTIF
BIT
To CPU
BITIF
[0EBH]
IENL
Interrupt Enable
Register (Lower byte)
Internal bus line
Figure 16-1 Block Diagram of Interrupt
66
MAY.2008 Ver 1.46
MC80F0504/0604
The Basic Interval Timer Interrupt is generated by BITIF
which is set by a overflow in the timer counter register.
Reset/Interrupt
The interrupts are controlled by the interrupt master enable
flag I-flag (bit 2 of PSW on Figure 8-3 ), the interrupt enable register (IENH, IENL), and the interrupt request flags
(in IRQH and IRQL) except Power-on reset and software
BRK interrupt. The Table 16-1 shows the Interrupt priority.
Hardware Reset
External Interrupt 0
External Interrupt 1
Timer/Counter 0
Timer/Counter 1
ADC Interrupt
Watchdog Timer
Basic Interval Timer
Vector addresses are shown in Figure 8-6 . Interrupt enable
registers are shown in Figure 16-2 . These registers are
composed of interrupt enable flags of each interrupt source
and these flags determines whether an interrupt will be accepted or not. When enable flag is “0”, a corresponding interrupt source is prohibited. Note that PSW contains also a
master enable bit, I-flag, which disables all interrupts at
once.
IENH
R/W
R/W
INT0E
INT1E
-
-
-
Priority
RESET
INT0
INT1
Timer 0
Timer 1
ADC
WDT
BIT
1
2
3
4
5
6
7
8
Table 16-1 Interrupt Priority
R/W
-
Symbol
-
ADDRESS: 0EAH
INITIAL VALUE: 0000 0000B
T0E
MSB
LSB
Timer/Counter 0 interrupt enable flag
External interrupt 1 enable flag
External interrupt 0 enable flag
R/W
IENL
T1E
MSB
R/W
-
R/W
ADCE WDTE
R/W
-
BITE
ADDRESS: 0EBH
INITIAL VALUE: 000- 00-0B
LSB
Basic Interval Timer interrupt enable flag
Watchdog timer interrupt enable flag
A/D Converter interrupt enable flag
Timer/Counter 1 interrupt enable flag
Figure 16-2 Interrupt Enable Flag Register
MAY.2008 Ver 1.46
MC80F0504/0604
R/W
IRQH
R/W
INT0IF INT1IF
-
-
-
-
R/W
R/W
SIOIF
T0IF
MSB
ADDRESS: 0ECH
INITIAL VALUE: 00-- --00B
LSB
Timer/Counter 0 interrupt request flag
External interrupt 1 request flag
External interrupt 0 request flag
R/W
IRQL
T1IF
R/W
-
-
-
R/W
ADCIF WDTIF
-
R/W
-
BITIF
ADDRESS: 0EDH
INITIAL VALUE: 0--- 00-0B
LSB
MSB
Basic Interval Timer interrupt request flag
Watchdog timer interrupt request flag
A/D Converter interrupt request flag
Timer/Counter 1 interrupt request flag
Figure 16-3 Interrupt Request Flag Register
16.1 Interrupt Sequence
An interrupt request is held until the interrupt is accepted
or the interrupt latch is cleared to “0” by a reset or an instruction. Interrupt acceptance sequence requires 8 cycles
of fXIN (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].
16.1.1 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. The contents of the program counter (return address)
and the program status word are saved (pushed) onto the
68
stack area. The stack pointer decreases 3 times.
3. 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.
4. The instruction stored at the entry address of the interrupt service program is executed.
MAY.2008 Ver 1.46
MC80F0504/0604
.
System clock
Instruction Fetch
SP
Address Bus
PC
Data Bus
Not used
SP-1
PCH
PCL
SP-2
PSW
V.L.
V.L.
V.H.
ADL
New PC
ADH
OP code
Internal Read
Internal Write
Interrupt Processing Step
Interrupt Service Task
V.L. and V.H. are vector addresses.
ADL and ADH are start addresses of interrupt service routine as vector contents.
Figure 16-4 Timing chart of Interrupt Acceptance and Interrupt Return Instruction
Basic Interval Timer
Vector Table Address
0FFE0H
0FFE1H
012H
0E3H
Entry Address
0E312H
0E313H
0EH
2EH
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.
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.
Correspondence between vector table address for BIT interrupt
and the entry address of the interrupt service program.
16.1.2 Clearing Interrupt Request Flag
The Interrupt Request flag may not cleared itself during interrupt acceptance processing. After interrupt acceptance,
it should be cleard as shown in interrupt service routine.
Example: Clearing Interrupt Request Flag
T1_INT:
CLR1
T1IF
;CLEAR T1 REQUEST
interrupt processing
Note: The MC80F0504 and HMS87C1102A is very
similar in function, but the interrupt processing method is different. When replacing the HMS87C1102A to
MC80F0504, clearing interrupt request flag should
be added.
RETI
;RETURN
16.1.3 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
MAY.2008 Ver 1.46
same data memory area for saving registers.
The following method is used to save/restore the general-purpose
registers.
MC80F0504/0604
Example: Register save using push and pop instructions
INTxx:
CLR1
PUSH
PUSH
PUSH
INTxxIF
A
X
Y
;CLEAR REQUEST.
;SAVE ACC.
;SAVE X REG.
;SAVE Y REG.
main task
acceptance of
interrupt
interrupt
service task
saving
registers
interrupt processing
POP
POP
POP
RETI
Y
X
A
;RESTORE Y REG.
;RESTORE X REG.
;RESTORE ACC.
;RETURN
restoring
registers
interrupt return
General-purpose register save/restore using push and pop instructions;
16.2 BRK Interrupt
Software interrupt can be invoked by BRK instruction,
which has the lowest priority order.
Interrupt vector address of BRK is shared with the vector
of TCALL 0 (Refer to Program Memory Section). When
BRK interrupt is generated, B-flag of PSW is set to distinguish BRK from TCALL 0.
Each processing step is determined by B-flag as shown in
Figure 16-5 .
B-FLAG
BRK or
TCALL0
=0
=1
BRK
INTERRUPT
ROUTINE
TCALL0
ROUTINE
RETI
RET
Figure 16-5 Execution of BRK/TCALL0
16.3 Multi Interrupt
If two requests of different priority levels are received simultaneously, the request of higher priority level is serviced. If requests of the interrupt are received at the same
time simultaneously, an internal polling sequence determines by hardware which request is serviced. However,
70
multiple processing through software for special features is
possible. Generally when an interrupt is accepted, the Iflag is cleared to disable any further interrupt. But as user
sets I-flag in interrupt routine, some further interrupt can
be serviced even if certain interrupt is in progress.
MAY.2008 Ver 1.46
MC80F0504/0604
Main Program
service
TIMER 1
service
enable INT0
disable other
INT0
service
EI
Occur
TIMER1 interrupt
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.
Occur
INT0
enable INT0
enable other
Figure 16-6 Execution of Multi Interrupt
Example: During Timer1 interrupt is in progress, INT0 interrupt serviced without any suspend.
TIMER1: PUSH
PUSH
PUSH
LDM
LDM
EI
:
:
A
X
Y
IENH,#80H
IENL,#0
MAY.2008 Ver 1.46
;Enable INT0 only
;Disable other int.
;Enable Interrupt
:
:
:
:
LDM
LDM
POP
POP
POP
RETI
IENH,#0FFH ;Enable all interrupts
IENL,#0FFH
Y
X
A
MC80F0504/0604
16.4 External Interrupt
The external interrupt on INT0 and INT1 pins are edge
triggered depending on the edge selection register IEDS
(address 0EEH) as shown in Figure 16-7 .
The edge detection of external interrupt has three transition
activated mode: rising edge, falling edge, and both edge.
01
INT0 pin
10
INT0IF
INT0 INTERRUPT
INT1IF
INT1 INTERRUPT
11
01
INT1 pin
10
11
2
2
IEDS
Edge selection
Register
[0EEH]
Figure 16-7 External Interrupt Block Diagram
INT0 and INT1 are multiplexed with general I/O ports
(R11, R12). To use as an external interrupt pin, the bit of
port selection register PSR0 should be set to “1” correspondingly.
Example: To use as an INT0 and INT1
:
;**** Set external interrupt port as pull-up state.
LDM
PU1,#0000_0110B
;
;**** Set port as an external interrupt port
LDM
PSR0,#0000_0011B
;
;**** Set Falling-edge Detection
LDM
IEDS,#0000_0101B
:
max. 12 fXIN
Interrupt Interrupt
goes
latched
active
Response Time
The INT0 and INT1 edge are latched into INT0IF and
INT1IF at every machine cycle. The values are not actually
polled by the circuitry until the next machine cycle. If a request is active and conditions are right for it to be acknowledged, a hardware subroutine call to the requested service
routine will be the next instruction to be executed. The
DIV itself takes twelve cycles. Thus, a minimum of twelve
complete machine cycles elapse between activation of an
external interrupt request and the beginning of execution
of the first instruction of the service routine.
Figure 16-8 shows interrupt response timings.
8 fXIN
Interrupt
processing
Interrupt
routine
Figure 16-8 Interrupt Response Timing Diagram
72
MAY.2008 Ver 1.46
MC80F0504/0604
MSB
-
-
-
-
-
-
IEDS
-
W
-
W
W
LSB
W
ADDRESS: 0EEH
INITIAL VALUE: ---- 0000B
BTCL IED1L IED0H IED0L
IED1H
INT1
INT0
Edge selection register
00: Reserved
01: Falling (1-to-0 transition)
10: Rising (0-to-1 transition)
11: Both (Rising & Falling)
-
PSR0
MSB
0: R10
1: PWM1O
0: R04
1: EC0
W
-
PWM1O
-
W
-
-
EC0E BTCL
-
-
W
W
ADDRESS: 0F8H
INITIAL VALUE: -0-0 --00B
INT1E INT0E
LSB
0: R11
1: INT0
0: R12
1: INT1
Figure 16-9 IEDS register and Port Selection Register PSR0
MAY.2008 Ver 1.46
MC80F0504/0604
17. POWER SAVING OPERATION
shows the status of each Power Saving Mode. SLEEP
mode is entered by the SSCR register to “0Fh”., and STOP
mode is entered by STOP instruction after the SSCR register to “5Ah”.
TheMC80F0504/0604 has two power-down modes. In
power-down mode, power consumption is reduced
considerably. For applications where power consumption
is a critical factor, device provides two kinds of power saving functions, STOP mode and SLEEP mode. Table 17-1
17.1 Sleep Mode
released by interrupt, interrupt should be enabled before
SLEEP mode.
In this mode, the internal oscillation circuits remain active.
Oscillation continues and peripherals are operate normally
but CPU stops. Movement of all peripherals is shown in
Table 17-1. SLEEP mode is entered by setting the SSCR
register to “0Fh”. It is released by Reset or interrupt. To be
W
7
W
6
W
5
W
4
W
3
W
2
W
1
W
0
ADDRESS: 0F5H
INITIAL VALUE: 0000 0000B
SSCR
Power Down Control
5AH: STOP mode
0FH: SLEEP mode
NOTE :
To get into STOP mode, SSCR must be set to 5AH just before STOP instruction execution.
At STOP mode, Stop & Sleep Control Register (SSCR) value is cleared automatically when released.
To get into SLEEP mode, SSCR must be set to 0FH.
Figure 17-1 STOP and SLEEP Control Register
Release the SLEEP mode
The exit from SLEEP mode is hardware reset or all interrupts. Reset re-defines all the Control registers but does not
change the on-chip RAM. Interrupts allow both on-chip
RAM and Control registers to retain their values.
If I-flag = 1, the normal interrupt response takes place. If Iflag = 0, the chip will resume execution starting with the
instruction following the SLEEP instruction. It will not
vector to interrupt service routine. (refer to Figure 17-4 )
When exit from SLEEP mode by reset, enough oscillation
74
stabilizing time is required to normal operation. Figure 173 shows the timing diagram. When released from the
SLEEP 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
SLEEP 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 interrupts, exit from SLEEP mode is shown in Figure
17-2 . By reset, exit from SLEEP mode is shown in Figure
17-3 .
MAY.2008 Ver 1.46
MC80F0504/0604
.
~
~
~ ~
~
~
Internal Clock
~ ~
~
~
~ ~
~
~
Oscillator
(XIN pin)
SLEEP Instruction
Executed
Normal Operation
SLEEP Operation
~
~
External Interrupt
Normal Operation
Figure 17-2 SLEEP Mode Release Timing by External Interrupt
~
~
~
~
Oscillator
(XIN pin)
~
~
CPU
Clock
~
~
Internal
RESET
~
~
~
~
RESET
~
~
SLEEP Instruction
Execution
Normal Operation
Stabilization Time
tST = 65.5mS @4MHz
Normal Operation
SLEEP Operation
Figure 17-3 Timing of SLEEP Mode Release by Reset
17.2 Stop Mode
In the Stop mode, the main oscillator, system clock and peripheral clock is stopped, but RC-oscillated watchdog timer continue to operate. 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
MAY.2008 Ver 1.46
"STOP" which starts the STOP operating mode.
Note: The Stop mode is activated by execution of STOP instruction after setting the SSCR to “5AH”. (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 occur undesired operation)
In the Stop mode of operation, VDD can be reduced to minimize power consumption. Care must be taken, however,
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.
MC80F0504/0604
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,#0FH ;more than 20ms
LDM SSCR,#5AH
STOP
NOP ;for stabilization time
NOP ;for stabilization time
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 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.
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
Peripheral
STOP Mode
SLEEP Mode
CPU
Stop
Stop
RAM
Retain
Retain
Basic Interval Timer
Halted
Operates Continuously
Watchdog Timer
Stop (Only operates in RC-WDT mode)
Operates Continuously
Timer/Counter
Halted (Only when the event counter mode
is enabled, timer operates normally)
Operates Continuously
ADC
Stop
Stop
Buzzer
Stop
Operates Continuously
Oscillator
Stop (XIN=L, XOUT=H)
Oscillation
I/O Ports
Retain
Retain
Control Registers
Retain
Retain
Internal Circuit
Stop mode
Sleep mode
Prescaler
Retain
Active
Address Data Bus
Retain
Retain
Release Source
Reset, Timer(EC0), Watchdog Timer (RCWDT mode), External Interrupt
Reset, All Interrupts
Table 17-1 Peripheral Operation During Power Saving Mode
Release the STOP mode
The source for exit from STOP mode is hardware reset, external interrupt, Timer(EC0), Watch Timer, WDT. 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. 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-4 )
76
When exit from Stop mode by external interrupt, enough
oscillation stabilizing time is required to normal operation.
Figure 17-5 shows the timing diagram. When released
from 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.
By reset, exit from Stop mode is shown in Figure 17-6 .
MAY.2008 Ver 1.46
MC80F0504/0604
STOP
INSTRUCTION
STOP Mode
Interrupt Request
Corresponding Interrupt
Enable Bit (IENH, IENL)
=0
IENH or IENL ?
=1
STOP Mode Release
Master Interrupt
Enable Bit PSW[2]
I-FLAG
=0
=1
Interrupt Service Routine
Next
INSTRUCTION
Figure 17-4 STOP Releasing Flow by Interrupts
.
~ ~
~
~
~
~
Oscillator
(XIN pin)
~
~
~
~
Internal Clock
~
~
STOP Instruction
Executed
n+1 n+2
n+3
0
1
~
~
~ ~
n
~ ~
~
~
BIT Counter
~
~
External Interrupt
FE
FF
0
1
2
Clear
Normal Operation
Stop Operation
Stabilization Time
tST > 20ms
by software
Normal Operation
Before executing Stop instruction, Basic Interval Timer must be set
properly by software to get stabilization time which is longer than 20ms.
Figure 17-5 STOP Mode Release Timing by External Interrupt
MAY.2008 Ver 1.46
MC80F0504/0604
STOP Mode
~
~
~
~
~ ~
~
~
Oscillator
(XI pin)
~
~
~ ~
~
~
Internal
Clock
RESET
~
~
Internal
RESET
~
~
STOP Instruction Execution
Time can not be control by software
Stabilization Time
tST = 65.5mS @4MHz
Figure 17-6 Timing of STOP Mode Release by Reset
17.3 Stop Mode at 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
RCWDT 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)
Note: Caution: After STOP instruction, at least two or more NOP
instruction should be written
Ex)
LDM WDTR,#1111_1111B
LDM CKCTLR,#0010_1110B
LDM SSCR,#0101_1010B
STOP
NOP
;for stabilization time
NOP
;for stabilization time
The exit from Internal RC-Oscillated Watchdog Timer
mode is hardware reset or external interrupt or watchdog
timer interrupt (at RC-watchdog timer mode). Reset re-de-
78
fines all the Control registers but does not change the onchip 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 8-6 ).
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-8 ). 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-4 )
When exit from Stop mode at Internal RC-Oscillated
Watchdog Timer mode by external interrupt, the oscillation stabilization time is required to normal operation. Figure 17-7 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 RCOscillated Watchdog Timer mode is shown in Figure 17-8
.
MAY.2008 Ver 1.46
MC80F0504/0604
~
~
~
~
~
~
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
STOP mode
at RC-WDT Mode
Stabilization Time
tST > 20mS
Normal Operation
Figure 17-7 Stop Mode Release at Internal RC-WDT Mode by External Interrupt or WDT Interrupt
RCWDT Mode
~
~
~
~
~
~
Oscillator
(XIN pin)
Internal
RC Clock
~
~
~
~
~
~
RESET
~
~
Internal
Clock
RESET by WDT
~
~
STOP Instruction Execution
Time can not be control by software
~
~
Internal
RESET
Stabilization Time
tST = 65.5mS @4MHz
Figure 17-8 Internal RC-WDT Mode Releasing by Reset
MAY.2008 Ver 1.46
MC80F0504/0604
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.
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 configured as an input, input level should
be closed to 0V or 5V to avoid power consumption.
Figure 17-9 Application Example of Unused Input Port
OUTPUT PIN
OUTPUT PIN
VDD
ON
OPEN
OFF
ON
OFF
OFF
i
VDD
GND
X
ON
O
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-10 Application Example of Unused Output Port
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/
80
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.
It should be set properly in order that current flow through
port doesn't exist.
First consider the port 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
MAY.2008 Ver 1.46
MC80F0504/0604
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
MAY.2008 Ver 1.46
output mode considering there is no current flow. The port
setting to High or Low is decided by 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.
MC80F0504/0604
18. RESET
The MC80F0504/0604 supports various kinds of reset as
below.
• Watchdog Timer Timeout Reset
• On-Chip Power-On Reset (POR)
• Address Fail Reset
• Power-Fail Detection (PFD) Reset
• RESET (external reset circuitry)
RESET
Noise Canceller
On-chip POR
(Power-On Reset)
S
Address Fail reset
Q
Internal
RESET
Overflow
R
PFD
(Power-Fail Detection)
Clear
WDT
(WDT Timeout Reset)
BIT
Figure 18-1 RESET Block Diagram
The on-chip POR circuit holds down the device in RESET
until VDD has reached a high enough level for proper operation. It will eliminate external components such as reset
IC or external resistor and capacitor for external reset circuit. In addition that the RESET pin can be used to normal
input port R35 by setting “POR” and “R35EN” bit ConfigOn-chip Hardware
Program counter
RAM page register
G-flag
Operation mode
Initial Value
uration Area(20FFH) in the Flash programming. When the
device starts normal operation, its operating parmeters
(voltage, frequency, temperature...etc) must be met.
.Table 18-1 shows on-chip hardware initialization by reset
action.
On-chip Hardware
Initial Value
(FFFFH) - (FFFEH)
Peripheral clock
Off
(RPR)
0
Watchdog timer
Disable
(G)
0
Control registers
Refer to Table 8-1 on page 29
(PC)
Main-frequency clock
Power fail detector
Disable
Table 18-1 Initializing Internal Status by Reset Action
The reset input is the RESET pin, which is the input to a
Schmitt Trigger. A reset in accomplished by holding the
RESET pin low for at least 8 oscillator periods, within the
operating voltage range and oscillation stable, it is applied,
and the internal state is initialized. After reset, 65.5ms (at
4 MHz) add with 7 oscillator periods are required to start
execution as shown in Figure 18-2 .
Internal RAM is not affected by reset. When VDD is turned
82
on, the RAM content is indeterminate. Therefore, this
RAM should be initialized before read or tested it.
When the RESET pin input goes to high, the reset operation is released and the program execution starts at the vector address stored at addresses FFFEH - FFFFH.
A connection for simple external reset circuit is shown in
Figure 18-1 .
MAY.2008 Ver 1.46
MC80F0504/0604
VCC
10kΩ
to the RESET pin
7036P
+
10uF
Figure 18-1 Simple External Reset Circuit
1
?
?
4
5
6
7
~
~
?
FFFE FFFF Start
?
~
~ ~
~
?
?
?
?
FE
ADL
ADH
OP
~
~
DATA
BUS
3
~
~
RESET
ADDRESS
BUS
2
~
~
Oscillator
(XIN pin)
Stabilization Time
tST =65.5mS at 4MHz
Reset Process Step
tST =
1
fXIN ÷1024
MAIN PROGRAM
x 256
Figure 18-2 Timing Diagram after Reset
The Address Fail Reset is the function to reset the system
by checking code access of abnormal and unwished address caused by erroneous program code itself or external
noise, which could not be returned to normal operation and
would become malfunction state. If the CPU tries to fetch
MAY.2008 Ver 1.46
the instruction from ineffective code area or RAM area, the
address fail reset is occurred. Please refer to Figure 11-2
for setting address fail option.
MC80F0504/0604
19. POWER FAIL PROCESSOR
shown in Figure 19-1
TheMC80F0504/0604 has an on-chip power fail detection
circuitry to immunize against power noise. A configuration register, PFDR, can enable or disable the power fail
detect circuitry. Whenever VDD falls close to or below
power fail voltage for 100ns, the power fail situation may
reset or freeze MCU according to PFDM bit of PFDR as
PFDR
7
-
6
-
5
-
4
-
3
-
R/W
2
In the in-circuit emulator, power fail function is not implemented and user can not experiment with it. Therefore, after final development of user program, this function may
be experimented or evaluated.
R/W
1
R/W
0
PFDEN PFDM PFDS
ADDRESS: 0F7H
INITIAL VALUE: ---- -000B
Power Fail Status
0: Normal operate
1: Set to “1” if power fail is detected
PFD Operation Mode
0 : MCU will be frozen by power fail detection
1 : MCU will be reset by power fail detection
* Cautions :
PFD Enable Bit
0: Power fail detection disable
1: Power fail detection enable
Be sure to set bits 3 through 7 to “0”.
Figure 19-1 Power Fail Voltage Detector Register
RESET VECTOR
PFDS =1
YES
NO
RAM Clear
Initialize RAM Data
Initialize All Ports
Initialize Registers
PFDS = 0
Skip the
initial routine
Function
Execution
Figure 19-2 Example S/W of Reset flow by Power fail
84
MAY.2008 Ver 1.46
MC80F0504/0604
VDD
Internal
RESET
VPFDMAX
VPFDMIN
65.5mS
VDD
When PFDM = 1
Internal
RESET
65.5mS
t < 65.5mS
VDD
Internal
RESET
65.5mS
Figure 19-3 Power Fail Processor Situations (at 4MHz operation)
MAY.2008 Ver 1.46
VPFDMAX
VPFDMIN
VPFDMAX
VPFDMIN
MC80F0504/0604
20. COUNTERMEASURE OF NOISE
20.1 Oscillation Noise Protector
by high frequency noise.
- Change system clock to the internal oscillation clock
when the high frequency noise is continuing.
- Change system clock to the internal oscillation clock
when the XIN/XOUT is shorted or opened, the main
oscillation is stopped except by stop instruction and
the low frequency noise is entered.
The Oscillation Noise Protector (ONP) is used to supply
stable internal system clock by excluding the noise which
could be entered into oscillator and recovery the oscillation
fail. This function could be enabled or disabled by the
“ONP” bit of the Device configuration area (20FFH) for
the MC80F0604.
The ONP function is like below.
- Recovery the oscillation wave crushed or loss caused
XIN
OFP
1
HF Noise
Canceller
HF Noise
Observer
XIN_NF
Mux
0S
0
CLK
Changer
Internal
OSC
1
FINTERNAL
S
en
INT_CLK
LF Noise
Observer
ONP
OFP
CLK_CHG
ONP
IN4(2)MCLK(XO)
en
o/f
PS10
ONPb = 0
CK
en
OFP
(8-Bit counter)
LF_on = 1
IN_CLK = 0
High Frq. Noise
INT_CLK 8 periods
(250ns × 8 =2us)
PS10(INT_CLK/512) 256 periods
(250ns × 512 × 256 =33 ms)
~
~
~
~
XIN
Noise Cancel
~
~
~
~
~
~
INT_CLK reset
~
~
XIN_NF
Low Frq. Noise or
Oscillation Fail
~
~
~ ~
~
~
INT_CLK
OFP_EN
~
~ ~
~
CHG_END
CLK_CHG
Clock Change Start(XIN to INT_CLK)
~
~
~
~
fINTERNAL
Clock Change End(INT_CLK to XIN))
Figure 20-1 Block Diagram of ONP & OFP and Respective Wave Forms
86
MAY.2008 Ver 1.46
MC80F0504/0604
20.2 Oscillation Fail Processor
The oscillation fail processor (OFP) can change the clock
source from external to internal oscillator when the oscillation fail occured. This function could be enabled or disabled by the “OFP” bit of the Device Configuration Area .
And this function can recover the external clock source
when the external clock is recovered to normal state.
IN4(2)MCLK/CLK(XO) Option
The internal 4MHz or 4MHz oscillation can be used as system clock source in timing insensitive applications. The
“IN4MCLK(XO)”, “IN2MCLK(XO)” bit of the Device
Configuration Area enables the function to operate the de-
MAY.2008 Ver 1.46
vice by using the internal oscillator clock in ONP block as
system clock. There is no need to connect the x-tal, resonator, RC and R externally.
When using internal oscillation, the XIN, XOUT pin can be
used as normal I/O pin. In case of selecting IN4MCLK or
IN2MCLK, the XIN pin can be used to R33 and the period
of internal oscillator clock could be checked by XOUT outputting clock divided the internal oscillator clock by 16. If
IN4MCLKXO or IN2MCLKCO is selected, the XIN and
XOUT pin can be used as R33 and R34 I/O ports.
MC80F0504/0604
21. Device Configuration Area
The Device Configuration Area can be programmed or left
unprogrammed to select device configuration such as
POR, ONP, CLK option and security bit. This area is not
accessible during normal execution but is readable and
writable during FLASH program / verify mode.
Configuration Option Bits
7
ONP
Note: The Configuration Option may not be read exactly
when VDD rising time is very slow. It is recommended to
adjust the VDD rising time faster than 40ms/V (200ms from
0V to 5V).
6
5
4
3
2
1
0
OFP LOCK POR R35EN CLK2 CLK1 CLK0
ADDRESS: 20FFH
INITIAL VALUE: 00H
Oscillation configuration
000 : IN4MCLK (Internal 4MHz Oscillation & R33/R34 Enable)
001 : IN2MCLK (Internal 2MHz Oscillation & R33/R34 Enable)
010 : EXRC (External R/RC Oscillation & R34 Enable)
011 : X-tal (Crystal or Resonator Oscillation)
100 : IN4MCLKXO (internal 4MHz Oscillation & R33 Enable
& XOUT = fSYS ÷ 4)
101 : IN2MCLKXO (internal 2MHz Oscillation & R33 Enable
& XOUT = fSYS ÷ 4)
110 : EXRCXO (External R/RC Oscillation & XOUT = fSYS ÷ 4)
111 : Prohibited
RESET/R35 Port configuration
0 : R35 Port Disable (Use RESET)
1 : R35 Port Enable (Disable RESET)
POR Use
0 : Disable POR Reset
1 : Enable POR Reset
Security Bit
0 : Enable reading User Code
1 : Disable reading User Code
OFP use
0 : Disable OFP (Clock Changer)
1 : Enable OFP (Clock Changer)
ONP disable
0 : Enable ONP (Enable OFP, Internal 4MHz/2MHz oscillation)
1 : Disable ONP (Disable OFP, Internal 4MHz/2MHz oscillation)
Figure 21-1 Device Configuration Area
These various options shown in Figure 21-1 can be selected by checking option field listed in writer (PGM Plus,
88
SIGMA or GANG4) software after selecting device name.
MAY.2008 Ver 1.46
MC80F0504/0604
22. Emulator EVA. Board Setting
NC
VDD
GND
R00
R01
R02
R03
R04
R05
R06
R07
GND
R20
R21
R22
R23
R24
R25
R26
R27
GND
NC
NC
NC
NC
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
J_USER
1
3
5
7
9
11
13
15
17
19
21
23
25
27
29
31
33
35
37
39
41
43
45
47
49
NC
VDD
GND
R10
R11
R12
R13
R14
R15
R16
R17
GND
R30
R31
R32
R33/XIN
R34/XOUT
R35/RST
R36
R37
GND
NC
NC
NC
NC
MAY.2008 Ver 1.46
➊
➎
➏
➐
➋
➌
➍
MC80F0504/0604
DIP Switch and VR Setting
Before execute the user program, keep in your mind the beDIP S/W
➊
low configuration
Description
-
ON/OFF Setting
This connector is only used for a device under 32 PIN.
For the MC80F0504/0504
Device select switch Low pin .
➋
SW6
Low Pin
Must be Low Pin position.
-
High Pin : For the MC80F0208/16/24.
Low Pin : For the MC80F0504/0604.
High Pin
These switches select the AVDD source for
high pin devices and should be set to use
Eva. VDD.
ON
1
2
OFF
Use Eva. VDD
ON & OFF : Use Eva. VDD
AVDD select switch to Eva. VDD.
This switch select the /Reset source.
Normally OFF.
EVA. chip can be reset by external user target board.
ON : Reset is available by either user target
system board or Emulator RESET switch.
OFF : Reset the MCU by Emulator RESET
switch. Does not work from user target
board.
This switch select the Xout signal on/off.
Normally OFF.
MCU XOUT pin is disconnected internally
in the Emulator. User may connect this circuit with this switch.
ON : Output XOUT signal
OFF : Disconnect circuit
➌
SW2
3
4
This switch select Eva. B/D Power supply source.
MDS
MDS
➍
SW3
Normally MDS.
This switch select Eva. B/D Power supply
source.
1
USER
Use MDS Power
➎
SW4
90
1
2
USER
Use User’s Power
This switch select the R22 or SXOUT.
This switch select the R21 or SXIN.
These switches select the Normal I/O port
(off) or Sub-Clock (on).
It is reserved for the MC80F0448.
ON : SXOUT, SXIN
OFF : R22, R21
OFF (MC80F0504/0604).
MAY.2008 Ver 1.46
MC80F0504/0604
DIP S/W
Description
ON/OFF Setting
These switches select the R33 or XIN
1
2
ON
OFF
OFF
ON
Select R33 port
➏
SW5
This switch select the Normal I/O port (off)
or XIN(NC) select (on).
ON & OFF : R33 Port selected.
OFF & ON : XIN(NC) selected.
Select XIN (NC)
These switches select the R34 or XOUT
3
4
ON
OFF
OFF
ON
Select R34 port
Select XOUT
This switch select the Normal I/O port (off)
or XOUT select (on).
ON & OFF : R34 Port selected.
OFF & ON : XOUT selected.
These switches select the R35 or XOUT
5
6
ON
OFF
OFF
ON
Select R35 port
➐
-
Select /Reset
This is External oscillation socket (CAN Type. OSC)
MAY.2008 Ver 1.46
This switch select the Normal I/O port (off)
or /Reset select (on).
ON & OFF : R35 Port selected.
OFF & ON : /Reset selected.
This is for External Clock (CAN Type.
OSC).
MC80F0504/0604
92
MAY.2008 Ver 1.46
APPENDIX
MC80F0504/0604
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
01010
0A
01011
0B
01100
0C
01101
0D
01110
0E
01111
0F
ADC
#imm
ADC
dp
ADC
dp+X
ADC
!abs
ASL
A
ASL
dp
TCALL
0
SETA1
.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
(N/A)
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
(N/A)
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
MAY.2008 Ver 1.46
MC80F0504/0604
B. INSTRUCTION SET
1. ARITHMETIC/ LOGIC OPERATION
NO.
1
ii
MNEMONIC
ADC #imm
OP BYTE CYCLE
CODE NO
NO
04
2
2
Add with carry.
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
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
“0”
Compare accumulator contents with memory contents
(A) -(M)
N-----ZC
Compare X contents with memory contents
(X)-(M)
CMPY #imm
7E
2
2
33
CMPY dp
8C
2
3
34
CMPY !abs
9C
3
4
35
COM dp
2C
2
4
1’S Complement : ( dp ) ← ~( dp )
36
DAA
-
-
-
Not supported
37
DAS
-
-
-
Not supported
38
DEC A
A8
1
2
Decrement
39
DEC dp
A9
2
4
40
DEC dp + X
B9
2
5
DEC !abs
B8
3
5
42
DEC X
AF
1
2
43
DEC Y
BE
1
2
44
DIV
9B
1
12
N-----ZC
0
32
41
FLAG
NVGBHIZC
OPERATION
N-----ZC
Compare Y contents with memory contents
(Y)-(M)
N-----ZC
N-----Z-
N-----Z-
M← (M)-1
N-----Z-
Divide : YA / X Q: A, R: Y
NV--H-Z-
MAY.2008 Ver 1.46
MC80F0504/0604
NO.
MNEMONIC
FLAG
NVGBHIZC
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
53
INC A
88
1
2
54
INC dp
89
2
4
N-----Z-
Increment
N-----Z-
M← (M)+1
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
N-----Z-
Logical shift right
7
6
5
4
3
2
1
0
C
N-----ZC
“0”
N-----Z-
A ← (A)∨(M)
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
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-
MAY.2008 Ver 1.46
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
Subtract with carry
A ← ( A ) - ( M ) - ~( C )
NV--HZC
MC80F0504/0604
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
FLAG
NVGBHIZC
OPERATION
Load accumulator
A←(M)
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
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
N-----Z-
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
N-----Z-
34
TAY
9F
1
2
Transfer accumulator contents to Y-register : Y ← A
N-----Z-
35
TSPX
AE
1
2
Transfer stack-pointer contents to X-register : X ← sp
N-----Z-
36
TXA
C8
1
2
Transfer X-register contents to accumulator: A ← X
N-----Z-
37
TXSP
8E
1
2
Transfer X-register contents to stack-pointer: sp ← X
N-----Z-
38
TYA
BF
1
2
Transfer Y-register contents to accumulator: A ← Y
N-----Z-
39
XAX
EE
1
4
(M)← X
--------
Store Y-register contents in memory
(M)← Y
--------
40
XAY
DE
1
4
Exchange X-register contents with accumulator :X ↔ A -------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
--------
MAY.2008 Ver 1.46
MC80F0504/0604
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 )
2
4
Clear bit : ( M.bit ) ← “0”
5
CLR1 dp.bit
y1
6
CLRA1 A.bit
2B
2
2
Clear A bit : ( A.bit )← “0”
--------
7
CLRC
20
1
2
Clear C-flag : C ← “0”
-------0
8
CLRG
40
1
2
Clear G-flag : G ← “0”
--0-----
9
CLRV
80
1
2
Clear V-flag : V ← “0”
-0--0---
10
EOR1 M.bit
AB
3
5
Bit exclusive-OR C-flag : C ← ( C ) ⊕ ( M .bit )
-------C
11
EOR1B M.bit
AB
3
5
12
LDC M.bit
CB
3
4
Bit exclusive-OR C-flag and NOT : C ← ( C ) ⊕ ~(M .bit) -------C
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
-------C
--------
OR1 M.bit
6B
3
5
Bit OR C-flag : C ← ( C ) ∨ ( M .bit )
16
OR1B M.bit
6B
3
5
Bit OR C-flag and NOT : C ← ( C ) ∨ ~( M .bit )
-------C
17
SET1 dp.bit
x1
2
4
Set bit : ( M.bit ) ← “1”
--------
18
SETA1 A.bit
0B
2
2
Set A bit : ( A.bit ) ← “1”
--------
19
SETC
A0
1
2
Set C-flag : C ← “1”
-------1
20
SETG
C0
1
2
Set G-flag : G ← “1”
--1-----
21
STC M.bit
EB
3
6
Store C-flag : ( M .bit ) ← C
--------
22
TCLR1 !abs
5C
3
6
Test and clear bits with A :
A - ( M ) , ( M ) ← ( M ) ∧ ~( A )
N-----Z-
23
TSET1 !abs
3C
3
6
Test and set bits with A :
A-(M), (M)← (M)∨(A)
N-----Z-
MAY.2008 Ver 1.46
MC80F0504/0604
5. BRANCH / JUMP OPERATION
NO.
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
--------
1
BBC A.bit,rel
2
BBC dp.bit,rel
3
BBS A.bit,rel
x2
2
4/6
BBS dp.bit,rel
x3
3
5/7
if ( bit ) = 1 , then pc ← ( pc ) + rel
--------
4
Branch if bit set :
--------
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
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
19
DBNE Y,rel
7B
2
4/6
20
JMP !abs
1B
3
3
3
5
21
vi
MNEMONIC
Subroutine call
M( sp)←( pcH ), sp←sp - 1, M(sp)← (pcL), sp ←sp - 1,
-------if !abs, pc← abs ; if [dp], pcL← ( dp ), pcH← ( dp+1 ) .
-------Compare and branch if not equal :
if ( A ) ≠ ( M ) , then pc ← ( pc ) + rel.
Decrement and branch if not equal :
M ← ( M ) - 1.
if ( M ) ≠ 0 , then pc ← ( pc ) + rel.
--------
Unconditional jump
pc ← jump address
JMP [!abs]
1F
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)
--------
--------
MAY.2008 Ver 1.46
MC80F0504/0604
6. CONTROL OPERATION & etc.
NO.
MNEMONIC
OP BYTE CYCLE
CODE NO
NO
OPERATION
FLAG
NVGBHIZC
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) .
1
BRK
0F
1
8
2
DI
60
1
3
Disable interrupts : I ← “0”
-----0--
3
EI
E0
1
3
Enable interrupts : I ← “1”
-----1--
4
NOP
FF
1
2
No operation
--------
5
POP A
0D
1
4
sp ← sp + 1, A ← M( sp )
6
sp ← sp + 1, X ← M( sp )
POP X
2D
1
4
7
POP Y
4D
1
4
sp ← sp + 1, Y ← M( sp )
8
POP PSW
6D
1
4
sp ← sp + 1, PSW ← M( sp )
9
PUSH A
0E
1
4
M( sp ) ← A , sp ← sp - 1
10
PUSH X
2E
1
4
M( sp ) ← X , sp ← sp - 1
11
PUSH Y
4E
1
4
M( sp ) ← Y , sp ← sp - 1
12
PUSH PSW
6E
1
4
M( sp ) ← PSW , sp ← sp - 1
13
RET
6F
1
5
Return from subroutine
-------sp ← sp +1, pcL ← M( sp ), sp ← sp +1, pcH ← M( sp )
14
RETI
7F
1
6
Return from interrupt
sp ← sp +1, PSW ← M( sp ), sp ← sp + 1,
pcL ← M( sp ), sp ← sp + 1, pcH ← M( sp )
restored
15
STOP
EF
1
3
Stop mode ( halt CPU, stop oscillator )
--------
MAY.2008 Ver 1.46
-------restored
--------