To provide the most up-to-date information, the revision of our
documents on the World Wide Web will be the most current. Your printed
copy may b e an earlier revision. To ve rify you have the latest information
available, refer to:
http://www.freescale.com
The following revision history table summarizes changes contained in
this document. For your convenience, the page number designators
have been linked to the appropriate location.
MC68HC705J1A — Rev. 4.0Technical Data
For More Information On This Product,
Go to: www.freescale.com
Page 4
Technical Data
Freescale Semiconductor, Inc.
Revision History
..
.
nc
Date
May , 20024.0
Revision
Level
Description
Figure 2-2. I/O Register Summary — Corrected reset state for
The MC68HC705J1A is a member of Motorola’s low-cost,
high-performance M68HC05 Family of 8-bit microcontroller units
(MCUs). The M68HC05 Fami ly is based on the customer-specified
integrated circuit (C SIC) design strategy. All MCUs in the family use the
popular M68HC05 centr al processor unit (CP U) and are available wit h a
variety of subsystems, memory sizes and types, and package types.
On-chip memory of the MC68HC705J1A includes 1240 bytes of
erasable, programmable read-only memory (EPROM). In packages
without the transparent window for EPROM erasure, the 1240 EPROM
bytes serve as one-time programmable read-only memory (OTPROM).
The MC68HRC705J1A is a resistor-capacitor (RC) oscillator mask
option version of the M C68HC705J1 A and is discussed in Appendix A.
MC68HRC705J1A.
A high-spee d version o f the MC 68HC705J1A , the MC68 HSC70 5J1A, is
discussed in Appendix B. MC68HSC705J1A.
The MC68HSR705J1A, discussed in Appendix C. MC68HSR705J1A,
is a high-speed version of the MC68HRC705J1A.
A functional block diagram of the MC68HC705J1A is shown in
Figure 1-1.
Freescale Semiconductor, I
Technical DataMC68HC705J1A — Rev. 4.0
For More Information On This Product,
General Descri ptio n
Go to: www.freescale.com
Page 23
Freescale Semiconductor, Inc.
General Description
Introduction
..
.
nc
Freescale Semiconductor, I
OSC1
OSC2
RESET
IRQ/V
PP
INTERNAL
OSCILLATOR
DIVIDE
BY ³2
68HC05 CPU
CPU REGISTERS
0000000011
PROGRAM COUNTER
CONDITION CODE
REGISTER
STATIC RAM (SRAM) — 64 BYTES
USER EPROM — 1240 BYTES
MASK OPTION REGISTER (EPROM)
15-STAGE
MULTIFUNCTION
TIMER SYSTEM
WATCHDOG AND
ILLEGAL ADDRESS
DETECT
ALUCPU CONTROL
ACCUMULATOR
INDEX REGISTER
STK PTR
111HINZC
Figure 1-1. Block Diagram
PB5
GISTER B
PORT B
PORT A
DATA DIRECTION REGISTER ADATA DIRECTION RE
*10-m A si nk capabil i ty
**External interrupt capability
•1240 bytes of EPROM/OTPROM, including eight bytes for user
vectors
•64 bytes of user random-access memory (RAM)
•Memory-mapped I/O registers
Freescale Semiconductor, I
•Fully static operation with no minimum clock speed
•Power-saving stop, halt, wait, and data-retention modes
•External interrupt mask bit and acknowledge bit
•Illegal address reset
•Internal steer ing d iode a nd p ul lup r esistor fro m RE SET
Technical DataMC68HC705J1A — Rev. 4.0
For More Information On This Product,
General Descri ptio n
Go to: www.freescale.com
pin to V
DD
Page 25
Freescale Semiconductor, Inc.
1.4 Programmable Options
The options in Table 1-1 are progr ammabl e in the mask option register
(MOR).
COP watchdog timerEnabled or disabled
External interrupt triggeringEdge-sensitive only or edge- and level-sensitive
General Description
Programmable Options
Table 1-1. Programmable Options
FeatureOption
..
.
nc
1.5 Pin A ssignments
1.5.1 VDD and V
Freescale Semiconductor, I
SS
Port A IRQ
Port pulldown resistors Enabled or disabled
STOP instruction mode Stop mode or halt mode
Crystal oscillator internal resistorEnabled or disabled
EPROM securityEnabled or disabled
Short oscillator delay counterEnabled or disabled
pin interruptsEnabled or disabled
Figure 1-2 shows the MC68HC705J1A pin assignments.
VDD and VSS are the power supply and g round pi ns. The MCU opera tes
from a single power supply.
Very fast signal transitions occur on the MCU pins, placing high,
short-duration current demands on the power supply. To prevent noise
problems, take special care as Figure 1-3 shows, by placing the bypas s
capacitors as close as possible to the MCU. C2 is an optional bulk
current bypass capaci tor for use in appl ications that requi re the port pi ns
to source high current levels.
MC68HC705J1A — Rev. 4.0Technical Data
For More Information On This Product,
General Description
Go to: www.freescale.com
Page 26
General Description
Freescale Semiconductor, Inc.
..
.
nc
Freescale Semiconductor, I
MCU
V
DD
C1
0.1 µF
V
SS
OSC1
OSC22
PB53
PB44
PB35
PB26
PB17
PB08
V
DD
V
SS
1
9
10
RESET
20
IRQ/V
19
PA018
PA117
PA216
PA315
PA414
PA513
PA6
12
PA7
11
Figure 1-2. Pin Assignments
V+
C2
+
C2
C1
PP
V
DD
V
SS
Figure 1-3. Bypassing Layout Recommendation
Technical DataMC68HC705J1A — Rev. 4.0
For More Information On This Product,
General Descri ptio n
Go to: www.freescale.com
Page 27
1.5.2 OSC1 and OSC2
Freescale Semiconductor, Inc.
The OSC1 and OSC2 pins are the connections for the on-chip oscillator.
The oscillator can be driven by any of these:
1.Crystal (See Figure 1-4 and Figure 1-5.)
2.Ceramic resonator (See Figure 1-6 and Figure 1-7.)
3.Resistor/capacitor (RC) oscillator (Refer to Appendix A.
General Description
Pin Assignments
MC68HRC705J1A and Appendix C. MC68HSR705J1A.)
..
.
nc
1.5.2.1 Crystal Oscillator
Freescale Semiconductor, I
4.External clock signal (See Figure 1-8.)
The frequency, f
by two to produce the internal operating frequency, fop.
Figure 1-4 and Figur e 1- 5 show a typica l crystal oscillator circuit for an
AT-cut, parallel resonant crystal. Follow the crystal supplier’s
recommendations, as the crystal parameters determine the external
component values required to provide reliable startup and maximum
stability. The loa d capacitance values used in the oscillator circuit design
should include all stray layout capacitances.
To minimize out put distortion, mount the crystal an d capacitors a s close
as possible to the pins. An internal startup resistor of approximately
2MΩ is provided between OSC1 and OSC2 for the crystal oscillator as
a programmable mask option.
, of the oscillator or external clock source is divided
osc
NOTE:Use an AT-cut crystal and not an AT-stri p crystal becau se the MCU can
overdrive an AT-strip crystal.
MC68HC705J1A — Rev. 4.0Technical Data
For More Information On This Product,
General Description
Go to: www.freescale.com
Page 28
General Description
Freescale Semiconductor, Inc.
OSC1
MCU
V
SS
C3
XTAL
OSC2
OSC1
OSC2
..
.
nc
C3
27 pF
C3
27 pF
XTAL
C4
27 pF
C4
C1C2
Figure 1-4. Crystal Connections with
Oscillator Internal Resistor Mask Option
V
SS
MCU
R
OSC1
10 M¾Ω
XTAL
OSC2
27 pF
C4
C3
XTAL
C4
R
C1C2
Figure 1-5. Crystal Connections without
Oscillator Internal Resistor Mask Option
V
DD
V
SS
OSC1
OSC2
V
DD
V
SS
Freescale Semiconductor, I
1.5.2.2 Ceramic Resonator Oscillator
To reduce cost, use a ceramic resonator instead of the crystal. The
circuits shown in Figure 1-6 and Figure 1-7 show ceramic resonator
circuits. Follow the resonator manufacturer’s recommendations, as the
resonator parameters determine the external component values
required for maximum stability and reliable starting. The load
capacitance values used in t he oscillator circui t design should include all
stray capacitances.
Technical DataMC68HC705J1A — Rev. 4.0
For More Information On This Product,
General Descri ptio n
Go to: www.freescale.com
Page 29
Freescale Semiconductor, Inc.
General Description
Pin Assignments
Mount the resonator and components as close as possible to the pins for
startup stabilization and to minimize o utput distortion. An internal startup
resistor of approximat ely 2 MΩ is provided between OSC1 and OSC2 as
a programmable mask option.
V
SS
MCU
C3
OSC1
..
.
nc
C3
27 pF
OSC1
CERAMIC
RESON ATOR
OSC2
C4
27 pF
C4
CERAMIC
RESON ATOR
C1C2
OSC2
V
DD
V
SS
Figure 1-6. Ceramic Resonator Connections
with Oscillator Internal Resistor Mask Option
V
SS
C3
OSC1
R
CERAMIC
RESON ATOR
OSC2
OSC1
MCU
R
10 M¾Ω
OSC2
Freescale Semiconductor, I
CERAMIC
C3
27 pF
RESON ATOR
C4
27 pF
C4
V
DD
C1C2
V
SS
Figure 1-7. Ceramic Resonator Connections
without Oscillator Internal Resistor Mask Option
MC68HC705J1A — Rev. 4.0Technical Data
For More Information On This Product,
General Description
Go to: www.freescale.com
Page 30
General Description
1.5.2.3 RC Oscillator
1.5.2.4 External Clock
..
.
nc
Freescale Semiconductor, Inc.
Refer to Appendix A. MC68HRC705J1A and Appendix C.
MC68HSR705J1A.
An external clock from another complementary metal-oxide
semiconductor (CMOS)-compatible device can be connected to the
OSC1 input, with the OSC2 input not connected, as shown in
Figure 1-8. This configuration is possible regardless of whether the
crystal/ceramic resonator or the RC oscillator is enabled.
1.6 RESET
Freescale Semiconductor, I
MCU
OSC1
EXTERNAL
CMOS CLOCK
OSC2
Figure 1-8. External Clock Connections
Applying a logic 0 to the RE SET pin for ces the M CU to a known startup
state. An internal r eset also pulls the RESET pin low. An internal resist or
to VDD pulls the RESE T pin high. A steeri n g diode b etw een the RESE T
and V
pins discharges any RESET pin voltage when power is
DD
removed from the MCU. The RESET pin contains an internal Schmitt
trigger to improve its noise immunity as an input. Refer to Section 4.
Resets and Interrupts for more information.
Technical DataMC68HC705J1A — Rev. 4.0
For More Information On This Product,
General Descri ptio n
Go to: www.freescale.com
Page 31
Freescale Semiconductor, Inc.
General Description
IRQ/V
PP
1.7 IRQ/V
..
.
nc
1.8 PA0–PA7
1.9 PB0–PB5
Freescale Semiconductor, I
PP
The external interrupt/programming voltage pin (IRQ/VPP) drives the
asynchronous IRQ interrupt function of the CPU. Additionally, it is used
to progra m t he u ser EPR OM and ma sk op tion r egi ste r. ( See Sect ion 2.
Memory and Section 8. External Interrupt Module (IRQ).)
The LEVEL bit in the mask option register provides negative
edge-sensitive triggering or both negative edge-sensitive and low
level-sensitive triggering for the interrupt function.
If level-sensitive triggering is selected, the IRQ/VPP input requires an
external resistor to VDD for wired- OR operat ion. I f the IR Q/VPP pin is no t
used, it must be tied to the VDD supply.
The IRQ/VPP pin contains an internal Schmitt trigge r as part of its input
to improve noise immunity. The voltage on this pin should not exceed
V
except when the pin is being used for programming the EPROM.
DD
NOTE:The mask option register can enable the PA0–PA3 pins to function as
external interrupt pins.
These eight input/ou tput (I/O) l ines comprise por t A, a genera l-purpose,
bidirectional I/O port. See Sectio n 8. E xte rnal In ter rupt Module ( IRQ)
for information on PA0–PA3 external interrupts.
These six I/O lines comprise port B, a general-purp ose, bidirectiona l I/O
port.
This section describes the organization of the on-chip memory
consisting of:
•1232 bytes of user erasable, programmable read-only memory
(EPROM), plus eight bytes for user vectors
•64 bytes of user random-access memory (RAM)
MC68HC705J1A — Rev . 4.0Technical Data
For More Information On This Product,
Go to: www.freescale.com
Memory
Page 34
Memory
2.3 Memory Map
..
.
nc
Freescale Semiconductor, I
$0000
↓
$001F↓
$0020
↓Pulldown Register Port A (PDRA)$0010
$00BFPulldown Register Port B (PDRB)$0011
$00C0
↓↓
$00FF$0017
$0100
↓
$02FF↓
$0300
↓Reserved$001F
$07CF
$07D0
↓Mask Option Register (MOR)$07F1
$07ED
$07EE
$07EF$07F7
$07F0
↓Timer Interrupt Vector Low$07F9
$07FFExternal Interrupt Vector High$07FA
Freescale Semiconductor, Inc.
I/O Registers
32 Bytes
Unimplemented
160 Bytes
RAM
64 Bytes
Unimplemented
512 Bytes
EPROM
1232 Bytes
Unimplemented
30 Bytes
Test ROM
2 Bytes
Registers and EPROM
16 Bytes
(1)
Writing to bit 0 of $07F0 clears the computer
operating properly (COP) watchdog.
Port A Data Register (PORTA)$0000
Port B Data Register (PORTB)$0001
Unimplemented
Data Direction Register A (DDRA)$0004
Data Direction Register B (DDRB)$0005
Unimplemented
Timer Status and Control Register (TSCR)$0008
Timer Control Register (TCR)$0009
IRQ Status and Control Register (ISCR)$000A
Unimplemented
Unimplemented
EPROM Programming Register (EPROG)$0018
Unimplemented
COP Register (COPR)
Reserved
Timer Interrupt Vector High$07F8
External Interrupt Vector Low$07FB
Software Interrupt Vector High$07FC
Software Interrupt Vector Low$07FD
Reset Vector High$07FE
Reset Vector Low$07FF
(1)
$0002
$0003
$0006
$0007
$000B
$000F
$0012
$0019
$001E
$07F0
$07F2
↓
Figure 2-1. Memory Map
Technical DataMC68HC705J1A — Rev. 4.0
For More Information On This Product,
Go to: www.freescale.com
Memory
Page 35
Freescale Semiconductor, Inc.
Memory
Input/Output Register Summary
2.4 Input/Output Regist er Summary
Addr.Register Name Bit 7654321Bit 0
..
.
nc
Port A Data Register
$0000
Port B Data Register
$0001
$0002Unimplemented
$0003Unimplemented
Data Direction Register A
$0004
Data Direction Register B
$0005
$0006Unimplemented
$0007Unimplemented
(PORTA)
See page 89.
(PORTB)
See page 92.
(DDRA)
See page 90.
(DDRB)
See page 93.
Read:
PA7PA6PA5PA4PA3PA2PA1PA0
Write:
Reset:Unaffected by reset
Read:00
PB5PB4PB3PB2PB1PB0
Write:
Reset:Unaffected by reset
Read:
DDRA7DDRA6DDRA5DDRA4DDRA3DDRA2DDRA1DDRA0
Write:
Reset:00000000
Read:00
DDRB5DDRB4DDRB3DDRB2DDRB1DDRB0
Write:
Reset:00000000
Freescale Semiconductor, I
Read:TOFRTIF
TOIERTIE
Write:TOFRRTIFR
Reset:00000011
= UnimplementedR = Reserved
$0008
Timer Status and Control
Register (TSCR)
See page 112.
Figure 2-2. I/O Register Summary (Sheet 1 of 3)
MC68HC705J1A — Rev. 4.0Technical Data
For More Information On This Product,
Go to: www.freescale.com
Memory
00
RT1RT0
Page 36
Freescale Semiconductor, Inc.
Memory
Addr.Register Name Bit 7654321Bit 0
..
.
nc
Freescale Semiconductor, I
Timer Counter Register
$0009
See page 114.
IRQ Status and Control
$000A
$000BUnimplemented
↓
$000FUnimplemented
$0010
$0011
$0012Unimplemented
↓
$0017Unimplemented
$0018
Register (ISCR)
See page 106.
Pulldown Register A
Pulldown Register B
EPROM Programming
Register (EPROG)
(TCR)
(PDRA)
See page 91.
(PDRB)
See page 94.
See page 39.
Read:TMR7TMR6TMR5TMR4TMR3TMR2TMR1TMR0
Write:
Reset:00000000
Read:
IRQE
Write:
Reset:10000000
Read:
Write:PDIA7PDIA6PDIA5PDIA4PDIA3PDIA2PDIA1PDIA0
Reset:00000000
Read:
Write:PDIB5PDIB4PDIB3PDIB2PDIB1PDIB0
Reset:00000000
Read:00000
Write:RRRR
Reset:00000000
000IRQF000
RIRQR
ELATMPGMEPGM
= UnimplementedR = Reserved
Figure 2-2. I/O Register Summary (Sheet 2 of 3)
Technical DataMC68HC705J1A — Rev. 4.0
For More Information On This Product,
Go to: www.freescale.com
Memory
Page 37
Freescale Semiconductor, Inc.
Addr.Register Name Bit 7654321Bit 0
$0019Unimplemented
↓
$001EUnimplemented
$001FReservedRRRRRRRR
Memory
RAM
..
.
nc
Freescale Semiconductor, I
$07F0
Mask Option Register
$07F1
2.5 RAM
COP Register
(COPR)
See page 99.
(MOR)
See page 41.
Figure 2-2. I/O Register Summary (Sheet 3 of 3)
Read:
Write:COPC
Reset:0
Read:
SOSCDEPMSEC OSCRESSWAITSWPDIPIRQLEVELCOPEN
Write:
Reset:Unaffected by reset
= UnimplementedR = Reserved
The 64 addresse s from $00C0 to $00FF serve as bo th the user RAM and
the stack RAM. Before processing an interrupt, the central processor
unit (CPU) uses five bytes of the stack to save the contents of the CPU
registers. During a sub rout ine cal l, th e CP U uses two bytes o f the stack
to store the re turn address. The stack po inter decrements when the CPU
stores a byte on the stack and increments when the CPU retrieves a byte
from the stack.
NOTE:Be careful when using nested subroutines or multiple interrupt levels.
The CPU may overwrite data in the RAM during a subroutine or during
the interrupt stacking operation.
MC68HC705J1A — Rev. 4.0Technical Data
For More Information On This Product,
Go to: www.freescale.com
Memory
Page 38
Memory
2.6 EPROM/OTPROM
NOTE:Keep the quartz window covered with an opaque material except when
..
.
nc
Freescale Semiconductor, Inc.
A microcontroller unit (MCU) with a quartz window has 1240 bytes of
erasable, programmable ROM (EPROM). The quartz window allows
EPROM erasure with ultraviolet light.
programming the MCU. Ambient light can affect MCU operation.
In an MCU without the quartz window, the EPROM cannot be erased
and serves as 1240 bytes of one- time pr ogra mma ble RO M (OT PROM ).
These addresses are user EPROM/OTPROM locations:
•$0300–$07CF
•$07F8–$07FF, used for user-defined interrupt and reset vectors
The computer operating properly (COP) register (COPR) is an
EPROM/OTPROM location at address $07F0.
The mask option register (MOR) is an EPROM/OTPROM location at
address $07F1.
2.6.1 EPROM/OTPROM Programming
The two ways to program the EPROM/OTPROM are:
1.Manipulatin g the contr ol bits in th e EPROM pro gramming register
2.Programming the EPROM/OTPROM with the M68HC705J
Freescale Semiconductor, I
to program the EPROM/OTPROM on a byte-by-byte basis
in-circuit simulator (M68HC705JICS) available from Freescale
Technical DataMC68HC705J1A — Rev. 4.0
For More Information On This Product,
Go to: www.freescale.com
Memory
Page 39
Freescale Semiconductor, Inc.
2.6.2 EPROM Programming Register
The EPROM programming register (EPROG) contains the control bits
for programming the EPROM/OTPROM.
Address:$0018
Bit 7654321Bit 0
Read:00000
Write:
Memory
EPROM/OTPROM
ELATMPGMEPGM
RRRR
..
.
nc
Reset:00000000
= UnimplementedR = Reserved
Figure 2-3. EPROM Programming Register (EPROG)
ELAT — EPROM Bus Latch Bit
This read/write bit latches the address and data buses for
EPROM/OTPROM p rogramming. Cleari ng the ELAT bit automatically
clears the EPGM bit. EPROM/OTPROM data cannot be read while
the ELAT bit is set. Reset clears the ELAT bit.
1 = Address and data buses configured for EPROM/OTPROM
programming the EPROM
0 = Address and data buses configured for normal operation
MPGM — MOR Programming Bit
This read/write bi t applies prog ram mi ng power from the IRQ/VPP pin
to the mask option register. Reset clears MPGM.
1 = Programming voltage applied to MOR
0 = Programming voltage not applied to MOR
Freescale Semiconductor, I
EPGM — EPROM Programming Bit
This read/write bit applies the voltage from the IRQ/V
pin to the
PP
EPROM. To write the EPGM bit, the ELAT bit must be set already.
Reset clears EPGM.
1 = Programming voltage (IRQ/VPP pin) applied to EPROM
0 = Programming voltage (IRQ/VPP pin) not applied to EPROM
MC68HC705J1A — Rev. 4.0Technical Data
For More Information On This Product,
Go to: www.freescale.com
Memory
Page 40
Memory
Freescale Semiconductor, Inc.
NOTE:Writing logic 1s to both the ELAT and EPGM b its with a s ingle instruction
sets ELAT and clears EPGM. ELAT must be set first by a separate
instruction.
Bits [7:3] — Reserved
Take these steps to program a byte of EPROM/OTPROM:
1.Apply the programming voltage, VPP, to the IRQ/VPP pin.
2.Set the ELAT bit.
..
.
nc
2.6.3 EPROM Erasing
2.7 Ma sk Option Reg ister
3.Write to any EPROM/OTPROM address.
4.Set the EPGM bit and wait for a time, t
5.Clear the ELAT bit.
The erased state of an EPROM bit is logic 0. Erase the EPROM by
exposing it to 15 Ws/cm
2537 angstroms. Position the ultraviolet light source one inch from the
EPROM. Do not use a shortwave filter.
The mask option register (MOR) is an EPROM/OTPROM byte that
controls these options:
•COP watchdog (enable or disable)
2
of ultraviolet light with a wave length of
EPGM
.
Freescale Semiconductor, I
Technical DataMC68HC705J1A — Rev. 4.0
•External in terr upt pin triggering (edge-sensitiv e o nly or ed ge- and
level-sensitive)
•Port A external interrupts (enable or disable)
•Port pulldown resistors (enable or disable)
•STOP instruction (stop mode or halt mode)
•Crystal oscillator internal resistor (enable or disable)
•EPROM security (enable or disable)
•Short oscillator delay (enable or disable)
For More Information On This Product,
Go to: www.freescale.com
Memory
Page 41
Freescale Semiconductor, Inc.
Take these steps to program the mask option register:
Memory
Mask Option Register
..
.
nc
Freescale Semiconductor, I
1.Apply the programming voltage, V
, to the IRQ/VPP pin.
PP
2.Write to the MOR.
3.Set the MPGM bit and wait for a time, t
MPGM
.
4.Clear the MPGM bit.
5.Reset the MCU.
Address:$07F1
Bit 7654321Bit 0
Read:
Write:
Reset:Unaffected by reset
SOSCDEPMSEC OSCRESSWAITSWPDIPIRQLEVELCOPEN
Figure 2-4. Mask Option Register (MOR)
SOSCD — Short Oscillator Delay Bit
The SOSCD bit controls the oscillator stabilization counter. The
normal stabilization delay following reset or exit from stop mode is
4064 t
. Setting SOSCD enables a short oscillator stabilization
cyc
delay.
1 = Short oscillator delay enabled
0 = Short oscillator delay disabled
EPMSEC — EPROM Security Bit
The EPMSEC bit controls access to the EPROM/OTPROM.
1 = External access to EPROM/OTPROM denied
0 = External access to EPROM/OTPROM not denied
OSCRES — Oscillator Internal Resistor Bit
The OSCRES bit enables a 2-MΩ internal resistor in the oscillator
circuit.
NOTE:Program the OSCRES bit to logic 0 in devices using RC oscillators.
MC68HC705J1A — Rev. 4.0Technical Data
For More Information On This Product,
Go to: www.freescale.com
Memory
Page 42
Memory
..
.
nc
Freescale Semiconductor, Inc.
SWAIT — Stop-to-Wait Conversion Bit
The SWAIT bit enables halt mode. When the SWAIT bit is set, the
CPU interprets the STOP instruction as a WAIT instruction, and the
MCU enters halt mo de. Halt mode i s the same as wait mo de, except
that an oscillator stabilization delay of 1 to 4064 t
exiting halt mode.
1 = Halt mode enabled
0 = Halt mode not enabled
SWPDI — Software Pulldown Inhibit Bit
The SWPDI bit inhibits software control of the I/O port pulldown
devices. The SWPDI b i t overri des t he pu lldow n inhib it bits in t he po rt
pulldown inhibit registers.
1 = Software pulldown control inhibited
0 = Software pulldown control not inhibited
occurs after
cyc
PIRQ — Port A External Interrupt Bit
The PIRQ bit enables the PA0–PA3
interrupt pins.
1 = PA0–PA3 enabled as external interrupt pins
0 = PA0–PA3 not enabled as external interrupt pins
LEVEL —External Interrupt Sensitivity Bit
The LEVEL bit controls external interrupt triggering sensitivity.
1 = External interrupts triggered by active edges and active levels
0 = External interrupts triggered only by active edges
The central processor unit (CPU) consists of a CPU control unit, an
arithmetic /logic unit (ALU), and fi ve CPU registers. Th e CPU control unit
fetches and decodes instructions. The ALU executes the instructions.
The CPU registers contain data, addresses, and status bits that reflect
the results of CPU operations. See Figure 3-1.
Features include:
..
.
Freescale Semiconductor, Inc.
•2.1-MHz bus frequency
•8-bit accumulator
nc
3.3 CPU Control Unit
Freescale Semiconductor, I
3.4 Arithmetic/Logic Unit
•8-bit index register
•11-bit program counter
•6-bit stack pointer
•Condition code register (CCR) with five status flags
•62 instructions
•Eight addressing modes
•Power-saving stop, wait, halt, and data-retention modes
The CPU control unit fetches and decodes instructions during program
operation. The control unit selects the memory locations to read and
write and coordinates the timing of all CPU operations.
The arithmetic/logic unit (ALU) performs the arithmetic, logic, and
manipulation operations decoded from the instruction set by the CPU
control unit . The ALU produces the resu lts called for by the program and
sets or clears status and control bits in the condition code register
(CCR).
Technical DataMC68HC705J1A — Rev. 4.0
Central Processor Unit (CPU)
For More Information On This Product,
Go to: www.freescale.com
Page 47
Freescale Semiconductor, Inc.
Central Processor Unit (CPU)
Arithmetic/Logic Unit
..
.
nc
CPU CONTROL UNIT
0
000000011
0
00
0
0
HALF-CARRY FLAG
INTERRUPT MASK
NEGATIVE FLAG
ZERO FLAG
CARRY/BORROW FLAG
Figure 3-1. Programming Model
ARITHMETIC/LOGIC UNIT
04756321
04756321
0475632181215131411 10 9
0475632181215131411 10 9
04756321
111HINZC
ACCUMULATOR (A)
INDEX REGISTER (X)
STACK POINTER (SP)
PROGRAM COUNTER (PC)
CONDITION CODE REGISTER (CCR)
Freescale Semiconductor, I
MC68HC705J1A — Rev. 4.0Technical Data
Central Processor Unit (CPU)
For More Information On This Product,
Go to: www.freescale.com
Page 48
Freescale Semiconductor, Inc.
Central Processor Unit (CPU)
3.5 CPU Registers
The M68HC05 CPU contains five registers that control and monitor
microcontroller unit (MCU) operation:
•Accumulator
•Index register
•Stack pointer
•Program counter
..
.
nc
3.5.1 Accumulator
3.5.2 Index Register
Freescale Semiconductor, I
•Condition code register
CPU registers are not memory mapped.
The accumulator (A) is a general-purpose 8-bit register. The CPU uses
the accumulator to hold operands and results of ALU operations.
Bit 7654321Bit 0
Read:
Write:
Res et:Unaff ected by reset
Figure 3-2. Accumulator (A)
In the indexed addr essing (X) modes, the CPU uses the byte i n the index
register to deter mine th e conditi o nal addr ess of the opera nd. The index
register also can serve as a temporary storage location or a counter.
Bit 7654321Bit 0
Read:
Write:
Res et:Unaff ected by reset
Figure 3-3. Index Register (X)
Technical DataMC68HC705J1A — Rev. 4.0
Central Processor Unit (CPU)
For More Information On This Product,
Go to: www.freescale.com
Page 49
3.5.3 Stack Pointer
Freescale Semiconductor, Inc.
Central Processor Unit (CPU)
CPU Registers
The stack pointer (SP) is a 16-bit register that contains the address of
the next location on the stack. During a reset or after the reset stack
pointer instruction (RSP), the stack pointer is preset to $00FF. The
address in the stack pointer decrements after a byte is stacked and
increments before a byte is unstacked.
..
.
nc
Bit
151413121110987654321
Read:0000000011
Write:
Reset:0000000011111111
= Unimplemented
Bit
0
Figure 3-4. Stack Pointe r (SP)
The 10 most significant bits of th e stack po inter are perman ently f ixed at
0000000011, so the stack pointer produces addresses from $00C0 to
$00FF. If subroutines and interrupts use more than 64 stack locations,
the stack pointer wraps around to address $00FF and begins writing
over the previously stored data. A subroutine uses two stack locations;
an interrupt uses five locations.
Freescale Semiconductor, I
MC68HC705J1A — Rev. 4.0Technical Data
Central Processor Unit (CPU)
For More Information On This Product,
Go to: www.freescale.com
Page 50
Central Processor Unit (CPU)
3.5.4 Program Counter
The program counter (P C) is a 16-bit register that contains the address
of the next instruction or operand to be fetch ed. The five most signi ficant
bits of the program counter are ignored and appear as 00000.
Normally, the address in the pr ogra m counte r auto maticall y incre ments
to the next sequential memory location every time an instruction or
operand is fetched. Jump, branch, and interrupt operations load the
program counter with an address other than that of the next sequential
..
.
location.
Freescale Semiconductor, Inc.
nc
3.5.5 Condition Code Register
Freescale Semiconductor, I
Bit
151413121110987654321
Read:
Write:
Reset:00000Loaded with vector from $07FE and $07FF
Figure 3-5. Program Counter (PC)
The condition code r egister (CCR) is a n 8- bit registe r who se t hree mo st
significant bits ar e permanently fixed at 11 1. The condition co de register
contains the interru pt mask and four flags that indica te the results of the
instruction just executed.
Bit 7654321Bit 0
Read:111
HINZC
Write:
Bit
0
Reset:111U1UUU
= UnimplementedU = Unaffected
Figure 3-6. Condition Code Register (CCR)
Technical DataMC68HC705J1A — Rev. 4.0
Central Processor Unit (CPU)
For More Information On This Product,
Go to: www.freescale.com
Page 51
..
.
nc
Freescale Semiconductor, Inc.
H — Half-Carry Flag
The CPU sets the half-carry fla g when a carr y occurs betwee n bits 3
and 4 of the accumulator during an ADD (add without carry) or ADC
(add with carry) operation. The half-carry flag is required for
binary-coded decimal (BCD) arithmetic operations.
I — Interrupt Mask Bit
Setting the interrupt mask disables interrupts. If an interrupt request
occurs while the interrupt mask is logic 0, the CPU saves the CPU
registers on the stack, sets the interrupt mask, and then fetches the
interrupt vector. If an interr upt request occurs while the interrupt mask
is logic 1, the interrupt request is latched. Normally, the CPU
processes the latch ed interrupt request as so on as the interrupt mask
is cleared again.
Central Processor Unit (CPU)
CPU Registers
A return-from-interrupt instruction (RTI) unstacks the CPU registers,
restoring the interrupt mask to its cleared state. After any reset, the
interrupt mask is set and can be cleared only by a software
instruction.
N — Negative Flag
The CPU sets the negative flag when an ALU operation produces a
negative result.
Z — Zero Flag
The CPU sets the zero flag when an ALU operation pr oduces a result
of $00.
C — Carry/Borrow Flag
Freescale Semiconductor, I
The CPU sets the carry/borrow flag when an addition operation
produces a carry out of bit 7 of the accumula tor or when a subtraction
operation requires a borrow. Some logical operations and data
manipulation instructions also clear or set the carry/borrow flag.
MC68HC705J1A — Rev. 4.0Technical Data
Central Processor Unit (CPU)
For More Information On This Product,
Go to: www.freescale.com
Page 52
Central Processor Unit (CPU)
3.6 Instruction Set
The MCU instruction set has 62 instructions and uses eight addressing
modes.
3.6.1 Addressing Modes
The CPU uses eight addressing modes for flexibility in accessing data.
The addressing modes provide eight different ways for the CPU to find
the data requir ed to execute an instruction. The eight addressing m odes
..
.
are:
Freescale Semiconductor, Inc.
nc
3.6.1.1 Inherent
Freescale Semiconductor, I
•Inherent
•Immediate
•Direct
•Extended
•Indexed, no offset
•Indexed, 8-bit offset
•Indexed, 16-bit offset
•Relative
Inherent instructions are those that have no operand, such as return
from interr upt ( RTI) a nd sto p (S TOP). So me of the i nh eren t instru cti ons
act on data in the CPU registers, such as set carry flag (SEC) and
increment accum ulator (INCA). Inherent instructi ons require no operand
address and are one byte long.
3.6.1.2 Immediate
Immediate instructions are those that contain a value to be used in an
operation wi th the value in the a ccumulator o r index reg ister. Im mediate
instructions require no operand address and are two bytes long. The
opcode is the first byte, and the i mmediate data valu e is the second byte.
Technical DataMC68HC705J1A — Rev. 4.0
Central Processor Unit (CPU)
For More Information On This Product,
Go to: www.freescale.com
Page 53
3.6.1.3 Direct
3.6.1.4 Extended
..
.
Freescale Semiconductor, Inc.
Direct instructio ns can access any of the first 256 me mory locations with
two bytes. The first byte i s the opcod e, and the second is the low byte of
the operand address. In direct addr essing, the CPU autom aticall y uses
$00 as the high byte of the operand address.
Extended instructions use three bytes and can access any address in
memory. The fir st byte i s the opco de; the seco nd and th ird bytes ar e the
high and low bytes of the operand address.
Central Processor Unit (CPU)
Instructi on Set
nc
3.6.1.5 Indexed, No Offset
3.6.1.6 Indexed, 8-Bit Offset
Freescale Semiconductor, I
When using the Freescale assembl er, th e prog ram mer does not ne ed to
specify whether an instruction is direct or extended. The assembler
automatically selects the shortest form of the instruction.
Indexed instructions with no offset are 1-byte instructions that can
access data with variable addresses within the first 256 memory
locations. The index register contains the low byte of the effective
address of the operand. The CPU automatically uses $00 as the high
byte, so these instructions can address locations $0000–$00FF.
Indexed, no offset instru ctions are often used to move a pointer thr ough
a table or to hold the address of a frequently used RAM or input/output
(I/O) location.
Indexed, 8-b it offset instru cti ons ar e 2-byte i n structio ns tha t can a ccess
data with variabl e addresses w ithin the fir st 511 m emory locations. The
CPU adds the unsigned byte in the index register to the unsigned byte
following the opcode. The sum is the effective address of the operand.
These instructions can access locations $0000–$01FE.
Indexed 8-bit offset instructions are usefu l for selecting the kth element
in an n-element table. The table can begin anywhe re within the fi rst 256
memory locations and could extend as far as location 510 ($01FE).
MC68HC705J1A — Rev. 4.0Technical Data
Central Processor Unit (CPU)
For More Information On This Product,
Go to: www.freescale.com
Page 54
Central Processor Unit (CPU)
The k value is typically in the index register, and the address of the
beginning of the table is in the byte following the opcode.
3.6.1.7 Indexed, 16-Bit Offset
Indexed, 16-b it offset instructions are 3-byte in structions that can access
data with variabl e ad dresse s at any lo cation i n memo ry. T he CP U adds
the unsigned byte in the index register to the two unsigned bytes
following the opcode. The sum is the effective address of the operand.
The first byte after the opcode is the high byte of the 16-bit offset; the
..
.
second byte is the low byte of the offset.
Freescale Semiconductor, Inc.
nc
3.6.1.8 Relative
Freescale Semiconductor, I
Indexed, 16-b it offset instructions are use ful for selecting the kth element
in an n-element table anywhere in memory.
As with direct and extended addressing, the Freescale assembler
determines the shortest form of indexed addressing.
Relative addressing is only for branch instructions. If the branch
condition is true, the CPU finds the effective branch destination by
adding the signed byte following the opcode to the contents of the
program counter. If the br anch condition is not true, the CPU goes to the
next instruction. The offset is a signed, tw o’s complement byte that gives
a branching range of –128 to +127 bytes from the address of the next
location after the branch instruction.
When using the Freescale assembl er, th e prog ram mer does not ne ed to
calculate the offset because the assem bler determines the prop er offset
and verifies that it is within the span of the branch.
Technical DataMC68HC705J1A — Rev. 4.0
Central Processor Unit (CPU)
For More Information On This Product,
Go to: www.freescale.com
Page 55
3.6.2 Instruct ion Types
The MCU instructions fall into these five categories:
..
.
3.6.2.1 Register/Memory Instructions
nc
These instructions operate on CPU registers and memory locations.
Most of them use two operands. One operand is in either the
accumulator or the index register. The CPU finds the other operand in
memory.
Freescale Semiconductor, Inc.
•Register/memory instructions
•Read-modify-write instructions
•Jump/branch instructions
•Bit manipulation instructions
•Control instructions
Central Processor Unit (CPU)
Instructi on Set
Table 3-1. Register/Memory Instructions
InstructionMnemonic
Add memory byte and carry bit to accumulatorADC
Add memory byte to accumulatorADD
AND memory byte with accumulatorAND
Bit test accumulatorBIT
Compare accumulatorCMP
Compare index register with memory byteCP X
EXCLUSIVE OR accu mu lator with me mo r y byteEOR
Freescale Semiconductor, I
Load accumulator with memory byteLDA
Load index register with memory byteLDX
MultiplyMUL
OR accumulator with memory byteORA
Subtract memory byte and carry bit from accumulatorSBC
Store accu mu lator in memorySTA
Store index register in memorySTX
Subtract memory byte from accumulatorSUB
MC68HC705J1A — Rev. 4.0Technical Data
Central Processor Unit (CPU)
For More Information On This Product,
Go to: www.freescale.com
Page 56
Freescale Semiconductor, Inc.
Central Processor Unit (CPU)
3.6.2.2 Read-Modify-Write Instructions
These instructions read a memory location or a register, modify its
contents, and write the modifi ed value b ack to the memor y location o r to
the register.
NOTE:Do not use read-modify-write instructions on registers with write-only
bits.
Table 3-2. Read-Modify-Write Instr uc tions
..
.
nc
Freescale Semiconductor, I
InstructionMnemonic
Arithmetic shift left (same as LSL)ASL
Arithmetic shift rightASR
Bit clear
Bit set
Clear registerCLR
Complement (one’s complement)COM
DecrementDEC
IncrementINC
Logical shift left (same as ASL)LSL
Logical shift rightLSR
Negate (two’s compl eme nt )NEG
Rotate left through carry bitROL
Rotate right through carry bitROR
Test for negative or zero
1. Unlike other read-modify-write instructions, BCLR and
BSET use only direct addressing.
2. TST is an exception to the read -modify-write seq uence
because it does not write a replacement value.
BCLR
BSET
TST
(1)
(1)
(2)
Technical DataMC68HC705J1A — Rev. 4.0
Central Processor Unit (CPU)
For More Information On This Product,
Go to: www.freescale.com
Page 57
3.6.2.3 Jump/Branch Instructions
..
.
nc
NOTE:Do not use BRCLR or BRSET instructions on registers with write-only
Freescale Semiconductor, Inc.
Jump instructions allow the CPU to interrupt the norma l sequence of the
program counter. The unconditional jump instruction (JMP) and the
jump-to-subroutine instruction (JSR) have no register operand. Branch
instructions allow the CPU to interrupt the normal sequence of the
program counter when a test condition is met. If the test conditi o n is n ot
met, the branch is not performed.
The BRCLR and BRSET i nstructions cause a br anch based on the state
of any readable bit in the first 256 memory locations. These 3-byte
instructions use a combination of direct addressing and relative
addressing. The direct address of the byte to be tested is in the byte
following the opcode. The third byte is the signed offset byte. The CPU
finds the effective branch destination by adding the third byte to the
program counter i f the specified bit tests true . The bit to be teste d and its
condition (set or clear) is part of the opcode. The span of branching is
from –128 to +127 from the addr ess of the next locatio n after the branch
instruction. The CPU also tr ansfe rs the tested b i t to the carr y/borrow bit
of the condition code register.
bits.
Central Processor Unit (CPU)
Instructi on Set
Freescale Semiconductor, I
MC68HC705J1A — Rev. 4.0Technical Data
Central Processor Unit (CPU)
For More Information On This Product,
Go to: www.freescale.com
Page 58
Central Processor Unit (CPU)
..
.
Freescale Semiconductor, Inc.
Table 3-3. Jump and Branch Instructions
InstructionMnemonic
Branch if carry bit clearBCC
Branch if carry bit setBCS
Branch if equalBEQ
Branch if half-carry bit clearBHCC
Branch if half-carry bit setBHCS
Branch if higherBHI
Branch if higher or sameBHS
nc
Freescale Semiconductor, I
Branch if IRQ
Branch if IRQ
Branch if lowerBLO
Branch if lower or sameBLS
Branch if interrupt mask clearBMC
Branch if minusBMI
Branch if interrupt mask setBMS
Branch if not equalBNE
Branch if plusBPL
Branch alwaysBRA
Branch if bit clearBRCLR
Branch neverBRN
Branch if bit setBRSET
Branch to subroutineBSR
Unconditional jumpJMP
pin highBIH
pin lowBIL
Jump to subroutineJSR
Technical DataMC68HC705J1A — Rev. 4.0
Central Processor Unit (CPU)
For More Information On This Product,
Go to: www.freescale.com
Page 59
Freescale Semiconductor, Inc.
3.6.2.4 Bit Manipulation Instructions
The CPU can set or clear any writable bit in the first 256 bytes of
memory, which includes I/O registers and on-chip RAM locations. The
CPU can also test and br anch based on th e state of any bit in an y of the
first 256 memory locations.
Central Processor Unit (CPU)
Instructi on Set
Table 3-4. Bit Manipulation Instructions
InstructionMnemonic
..
.
nc
Bit clearBCLR
Branch if bit clearBRCLR
Branch if bit setBRSET
Bit setBSET
NOTE:Do not use bit manipulation i nstru ctions on r egister s wit h write- only bits.
Freescale Semiconductor, I
MC68HC705J1A — Rev. 4.0Technical Data
Central Processor Unit (CPU)
For More Information On This Product,
Go to: www.freescale.com
Page 60
Freescale Semiconductor, Inc.
Central Processor Unit (CPU)
3.6.2.5 Control Instructions
These instructions act on CPU registers and control CPU operation
during program execution.
Table 3-5. Control Instructions
InstructionMnemonic
Clear carry bitCLC
Clear interrupt maskCLI
..
.
nc
No operationNOP
Reset stack pointerRSP
Return from interrup tRTI
Return from subroutineRT S
Set carry bitSEC
Set interrupt maskSEI
Stop oscillator and enable IR Q
Software interruptSWI
Transfer accumulator to index registerTAX
Transfer index register to accumulatorTXA
Stop CPU clock and enable interrupts
pinSTOP
WAIT
Freescale Semiconductor, I
Technical DataMC68HC705J1A — Rev. 4.0
Central Processor Unit (CPU)
For More Information On This Product,
Go to: www.freescale.com
Page 61
Freescale Semiconductor, Inc.
3.7 Instruct ion Set Summary
Table 3-6. Instruction Set Summary (Sheet 1 of 6)
Central Processor Unit (CPU)
Instruction Set Summary
Source
Form
OperationDescription
on CCR
HINZC
Effect
ADC #opr
ADC opr
ADC opr
ADC opr,X
ADC opr,X
..
ADC ,X
.
ADD #opr
ADD opr
nc
ADD opr
ADD opr,X
ADD opr,X
ADD ,X
AND #opr
AND opr
opr
AND
AND opr,X
AND opr,X
AND ,X
ASL opr
ASLA
ASLX
ASL opr,X
ASL ,X
ASR opr
ASRA
ASRX
ASR opr,X
ASR ,X
BCC relBranch if Carry Bit ClearPC ← (PC) + 2 + rel ? C = 0————— REL24rr3
Add with CarryA ← (A) + (M) + (C)
Add with ou t C arr yA ← (A) + (M)
Logica l ANDA ← (A) ∧ (M)——
Arithmetic Sh ift Left (Same as LSL)——
Arithmetic Shift R ight——
C
b7
b7
b0
b0
—
—
0
C
Freescale Semiconductor, I
BCLR n oprClear Bit nMn ← 0—————
BCS relBranch if Carry Bit Set (Same as BLO)PC ← (PC) + 2 + rel ? C = 1————— REL25rr3
BEQ relBranch if EqualPC ← (PC) + 2 + rel ? Z = 1————— REL27rr3
BHCC relBranch if Half-Carry Bit ClearPC ← (PC) + 2 + rel ? H = 0————— REL28rr3
BHCS relBranch if Half-Carry Bit SetPC ← (PC) + 2 + rel ? H = 1————— REL29rr3
—
IMM
DIR
EXT
IX2
IX1
IX
IMM
DIR
EXT
IX2
IX1
IX
IMM
DIR
EXT
IX2
IX1
IX
DIR
INH
INH
IX1
IX
DIR
INH
INH
IX1
IX
DIR (b0)
DIR (b1)
DIR (b2)
DIR (b3)
DIR (b4)
DIR (b5)
DIR (b6)
DIR (b7)
Address
Mode
A9
B9
C9
D9
E9
F9
AB
BB
CB
DB
EB
FB
A4
B4
C4
D4
E4
F4
38
48
58
68
78
37
47
57
67
77
11
13
15
17
19
1B
1D
1F
ii
dd
hh ll
ee ff
ff
ii
dd
hh ll
ee ff
ff
ii
dd
hh ll
ee ff
ff
dd
ff
dd
ff
dd
dd
dd
dd
dd
dd
dd
dd
Cycles
Operand
2
3
4
5
4
3
2
3
4
5
4
3
2
3
4
5
4
3
5
3
3
6
5
5
3
3
6
5
5
5
5
5
5
5
5
5
Opcode
MC68HC705J1A — Rev . 4.0Technical Data
Central Processor Unit (CPU)
For More Information On This Product,
Go to: www.freescale.com
Page 62
Freescale Semiconductor, Inc.
Central Processor Unit (CPU)
Table 3-6. Instruction Set Summary (Sheet 2 of 6)
Source
Form
OperationDescription
on CCR
HINZC
BHI relBranch i f HigherPC ← (PC) + 2 + rel ? C ∨ Z = 0 ————— REL22rr3
BHS relBranch if High er or SamePC ← (PC) + 2 + rel ? C = 0————— REL24rr3
BIH relBranch if IRQ Pin HighPC ← (PC) + 2 + rel ? IRQ = 1————— REL2Frr3
BIL relBranch if IRQ Pin LowPC ← (PC) + 2 + rel ? IRQ = 0————— REL2Err3
Effect
BIT #opr
BIT opr
BIT opr
..
BIT opr,X
.
BIT opr,X
BIT ,X
nc
BLO relBranch if Lower (Same as BCS)PC ← (PC) + 2 + rel ? C = 1————— REL25rr3
BLS relBranch if Lower or SamePC ← (PC) + 2 + rel ? C ∨ Z = 1 ————— REL23rr3
BMC relBranch if Interrupt Mask ClearPC ← (PC) + 2 + rel ? I = 0————— REL2Crr3
BMI relBranch if MinusPC ← (PC) + 2 + rel ? N = 1————— REL2Brr3
BMS relBranch if Interrupt Mask SetPC ← (PC) + 2 + rel ? I = 1————— REL2Drr3
BNE relBranch if Not EqualPC ← (PC) + 2 + rel ? Z = 0————— REL26rr3
BPL relBranch if PlusPC ← (PC) + 2 + rel ? N = 0————— REL2Arr3
BRA relBranch AlwaysPC ← (PC) + 2 + rel ? 1 = 1————— REL20rr3
BRCLR n opr rel Branch if Bit n ClearPC ← (PC) + 2 + rel ? Mn = 0————
Subtract Memory Byte and Carry Bit from
Accumulator
Store Accumulato r in MemoryM ← (A)——
OperationDescription
C
b7
b7
SP ← (SP) + 1; Pull (CCR)
SP ← (SP) + 1; Pull (A)
SP ← (SP) + 1; Pull (X)
SP ← (SP) + 1; Pull (PCH)
SP ← (SP) + 1; Pull (PCL)
SP ← (SP) + 1; Pull (PCH)
SP ← (SP) + 1; Pull (PCL)
A ← (A) – (M) – (C)——
b0
b0
C
on CCR
HINZC
————— INH816
—
Mode
Address
DIR
INH
INH
IX1
IX
DIR
INH
INH
IX1
IX
INH809
IMM
DIR
EXT
IX2
IX1
IX
DIR
EXT
IX2
IX1
IX
Effect
39
49
59
69
79
36
46
56
66
76
A2
B2
C2
D2
E2
F2
B7
C7
D7
E7
F7
Opcode
dd
ff
dd
ff
ii
dd
hh ll
ee ff
ff
dd
hh ll
ee ff
ff
Operand
5
3
3
6
5
5
3
3
6
5
2
3
4
5
4
3
4
5
6
5
4
Cycles
STOPStop Oscillator and Enable IRQ Pin— 0 ——— INH8E2
Freescale Semiconductor, I
STX opr
STX opr
STX opr,X
STX opr,X
STX ,X
SUB #opr
SUB opr
SUB opr
SUB opr,X
SUB opr,X
SUB ,X
Store Index Register In MemoryM ← (X)——
Subtract Memory Byte from AccumulatorA ← (A) – (M)——
DIR
EXT
—
IX2
IX1
IX
IMM
DIR
EXT
IX2
IX1
IX
MC68HC705J1A — Rev . 4.0Technical Data
Central Processor Unit (CPU)
For More Information On This Product,
Go to: www.freescale.com
BF
CF
DF
EF
FF
A0
B0
C0
D0
E0
F0
dd
hh ll
ee ff
ff
ii
dd
hh ll
ee ff
ff
4
5
6
5
4
2
3
4
5
4
3
Page 66
Freescale Semiconductor, Inc.
Central Processor Unit (CPU)
Table 3-6. Instruction Set Summary (Sheet 6 of 6)
Source
Form
SWISoftware Interrupt
TAXTransfer Accumu la tor to Ind e x Reg isterX ← (A)————— INH972
..
.
TST opr
TSTA
nc
TSTX
TST opr,X
TST ,X
TXATransfer Index Register to AccumulatorA ← (X)————— INH9F2
WAITStop CPU Clock and Enable Interrupts—
AAccumulatoroprOpe r an d (one or two bytes)
CCarry/borrow flagPCProgram counter
CCRCondition code registerPCHProgram counter high byte
ddDirect address of operandPCLProgram counter low byte
dd rrDirect address of operand and relative offset of branch instructionRELRelative addressing mode
DIRDirect addressing moderelRelative program cou nter of fset byte
ee ffHigh and low bytes of offset in indexed, 16-bit offset addressingrrRelative program counter offset byte
EXTExtended addressing modeSPStack pointer
ffOffset byte in indexed, 8-bit offs et addre ssingXIndex register
HHalf-carry flagZZero flag
hh llHigh and low bytes of operand address in extended addressing#Immediate value
IInterrupt mask∧Lo gi cal AND
iiImmediate operand byte∨Lo gi ca l O R
IMMImmediate addressing mode⊕Logical EXCL U S IVE OR
INHInherent addressi ng mode( )Cont ents of
IXIndexed, no offset addressing mode–( )Negation (two’s complement)
IX1Index ed, 8-bit offset addressing mode←Loaded with
IX2Indexed, 16-bit offs et addressing mode?If
Freescale Semiconductor, I
MMemory location:Concatenated with
NNegative flag
nAny bit—Not affected
Reset initiali zes the microcontroll er unit (MCU) by returning the program
counter to a known address and by forcing control and status bits to
known states.
Interrupts temporarily change the sequence of program execution to
respond to events that occur during processing.
MC68HC705J1A — Rev . 4.0Technical Data
For More Information On This Product,
Resets and Interrupts
Go to: www.freescale.com
Page 70
Resets and Interrup ts
4.3 Resets
..
.
nc
Freescale Semiconductor, Inc.
A reset immediately stops the operation of the instruction being
executed, initializes certain control and status bits, and loads the
program counter with a user-defined reset vector address. These
sources can generate a reset:
•Power-on reset (POR) circuit
•RESET pin
•Computer operating properly (COP) watchdog
•Illegal address
ILLEGAL ADDRESS
COP WATCHDOG
V
DD
RESET
PIN
POWER-ON RESET
INTERNAL CLOCK
Figure 4-1. Reset Sources
RST
S
DQ
CK
RESET
LATCH
TO CPU AND
PERIPHERAL
MODULES
Freescale Semiconductor, I
Technical DataMC68HC705J1A — Rev. 4.0
For More Information On This Product,
Resets and Interrupts
Go to: www.freescale.com
Page 71
4.3.1 Power-On Reset
Freescale Semiconductor, Inc.
Resets and Interrupts
Resets
..
.
nc
A positive transition on the V
pin generates a power-on reset.
DD
NOTE:The power-on reset is strictly for power-up conditions and cannot be
used to detect drops in power supply voltage.
A 4064-t
active allows the clock generator to stabilize . If any reset source is active
at the end of this delay, the MCU remains in the reset condition until all
reset sources are inactive.
OSC1 PIN
INTERNAL
CLOCK
INTERNAL
ADDRESS BUS
INTER NAL
DATA BUS
Notes:
1. Power-on reset threshold is typically between 1 V and 2 V.
2. Internal clock, internal address bus, and internal data bus are not available externally.
(internal clock cycle) delay after the oscillator becomes
cyc
V
DD
(NOTE 1)
OSCILLATOR STABILIZATION DELAY
$07FE$07FE$07FE$07FE$07FE$07FE$07FF
NEW PCH
Figure 4-2. Power-On Reset Timing
NEW PCL
Freescale Semiconductor, I
MC68HC705J1A — Rev. 4.0Technical Data
For More Information On This Product,
Resets and Interrupts
Go to: www.freescale.com
Page 72
Resets and Interrup ts
4.3.2 External Reset
Freescale Semiconductor, Inc.
..
.
nc
4.3.3 COP Watchdog Reset
Freescale Semiconductor, I
A logic 0 applied to the RESET
reset. A Schmitt trigger senses the logic level at the RESET
INTERNAL
CLOCK
INTERNAL
ADDRESS BUS
INTER NAL
DATA BUS
RESET
Notes:
1. Inter nal clock, internal address bus, and internal data bus are not avail able externally.
2. The next rising edge of the internal clo ck after the rising edge of RESET
$07FE$0 7FE$07FE$07FE$07FFNEW PC
t
RL
pin for 1 1/2 t
NEW
PCH
generates an external
cyc
pin.
NEW PC
NEW
PCL
DUMMY
initiates the reset sequence.
OP
CODE
Figure 4-3. External Reset Timing
Table 4-1. External Reset Timing
CharacteristicSymbolMinMaxUnit
RESET
pulse width
t
RL
1.5—
t
cyc
A timeout of the COP watchdog generates a COP reset. The COP
watchdog is part of a software error detection system and must be
cleared periodically to start a new timeout period. To clear the COP
watchdog and pr event a COP reset, wri te a logic 0 to bit 0 (C OPC) of the
COP register at location $07F0.
4.3.4 Illegal Address Reset
An opcode fetch from an address not in ra ndom-access m emory (R AM)
or erasable, programmable read-only memory (EPROM) generates a
reset.
Technical DataMC68HC705J1A — Rev. 4.0
For More Information On This Product,
Resets and Interrupts
Go to: www.freescale.com
Page 73
4.4 Interrupts
Freescale Semiconductor, Inc.
These sources can generate interrupts:
•Software interrupt (SWI) instruction
•External interrupt pins:
•Timer:
–IRQ/VPP
–PA0–PA3
Resets and Interrupts
Interrupts
..
.
nc
4.4.1 Software Interrupt
4.4.2 External Interrupt
Freescale Semiconductor, I
–Real-time interrupt flag (RTIF)
–Timer overflow flag (TOF)
An interrupt temporarily stops the pr ogram sequence to process a
particular event. An interrupt does not stop the operation of the
instruction bein g exe cuted, but takes effect when the cu rre nt i n struction
completes its execution. Interrupt processing automatically saves the
CPU registers on the stack and loads the program counter with a
user-defined interrupt vector address.
The software interrupt (SWI) instruction causes a non-maskable
interrupt.
An interrupt signal on the IRQ
request. When the CPU co mpletes its curr ent instru ction, it tests th e IRQ
latch. If the IRQ latch is set, the CPU then tests the I bit in the condition
code register. If the I bit is clear, the CPU then begins the interrupt
sequence.
/VPP pin latches an external interrupt
MC68HC705J1A — Rev. 4.0Technical Data
For More Information On This Product,
Resets and Interrupts
Go to: www.freescale.com
Page 74
Resets and Interrup ts
..
.
nc
Freescale Semiconductor, Inc.
The CPU clears the IRQ latch during interrupt processing, so that
another interrupt signal on the IRQ
/VPP pin can latch another interrupt
request duri ng the interrupt service routine. As soon a s the I bit is cleare d
during the retur n from interrupt, the CPU can re cognize the new interrupt
request. Figure 4-4 shows the IRQ/VPP pin interrupt logic.
TO BIH & BIL
IRQ
PA3
PA2
PA1
PA0
PIRQ
(MOR)
LEVEL-SENSITIVE TRIGG ER
(MOR LEVEL BIT)
V
DD
IRQ
DQ
LATCH
CK
CLR
IRQF
IRQE
INSTRUCTION
PROCESSING
EXTERNAL
INTERRUPT
REQUEST
IRQ VECTOR FETCH
Figure 4-4. External Interrupt Logic
Setting the I b it in the co ndition code reg ister disables external int errupts.
The port A external interrupt bit (PIRQ) in the mask option register
enables pins PA0–PA3 to function as external interrupt pins.
The external inter rup t sen sitivity bit ( LE VEL) in th e m ask op tion r egister
controls interrupt triggering sensitivity of external interrupt pins. The
/VPP pin can be negative-e dge trigg ered only or nega tive-ed ge and
Freescale Semiconductor, I
IRQ
RESET
IRQR
low-level triggered. Port A external interrupt pins can be positive-edge
triggered only or both positive-edge and high-level triggered. The
level-sensitive trigge ri ng option allo ws multiple extern al interrupt
sources to be wire-ORed to an external interrupt pin. An external
interrupt requ est, shown in Figure 4-5, is latched as long as any source
is holding an external interrupt pin low.
Technical DataMC68HC705J1A — Rev. 4.0
For More Information On This Product,
Resets and Interrupts
Go to: www.freescale.com
Page 75
Freescale Semiconductor, Inc.
t
ILIL
Resets and Interrupts
Interrupts
..
.
nc
Freescale Semiconductor, I
IRQ PIN
IRQ
.
.
.
IRQ
IRQ (INTERNAL)
t
ILIH
t
1
n
ILIH
Figure 4-5. External Interrupt Timin g
—
—
(1)
(1)
t
t
cyc
cyc
Table 4-2. External Interrupt Timing (V
CharacteristicSymbolMinMaxUnit
Interrupt pulse width low (edge-triggered)
Interrupt pulse period
1. VDD = 5.0 Vdc ±10%, VSS = 0 Vdc, TA = –40°C to +10 5 °C, unless otherwise noted
2. The minimum, t
plus 19
t
cyc
, should not be less than the number of interrupt service routine cycles
Interrupt pulse width low (edge-triggered)
Interrupt pulse period
1. VDD = 3.3 Vdc ±10%, VSS = 0 Vdc, TA = –40°C to +10 5 °C, unless otherwise noted
2. The minimum, t
plus 19
t
cyc
, should not be less than the number of interrupt service routine cycles
ILIL
.
t
t
ILIH
ILIL
250—ns
(2)
Note
MC68HC705J1A — Rev. 4.0Technical Data
For More Information On This Product,
Resets and Interrupts
Go to: www.freescale.com
Page 76
Resets and Interrup ts
4.4.3 Timer Interrupts
The timer can generate these interrupt requests:
Setting the I bit in the condition code register disables timer interrupts.
4.4.3.1 Real-Time Interrupt
Freescale Semiconductor, Inc.
•Real time
•Timer overflow
..
.
nc
4.4.3.2 Timer Overflow Interrupt
4.4.4 Interrupt Processing
A real-time inte rrupt occurs if th e real-time interru pt flag, RTIF, beco mes
set while the real-time interrupt enable bit, RTIE, is also set. RTIF and
RTIE are in the timer status and control register.
A timer overflow inter rupt request occurs i f the timer overflow fl ag, TOF,
becomes set while the timer overflow interrupt enable bit, TOIE, is also
set. TOF and TOIE are in the timer status and control register.
The CPU takes these actions to begin servicing an interrupt:
•Stores the CPU registers on the stack in the order shown in
Figure 4-6
•Sets the I bit in the condition code register to prevent further
interrupts
Freescale Semiconductor, I
Technical DataMC68HC705J1A — Rev. 4.0
•Loads the program counter with the contents of the appropriate
interrupt vector locations:
–$07FC and $07FD (software interrupt vector)
–$07FA and $07FB (external interrupt vector)
–$07F8 and $07F9 (timer interrupt vector)
The return-from-interrupt (RTI) instruction causes the CPU to recover
the CPU registers from the stack as shown in Figure 4-6.
For More Information On This Product,
Resets and Interrupts
Go to: www.freescale.com
Page 77
Freescale Semiconductor, Inc.
UNSTACKING
ORDER
•
•
•
Resets and Interrupts
Interrupts
$00C0 (BOTTOM OF STACK)
$00C1
$00C2
•
•
•
..
.
nc
5
4
3
2
1
STACKING
ORDER
1
2
3
4
5
Figure 4-6. Interrupt Stacking Order
Table 4-4. Reset/Interrupt Vector Addresses
FunctionSource
Power-on
RESET
Reset
watchdog
illegal address
pin
COP
CONDITION CODE REGISTER
ACCUMULATOR
INDEX REGISTER
PROGRAM COUNTER (HIGH BYTE)
PROGRAM COUNTER (LOW BYTE)
•
•
•
Local
Mask
NoneNone1$07F E–$07FF
(1)
Global
Mask
$00FD
$00FE
$00FF (TOP OF STACK)
Priority
(1 = Highest)
•
•
•
Vector
Address
Freescale Semiconductor, I
MC68HC705J1A — Rev. 4.0Technical Data
Software
interrupt
(SWI)
External
interrupt
Timer
interrupts
1. The COP watchdog is programmab le in the mask option register .
The microcontroller unit (MCU) can enter these low-power standby
modes:
•Stop mode — The STOP instruction puts the MCU in its lowest
power-consumption mode.
Freescale Semiconductor, I
MC68HC705J1A — Rev . 4.0Technical Data
•Wait mode — The WAIT instruction puts the MCU in an
intermediate power-consumption mode.
•Halt mode — Halt mode is identical to wait mode, except that an
oscillator stabilization delay of 1 to 4064 internal clock cycles
occurs when the MCU exits halt mode. The stop-to-wait
conversion bit, SWAIT, in the mask option register, enables halt
mode.
For More Information On This Product,
Low-Power Modes
Go to: www.freescale.com
Page 80
Freescale Semiconductor, Inc.
Low-Power Modes
•Data-retention mode — In data-retention mode, the MCU retains
..
.
5.3 Exiting Stop and Wait Mode s
Enabling halt mode prevents the computer operating properly
(COP) watchdog from being inadvertently turned off by a STOP
instruction.
RAM contents and CPU register contents at V
as 2.0 Vdc. The data-retention feature allows the MCU to remain
in a low power-consu mption state du ring wh ich it reta ins data, but
the CPU cannot execute instructions.
voltages as low
DD
nc
Freescale Semiconductor, I
The events describ ed in this subsection brin g the MCU out of stop mode
and load the program counter with the reset vector or with an interrupt
vector.
Exiting stop mode:
•External reset — A logic 0 on the RESET pin resets the MCU,
starts the CPU clock, and loads the program counter with the
contents of locations $07FE and $07FF.
•External inte rrupt — A high-to-low transition on the IRQ/VPP pin or
a low-to-high transit ion on an enabled port A exte rnal interrupt pin
starts the CPU clock and loads the program counter with the
contents of locations $07FA and $07FB.
Exiting wait mode:
•External reset — A logic 0 on the RESET pin resets the MCU,
starts the CPU clock, and loads the program counter with the
contents of locations $07FE and $07FF.
•External inte rrupt — A high-to-low transition on the IRQ/VPP pin or
a low-to-high transit ion on an enabled port A exte rnal interrupt pin
starts the CPU clock and loads the program counter with the
contents of locations $07FA and $07FB.
Technical DataMC68HC705J1A — Rev. 4.0
For More Information On This Product,
Low-Power Modes
Go to: www.freescale.com
Page 81
Freescale Semiconductor, Inc.
•COP watchdog rese t — A timeout of the COP watchdog rese ts the
MCU, starts the CPU clock, and loads the program counter with
the contents of locations $07FE and $07FF. Softw are can enable
timer interrupts so that the MCU perio dically can exit wait mode to
reset the COP watchdog.
•Timer int errupt — Real-time interrupt requests an d timer overflow
interrupt requests start the MCU clock and load the program
counter with the contents of locations $07F8 and $07F9.
..
.
5.4 Effects of Stop and Wait Mo des
Low-Power Modes
Effects of Stop and Wait Modes
nc
5.4.1 Clock Generation
Freescale Semiconductor, I
The STOP and WAIT instructions have the effects described in this
subsection on MCU modules.
The STOP instruction:
The STOP instruction disables the internal oscillator, stopping the
CPU clock and all peripheral clocks.
After exiting stop mode, the CPU clock and all enabled peripheral
clocks begin running after the oscillator stabilization delay.
NOTE:The oscillator stabilization delay holds the MCU in reset for the first 406 4
internal clock cycles.
The WAIT instruction:
The WAIT instruction disables the CPU clock.
After exiting wait mode, the CPU clock and all enabled peripheral
clocks immediately begin running.
MC68HC705J1A — Rev. 4.0Technical Data
For More Information On This Product,
Low-Power Modes
Go to: www.freescale.com
Page 82
Low-Power Modes
5.4.2 CPU
..
.
Freescale Semiconductor, Inc.
The STOP instruction:
•Clears the interrupt mask (I bit) in the condition code register,
•Disables the CPU clock
After exiting stop mode, the CPU clock begins running after the
oscillator stabilization delay.
After exit from stop mo de by external int errupt, the I bit rema ins clear.
After exit from stop mode by reset, the I bit is set.
enabling external interrupts
nc
5.4.3 COP Watchdog
Freescale Semiconductor, I
The WAIT instruction:
•Clears the interrupt mask (I bit) in the condition code register,
enabling interrupts
•Disables the CPU clock
After exit from wait mode by interrupt, the I bit remains clear.
After exit from wait mode by reset, the I bit is set.
The STOP instruction:
•Clears the COP watchdog counter
•Disables the COP watchdog clock
NOTE:To prevent the STOP instruction from disabling the COP watchdog,
program the stop-to-wait conversion bit (SWAIT) in the mask option
register to logic 1.
After exit from stop mode by external interrupt, the COP watchdog
counter immediately begins counting from $0000 and continues
counting throughout the oscillator stabilization delay.
NOTE:Immediately after exiting stop mode by external interrupt, service the
COP to ensure a full COP timeout period.
Technical DataMC68HC705J1A — Rev. 4.0
For More Information On This Product,
Low-Power Modes
Go to: www.freescale.com
Page 83
Freescale Semiconductor, Inc.
After exit from stop mode by reset:
•The COP watchdog counter immediately begins counting from
•The COP watchdog counter is cleared at the end of the oscillator
The WAIT instruction:
The WAIT instruction has no effect on the COP watchdog.
Low-Power Modes
Effects of Stop and Wait Modes
$0000.
stabilization delay and begins counting from $0000 again.
..
.
nc
Freescale Semiconductor, I
5.4.4 Timer
NOTE:To prevent a COP timeo ut duri ng wait mode, exit wa it mod e periodical ly
to service the COP.
The STOP instruction:
•Clears the RTIE, TOF E, RTIF, and TOF bits i n the timer status and
control register, disabling timer interrupt requests and removing
any pending timer interrupt requests
•Disables the clock to the timer
After exiting stop mode by external interrupt, the timer immediately
resumes countin g from the last value before the STOP instruction and
continues counting throughout the oscillator stabilization delay.
After exiting stop mode by reset and after the oscillator stabilization
delay, the timer resumes operation from its reset state.
The WAIT instruction:
The WAIT instruction has no effect on the timer.
MC68HC705J1A — Rev. 4.0Technical Data
For More Information On This Product,
Low-Power Modes
Go to: www.freescale.com
Page 84
Low-Power Modes
5.4.5 EPROM/OTPROM
..
.
nc
5.4.6 Data-Retention Mode
Freescale Semiconductor, Inc.
The STOP instruction:
The STOP instruction during erasable, programmable read-only
memory (EP ROM) p rogr amm ing cl ear s the EP GM b it in the EP ROM
programming register, removing the programming voltage from the
EPROM.
The WAIT instruction:
The WAIT instruction has no effect on EPROM/one-time
programmable read-only memory (OTPROM) operation.
In data-re tention mode, the M CU retains rando m-access memory (RA M)
contents and CPU registe r conten ts at VDD voltages as low as 2.0 Vdc.
The data-retention feature allows the MCU to remain in a low
power-consumption state during which it retains data, but the CPU
cannot execute instructions.
To put the MCU in data-retention mode:
1.Drive the RESET pin to logic 0.
2.Lower the V
continuously during data-ret ention mode .
To take the MCU out of data-retention mode:
1.Return VDD to normal operating voltage.
2.Return the RESET pin to logic 1.
voltage. The RESET pin must remain low
DD
Freescale Semiconductor, I
Technical DataMC68HC705J1A — Rev. 4.0
For More Information On This Product,
Low-Power Modes
Go to: www.freescale.com
Page 85
5.5 Timi ng
..
.
OSC
(NOTE 1)
RESET
IRQ/V
(NOTE 2)
IRQ/V
(NOTE 3)
Freescale Semiconductor, Inc.
t
RL
t
PP
PP
ILIH
Low-Power Modes
Timing
OSCILLATOR STABIL IZATION DELAY
nc
Freescale Semiconductor, I
INTERNAL
CLOCK
INTERNAL
ADDRESS
BUS
Notes:
1. Internal clock ing fro m O SC1 pi n
2. Edge-triggered external interrupt mask option
3. Edge- and level-triggered external interrupt mask option
4. Reset vector shown as example
$07FE
(NOTE 4)
$07FE$ 07FE$07FE$07FE$07FF
Figure 5-1. Stop Mode Recovery Timing
RESET OR INTERRUPT
VECTOR FETCH
MC68HC705J1A — Rev. 4.0Technical Data
For More Information On This Product,
Low-Power Modes
Go to: www.freescale.com
Page 86
Low-Power Modes
Freescale Semiconductor, Inc.
STOP
..
.
nc
SWAIT
BIT SET?
NO
CLEAR I BIT IN CCR
CLEAR TOF, RTIF, TOIE, AND RTIE BITS IN TSCR
EXTERNAL
EXTERNAL
INTERRUPT?
SET IRQE BIT IN ISCR
TURN OFF INTERNAL OSCILLATOR
YES
RESET?
NO
YES
NO
TURN ON INTERNAL OSCILLATOR
RESET STABILIZATION TIMER
END OF
STABILIZATION
DELAY?
YES
YES
NO
TURN ON CPU CLOCK
HALT
CLEAR I BIT IN CCR
SET IRQE BIT IN ISCR
TURN OFF CPU CLOCK
TIMER CLOCK ACTIVE
YES
YES
YES
YES
EXTERNAL
RESET?
NO
EXTERNAL
INTERRUPT?
NO
TIMER
INTERRUPT?
NO
COP
RESET?
NO
WAIT
CLEAR I BIT IN CCR
SET IRQE BIT IN ISCR
TURN OFF CPU CLOCK
TIMER CLOCK ACTIVE
YES
YES
YES
YES
EXTERNAL
RESET?
NO
EXTERNAL
INTERRUPT?
NO
TIMER
INTERRUPT?
NO
COP
RESET?
NO
Freescale Semiconductor, I
1. LOAD PC WITH RESET VECTOR
2. SERVICE INTERRUPT
a. SAVE CPU REGISTERS ON STACK
b. SET I BIT IN CCR
c. LOAD PC WITH INTERRUPT VECTOR
Fourteen bidirectiona l pins form one 8-bit input/o utput (I/O) port an d one
6-bit I/O port. All the bidirectional port pins are program mable as inputs
or outputs.
NOTE:Connect any unused I/O pins to an app ropriate logic lev el, either V
V
Although the I/O ports do not require termination for proper
SS.
operation, termination reduces excess current consumption and the
possibility of electrostatic damage.
MC68HC705J1A — Rev . 4.0Technical Data
Parallel Input/Output (I/O) Ports
For More Information On This Product,
Go to: www.freescale.com
DD
or
Page 88
Freescale Semiconductor, Inc.
Parallel Input/Output (I/O) Ports
Addr.Register NameBit 7654321Bit 0
..
.
nc
$0000
$0001
$0004
$0005
$0010
$0011
Port A Data Register
(PORTA)
See page 89.
Port B Data Register
(PORTB)
See page 92.
Data Direction Register A
(DDRA)
See page 90.
Data Direction Register B
(DDRB)
See page 93.
Pulldown Register A
(PDRA)
See page 91.
Pulldown Register B
(PDRB)
See page 94.
Figure 6-1. Parallel I/O Port Register Summary
Read:
PA7PA6PA5PA4PA3PA2PA1PA0
Write:
Reset:Unaffected by reset
Read:00
PB5PB4PB3PB2PB1PB0
Write:
Reset:Unaffected by reset
Read:
DDRA7DDRA6DDRA5DDRA4DDRA3DDRA2DDRA1DDRA0
Write:
Reset:00000000
Read:00
DDRB5DDRB4DDRB3DDRB2DDRB1DDRB0
Write:
Reset:00000000
Read:
Write:PDIA7PDIA6PDIA5PDIA4PDIA3PDIA2PDIA1PDIA0
Reset:00000000
Read:
Write:PDIB5PDIB4PDIB3PDIB2PDIB1PDIB0
Reset:000000
= Unimplemented
Freescale Semiconductor, I
Technical DataMC68HC705J1A — Rev. 4.0
Parallel Input/Output (I/O) Ports
For More Information On This Product,
Go to: www.freescale.com
Page 89
Freescale Semiconductor, Inc.
6.3 Port A
Port A is an 8-bit bidirectional port.
6.3.1 Port A Data Register
The port A data register (PORTA) contains a latch for each port A pin.
Address:$0000
Parallel Input/Output (I/O) Ports
Port A
..
.
nc
Bit 7654321Bit 0
Read:
PA7PA6PA5PA4PA3PA2PA1PA0
Write:
Reset:Unaffected by reset
Figure 6-2. Port A Data Register (PORTA)
PA[7:0] — Port A Data Bits
These read/write bits are software programmable. Data direction of
each port A pin is under the control of the corresponding bit in data
direction register A. Reset has no effect on port A data.
Freescale Semiconductor, I
MC68HC705J1A — Rev. 4.0Technical Data
Parallel Input/Output (I/O) Ports
For More Information On This Product,
Go to: www.freescale.com
Page 90
Freescale Semiconductor, Inc.
Parallel Input/Output (I/O) Ports
6.3.2 Data Direction Register A
Data direction register A (DDRA) determines whether each port A pin is
an input or an output.
Address:$0004
Bit 7654321Bit 0
Read:
Write:
DDRA7DDRA6DDRA5DDRA4DDRA3DDRA2DDRA1DDRA0
..
.
nc
Freescale Semiconductor, I
Reset:00000000
Figure 6-3. Data Direction Register A (DDRA)
DDRA[7:0] — Data Direction Register A Bits
These read/write bits control port A data direction. Reset clears
DDRA[7:0], configuring all port A pins as inputs.
1 = Corresponding port A pin configured as output
0 = Corresponding port A pin configured as input
NOTE:Avoid glitches on port A pi ns by writing to the p ort A data register befo re
changing data direction register A bits from 0 to 1.
Figure 6-4 shows the I/O logic of port A.
READ DDRA
WRITE DDRA
WRITE PORTA
READ PORTA
INTERNAL DATA BUS
WRITE PDRA
RESET
DDRAx
PAx
PDRAx
SWPDI
10-mA SINK CAPABILITY
(PINS PA4–PA7 O NLY)
PAx
(PA0–PA3 TO
IRQ MODULE)
100-µA
PULLDOWN
Figure 6-4. Port A I/O Circuitry
Technical DataMC68HC705J1A — Rev. 4.0
Parallel Input/Output (I/O) Ports
For More Information On This Product,
Go to: www.freescale.com
Page 91
Freescale Semiconductor, Inc.
Parallel Input/Output (I/O) Ports
Port A
Writing a logic 1 to a DDRA bit enables the output buffer for the
corresponding port A pin; a logic 0 disables the output buffer.
When bit DDRAx is a logic 1 , reading address $0 000 reads the PAx data
latch. When bit DDRAx is a logic 0, reading address $0000 reads the
voltage level on the pin . The data latch can always be written, regardl ess
of the sta te of its dat a direction bit. Table 6-1 summarizes the operation
of the port A pins.
Table 6-1. Port A Pin Operation
..
.
nc
6.3.3 Pulldown Register A
NOTE:If the SWPDI bit in the mask option register is programmed to logic 1,
Freescale Semiconductor, I
Data Direction BitI/O Pin Mode
0Input, high-impedancePinLatch
1OutputLatchLatch
1. Writing affects the data regist er but does not affect inpu t.
Accesses to Data Bit
ReadWrite
(1)
Pulldown registe r A (P DRA) inhib its the p ulldown d evices on por t A pins
programmed as inputs.
reset initializes a ll port A pins as inputs w ith disabled pulld own devices.
Address:$0010
Bit 7654321Bit 0
Read:
Write:PDIA7PDIA6PDIA5PDIA4PDIA3PDIA2PDIA1PDIA0
Reset:00000000
= Unimplemented
Figure 6-5. Pulldown Register A (PDRA)
PDIA[7:0] — Pulldown Inhibit A Bits
PDIA[7:0] disable the port A pulldown devices. Reset clears
PDIA[7:0].
1 = Corresponding port A pulldown device disabled
0 = Corresponding port A pulldown device not disabled
MC68HC705J1A — Rev. 4.0Technical Data
Parallel Input/Output (I/O) Ports
For More Information On This Product,
Go to: www.freescale.com
Page 92
Freescale Semiconductor, Inc.
Parallel Input/Output (I/O) Ports
6.3.4 Port A LED Drive Capability
The outputs for the upper four bits of port A (PA4–PA7) can drive
light-emitti ng diodes (LEDs). P A4–PA7can sink a pproximately 10 mA of
current to V
6.3.5 Port A I/O Pin Interrupts
If the PIRQ bit in the mask option register is programmed to logic 1,
PA0–PA3 pins function as external interrupt pins. See Section 8.
..
.
External Interrupt Module (IRQ).
nc
6.4 Port B
SS
.
6.4.1 Port B Data Register
Freescale Semiconductor, I
Port B is a 6-bit bidirectional port.
The port B data register (PORTB) contains a latch for each port B pin.
Address:$0001
Bit 7654321Bit 0
Read:00
PB5PB4PB3PB2PB1PB0
Write:
Reset:Unaffected by reset
= Unimplemented
Figure 6-6. Port B Data Register (PORTB)
PB[5:0] — Port B Data Bits
These read/write bits are software programmable. Data direction of
each port B pin is under the control of the corresponding bit in data
direction register B. Reset has no effect on port B data.
Technical DataMC68HC705J1A — Rev. 4.0
Parallel Input/Output (I/O) Ports
For More Information On This Product,
Go to: www.freescale.com
Page 93
Freescale Semiconductor, Inc.
6.4.2 Data Direction Register B
Data direction register B (DDRB) determines whether each port B pin is
an input or an output.
Address:$0005
Read:00
Write:
Parallel Input/Output (I/O) Ports
Port B
Bit 7654321Bit 0
DDRB5DDRB4DDRB3DDRB2DDRB1DDRB0
..
.
nc
Freescale Semiconductor, I
Reset:00000000
= Unimplemented
Figure 6-7. Data Direction Register B (DDRB)
DDRB[5:0] — Data Direction Register B Bits
These read/write bits control port B data direction. Reset clears
DDRB[5:0], configuring all port B pins as inputs.
1 = Corresponding port B pin configured as output
0 = Corresponding port B pin configured as input
NOTE:Avoid glitches on port B pi ns by writing to the p ort B data register befo re
changing data direction register B bits from 0 to 1.
Figure 6-8 shows the I/O logic of port B.
READ DDRB
WRITE DDRB
WRITE PORTB
DDRBx
PBx
PBx
READ PORTB
INTERNAL DATA BUS
WRITE PDRB
PDRBx
RESET
SWPDI
100-µA
PULLDOWN
Figure 6-8. Port B I/O Circuitry
MC68HC705J1A — Rev. 4.0Technical Data
Parallel Input/Output (I/O) Ports
For More Information On This Product,
Go to: www.freescale.com
Page 94
Freescale Semiconductor, Inc.
Parallel Input/Output (I/O) Ports
Writing a logic 1 to a DDRB bit enables the output buffer for the
corresponding port B pin; a logic 0 disables the output buffer.
When bit DDRBx is a logic 1 , reading address $0 001 reads the PBx data
latch. When bit DDRBx is a logic 0, reading address $0001 reads the
voltage level on the pin . The data latch can always be written, regardl ess
of the sta te of its dat a direction bit. Table 6-2 summarizes the operation
of the port B pins.
Table 6-2. Port B Pin Operation
..
.
nc
6.4.3 Pulldown Register B
NOTE:If the SWPDI bit in the mask option register is programmed to logic 1,
Freescale Semiconductor, I
Data Direction BitI/O Pin Mode
0Input, high-impedancePinLatch
1OutputLatchLatch
1. Writing affects the data regist er, but does not affect i nput.
Accesses to Data Bit
ReadWrite
(1)
Pulldown registe r B (P DRB) inhib its the p ulldown d evices on por t B pins
programmed as inputs.
reset initializes a ll port B pins as inputs w ith disabled pulld own devices.
Address:$0011
Bit 7654321Bit 0
Read:
Write:PDIB5PDIB4PDIB3PDIB2PDIB1PDIB0
Reset:000000
= Unimplemented
Figure 6-9. Pulldown Register B (PDRB)
PDIB[7:0] — Pulldown Inhibit B Bits
PDIB[7:0] disable the port B pulldown devices. Reset clears
PDIB[7:0].
1 = Corresponding port B pulldown device disabled
0 = Corresponding port B pulldown device not disabled
Technical DataMC68HC705J1A — Rev. 4.0
Parallel Input/Output (I/O) Ports
For More Information On This Product,
Go to: www.freescale.com
Page 95
Freescale Semiconductor, Inc.
6.5 5.0-Volt I/O Port Electrical Characteristics
Parallel Input/Output (I/O) Ports
5.0-Volt I/O Port Electrical Characteristics
(1)
..
.
nc
Characteristic
Current drain per pin excluding PA4–PA7I—25—mA
Output high voltage
= –0.8 mA) PA 0–PA7, PB0–PB5
(I
Load
Output low voltage
= 1.6 mA) PA0–PA3 , PB0 –PB5
(I
Load
(I
= 10.0 mA) PA4–PA7
Load
Input high voltage
PA0–PA7, PB0–PB5
Input low voltage
PA0–PA7, PB0–PB5
I/O ports hi-z leakage current
PA0–PA7, P B0–PB5 (without individual pulldown activated)
The computer operating properly (COP) watchdog resets the
microcontroller (MCU) in case of software failure. Software that is
operating proper ly periodically services the COP watchdog and prevents
COP reset. The COP watchdog function is programmable by the
COPEN bit in the mask option register.
Features include:
•Protection from runaway software
•Wait and halt mode operation
MC68HC705J1A — Rev . 4.0Technical Data
Computer Operating Properly (COP) Module
For More Information On This Product,
Go to: www.freescale.com
Page 98
Freescale Semiconductor, Inc.
Computer Operating Properly (COP) Module
7.3 Operation
Operation of the COP is described in this subsection.
7.3.1 COP Watchdog Timeout
Four counter stages at the end of the timer make up the COP watchdog.
The COP resets the MCU if the timeout period occurs before the COP
watchdog timer is cleared by application software and the IRQ/VPP pin
voltage is between VSS and VDD. Periodically clearing the count er starts
..
.
nc
a new timeout perio d and prevents COP reset. A COP watchdog timeout
indicates that the software is not executing instructions in the correct
sequence.
NOTE:The internal clock drives the COP watchdog. Therefore, the COP
watchdog cannot gen erate a reset for errors that cause the inte rnal clock
to stop.
The COP watchdog depends on a power supply voltage at or above a
minimum specification and is not guaranteed to protect against
brownout.
7.3.2 COP Watchdog Timeout Period
The COP wa tchdog time r functi on is impl emente d by dividi ng the output
of the real-time int err upt ci rcuit ( RTI) by eight. T he RTI se lect bi ts in the
timer status and control register control RTI output, and the selected
output drives the COP watchdog. See timer status and control register
in Section 9. Multifunction Timer Module.
Freescale Semiconductor, I
NOTE:The minimum COP timeout period is seven times the RTI period. The
COP is cleared a synchronously w ith the value in the RTI divider ; hence,
the COP timeout period will vary between 7x and 8x the RTI period.
7.3.3 Clearing the COP Watchdog
To clear the COP watchdog and prevent a COP reset, write a logic 0 to
bit 0 (COPC) of the COP register at location $07F0 (see Figure 7-1).
Technical DataMC68HC705J1A — Rev. 4.0
Computer Operating Properly (COP) Module
For More Information On This Product,
Go to: www.freescale.com
Page 99
..
.
nc
7.4 Interrupts
Freescale Semiconductor, Inc.
Clearing the C OP bit disab les the COP watchd og timer rega rdless of the
IRQ
/VPP pin voltage.
If the main p rogram executes within t he COP timeout period , the clearing
routine should be e xecuted onl y o nce. If the main pro gram take s longe r
than the COP timeout period, the clearing routine must be executed
more than once.
Computer Operating Properly (COP) Module
Interrupts
NOTE:Place the clearing routine in the main program and not in an interrupt
routine. Clea ring the COP watchdog in an interrupt routine might pr event
COP watchdog timeouts even th ough the main program is not operati ng
properly.
7.5 COP Register
Freescale Semiconductor, I
The COP watchdog does not generate interrupts.
The COP register (COPR) is a write-only register that returns the
contents of EPROM location $07F0 when read.
Address:$07F0
Bit 7654321Bit 0
Read:
Write:COPC
Reset:0
= Unimplemented
Figure 7-1. COP Register (COPR)
COPC — COP Clear Bit
This write-only bit resets the C OP watchdog. Reading address $07F 0
returns undefined results.
MC68HC705J1A — Rev. 4.0Technical Data
Computer Operating Properly (COP) Module
For More Information On This Product,
Go to: www.freescale.com
Page 100
Freescale Semiconductor, Inc.
Computer Operating Properly (COP) Module
7.6 Low-Power Modes
The STOP and WAIT instructions have these effects on the COP
watchdog.
7.6.1 Stop Mode
The STOP instruction clears the COP watchdog counter and disables
the clock to the COP watchdog.
..
.
nc
NOTE:To prevent the STOP instruction from disabling the COP watchdog,
program the stop-to-wait conversion bit (SWAIT) in the mask option
register to logic 1.
Upon exit from stop mode by external reset:
•The counter begins counting from $0000.
•The counter is cleared again after the oscillator stabilization delay
and begins counting from $0000 again.
Upon exit from stop mode by external interrupt:
•The counter begins counting from $0000.
•The counter is not cleared again after the oscillator stabilization
delay and continues counting throughout the oscillator
stabilization delay.
NOTE:Immediately after exiting stop mode by external interrupt, service the
COP to ensure a full COP timeout period.
Freescale Semiconductor, I
7.6.2 Wait Mode
The WAIT instruction has no effect on the COP watchdog.
NOTE:To prevent a COP timeo ut duri ng wait mode, exit wa it mod e periodical ly
to service the COP.
Technical DataMC68HC705J1A — Rev. 4.0
Computer Operating Properly (COP) Module
For More Information On This Product,
Go to: www.freescale.com
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.