Escolar Documentos
Profissional Documentos
Cultura Documentos
MC80F0504/0604
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
REVISION HISTORY
VERSION 1.47 (NOV.2011) This book
Logo is changed.
Table of Contents
1. OVERVIEW .........................................................1 13. TIMER/EVENT COUNTER ............................ 47
Description .........................................................1 8-bit Timer / Counter Mode ............................. 49
Features .............................................................1 16-bit Timer / Counter Mode ........................... 53
Development Tools ............................................2 8-bit (16-bit) Compare Output ......................... 53
Ordering Information ........................................3 8-bit Capture Mode ......................................... 54
2. BLOCK DIAGRAM .............................................4 16-bit Capture Mode ....................................... 57
PWM Mode ..................................................... 58
3. PIN ASSIGNMENT .............................................5
14. ANALOG TO DIGITAL CONVERTER ........... 61
4. PACKAGE DRAWING ........................................6
15. BUZZER FUNCTION ..................................... 64
5. PIN FUNCTION .................................................10
16. INTERRUPTS ................................................ 66
6. PORT STRUCTURES .......................................12
Interrupt Sequence .......................................... 68
7. ELECTRICAL CHARACTERISTICS ................15 BRK Interrupt .................................................. 70
Absolute Maximum Ratings .............................15 Multi Interrupt .................................................. 70
Recommended Operating Conditions ..............15 External Interrupt ............................................. 72
A/D Converter Characteristics .........................15
17. POWER SAVING OPERATION ..................... 74
DC Electrical Characteristics ...........................16
Sleep Mode ..................................................... 74
AC Characteristics ...........................................17
Stop Mode ....................................................... 75
Typical Characteristics .....................................18
Stop Mode at Internal RC-Oscillated Watchdog
8. MEMORY ORGANIZATION .............................21 Timer Mode ..................................................... 78
Registers ..........................................................21 Minimizing Current Consumption .................... 80
Program Memory .............................................24 18. RESET ........................................................... 82
Data Memory ...................................................27
19. POWER FAIL PROCESSOR ......................... 84
Addressing Mode .............................................32
20. COUNTERMEASURE OF NOISE ................. 86
9. I/O PORTS ........................................................36
Oscillation Noise Protector .............................. 86
R0 and R0IO register .......................................36
Oscillation Fail Processor ................................ 87
R1 and R1IO register .......................................37
R3 and R3IO register .......................................39 21. DEVICE CONFIGURATION AREA ............... 88
10. CLOCK GENERATOR ...................................40 22. EMULATOR EVA. BOARD SETTING .......... 89
Oscillation Circuit ............................................40 A. INSTRUCTION .................................................. ii
Terminology List .................................................ii
11. BASIC INTERVAL TIMER ..............................42 Instruction Map .................................................. iii
12. WATCHDOG TIMER ......................................44 Instruction Set ...................................................iv
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 microcontrol-
ler 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 others eliminated functions are same as below table.
FLASH (ROM)
Device Name RAM ADC I/O PORT Package
Size
MC80F0604 10 channel 18 port 20 PDIP, 20SOP, 20 SSOP
4KB 256B 16 PDIP, 16 SOP,
MC80F0504 8 channel 14 port
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) Two External Interrupt input ports
- Endurance : 100 times
On-chip POR (Power on Reset)
- Retention time : 10 years
Seven Interrupt sources
256 Bytes On-chip Data RAM - External input : 2
(Included stack memory) - Timer : 4
Minimum Instruction Execution Time: - A/D Conversion : 1
- 333ns at 12MHz (NOP instruction)
Built in Noise Immunity Circuit
Programmable I/O pins - Noise Canceller
(LED direct driving can be a source and sink) - PFD (Power fail detector)
- MC80F0604 : 18(17) - ONP (Oscillation Noise Protector)
- MC80F0504 : 14(13)
Operating Voltage & Frequency
One 8-bit Basic Interval Timer - 2.2V ~ 5.5V (at 1 ~ 4MHz)
- 2.7V ~ 5.5V (at 1 ~ 8MHz)
Two 8-bit Timer/counters
- 4.5V ~ 5.5V (at 1 ~ 12MHz)
(or one 16-bit Timer/counter)
Operating Temperature : -40C ~ 85C
One Watchdog timer
Power Saving Modes
One 10-bit High Speed PWM Outputs
- STOP mode
10-bit A/D converter - SLEEP mode
- MC80F0604 : 10 channels - RC-WDT mode
- MC80F0504 : 8 channels
Oscillator Type
One Buzzer Driving port - Crystal
- 488Hz ~ 250kHz@4MHz - Ceramic resonator
Choice-Dr. (Emulator)
Pb free package :
The P suffix will be added at the original part number.
For example; MC80F0604B (Normal package), MC80F0604B P (Pb free package)
2. BLOCK DIAGRAM
Program
RESET System controller Memory
System 8-bit Basic
Clock Controller Interval Interrupt Controller Data Table
Timer
Timing generator
Clock Generator
Instruction
Decoder
10-bit 8-bit High Buzzer
Watch-dog A/D Timer/ Speed
Converter Counter PWM Driver
Timer
VDD
R3 R0 R1
VSS
Power
Supply
3. PIN ASSIGNMENT
MC80F0604B/0604D
20 PDIP
20 SOP
MC80F0604B/D
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
MC80F0504B/0504D/0504R
16 PDIP
16 SOP
16 TSSOP
4. PACKAGE DRAWING
1.043
1.010 TYP 0.300
0.270
MIN 0.015
0.245
MAX 0.180
0.140
0.120
4
0.01
0.021 . 00 8
0
0.015 0.065 TYP 0.100 0 ~ 15
0.050
20 SOP
0.299
0.291
0.419
0.398
0.5118
0.4961
0.0118
0.004
0.104
0.093
0.020 0 ~ 8
0.042
0.0125
0.0091
0.177
0.169
0.260
0.244
0.264
0.248
0.002
0.008
0.057
0.013 0 ~ 8
0.008 0.030
0.008
0.004
TYP 0.026 0.018
TYP 0.300
0.765
0.745 0.260
MIN 0.015
0.240
MAX 0.180
0.140
0.120
4
0.01
0.022 08
0.0
0.065 0 ~ 15
0.015 TYP 0.100
0.050
16 SOP
0.299
0.292
0.416
0.398
0.412
0.402
0.0118
0.004
0.104
0.094
0.019 0 ~ 8
0.040
0.0125
0.0091
unit: inch
16 SOP (153 mil)
MAX
MIN
0.158
0.149
0.244
0.228
0.394
0.0039
0.0098
0.385
0.069
0.053
0.019 0 ~ 8
TYP 0.0098
0.014 0.032
TYP 0.050 0.017
16 TSSOP
0.177
0.169
0.258
0.246
0.201
0.193
0.002
0.006
0.047MAX
0 ~ 8
0.012 0.030
0.007 0.026BSC 0.020
5. PIN FUNCTION
VDD: Supply voltage. R1 serves the functions of the various following special
features in Table 5-2
VSS: Circuit ground.
RESET: Reset the MCU.
Port pin Alternate function
XIN: Input to the inverting oscillator amplifier and input to
R10 AN0 ( Analog Input Port 0 )
the internal main clock operating circuit. AVref ( External Analog Reference Pin )
XOUT: Output from the inverting oscillator amplifier. PWM1O ( PWM1 Output )
R11 INT0 ( External Interrupt Input Port 0 )
R00~R07: R0 is an 8-bit, CMOS, bidirectional I/O port. R12 INT1 ( External Interrupt Input Port 1 )
RA pins can be used as outputs or inputs according to 1 BUZ ( Buzzer Driving Output Port )
or 0 written the their Port Direction Register(R0IO). R13
R14
Port pin Alternate function
Table 5-2 R1 Port
R00
R01 AN1 ( Analog Input Port 1 ) R31~R35: R3 is an 5-bit, CMOS, bidirectional I/O port.
R02 AN2 ( Analog Input Port 2 ) R3 pins can be used as outputs or inputs according to 1
R03 AN3 ( Analog Input Port 3 )
or 0 written the their Port Direction Register (R3IO). In
R04 AN4 ( Analog Input Port 4 )
R3 pins, R35 pin can be used as input port only.
EC0 ( Event Counter Input Source 0 )
R05 AN5 ( Analog Input Port 5 ) R3 serves the functions of the following special features in
T0O (Timer0 Clock Output ) Table 5-3 .
R06 AN6 ( Analog Input Port 6 )
R07 AN7 ( Analog Input Port 7 )
Port pin Alternate function
Table 5-1 R0 Port R31 AN14 ( Analog Input Port 14 )
R32 AN15 ( Analog Input Port 15 )
In addition, R0 serves the functions of the various special R33 XIN ( Oscillation Input )
features in Table 5-1 . R34 XOUT ( Oscillation Output )
R35 RESET ( Reset input port )
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 Table 5-3 R3 Port
0 written the their Port Direction Register (R1IO).
Pin No.
PIN NAME In/Out Function
(20PDIP)
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) Analog Input Port 4 / Event Counter Input 0
R05 (AN5 / T0O) 2 I/O (Input/Output) Analog Input Port 5 / Timer0 Output
R06 (AN6) 3 I/O (Input) Analog Input Port 6
R07 (AN7) 4 I/O (Input) Analog Input Port 7
Normal I/O Ports
R10 (AN0 / AVREF / Analog Input Port 0 / Analog Reference / PWM 1
6 I/O (Input/Input/Output)
PWM1O) output
R11 (INT0) 7 I/O (Input) External Interrupt Input 0
R12 (INT1 / BUZO) 8 I/O (Input/Output) External Interrupt Input 1 / Buzzer Driving Output
R13 9 I/O -
R14 10 I/O -
R31 (AN14) 11 I/O (Input) Analog Input Port 14
R32 (AN15) 12 I/O (Input) Analog Input Port 15
6. PORT STRUCTURES
Data Bus
MUX
AN[1]
RD
ADEN & ADS[3:0]
(ADCM)
Noise
EC0
Filter
EC0E (PSR0)
Direction Pin
Reg. Direction Pin
Reg.
VSS
VSS Data Bus VSS
MUX VSS
RD
Data Bus
MUX
RD Noise
INT0
Filter
AN[15:14]
AN[7:6] INT0E (PSR0)
AN[3:1]
Noise AN[5]
INT1
Filter
ADEN & ADS[3:0]
INT1E(PSR0.1) (ADCM)
RESET(R35)
R10 (AN0 / AVREF / PWM1O)
VDD
VDD
Pull-up
Pull-up Pull-up Tr.
Pull-up Tr. Reg. VDD
Reg.
Open Drain RD
Reg. VDD
VDD Mask only
Data Reg.
MUX Data Bus
PWM1O Internal Reset Pin
Pin
PWM1OE(PSR0.6)
VSS Reset Disable VSS
VSS (Configuration option bit)
Direction
Reg.
Data Bus
MUX
RD
AN[0]
ADEN & ADS[3:0]
(ADCM) VDD
ADC Reference
Voltage Input
MUX
AVREFS(PSR1.3)
VDD
VDD
VDD Pull-up
Pull-up
Tr.
Reg.
Open Drain
Reg. VDD
XIN VDD
STOP
Data Reg.
VSS
VSS
IN4MCLK RD
IN2MCLK
IN4MCLKXO
IN2MCLKXO
CLOCK option
(Configuration
option bit)
XIN, XOUT (External RC or R oscillation)
IN4MCLK
IN2MCLK
EXRC
VDD Main Clock
VDD (to ONP Block)
VDD
Pull-up
Pull-up Tr.
Reg.
XIN
STOP
Open Drain
Reg. VDD
VSS VDD
VSS
Data Bus MUX
RD
System Clock 4
IN4MCLKXO
IN2MCLKCO
EXRCXO
CLOCK option
(Configuration option bit)
7. ELECTRICAL CHARACTERISTICS
Specifications
Parameter Symbol Pin Condition Unit
Min. Typ. Max.
VIH1 XIN, RESET 0.8 VDD - VDD
Input High Voltage VIH2 Hysteresis Input1 0.8 VDD - VDD V
VIH3 Normal Input 0.7 VDD - VDD
VIL1 XIN, RESET 0 - 0.2 VDD
Input Low Voltage VIL2 Hysteresis Input1 0 - 0.2 VDD V
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
7.5 AC Characteristics
(TA=-40~85C, VDD=5V10%, VSS=0V)
Specifications
Parameter Symbol Pins Unit
Min. Typ. Max.
Operating Frequency fXIN XIN 1 - 12 MHz
System Clock Cycle
tSYS - 166 - 5000 nS
Time
Oscillation Stabilizing
tST XIN, XOUT - - 20 mS
Time (4MHz)
External Clock Pulse
tCPW XIN 35 - - nS
Width
External Clock Transi-
tRCP,tFCP XIN - - 20 nS
tion Time
Interrupt Pulse Width tIW INT0, INT1 2 - - tSYS
RESET Input Width tRST RESET 8 - - tSYS
Event Counter Input
tECW EC0 2 - - tSYS
Pulse Width
Event Counter Transi-
tREC,tFEC EC0 - - 20 nS
tion Time
XIN 0.5V
tRCP tFCP
tIW tIW
0.8VDD
INT0, INT1 0.2VDD
tRST
RESET
0.2VDD
tECW tECW
0.8VDD
EC0 0.2VDD
tREC tFEC
Operating Area
fXIN Normal Operation
(MHz) Ta=25C
16
IDDVDD
IDD
14 (mA) Ta=25C
12
12
10 10
8 8
fXIN=12MHz
6 6
4MHz
4 4
2 2
0 0 VDD
VDD
2 3 4 5 6 (V) 2 3 4 5 6 (V)
1 1.0
0.5 0.5
0 VDD 0 VDD
2 3 4 5 (V) 2 3 4 5 6 (V)
15
TRCWDT = 50uS
10
0 VDD
2 3 4 5 6 (V)
15 -15
-10
10
5 -5
0 0 VOH
VOL
3.5 4 4.5 5 (V)
0.5 1 1.5 2 (V)
3 3 3
2 2 2
1 1 1
3 3 3
2 2 2
1 1 1
9 9
R = 4.7K
8 8
R = 4.7K
7 7
R = 10K
6 6
5 5 R = 10K
4 4
R = 20K
3 3
R = 20K
R = 30K
2 2
R = 30K
1 1
0 VDD 0 VDD
2.5 3.0 3.5 4.0 4.5 5.0 5.5 (V) 2.5 3.0 3.5 4.0 4.5 5.0 5.5 (V)
6 6
R = 4.7K R = 4.7K
5 5
4 4
R = 10K
3 3 R = 10K
R = 20K
2 2 R = 20K
1 R = 30K 1
R = 30K
0 VDD 0 VDD
2.5 3.0 3.5 4.0 4.5 5.0 5.5 (V) 2.5 3.0 3.5 4.0 4.5 5.0 5.5 (V)
Note: The external RC oscillation frequencies shown in Note: There may be the difference between package
above are provided for design guidance only and not tested types(PDIP, SOP, TSSOP). The user should modify the
or guaranteed. The user needs to take into account that the value of R and C components to get the proper frequency
external RC oscillation frequencies generated by the same in exchanging MC80F0104/0204 to MC80F0504/0604 or
circuit design may be not the same. Because there are vari- one package type to another package type.
ations in the resistance and capacitance due to the toler-
ance of external R and C components. The parasitic
capacitance difference due to the different wiring length
and layout may change the external RC oscillation frequen-
cies.
8. MEMORY ORGANIZATION
The MC80F0504/0604 has separate address spaces for Data memory can be read and written to up to 256 bytes in-
Program memory and Data Memory. 4K bytes program cluding the stack area.
memory can only be read, not written to.
8.1 Registers
This device has six registers that are the Program Counter call is executed or an interrupt is accepted. However, if it
(PC), a Accumulator (A), two index registers (X, Y), the is used in excess of the stack area permitted by the data
Stack Pointer (SP), and the Program Status Word (PSW). memory allocating configuration, the user-processed data
The Program Counter consists of 16-bit register. may be lost.
The stack can be located at any position within 1C0H to
A ACCUMULATOR 1FFH of the internal data memory. The SP is not initialized
X REGISTER
by hardware, requiring to write the initial value (the loca-
X
tion with which the use of the stack starts) by using the ini-
Y Y REGISTER tialization routine. Normally, the initial value of FFH is
SP STACK POINTER used.
PCH PCL PROGRAM COUNTER
Stack Address (1C0H ~ 1FFH)
PSW PROGRAM STATUS WORD Bit 15 8 7 Bit 0
01H SP
C0H~FFH
Hardware fixed
Figure 8-1 Configuration of Registers
Accumulator: The Accumulator is the 8-bit general pur-
pose register, used for data operation such as transfer, tem- Note: The Stack Pointer must be initialized by software because
its value is undefined after Reset.
porary saving, and conditional judgement, etc.
The Accumulator can be used as a 16-bit register with Y Example: To initialize the SP
LDX #0FFH
Register as shown below.
TXSP ; SP FFH
MSB LSB
PSW N V G B H I Z C RESET VALUE: 00H
01FF Push
PCH 01FF PCH 01FF PCH 01FF PCH
down Push Pop Pop
01FE PCL 01FE PCL 01FE PCL 01FE PCL
down up up
01FD 01FD PSW 01FD 01FD PSW
01FC 01FC 01FC 01FC
SP before
execution 01FF 01FF 01FD 01FC
SP after
execution 01FD 01FC 01FF 01FF
At execution At execution
of PUSH instruction of POP instruction
PUSH A (X,Y,PSW) POP A (X,Y,PSW)
SP before
execution 01FF 01FE
SP after
execution 01FE 01FF
4F 4A 01001010
35 Reverse
~ ~ 1
~ ~
~
~ ~
~ NEXT PC: 11111111 11010110
0D125H
FH FH DH 6H
0FF00H
0FFFFH 0FFFFH
LDX #0C0h
RAM_Clear1:
LDA #0
STA {X}+
CMPX #00h
BNE RAM_Clear1
RAM_Clear_Finish:
CLRG ;Page0 Select
LDX #0FFh ;Initial Stack Pointer
TXSP
:
:
;Initialize IO
LDM R0, #0 ;Normal Port R0
LDM R0IO,#0FFH ;Normal Port R0 Direction
:
:
PAGE0
More detailed informations of each register are explained
00BFH
(When G-flag=0,
in each peripheral section.
00C0H
Control this page0 is selected)
Registers
00FFH Note: Write only registers can not be accessed by bit manipula-
0100H tion instruction. Do not use read-modify-write instruction. Use byte
Not Available manipulation instruction, for example LDM.
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
Figure 8-8 Data Memory Map saved before a jump is performed during the processing
routine at the execution of a subroutine call instruction or
User Memory the acceptance of an interrupt.
The MC80F0504/0604 has 256 8 bits for the user mem- When returning from the processing routine, executing the
ory (RAM). RAM pages are selected by RPR (See Figure subroutine return instruction [RET] restores the contents of
8-9 ). the program counter from the stack; executing the interrupt
return instruction [RETI] restores the contents of the pro-
Note: After setting RPR(RAM Page Select Register), be sure to gram counter and flags.
execute SETG instruction. When executing CLRG instruction, be The save/restore locations in the stack are determined by
selected PAGE0 regardless of RPR.
the stack pointed (SP). The SP is automatically decreased
after the saving, and increased before the restoring. This
Control Registers means the value of the SP indicates the stack location
The control registers are used by the CPU and Peripheral number for the next save. Refer to Figure 8-4 .
function blocks for controlling the desired operation of the
device. Therefore these registers contain control and status
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.
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
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 - - CAP0 T0CK2 T0CK1 T0CK0 T0CN T0ST
T0/TDR0/
0D1H Timer0 Register / Timer0 Data Register / Timer0 Capture Data Register
CDR0
0D2H TM1 POL 16BIT PWM1E CAP1 T1CK1 T1CK0 T1CN T1ST
TDR1/
0D3H Timer1 Data Register / Timer1 PWM Period Register
T1PPR
T1/CDR1/
0D4H Timer1 Register / Timer1 Capture Data Register /Timer1 PWM Duty Register
T1PDR
0D5H PWM1HR - - - - Timer1 PWM High Register
0E0H BUZR BUCK1 BUCK0 BUR5 BUR4 BUR3 BUR2 BUR1 BUR0
0E1H 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 - - - ADC Result Reg. High
0F1H ADCRL ADC Result Register Low
BITR1 Basic Interval Timer Data Register
0F2H
CKCTLR1 ADRST - RCWDT WDTON BTCL BTS2 BTS1 BTS0
WDTR WDTCL 7-bit Watchdog Timer Register
0F4H
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
Address Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
0FDH PU1 R1 Pull-up Selection Register
0FFH PU3 R3 Pull-up Selection Register
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".
~
~ ~
~
1 2 The operation within data memory (RAM)
0F100H E4 ASL, BIT, DEC, INC, LSR, ROL, ROR
0F101H 55
Example; Addressing accesses the address 0135H regard-
0F102H 35
less of G-flag.
35H data 2
135H data
3 ~
~ ~
~
data A
~ ~ 2 1 36H X
~ ~
data+1 data DB
0F100H 98 1
0F101H 35 address: 0135
0F102H 01
35H 05
0F100H D5 36H E0
0F101H 00
1
~ ~ 2 0E005H
0F102H FA 0FA00H+55H=0FA55H ~ ~
0E005H data 1 25 + X(10) = 35H
~
~ ~
~ 2
~
~ ~
~
0FA55H data data A
3 0FA00H 16
25
3 A + data + C A
8.4.6 Indirect Addressing
Y indexed indirect [dp]+Y
Direct page indirect [dp]
Processes memory data as Data, assigned by the data
Assigns data address to use for accomplishing command
[dp+1][dp] of 16-bit pair memory paired by Operand in Di-
which sets memory data (or pair memory) by Operand.
rect page plus Y-register data.
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
1725 ADC [25H]+Y
3F35 JMP [35H]
35H 0A 25H 05
36H E3 26H E0
~ ~ 2 2
~ ~ ~
~ ~
~
1 1
0E30AH NEXT jump to 0E015H data 0E005H + Y(10)
address 0E30AH = 0E015H
~
~ ~
~ ~ ~
~ ~
0FA00H 3F 0FA00H 17
35 25
3
A + data + C A
PROGRAM MEMORY
0E025H 25
0E026H E7
~ ~ 2
~ ~ jump to
address 0E30AH
1 0E725H NEXT
~
~ ~
~
0FA00H 1F
25
E0
9. I/O PORTS
The MC80F0504/0604 has three ports (R0, R1 and R3). its initial status is input.
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
WRITE 55H TO PORT R0 DIRECTION REGISTER
state, so it can directly drive LED device.
0C0H R0 data 0 1 0 1 0 1 0 1 BIT
All pins have data direction registers which can define 7 6 5 4 3 2 1 0
0C1H R0 direction
these ports as output or input. A 1 in the port direction
0C2H R1 data
register configure the corresponding port pin as output.
0C3H R1 direction I O I O I O I O PORT
Conversely, write 0 to the corresponding bit to specify it 7 6 5 4 3 2 1 0
as input pin. For example, to use the even numbered bit of
I: INPUT PORT
R0 as output ports and the odd numbered bits as input O: OUTPUT PORT
ports, write 55H to address 0C1H (R0 port direction reg-
ister) during initial setting as shown in Figure 9-1 . 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,
R0 R07 R06 R05 R04 R03 R02 R01 R00 PSR0 - PWM1OE - EC0E - - INT1E INT0E
R33, R34 and R35 is multiplexed with XIN, XOUT, and Pull-up Resister Selection
RESET pin. These pins can be used as general I/O pins by 0: Disable
setting writing option described in "21. DEVICE CON- 1: Enable
FIGURATION AREA" .
R3 Open Drain ADDRESS: 0CBH
Selection Register RESET VALUE: ---0 000-B
R3OD
INOSC SLEEP
Main OSC
Stop
INOSC
PRESCALER
INOSC (IN4MCLK/IN2MCLK/ PS0 PS1 PS2 PS3 PS4 PS5 PS6 PS7 PS8 PS9 PS10 PS11 PS12
IN4MCLKXO/IN2MCLKXO)
fEX (Hz) 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
4M
period 250n 500n 1u 2u 4u 8u 16u 32u 64u 128u 256u 512u 1.024m
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 exter-
nal RC oscillation.
Vdd
XOUT
REXT XIN
XIN
fXIN4 XOUT
Internal RC OSC
RCWDT
8
8-bit up-counter Basic Interval
16 1 source
clock overflow Timer Interrupt
32 BITIF
BITR
Prescaler
64
XIN PIN MUX
0
128 [0F2H]
256 To Watchdog timer (WDTCK)
512 clear
1024
7 6 5 4 3 2 1 0 ADDRESS: 0F2H
CKCTLR ADRST - RCWDT WDTONBTCL
BTCL BTS2 BTS1 BTS0 INITIAL VALUE: 0-01 0111B
7 6 5 4 3 2 1 0
ADDRESS: 0F2H
BITR BTCL
INITIAL VALUE: Undefined
8-BIT FREE-RUN BINARY COUNTER
clear
Watchdog clear
BASIC INTERVAL TIMER
Count Counter (7-bit)
OVERFLOW
source
0
to reset CPU
comparator 1
enable
WDTON in CKCTLR [0F2H]
WDTCL 7-bit compare data
7 WDTIF
Watchdog Timer interrupt
Watchdog Timer Control er output will become active at the rising overflow from
the binary counters unless the binary counter is cleared. At
Figure 12-2 shows the watchdog timer control register.
this time, when WDTON=1, a reset is generated, which
The watchdog timer is automatically disabled after reset.
drives the RESET pin to low to reset the internal hardware.
The CPU malfunction is detected during setting of the de- When WDTON=0, a watchdog timer interrupt (WDTIF) is
tection time, selecting of output, and clearing of the binary generated. The WDTON bit is in register CLKCTLR.
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 au-
If the malfunction occurs for any cause, the watchdog tim- tomatically restarts (continues counting).
W W W W W W W W
7 6 5 4 3 2 1 0
ADDRESS: 0F4H
WDTR WDTCL
INITIAL VALUE: 0111 1111B
Source clock
BIT overflow
Binary-counter 1 2 3 0 1 2 3 0
Counter Counter
Clear Clear
WDTR n 3
Match
Detect
WDTIF interrupt
WDTR 1000_0011B
WDT reset reset
T0CK T1CK
16BIT CAP0 CAP1 PWM1E PWM1O TIMER 0 TIMER 1
[2:0] [1:0]
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)
7 6 5 4 3 2 1 0
ADDRESS: 0D0H
TM0 - - CAP0 T0CK2 T0CK1
BTCL T0CK0 T0CN T0ST INITIAL VALUE: --00 0000B
- - 0 X X X X X
7 6 5 4 3 2 1 0
ADDRESS: 0D2H
TM1 POL 16BIT PWM1E CAP1 T1CK1
BTCL T1CK0 T1CN T1ST INITIAL VALUE: 00H
X 0 0 0 X X X X
T0CK[2:0]
EDGE
DETECTOR
T0ST
2 000
0: Stop
4
001 1: Clear and start
8
010 T0 (8-bit)
Prescaler
32 clear
011
XIN PIN 128
100 TIMER 0
512 T0CN T0IF
101 INTERRUPT
2048 Comparator
110
R05 / T0O
T1CK[1:0]
T1ST
11 0: Stop
1 1: Clear and start
00
2 T1 (8-bit)
01 clear
8
10
TIMER 1
T1CN T1IF
MUX INTERRUPT
Comparator
LDM TDR0,#249 In the timer mode, the internal clock is used for counting
LDM TDR1,#249 up. Thus, you can think of it as counting internal clock in-
LDM TM0,#0001_1111B put. The contents of TDRn are compared with the contents
LDM TM1,#0000_1011B
SET1 T0E of up-counter, Tn. If match is found, a timer n interrupt
SET1 T1E (TnIF) is generated and the up-counter is cleared to 0.
EI Counting up is resumed after the up-counter is cleared.
These timers have each 8-bit count register and data regis- As the value of TDRn is changeable by software, time in-
ter. The count register is increased by every internal or ex- terval is set as you want.
ternal clock input. The internal clock has a prescaler divide
Start count
Source clock
~
~
~
~
TDR1 n
~
~
Match Counter
T1IF interrupt Detect Clear
~
~
~~
7A
nt
8 s
ou
-c
up
~~
~~
6
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
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
In this mode, counting up is started by an external trigger.
This trigger means rising edge of the EC0 pin input. Source set to 1.
clock is used as an internal clock selected with timer mode After reset, the value of timer data register TDRn is initial-
register TM0. The contents of timer data register TDR0 are ized to "0", The interval period of Timer is calculated as
compared with the contents of the up-counter T1. If a below equation.
match is found, an timer interrupt request flag T0IF is gen-
1
erated, and the counter is cleared to 0. The counter is re- Period (sec) = ----------- 2 Divide Ratio (TDRn+1)
f XIN
start 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].
Start count
~
~
Up-counter 0 1 2 n-1 n 0 1 2
~
~
~
~
TDR0 n
~
~
T0IF interrupt
~
~
TDR1
disable enable
~~
stop
t
oun
-c
up
~~
TIME
Timer 1 (T1IF)
Interrupt
Occur interrupt Occur interrupt
T1ST
T1ST = 1
Start & Stop
T1ST = 0
T1CN
Control count T1CN = 1
T1CN = 0
7 6 5 4 3 2 1 0
ADDRESS: 0D0H
TM0 - - CAP0 T0CK2 T0CK1
BTCL T0CK0 T0CN T0ST INITIAL VALUE: --00 0000B
- - 0 X X X X X
7 6 5 4 3 2 1 0
ADDRESS: 0D2H
TM1 POL 16BIT PWM1E CAP1 T1CK1
BTCL T1CK0 T1CN T1ST INITIAL VALUE: 00H
X 1 0 0 1 1 X X
T0CK[2:0]
EDGE
DETECTOR
32 (16-bit) clear
011
128
100
512 T0CN TIMER 0
101 T0IF
INTERRUPT
2048 Comparator
110 (Not Timer 1 interrupt)
7 6 5 4 3 2 1 0
ADDRESS: 0D0H
TM0 - - CAP0 T0CK2 T0CK1
BTCL T0CK0 T0CN T0ST INITIAL VALUE: --00 0000B
- - 1 X X X X X
7 6 5 4 3 2 1 0
ADDRESS: 0D2H
TM1 POL 16BIT PWM1E CAP1 T1CK1
BTCL T1CK0 T1CN T1ST INITIAL VALUE: 00H
X 0 0 1 X X X X
32
011
128 clear
100
512 T0CN
101 Capture
2048
110
CDR0 (8-bit)
MUX
IEDS[1:0]
01
10 INT0
INT0 PIN INT0IF
INTERRUPT
T1CK[1:0]
11
T1ST
11 0: Stop
1 1: Clear and start
00
2 T1 (8-bit)
01
8
10 clear
T1CN
MUX Capture
CDR1 (8-bit)
IEDS[3:2]
01
10 INT1
INT1 PIN INT1IF
INTERRUPT
11
~~
~~
9
n t
8
ou
-c
7
up
6
5
4
3
~~
2
1
0
TIME
Interrupt Request
( INT0IF )
Interrupt Interval Period
Interrupt Request
( INT0IF )
20nS 5nS Delay
Interrupt Request
( INT0IF )
Interrupt Interval Period=01H+FFH +01H+FFH +01H+13H=214H
Interrupt Request
( T0IF )
FFH FFH
T0
13H
00H 00H
7 6 5 4 3 2 1 0
ADDRESS: 0D0H
TM0 - - CAP0 T0CK2 T0CK1
BTCL T0CK0 T0CN T0ST INITIAL VALUE: --00 0000B
- - 1 X X X X X
7 6 5 4 3 2 1 0
ADDRESS: 0D2H
TM1 POL 16BIT PWM1E CAP1 T1CK1
BTCL T1CK0 T1CN T1ST INITIAL VALUE: 00H
X 1 0 1 1 1 X X
32
011
128 clear
100
512 T0CN
101 Capture
2048
110
CDR1 + CDR0
MUX (16-bit)
IEDS[1:0] Higher byte Lower byte
CAPTURE DATA
01
10 INT0
INT0 PIN INT0IF
INTERRUPT
11
The user writes the lower 8-bit period value to the T1PPR The bit POL of TM1 decides the polarity of duty cycle.
and the higher 2-bit period value to the T1PWHR[3:2].
And writes duty value to the T1PDR and the If the duty value is set same to the period value, the PWM
T1PWHR[1:0] same way. output is determined by the bit POL (1: High, 0: Low). And
if the duty value is set to "00H", the PWM output is deter-
The T1PDR is configured as a double buffering for glitch-
mined by the bit POL (1: Low, 0: High).
less PWM output. In Figure 13-12 , the duty data is trans-
ferred from the master to the slave when the period data It can be changed duty value when the PWM output. How-
matched to the counted value. (i.e. at the beginning of next ever the changed duty value is output after the current pe-
duty cycle) riod is over. And it can be maintained the duty value at
present output when changed only period value shown as
PWM1 Period = [PWM1HR[3:2]T1PPR + 1] X
Figure 13-14 . As it were, the absolute duty time is not
Source Clock changed in varying frequency. But the changed period val-
PWM1 Duty = [PWM1HR[1:0]T1PDR + 1] X ue must greater than the duty value.
Source Clock
Note: If changing the Timer1 to PWM function, it should be stop
the timer clock firstly, and then set period and duty register value.
If user writes register values while timer is in operation, these reg-
The relation of frequency and resolution is in inverse pro-
ister could be set with certain values.
portion. Table 13-2 shows the relation of PWM frequency
vs. resolution. Ex) Sample Program @4MHz 2uS
If it needed more higher frequency of PWM, it should be LDM TM1,#1010_1000b ; Set Clock & PWM1E
LDM T1PPR,#199 ; Period :400uS=2uSX(199+1)
LDM T1PDR,#99 ; Duty:200uS=2uSX(99+1)
LDM PWM1HR,00H
LDM TM1,#1010_1011b ; Start timer1
- - - - W W W W
7 6 5 4 3 2 1 0
ADDRESS: 0D5H
T1PWHR - - - - BTCL T1PWHR2 T1PWHR1 T1PWHR0
T1PWHR3
INITIAL VALUE: ---- 0000B
- - - - X X X X Bit Manipulation Not Available
X:The value "0" or "1" corresponding your operation.
Period High Duty High
W W W W W W W W
7 6 5 4 3 2 1 0
ADDRESS: 0D3H
T1PPR BTCL INITIAL VALUE: 0FFH
T1PWHR[3:2]
2
R R10 / PWM1O PIN
XIN PIN 01 2-bit T1(8-bit)
8
10 POL
T1CN Comparator
MUX
Slave T1PDR(8-bit)
T1PWHR[1:0]
Master T1PDR(8-bit)
~
~
~
~
Source
clock
~
~ ~
~ ~
~
T1 00 01 02 03 04 7E 7F 80 3FF 00 01 02
~
~ ~
~
PWM1E
~
~
T1ST
~
~
T1CN
PWM1O
[POL=1] ~
~
~
~
~
~
PWM1O
[POL=0]
~
~
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
Period Cycle [ (1+0Dh) x 2uS = 28uS, 35.5KHz ] Period Cycle [ (1+09h) x 2uS = 20uS, 50KHz ]
Figure 13-14 Example of Changing the PWM1 Period in Absolute Duty Cycle (@4MHz)
Analog
NOP Input AN0~AN7
AN14, AN15
0~1000pF
User Selectable
ADSF = 1
NO
YES
AVREFS (PSR1.3)
ADEN
VDD
0
AN0 / AVREF
AN1
Successive
ADC
MUX Approximation ADCIF INTERRUPT
Sample & Hold
Circuit
AN7
AN14
ADC8 0 1
AN15
ADS[3:0] (ADCM[5:2])
98 98 32
ADCR (10-bit)
10-bit ADCR 10-bit ADCR
0 0
W W W - - - R R
7 6 5 4 3 2 1 0
ADCRH BTCL ADDRESS: 0F0H
PSSEL1 PSSEL0 ADC8 - - - INITIAL VALUE: 010- ----B
8
00 6-BIT BINARY
16 COUNTER
Prescaler
01 MUX
XIN PIN 32
10 0
R12/BUZO PIN
64 F/F 1
11
MUX Comparator
2
Compare data
BUZO
6 PSR1 Port selection register 1
BUR [0F9H]
[0E0H]
ADDRESS: 0E0H
RESET VALUE: 0FFH ADDRESS: 0F9H
W W W W W W W W RESET VALUE: ---- 0000B
The 6-bit counter is cleared and starts the counting by writ- When main-frequency is 4MHz, buzzer frequency is
ing signal at BUZR register. It is incremental from 00H un- shown as below Table 15-1.
til it matches 6-bit BUR value.
16. INTERRUPTS
TheMC80F0504/0604 interrupt circuits consist of Inter- interrupt was transition-activated.
rupt enable register (IENH, IENL), Interrupt request flags The Timer 0 and Timer 1 Interrupts are generated by T0IF,
of IRQH, IRQL, Priority circuit, and Master enable flag T1IF and T1IF which is set by a match in their respective
(I flag of PSW). Fifteen interrupt sources are provided. timer/counter register.
The configuration of interrupt circuit is shown in Figure
16-1 and interrupt priority is shown in Table 16-1. 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 transi-
tion-activated (1-to-0 or 0-to-1 transition) by selection The AD converter Interrupt is generated by ADCIF which
IEDS register. is set by finishing the analog to digital conversion.
The flags that actually generate these interrupts are bit The Watchdog timer is generated by WDTIF and WTIF
INT0IF and INT1IF in register IRQH. When an external which is set by a match in Watchdog timer register.
interrupt is generated, the generated flag is cleared by the
hardware when the service routine is vectored to only if the
[0EAH]
I-flag is in PSW, it is cleared by DI, set by
IENH Interrupt Enable EI instruction. When it goes interrupt service,
Register (Higher byte) I-flag is cleared by hardware, thus any other
IRQH interrupt are inhibited. When interrupt service is
[0ECH] completed by RETI instruction, I-flag is set to
1 by hardware.
INT0 INT0IF
INT1 INT1IF
Release STOP/SLEEP
Priority Control
To CPU
Timer 0 T0IF
I-flag
Interrupt Master
IRQL Enable Flag
[0EDH]
Timer 1 T1IF Interrupt
Vector
Address
Generator
BIT BITIF
System clock
Instruction Fetch
Data Bus Not used PCH PCL PSW V.L. ADL ADH OP code
Internal Read
Internal Write
Figure 16-4 Timing chart of Interrupt Acceptance and Interrupt Return Instruction
A interrupt request is not accepted until the I-flag is set to
Basic Interval Timer
Entry Address
1 even if a requested interrupt has higher priority than
Vector Table Address
that of the current interrupt being serviced.
012H
When nested interrupt service is required, the I-flag should
0FFE0H 0E312H 0EH
0FFE1H 0E3H 2EH
be set to 1 by EI instruction in the interrupt service
0E313H
program. In this case, acceptable interrupt sources are se-
lectively enabled by the individual interrupt enable flags.
interrupt processing
Note: The MC80F0504 and HMS87C1102A is very
similar in function, but the interrupt processing meth- RETI ;RETURN
od is different. When replacing the HMS87C1102A to
MC80F0504, clearing interrupt request flag should
be added.
RETI RET
Main Program
service TIMER 1
service
INT0
service
enable INT0
disable other
EI
Occur Occur In this example, the INT0 interrupt can be serviced without any
TIMER1 interrupt INT0 pending, even TIMER1 is in progress.
Because of re-setting the interrupt enable registers IENH,IENL
and master enable EI in the TIMER1 routine.
enable INT0
enable other
01
INT0 pin 10 INT0IF INT0 INTERRUPT
11
01
INT1 pin 10 INT1IF INT1 INTERRUPT
11
2 2
Edge selection
IEDS Register
[0EEH]
MSB LSB
- - - - W W W W
ADDRESS: 0EEH
IEDS - - - - BTCL IED1L IED0H IED0L
IED1H INITIAL VALUE: ---- 0000B
INT1 INT0
- W - W - - W W
ADDRESS: 0F8H
PSR0 - PWM1O - EC0E BTCL
- - INT1E INT0E INITIAL VALUE: -0-0 --00B
MSB LSB
0: R10 0: R11
1: PWM1O 1: INT0
0: R12
1: INT1
0: R04
1: EC0
W W W W W W W W
7 6 5 4 3 2 1 0
SSCR ADDRESS: 0F5H
INITIAL VALUE: 0000 0000B
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.
Release the SLEEP mode stabilizing time is required to normal operation. Figure 17-
The exit from SLEEP mode is hardware reset or all inter- 3 shows the timing diagram. When released from the
rupts. Reset re-defines all the Control registers but does not SLEEP mode, the Basic interval timer is activated on
change the on-chip RAM. Interrupts allow both on-chip wake-up. It is increased from 00H until FFH. The count
RAM and Control registers to retain their values. overflow is set to start normal operation. Therefore, before
SLEEP instruction, user must be set its relevant prescaler
If I-flag = 1, the normal interrupt response takes place. If I-
divide ratio to have long enough time (more than 20msec).
flag = 0, the chip will resume execution starting with the
This guarantees that oscillator has started and stabilized.
instruction following the SLEEP instruction. It will not
By interrupts, exit from SLEEP mode is shown in Figure
vector to interrupt service routine. (refer to Figure 17-4 )
17-2 . By reset, exit from SLEEP mode is shown in Figure
When exit from SLEEP mode by reset, enough oscillation 17-3 .
Oscillator
~ ~
~
~ ~
~
(XIN pin)
~
Internal Clock
~
~
~ ~
~ ~
External Interrupt
~
~
SLEEP Instruction
Executed
Oscillator
(XIN pin)
~
~
CPU
Clock
~
~
~
~
~
~
RESET
Internal
~
~
RESET
~
~
The reset should not be activated before VDD is restored to pin interface (depending on the external circuitry and pro-
its normal operating level, and must be held active long gram) is not directly determined by the hardware operation
enough to allow the oscillator to restart and stabilize. of the STOP feature. This point should be little current
flows when the input level is stable at the power voltage
Note: After STOP instruction, at least two or more NOP instruc- level (VDD/VSS); however, when the input level gets high-
tion should be written. er than the power voltage level (by approximately 0.3 to
Ex) LDM CKCTLR,#0FH ;more than 20ms 0.5V), a current begins to flow. Therefore, if cutting off the
LDM SSCR,#5AH
output transistor at an I/O port puts the pin signal into the
STOP
NOP ;for stabilization time high-impedance state, a current flow across the ports input
NOP ;for stabilization time transistor, requiring to fix the level by pull-up or other
means.
In the STOP operation, the dissipation of the power asso-
ciated with the oscillator and the internal hardware is low-
ered; however, the power dissipation associated with the
Release the STOP mode When exit from Stop mode by external interrupt, enough
The source for exit from STOP mode is hardware reset, ex- oscillation stabilizing time is required to normal operation.
ternal interrupt, Timer(EC0), Watch Timer, WDT. Reset Figure 17-5 shows the timing diagram. When released
re-defines all the Control registers but does not change the from the Stop mode, the Basic interval timer is activated on
on-chip RAM. External interrupts allow both on-chip wake-up. It is increased from 00H until FFH. The count
RAM and Control registers to retain their values. overflow is set to start normal operation. Therefore, before
STOP instruction, user must be set its relevant prescaler di-
If I-flag = 1, the normal interrupt response takes place. If I-
vide ratio to have long enough time (more than 20msec).
flag = 0, the chip will resume execution starting with the
This guarantees that oscillator has started and stabilized.
instruction following the STOP instruction. It will not vec-
tor to interrupt service routine. (refer to Figure 17-4 ) By reset, exit from Stop mode is shown in Figure 17-6 .
STOP
INSTRUCTION
STOP Mode
Interrupt Request
Corresponding Interrupt =0
IENH or IENL ?
Enable Bit (IENH, IENL)
=1
Master Interrupt =0
Enable Bit PSW[2] I-FLAG
=1
Next
INSTRUCTION
Oscillator
~ ~
~
(XIN pin)
~
~
~
~
~
Internal Clock
~
~
~
~
External Interrupt
~
~
STOP Instruction
Executed
~ ~
~
~ ~
~
Clear
Normal Operation Stop Operation Stabilization Time Normal Operation
tST > 20ms
by software
STOP Mode
~
~
Oscillator
(XI pin)
~
~
~ ~
~ ~
Internal
Clock
~ ~
~
~
~
~
RESET
Internal
~
~
RESET
~
~
STOP Instruction Execution
Stabilization Time
Time can not be control by software tST = 65.5mS @4MHz
~
~
Oscillator
(XIN pin)
~
~
~
~
Internal
RC Clock
~
~
Internal
Clock
~
~
External
~
~
Interrupt
~
~
( or WDT Interrupt )
STOP Instruction Execution Clear Basic Interval Timer
~
~
BIT
N-2 N-1 N N+1 N+2 00 01 FE FF 00 00
Counter
~
~
Normal Operation STOP mode Stabilization Time Normal Operation
at RC-WDT Mode tST > 20mS
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
~
~
Internal
Clock
~
~
RESET
~
~
~
~
RESET by WDT
Internal
~
~
RESET
~
~
VDD
INPUT PIN
INPUT PIN VDD VDD
internal
pull-up i=0
O
VDD
OPEN
O i
i
Very weak current flows
VDD
GND
X i=0
X
GND
OFF
O OFF i ON i=0
i
ON
X X O
OFF
O
In the left case, Tr. base current flows from port to GND.
To avoid power consumption, there should be low output
to the port .
O port puts the pin signal into the high-impedance state, a current
Note: In the STOP operation, the power dissipation associated flow across the ports input transistor, requiring it to fix the level by
with the oscillator and the internal hardware is lowered; however, pull-up or other means.
the power dissipation associated with the pin interface (depending
on the external circuitry and program) is not directly determined by
It should be set properly in order that current flow through
the hardware operation of the STOP feature. This point should be
little current flows when the input level is stable at the power volt- port doesn't exist.
age level (VDD/VSS); however, when the input level becomes high- First consider the port setting to input mode. Be sure that
er than the power voltage level (by approximately 0.3V), a current
begins to flow. Therefore, if cutting off the output transistor at an I/
there is no current flow after considering its relationship
with external circuit. In input mode, the pin impedance
viewing from external MCU is very high that the current output mode considering there is no current flow. The port
doesnt flow. setting to High or Low is decided by considering its rela-
tionship with external circuit. For example, if there is ex-
But input voltage level should be VSS or VDD. Be careful
ternal pull-up resistor then it is set to output mode, i.e. to
that if unspecified voltage, i.e. if uncertain voltage level
High, and if there is external pull-down register, it is set to
(not VSS or VDD) is applied to input pin, there can be little
low.
current (max. 1mA at around 2V) flow.
If it is not appropriate to set as an input mode, then set to
18. RESET
The MC80F0504/0604 supports various kinds of reset as Watchdog Timer Timeout Reset
below. Power-Fail Detection (PFD) Reset
RESET
Noise Canceller
On-chip POR
(Power-On Reset)
Internal
Address Fail reset S Q RESET
Overflow
R
PFD
(Power-Fail Detection)
Clear
WDT
(WDT Timeout Reset)
BIT
The on-chip POR circuit holds down the device in RESET uration Area(20FFH) in the Flash programming. When the
until VDD has reached a high enough level for proper op- device starts normal operation, its operating parmeters
eration. It will eliminate external components such as reset (voltage, frequency, temperature...etc) must be met.
IC or external resistor and capacitor for external reset cir- .Table 18-1 shows on-chip hardware initialization by reset
cuit. In addition that the RESET pin can be used to normal
action.
input port R35 by setting POR and R35EN bit Config-
VCC
10k
~ 1 2 3 4 5 6 7
~
Oscillator
(XIN pin)
~
~
RESET
~
~
ADDRESS
? ? ? ? FFFE FFFF Start
BUS
~
~ ~
~
DATA
? ? ? ? FE ADL ADH OP
BUS
~
~
MAIN PROGRAM
Stabilization Time Reset Process Step
tST =65.5mS at 4MHz
1
tST = x 256
fXIN 1024
RESET VECTOR
YES
PFDS =1
NO
RAM Clear
Initialize RAM Data PFDS = 0
Skip the
Initialize All Ports initial routine
Initialize Registers
Function
Execution
VDD
VPFDMAX
VPFDMIN
65.5mS
Internal
RESET
VDD VPFDMAX
When PFDM = 1 VPFDMIN
Internal 65.5mS
t < 65.5mS
RESET
VDD
VPFDMAX
VPFDMIN
65.5mS
Internal
RESET
XIN OFP
1
XIN_NF
Mux 0
HF Noise CLK
HF Noise Canceller 0S
Internal Changer FINTERNAL
Observer OSC 1 S
en
INT_CLK
LF Noise
CLK_CHG
ONP Observer ONP
OFP
en
IN4(2)MCLK(XO)
en
o/f
CK
OFP
PS10
ONPb = 0 (8-Bit counter)
LF_on = 1
IN_CLK = 0
INT_CLK 8 periods PS10(INT_CLK/512) 256 periods
High Frq. Noise (250ns 8 =2us) (250ns 512 256 =33 ms)
~
~
XIN
~
~
Oscillation Fail
XIN_NF
~
~
INT_CLK reset
~
~
~
~
~
~
INT_CLK
~
~ ~
~
OFP_EN
CHG_END
~
~ ~
~
CLK_CHG
Clock Change Start(XIN to INT_CLK) Clock Change End(INT_CLK to XIN))
fINTERNAL
~
~
~
Figure 20-1 Block Diagram of ONP & OFP and Respective Wave Forms
7 6 5 4 3 2 1 0
ONP OFP LOCK POR R35EN CLK2 CLK1 CLK0 ADDRESS: 20FFH
Configuration Option Bits
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
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)
These various options shown in Figure 21-1 can be select- SIGMA or GANG4) software after selecting device name.
ed by checking option field listed in writer (PGM Plus,
89
6
J_USER
NC 1 2 NC
VDD 3 4 VDD
GND 5 6 GND
R00 7 8 R10
R01 9 10 R11
R02 11 12 R12
R03 13 14 R13
R04 15 16 R14
R05 17 18 R15
R06 19 20 R16
R07 21 22 R17
GND 23 24 GND
1
R20 25 26 R30
R21 27 28 R31
R22 29 30 R32
22. EMULATOR EVA. BOARD SETTING
R23 31 32 R33/XIN
R24 33 34 R34/XOUT
R25 35 36 R35/RST
R26 37 38 R36
5
R27 39 40 R37
GND 41 42 GND
NC 43 44 NC
NC 45 46 NC
NC 47 48 NC
NC 49 50 NC
4
MC80F0504/0604
1 - This connector is only used for a device under 32 PIN. For the MC80F0504/0504
Device select switch Low pin .
High Pin
4 Normally MDS.
SW3 1 This switch select Eva. B/D Power supply
source.
USER USER
A. INSTRUCTION
Terminology Description
A Accumulator
X X - register
Y Y - register
PSW Program Status Word
#imm 8-bit Immediate data
dp Direct Page Offset Address
!abs Absolute Address
[] Indirect expression
{} Register Indirect expression
{ }+ Register Indirect expression, after that, Register auto-increment
.bit Bit Position
A.bit Bit Position of Accumulator
dp.bit Bit Position of Direct Page Memory
M.bit Bit Position of Memory Data (000H~0FFFH)
rel Relative Addressing Data
upage U-page (0FF00H~0FFFFH) Offset Address
n Table CALL Number (0~15)
+ Addition
0
Upper Nibble Expression in Opcode
x
Bit Position
1
Upper Nibble Expression in Opcode
y
Bit Position
Subtraction
Multiplication
/ Division
() Contents Expression
AND
OR
Exclusive OR
~ NOT
Assignment / Transfer / Shift Left
Shift Right
Exchange
= Equal
Not Equal
LOW 00000 00001 00010 00011 00100 00101 00110 00111 01000 01001 01010 01011 01100 01101 01110 01111
HIGH 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
SET1 BBS BBS ADC ADC ADC ADC ASL ASL TCALL SETA1 BIT POP PUSH
000 - BRK
dp.bit A.bit,rel dp.bit,rel #imm dp dp+X !abs A dp 0 .bit dp A A
SBC SBC SBC SBC ROL ROL TCALL CLRA1 COM POP PUSH BRA
001 CLRC
#imm dp dp+X !abs A dp 2 .bit dp X X rel
CMP CMP CMP CMP LSR LSR TCALL NOT1 TST POP PUSH PCALL
010 CLRG
#imm dp dp+X !abs A dp 4 M.bit dp Y Y Upage
OR OR OR OR ROR ROR TCALL OR1 CMPX POP PUSH
011 DI RET
#imm dp dp+X !abs A dp 6 OR1B dp PSW PSW
AND AND AND AND INC INC TCALL AND1 CMPY CBNE INC
100 CLRV TXSP
#imm dp dp+X !abs A dp 8 AND1B dp dp+X X
EOR EOR EOR EOR DEC DEC TCALL EOR1 DBNE XMA DEC
101 SETC TSPX
#imm dp dp+X !abs A dp 10 EOR1B dp dp+X X
LDA LDA LDA LDA LDY TCALL LDC LDX LDX DAS
110 SETG TXA XCN
#imm dp dp+X !abs dp 12 LDCB dp dp+Y (N/A)
LDM STA STA STA STY TCALL STC STX STX
111 EI TAX XAX STOP
dp,#imm dp dp+X !abs dp 14 M.bit dp dp+Y
LOW 10000 10001 10010 10011 10100 10101 10110 10111 11000 11001 11010 11011 11100 11101 11110 11111
HIGH 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
BPL CLR1 BBC BBC ADC ADC ADC ADC ASL ASL TCALL JMP BIT ADDW LDX JMP
000
rel dp.bit A.bit,rel dp.bit,rel {X} !abs+Y [dp+X] [dp]+Y !abs dp+X 1 !abs !abs dp #imm [!abs]
BVC SBC SBC SBC SBC ROL ROL TCALL CALL TEST SUBW LDY JMP
001
rel {X} !abs+Y [dp+X] [dp]+Y !abs dp+X 3 !abs !abs dp #imm [dp]
BCC CMP CMP CMP CMP LSR LSR TCALL TCLR1 CMPW CMPX CALL
010 MUL
rel {X} !abs+Y [dp+X] [dp]+Y !abs dp+X 5 !abs dp #imm [dp]
BNE OR OR OR OR ROR ROR TCALL DBNE CMPX LDYA CMPY
011 RETI
rel {X} !abs+Y [dp+X] [dp]+Y !abs dp+X 7 Y !abs dp #imm
BMI AND AND AND AND INC INC TCALL CMPY INCW INC
100 DIV TAY
rel {X} !abs+Y [dp+X] [dp]+Y !abs dp+X 9 !abs dp Y
BVS EOR EOR EOR EOR DEC DEC TCALL XMA XMA DECW DEC
101 TYA
rel {X} !abs+Y [dp+X] [dp]+Y !abs dp+X 11 {X} dp dp Y
BCS LDA LDA LDA LDA LDY LDY TCALL LDA LDX STYA DAA
110 XAY
rel {X} !abs+Y [dp+X] [dp]+Y !abs dp+X 13 {X}+ !abs dp (N/A)
BEQ STA STA STA STA STY STY TCALL STA STX CBNE
111 XYX NOP
rel {X} !abs+Y [dp+X] [dp]+Y !abs dp+X 15 {X}+ !abs dp
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 Subtract with carry
NV--HZC
84 SBC !abs + Y 35 3 5 A ( A ) - ( M ) - ~( C )
85 SBC [ dp + X ] 36 2 6
86 SBC [ dp ] + Y 37 2 6
87 SBC { X } 34 1 3
16-BIT Operation
OP BYTE CYCLE FLAG
NO. MNEMONIC OPERATION NVGBHIZC
CODE NO NO
1 ADDW dp 1D 2 5 16-Bits add without carry NV--H-ZC
YA ( YA ) + ( dp +1 ) ( dp )
Bit Manipulation
OP BYTE CYCLE FLAG
NO. MNEMONIC OPERATION NVGBHIZC
CODE NO NO
1 AND1 M.bit 8B 3 4 Bit AND C-flag : C ( C ) ( M .bit ) -------C
2 AND1B M.bit 8B 3 4 Bit AND C-flag and NOT : C ( C ) ~( M .bit ) -------C
3 BIT dp 0C 2 4 Bit test A with memory :
Z ( A ) ( M ) , N ( M7 ) , V ( M6 ) MM----Z-
4 BIT !abs 1C 3 5
5 CLR1 dp.bit y1 2 4 Clear bit : ( M.bit ) 0 --------
6 CLRA1 A.bit 2B 2 2 Clear A bit : ( A.bit ) 0 --------
7 CLRC 20 1 2 Clear C-flag : C 0 -------0
8 CLRG 40 1 2 Clear G-flag : G 0 --0-----
9 CLRV 80 1 2 Clear V-flag : V 0 -0--0---
10 EOR1 M.bit AB 3 5 Bit exclusive-OR C-flag : C ( C ) ( M .bit ) -------C
11 EOR1B M.bit AB 3 5 Bit exclusive-OR C-flag and NOT : C ( C ) ~(M .bit) -------C
12 LDC M.bit CB 3 4 Load C-flag : C ( M .bit ) -------C
13 LDCB M.bit CB 3 4 Load C-flag with NOT : C ~( M .bit ) -------C
14 NOT1 M.bit 4B 3 5 Bit complement : ( M .bit ) ~( M .bit ) --------
15 OR1 M.bit 6B 3 5 Bit OR C-flag : C ( C ) ( M .bit ) -------C
16 OR1B M.bit 6B 3 5 Bit OR C-flag and NOT : C ( C ) ~( M .bit ) -------C
17 SET1 dp.bit x1 2 4 Set bit : ( M.bit ) 1 --------
18 SETA1 A.bit 0B 2 2 Set A bit : ( A.bit ) 1 --------
19 SETC A0 1 2 Set C-flag : C 1 -------1
20 SETG C0 1 2 Set G-flag : G 1 --1-----
21 STC M.bit EB 3 6 Store C-flag : ( M .bit ) C --------
Test and clear bits with A :
22 TCLR1 !abs 5C 3 6 N-----Z-
A - ( M ) , ( M ) ( M ) ~( A )
Test and set bits with A :
23 TSET1 !abs 3C 3 6 N-----Z-
A-(M), (M) (M)(A)