Brought to you as a courtesy from Midon Design - home of the TEMP05
www.midondesign.com
Rev. 2.0
HC5
MC68HC705C8A
MC68HSC705C8A
HCMOS Microcontroller Unit
TECHNICAL DATA
Page 2
Technical Data
Motorola reserves the right to make changes without further notice to
any products herein to improve reliability, function or design. Motorola
does not assume any liability arising out of the application or use of any
product or circuit described herein; neither does it convey any license
under its patent rights nor the rights of others. Motorola products are not
designed, intended, or authorized for use as components in systems
intendedfor surgical implant into thebody, or other applications intended
to support or sustain life, or for any other application in which the failure
of the Motorola product could create a situation where personal injury or
death may occur. Should Buyer purchase or use Motorola products for
any such unintended or unauthorized application, Buyer shall indemnify
and hold Motorola and its officers, employees, subsidiaries, affiliates,
and distributors harmless against all claims, costs, damages, and
expenses, and reasonable attorney fees arising out of, directly or
indirectly, any claim of personal injury or death associated with such
unintended or unauthorized use, evenif such claim alleges that Motorola
was negligent regarding the design or manufacture of the part.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAGeneral Description 19
Page 20
General Description
1.2 Introduction
1.3 Features
The MC68HC705C8A, an enhanced version of the MC68HC705C8, is a
member of the low-cost, high-performance M68HC05 Family of 8-bit
microcontroller units (MCU). The MC68HSC705C8A, introduced in
AppendixA.MC68HSC705C8A,isanenhanced, high-speed version of
the MC68HC705C8A. The M68HC05 Family is based on the
customer-specified integrated circuit (CSIC) design strategy. All MCUs
in the family use the M68HC05 central processor unit (CPU) and are
available with a variety of subsystems, memory sizes and types, and
package types.
Features of the MC68HC705C8A include:
•M68HC05 central processor unit (CPU)
•On-chip oscillator with crystal/ceramic resonator
NOTE:A line over a signal name indicates an active low signal. For example,
RESETisactive high and
current, or frequency specified in this document will refer to the nominal
values. The exact values and their tolerance or limits are specified in
Section 13. Electrical Specifications.
1.4 Programmable Options
These options are programmable in the mask option registers:
•Enabling of port B pullup devices (see 9.5.2 Mask Option
Register 1)
•Enabling of non-programmable COP watchdog (see 9.5.3 Mask
Option Register 2)
These options are programmable in the option register (see Figure 1-1):
•One of four selectable memory configurations
RESET pin
RESETisactive low. Any reference tovoltage,
•Programmable read-only memory (PROM) security
1
•External interrupt sensitivity
Address:$1FDF
Bit 7654321Bit 0
Read:
RAM0RAM100SEC*IRQ0
Write:
Reset:0000*U10
*Implemented as an EPROM cell
= UnimplementedU = Unaffected
Figure 1-1. Option Register (Option)
1. No security feature is absolutely secure. However, Motorola’s strategy is to make reading or
copying the PROM difficult for unauthorized users.
1 = Maps 32 bytes of RAM into page zero starting at address
$0030. Addresses from $0020 to $002F are reserved. This bit
can be read or written at any time, allowing memory
configuration to be changed during program execution.
0 = Provides 48 bytes of PROM at location $0020–$005F.
RAM1 — Random-Access Memory Control Bit 1
1=Maps 96 bytes of RAM intopageone starting at address $0100.
This bit can be read or written at any time, allowing memory
configuration to be changed during program execution.
0 = Provides 96 bytes of PROM at location $0100.
SEC — Security Bit
This bit is implemented as an erasable, programmable read-only
memory (EPROM) cell and is not affected by reset.
1 = Bootloader disabled; MCU operates only in single-chip mode
0 = Security off; bootloader can be enabled
1.5 Block Diagram
IRQ — Interrupt Request Pin Sensitivity Bit
IRQ is set only by reset, but can be cleared by software. This bit can
be written only once.
1 =
IRQ pin is both negative edge- and level-sensitive.
0 =
IRQ pin is negative edge-sensitive only.
Bits 5, 4, and 0 — Not used; always read 0
Bit 2 — Unaffected by reset; reads either 1 or 0
Figure 1-2 shows the structure of the MC68HC705C8A.
This subsection describes the MC68HC705C8A signals. Reference is
made, where applicable, to other sections that contain moredetail about
the function being performed.
1.7.1 V
and V
DD
SS
1.7.2 OSC1 and OSC2
VDDand VSSare the power supply and ground pins. The MCU operates
from a single power supply.
Very fast signal transitions occur
on the MCU pins, placing high
V+
V
DD
short-duration current demands
on the power supply. To prevent
noise problems, take special care
MCU
C1
+
C2
to provide good power supply
V
bypassing at the MCU. Place
SS
bypass capacitors as close to the
MCU as possible, as shown in
Figure 1-7.
Figure 1-7. Bypassing Layout
Recommendation
The OSC1 and OSC2 pins are the control connections for the 2-pin
on-chip oscillator. The oscillator can be driven by:
•Crystal resonator
•Ceramic resonator
•External clock signal
NOTE:The frequency of the internal oscillator is f
. The MCU divides the
OSC
internal oscillator output by two to produce the internal clock with a
frequency of f
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAGeneral Description 27
OP
.
Page 28
General Description
1.7.2.1 Crystal Resonator
The circuit in Figure 1-8 shows a
MCU
crystal oscillator circuit for an AT-cut,
parallel resonant crystal. Follow the
crystal supplier’s recommendations,
OSC1
10 MΩ
∗
OSC2
because the crystal parameters
determine the external component
values required to provide reliable
startup and maximum stability. The
22 pF
∗
XTAL
2 MHz
22 pF
∗
load capacitance values used in the
oscillator circuit design should
account for all stray layout
capacitances. To minimize output
distortion, mount the crystal and
capacitorsasclose as possible tothe
∗
Starting value only. Follow crystal supplier’s
recommendations regarding component
values that will provide reliable startup and
maximum stability.
Figure 1-8. Crystal
Connections
pins.
NOTE:Use an AT-cut crystal and not a strip or tuning fork crystal. The MCU
mightoverdrive or havethe incorrect characteristicimpedance for astrip
or tuning fork crystal.
1.7.2.2 Ceramic Resonator
To reduce cost, use a ceramic
MCU
resonator instead of a crystal. Use the
circuit shown in Figure 1-9 for a 2-pin
ceramic resonator or the circuit shown
OSC1
R
OSC2
in Figure 1-10 for a 3-pin ceramic
resonator, and follow the resonator
manufacturer’s recommendations.
CC
CERAMIC
RESONATOR
The external component values
required for maximum stability and
reliable starting depend upon the
resonator parameters. The load
Figure 1-9. 2-Pin Ceramic
Resonator Connections
.
capacitancevalues used in the oscillator circuit designshould include all
stray layout capacitances. To minimize output distortion, mount the
resonator and capacitors as close as possible to the pins.
An external clock from another
CMOS-compatible device can drive the
OSC1 input, with the OSC2 pin
unconnected, as Figure 1-11 shows.
NOTE:The bus frequency (f
the processor clock cycle is two times the f
) is one-half the external or crystal frequency
OP
), while the processor clock cycle (t
) is one-half the external frequency (f
OP
) is two times the f
CYC
MCU
OSC1
EXTERNAL
CMOS CLOCK
Figure 1-11. External
Clock
period.
OSC
OSC
OSC
OSC2
) while
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAGeneral Description 29
Page 30
General Description
1.7.3 External Reset Pin (RESET)
A logic 0 on the bidirectional
startup state. The
RESET pin contains an internal Schmitt trigger as part
of its input to improve noise immunity. See Section 5. Resets.
1.7.4 External Interrupt Request Pin (IRQ)
IRQ pin is an asynchronous external interrupt pin. The IRQ pin
The
contains an internal Schmitt trigger as part of its input to improve noise
immunity. See 4.3.2 External Interrupt (IRQ).
1.7.5 Input Capture Pin (TCAP)
The TCAP pin is the input capture pin for the on-chip capture/compare
timer. The TCAP pin contains an internal Schmitt trigger as part of its
input to improve noise immunity. See Section 8. Capture/Compare
Timer.
RESET pin forces the MCU to a known
1.7.6 Output Compare Pin (TCMP)
The TCMP pin is the output compare pin for the on-chip
capture/compare timer. See Section 8. Capture/Compare Timer.
1.7.7 Port A I/O Pins (PA7–PA0)
These eight I/O lines comprise port A, a general-purpose, bidirectional
I/O port. The pins are programmable as either inputs or outputs under
software control of the data direction registers. See 7.3 Port A.
1.7.8 Port B I/O Pins (PB7–PB0)
These eight I/O pins comprise port B, a general-purpose, bidirectional
I/O port. The pins are programmable as either inputs or outputs under
software control of the data direction registers. Port B pins also can be
configured to function as external interrupts. See 7.4 Port B.
These eight I/O pins comprise port C, a general-purpose, bidirectional
I/O port. The pins are programmable as either inputs or outputs under
software control of the data direction registers. PC7 has a high current
sink and source capability. See 7.5 Port C.
1.7.10 Port D I/O Pins (PD7 and PD5–PD0)
These seven lines comprise port D, a fixed input port. All special
functions that are enabled (SPI and SCI) affect this port. See 7.6 Port D.
General Description
Pin Functions
NOTE:Connecting the V
result in damage to the MCU.
pin (programming voltage) to VSS (ground) could
PP
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAGeneral Description 31
This section describes the organization of the on-chip memory.
The central processor unit (CPU) can address eight Kbytes of memory
andinput/output (I/O) registers. The program counter typically advances
oneaddress at a timethrough memory, reading theprogram instructions
and data. The programmable read-only memory (PROM) portion of
memory — either one-time programmable read-only memory
(OTPROM) or erasable, programmable read-only memory
(EPROM) — holds the program instructions, fixed data, user-defined
vectors, and interrupt service routines. The random-access memory
(RAM) portion of memory holds variable data.
I/O registers are memory-mapped so that the CPU can access their
locations in the same way that it accesses all other memory locations.
The shared stack area is used during processing of an interrupt or
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAMemory 33
Page 34
Memory
2.4 Input/Output (I/O)
subroutine call to save the CPU state. The stack pointer decrements
during pushes and increments during pulls.
Figure 2-1 is a memory map of the MCU. Addresses $0000–$001F,
shown in Figure 2-2, contain most of the control, status, and data
registers. Additional I/O registers have these addresses:
•$1FDF, option register
•$1FF0, mask option register 1 (MOR1)
•$1FF1, mask option register 2 (MOR2)
The first 32 addresses of memory space, from $0000 to $001F, are the
I/O section. These are the addresses of the I/O control registers, status
registers, and data registers. See Figure 2-2 for more information.
2.5 RAM
One of four selectable memory configurations is selected by the state of
the RAM1 and RAM0 bits in the option register located at $1FDF. Reset
or power-on reset (POR) clears these bits, automatically selecting the
first memory configuration as shown in Table 2-1. See 9.5.1 Option
Register.
Table 2-1. Memory Configurations
RAM0RAM1RAM BytesPROM Bytes
001767744
102087696
012727648
113047600
NOTE:Be careful when using nested subroutines or multiple interrupt levels.
The CPU can overwrite data in the stack RAM during a subroutine or
during the interrupt stacking operation.
AnMCU with a quartzwindow has a maximumof 7744 bytesofEPROM.
The quartz window allows the EPROM erasure with ultraviolet light. In
an MCU without a quartz window, the EPROM cannot be erased and
serves a maximum 7744 bytes of OTPROM (see Table 2-1). See
Section 9. EPROM/OTPROM (PROM).
2.7 Bootloader ROM
The 240 bytes at addresses $1F00–$1FEF are reserved ROM
addresses that contain the instructions for the bootloader functions. See
Section 9. EPROM/OTPROM (PROM).
Memory
EPROM/OTPROM (PROM)
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAMemory 35
Page 36
Memory
$0000
$001FPORT C DATA REGISTER$0002
$0020
$002FPORT B DATA DIRECTION REGISTER$0005
$0030
$004FRAM0 = 1
$0050SPI CONTROL REGISTER$000A
$00BFSPI DATA REGISTER$000C
$00C0
$00FFSCI CONTROL REGISTER 2$000F
$0100
USER PROM
$015FRAM1 = 0
$0160
$1EFFALTERNATE TIMER REGISTER (LOW)$001B
$1F00
$1FDECOP CONTROL REGISTER$001E
$1FDFOPTION REGISTERUNUSED$001F
$1FE0
$1FEF
$1FF0MASK OPTION REGISTER 1
$1FF1MASK OPTION REGISTER 2
$1FF2
$1FFFTIMER INTERRUPT VECTOR (HIGH)$1FF8
(1)
See 9.5.1 Option Register for information.EXTERNAL INTERRUPT VECTOR (LOW)$1FFB
I/O REGISTERS
32 BYTES
UNUSED
16 BYTES
RAM
32 BYTES
(1)
RAM
176 BYTES
96 BYTES
(1)
USER PROM
7584 BYTES
BOOTLOADER ROM
240 BYTES
BOOT ROM VECTORS
16 BYTES
USER PROM VECTORS
12 BYTES
USER PROM
48 BYTES
(1)
RAM0 = 0
STACK
64 BYTES
RAM
96 BYTES
(1)
RAM1 = 1
PORT A DATA REGISTER$0000
PORT B DATA REGISTER$0001
PORT D FIXED INPUT PORT$0003
PORT A DATA DIRECTION REGISTER$0004
PORT C DATA DIRECTION REGISTER$0006
UNUSED$0007
UNUSED$0008
UNUSED$0009
SPI STATUS REGISTER$000B
SCI BAUD RATE REGISTER$000D
SCI CONTROL REGISTER 1$000E
This section describes the central processor unit (CPU) registers.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLACentral Processor Unit (CPU) 41
Page 42
Central Processor Unit (CPU)
3.3 CPU Registers
Figure 3-1 shows the fiveCPU registers. These arehard-wired registers
within the CPU and are not part of the memory map.
Bit 04Bit 756321
ACCUMULATOR (A)
Bit 04Bit 756321
INDEX REGISTER (X)
8Bit 12 11109
1100000
8Bit 12 11109
6321
HALF-CARRY FLAG
INTERRUPT MASK
NEGATIVE FLAG
ZERO FLAG
CARRY/BORROW FLAG
Figure 3-1. Programming Model
Bit 04756321
STACK POINTER (SP)
Bit 04756321
PROGRAM COUNTER (PC)
Bit 04Bit 75
ZCIN1H11
CONDITION CODE REGISTER (CCR)
Technical DataMC68HC705C8A — Rev. 2.0
42Central Processor Unit (CPU)MOTOROLA
Page 43
3.3.1 Accumulator
3.3.2 Index Register
Central Processor Unit (CPU)
CPU Registers
The accumulator (A) shown in Figure 3-2 is a general-purpose 8-bit
register. The CPU uses the accumulator to hold operands and results of
arithmetic and non-arithmetic operations.
Bit 7654321Bit 0
Read:
Write:
Reset:Unaffected by reset
Figure 3-2. Accumulator (A)
In the indexed addressing modes, the CPU uses the byte in the index
register (X) shown in Figure 3-3 to determine the conditional address of
the operand. See 12.3.5 Indexed, No Offset, 12.3.6 Indexed, 8-Bit
Offset, and 12.3.7 Indexed, 16-Bit Offset for more information on
indexed addressing.
The 8-bit index register also can serve as a temporary data storage
location.
Bit 7654321Bit 0
Read:
Write:
Reset:Unaffected by reset
Figure 3-3. Index Register (X)
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLACentral Processor Unit (CPU) 43
Page 44
Central Processor Unit (CPU)
3.3.3 Stack Pointer
The stack pointer (SP) shown in Figure 3-4 is a 13-bit register that
contains the address of the next free location on the stack. During a
reset or after the reset stack pointer (RSP) instruction, the stack pointer
initializesto$00FF. The address inthestack pointer decrements asdata
is pushed onto the stack and increments as data is pulled from the stack.
The seven most significant bits of the stack pointer are fixed
permanently at 0000011, 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.
Bit 121110987654321Bit 0
Read:0000011
Write:
Reset:0000011111111
3.3.4 Program Counter
Bit 121110987654321Bit 0
= Unimplemented
Figure 3-4. Stack Pointer (SP)
The program counter (PC) shown in Figure 3-5 is a 13-bit register that
contains the address of the next instruction or operand to be fetched.
Normally, the address in the program counter automatically increments
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.
Read:
Write:
Reset:Loaded with reset vector from $1FFE and $1FFF
Figure 3-5. Program Counter (PC)
Technical DataMC68HC705C8A — Rev. 2.0
44Central Processor Unit (CPU)MOTOROLA
Page 45
3.3.5 Condition Code Register
The condition code register (CCR) shown in Figure 3-6 is an 8-bit
register whose three most significant bits are permanently fixed at 111.
Thecondition code registercontains the interrupt mask and four bits that
indicate the results of prior instructions.
Read:111
Write:
Reset:111U1UUU
Central Processor Unit (CPU)
CPU Registers
Bit 7654321Bit 0
HINZC
= UnimplementedU = Unaffected
Figure 3-6. Condition Code Register (CCR)
H — Half-Carry Bit
The CPU sets the half-carry flag when a carry occurs between bits 3
and 4 of the accumulator during an add without carry (ADD) or add
with carry (ADC) operation. The half-carry bit is required for
binary-coded decimal (BCD) arithmetic operations. Reset has no
affect on the half-carry flag.
I — Interrupt Mask Bit
Setting the interrupt mask (I) disables interrupts. If an interrupt
request occurs while the interrupt mask is a logic 0, the CPU saves
the CPU registers on the stack, sets the interrupt mask, and then
fetches the interrupt vector. If an interrupt request occurs while the
interrupt mask is set, the interrupt request is latched. The CPU
processes the latched interrupt as soon as the interrupt mask is
cleared again.
A return-from-interrupt (RTI) instruction pulls the CPU registers from
the stack, restoring the interrupt mask to its cleared state. After a
reset, the interrupt mask is set and can be cleared only by a CLI,
STOP, or WAIT instruction.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLACentral Processor Unit (CPU) 45
Page 46
Central Processor Unit (CPU)
N — Negative Flag
The CPU sets the negative flag when an arithmetic operation, logical
operation,ordata manipulation produces a negativeresult(bit7 in the
results is a logic 1). Reset has no effect on the negative flag.
Z — Zero Flag
The CPU sets the zero flag when an arithmetic operation, logical
operation, or data manipulation produces a result of $00. Reset has
no effect on the zero flag.
C — Carry/Borrow Flag
The CPU sets the carry/borrow flag when an addition operation
produces a carry out of bit 7 of the accumulator or when a subtraction
operation requires a borrow. Some logical operations and data
manipulation instructions also clear or set the carry/borrow bit. Reset
has no effect on the carry/borrow flag.
3.4 Arithmetic/Logic Unit (ALU)
The arithmetic/logic unit (ALU) performs the arithmetic and logical
operations defined by the instruction set. The binary arithmetic circuits
decode instructions and set up the ALU for the selected operation. Most
binary arithmetic is based on the addition algorithm, carrying out
subtraction as negative addition. Multiplication is not performed as a
discrete operation but as a chain of addition and shift operations within
the ALU. The multiply instruction requires 11 internal clock cycles to
complete this chain of operations.
Technical DataMC68HC705C8A — Rev. 2.0
46Central Processor Unit (CPU)MOTOROLA
This section describes how interrupts temporarily change the normal
processing sequence.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAInterrupts 47
Page 48
Interrupts
4.3 Interrupt Sources
These sources can generate interrupts:
•Software instructions (SWI)
•External interrupt pin (IRQ)
•Port B pins
•Serial communications interface (SCI):
–SCI transmit data register empty
–SCI transmission complete
–SCI receive data register full
–SCI receiver overrun
–SCI receiver input idle
The
setting the I bit of the condition code register (CCR). The software
interrupt (SWI) instruction is non-maskable.
An interrupt temporarily changes the program sequence to process a
particular event. An interrupt does not stop the execution of the
instruction in progress but takes effect when the current instruction
completes its execution. Interrupt processing automatically saves the
central processor unit (CPU) registers on the stack and loads the
program counter with a user-defined vector address.
After completing the current instruction, the CPU tests these bits:
•IRQ latch
•I bit in the CCR
Setting the I bit in the CCR disables external interrupts.
If the IRQ latch is set and the I bit is clear, the CPU then begins the
interrupt sequence. The CPU clears the IRQ latch while it fetches the
interrupt vector,so thatanother external interrupt request can be latched
during the interrupt service routine. As soon as the I bit is cleared during
the return-from-interrupt (RTI) instruction, the CPU can recognize the
newinterrupt request. Figure 4-1 shows the logic forexternal interrupts.
Figure 4-1 shows an external interrupt functional diagram. Figure 4-2
shows an external interrupt timing diagram for the interrupt line. The
timing diagram illustrates two treatments of the interrupt line to the
processor.
1.Two single pulses on the interrupt line are spaced far enough
apart to be serviced. The minimum time between pulses is a
function of the length of the interrupt service.
Once a pulse occurs, the next pulse normally should not occur
until an RTI occurs. This time (t
) is obtained by adding 19
ILIL
instructioncyclestothe total number of cycles neededtocomplete
the service routine (not including the RTI instruction).
2.Many interrupt lines are “wire-ORed” to the
IRQ line. If the
interrupt line remains low after servicing an interrupt, then the
CPU continues to recognize an interrupt.
NOTE:The internal interrupt latch is cleared in the first part of the interrupt
service routine. Therefore, a new external interrupt pulse could be
latched and serviced as soon as the I bit is cleared.
If the
IRQ pin is not in use, connect it to the VDD pin.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAInterrupts 49
Page 50
Interrupts
EDGE- AND LEVEL-SENSITIVE TRIGGER
OPTION REGISTER
V
DD
DQ
IRQ LATCH
EXTERNAL
INTERRUPT
REQUEST
I BIT (CCR)
INTERRUPT PIN
C
Q
R
Figure 4-1. External Interrupt Internal Function Diagram
t
ILIL
IRQ PIN
a. Edge-Sensitive Trigger Condition. The minimum pulse width (t
or 250 ns (f
= 1 MHz). The period t
OP
execute the interrupt service routine plus 19 t
t
ILIH
should not be less than the number of t
ILIL
CYC
cycles.
POR
INTERNAL RESET (COP)
EXTERNAL RESET
EXTERNAL INTERRUPT BEING SERVICED
(VECTOR FETCH)
) is either 125 ns (fOP = 2.1 MHz)
ILIH
cycles it takes to
CYC
t
ILIH
NORMALLY
USED WITH
WIRED-OR
CONNECTION
IRQ
1
.
.
.
IRQ
n
IRQ
(INTERNAL)
b. Level-Sensitive Trigger Condition. If the interrupt line remains low after servicing an interrupt, then the
When these three conditions are true, a port B pin (PBx) acts as an
external interrupt pin:
•The corresponding port B pullup bit (PBPUx) in mask option
register 1 (MOR1) is programmed to a logic 1.
•The corresponding port B data direction bit (DDRBx) in data
direction register B (DDRB) is a logic 0.
•The clear interrupt mask (CLI) instruction has cleared the I bit in
the CCR.
MOR1 is an erasable, programmable read-only memory (EPROM)
register that enables the port B pullup device. Data from MOR1 is
latched on the rising edge of the voltage on the
RESET pin. See 9.5.2
Mask Option Register 1.
Port B external interrupt pins can be falling-edge sensitive only or both
falling-edge and low-level sensitive, depending on the state of the IRQ
bit in the option register at location $1FDF.
When the IRQ bit is a logic 1, a falling edge or a low level on a port B
external interrupt pin latches an external interrupt request. As long as
any port B external interrupt pin is low, an external interrupt request is
present, and the CPU continues to execute the interrupt service routine.
When the IRQ bit is a logic 0, a falling-edge only on a port B external
interrupt pin latches an external interrupt request. A subsequent port B
external interrupt request can be latched only after the voltage level of
the previous port B external interrupt signal returns to a logic 1 and then
falls again to a logic 0.
Figure 4-3 shows the port B input/output (I/O) logic.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAInterrupts 51
Setting the I bit in the CCR disables all interrupts except for SWI.
4.3.5 SCI Interrupts
The serial communications interface (SCI) can generate these
interrupts:
•Transmit data register empty interrupt
•Transmission complete interrupt
•Receive data register full interrupt
•Receiver overrun interrupt
•Receiver input idle interrupt
Interrupts
Interrupt Sources
Setting the I bit in the CCR disables all SCI interrupts.
•SCI Transmit Data Register Empty Interrupt — The transmit
data register empty bit (TDRE) indicates that the SCI data register
is ready to receive a byte for transmission. TDRE becomes set
when data in the SCI data register transfers to the transmit shift
register. TDRE generates an interrupt request if the transmit
interrupt enable bit (TIE) is set also.
•SCI Transmission Complete Interrupt — The transmission
completebit (TC) indicates thecompletion of an SCItransmission.
TC becomes set when the TDRE bit becomes set and no data,
preamble, or break character is being transmitted. TC generates
an interrupt request if the transmission complete interrupt enable
bit (TCIE) is set also.
•SCI Receive Data Register Full Interrupt — The receive data
register full bit (RDRF) indicates that a byte is ready to be read in
the SCI data register. RDRF becomes set when the data in the
receive shift register transfers to the SCI data register. RDRF
generates an interrupt request if the receive interrupt enable bit
(RIE) is set also.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAInterrupts 53
Page 54
Interrupts
4.3.6 SPI Interrupts
•SCI Receiver Overrun Interrupt — The overrun bit (OR)
indicates that a received byte is lost because software has not
read the previously received byte. OR becomes set when a byte
shifts into the receive shift register before software reads the word
already in the SCI data register. OR generates an interrupt
request if the receive interrupt enable bit (RIE) is set also.
•SCI Receiver Input Idle Interrupt — The receiver input idle bit
(IDLE) indicates that the SCI receiver input is not receiving data.
IDLE becomes set when 10 or 11 consecutive logic 1s appear on
the receiver input. IDLE generates an interrupt request if the idle
line interrupt enable bit (ILIE) is set also.
The serial peripheral interrupt (SPI) can generate these interrupts:
•SPI transmission complete interrupt
•SPI mode fault interrupt
Setting the I bit in the CCR disables all SPI interrupts.
•SPI Transmission Complete Interrupt — The SPI flag bit (SPIF)
in the SPI status register indicates the completion of an SPI
transmission. SPIF becomes set when a byte shifts into or out of
the SPI data register. SPIF generates an interrupt request if the
SPIE bit is set also.
•SPIMode Fault Interrupt — The mode faultbit(MODF)in the SPI
status register indicates an SPI mode error. MODF becomes set
when a logic 0 occurs on the PD5/
SS pin while the master bit
(MSTR) in the SPI control register is set. MODF generates an
interrupt request if the SPIE bit is set also.
The CPU takes these actions to begin servicing an interrupt:
1.Stores the CPU registers on the stack in the order shown in
2.Sets the I bit in the CCR to prevent further interrupts
3.Loads the program counter with the contents of the appropriate
Interrupts
Interrupt Processing
Figure 4-4
interrupt vector locations as shown in Table 4-1.
Table 4-1. Reset/Interrupt Vector Addresses
FunctionSource
Power-on
Reset
Software
interrupt
(SWI)
External
interrupt
Timer
interrupts
SCI
interrupts
logic
RESET pin
User codeNoneNone
IRQ pin
Port B pins
ICF bitICIE bit
TOF bitTOIE bit
TDRE bit
TC bit
RDRF bit
OR bit
Local
Mask
NoneNone1$1FFE–$1FFF
NoneI bit2$1FFA–$1FFB
TCIE bit
RIE bit
Global
Mask
I bit3$1FF8–$1FF9OCF bitOCIE bit
I bit4$1FF6–$1FF7
Priority
(1 = Highest)
Same priority
as any
instruction
Vector Address
$1FFC–$1FFD
IDLE bitILIE bit
SPI
interrupts
SPIF bit
SPIEI bit5$1FF4–$1FF5
MODF bit
The return-from-interrupt (RTI) instruction causes the CPU to recover
the CPU registers from the stack as shown in Figure 4-4.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAInterrupts 55
Page 56
Interrupts
UNSTACKING
ORDER
$00C0 (BOTTOM OF STACK)
$00C1
$00C2
•
•
•
•
•
•
5
4
3
2
1
STACKING
ORDER
1
2
3
4
5
CONDITION CODE REGISTER
ACCUMULATOR
INDEX REGISTER
PROGRAM COUNTER (HIGH BYTE)
PROGRAM COUNTER (LOW BYTE)
•
•
•
•
•
•
$00FD
$00FE
$00FF (TOP OF STACK)
Figure 4-4. Interrupt Stacking Order
NOTE:If morethan one interrupt request ispending, the CPUfetchesthe vector
of the higher priority interrupt first. A higher priority interrupt does not
interrupt a lower priority interruptservice routineunless the lowerpriority
interrupt service routine clears the I bit. See Table 4-1 for a priority
listing.
Figure 4-5 shows the sequence of events caused by an interrupt.
This section describes how resets initialize the microcontroller unit
(MCU).
A reset immediately stops the operation of the instruction being
executed, initializes certain control bits, and loads the program counter
with a user-defined reset vector address. These conditions produce a
reset:
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAResets 59
Page 60
Resets
5.3.1 Power-On Reset (POR)
5.3.2 External Reset
A positive transition on the V
pin generates a power-on reset (POR).
DD
The POR is strictly for the power-up condition and cannot be used to
detect drops in power supply voltage.
A 4064 t
active allows the clock generator to stabilize. If the
logic 0 at the end of 4064 t
until the signal on the
(internal clock cycle) delay after the oscillator becomes
CYC
RESET pin is at
, the MCU remains in the reset condition
CYC
RESET pin goes to logic 1.
The minimum time required for the MCU to recognize a reset is 1 1/2
.However, to guarantee that the MCU recognizes an external reset
t
CYC
asan external reset and notas a COP orclock monitor reset, the
pin must be low for eight t
. After six t
CYC
, the input on the RESET pin
CYC
RESET
is sampled. If the pin is still low, an external reset has occurred. If the
input is high, then the MCU assumes that the reset was initiated
internally by either the COP watchdog timer or by the clock monitor.This
method of differentiating between external and internal reset conditions
assumes that the
RESET pin will rise to a logic 1 less than two t
CYC
after
its release and that an externally generated reset should stay active for
at least eight t
CYC
.
5.3.3 Programmable and Non-Programmable COP Watchdog Resets
Atimeout of aCOP watchdog generates aCOP reset. ACOP watchdog,
once enabled, is part of a software error detection system and must be
cleared periodically to start a new timeout period.
The MC68HC705C8A has two different COP watchdogs for
compatibility with devices such as the MC68HC705C8 and the
MC68HC05C4A:
One COP has four programmable timeout periods and the other has a
fixed non-programmable timeout period.
5.3.3.1 Programmable COP Watchdog Reset
A timeout of the 18-stage ripple counter in the programmable COP
watchdog generates a reset. Figure 5-1 is a diagram of the
programmable COP watchdog. Two registers control and monitor
operation of the programmable COP watchdog:
•COP reset register (COPRST), $001D
•COP control register (COPCR), $001E
To clear the programmable COP watchdog and begin a new timeout
period, write these values to the COP reset register (COPRST).
See Figure 5-2.
Resets
Reset Sources
INTERNAL
CLOCK
(fOP)
COPRST
1.$55
2.$AA
The$55write must precede the$AAwrite. Instructions may beexecuted
between the write operations provided that the COP watchdog does not
time out before the second write.
PROGRAMMABLE COP WATCHDOG (MC68HC705C8 TYPE)
÷ 4÷ 2 ÷ 2÷ 2 ÷ 2÷ 2 ÷ 2
÷2
÷2÷2 ÷2 ÷2 ÷2 ÷2 ÷2 ÷2 ÷2÷2 ÷2 ÷2 ÷2 ÷2 ÷2÷4
13
CM0
2
CM1
15
2
17
2
19
2
21
2
PCOPE
RESET
Figure 5-1. Programmable COP Watchdog Diagram
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAResets 61
The programmable COP control register (COPCR) shown in Figure 5-3
does these functions:
•Flags programmable COP watchdog resets
•Enables the clock monitor
•Enables the programmable COP watchdog
•Controls the timeout period of the programmable COP watchdog
Address:$001E
Bit 7654321Bit 0
Read:000COPFCMEPCOPECM1CM0
Write:
Reset:000U0000
= UnimplementedU = Unaffected
Figure 5-3. Programmable COP Control Register (COPCR)
COPF — COP Flag
This read-only bit is set when a timeout of the programmable COP
watchdog occurs or when the clock monitor detects a slow or absent
internal clock. Clear the COPF bit by reading the COP control
register. Reset has no effect on the COPF bit.
1 = COP timeout or internal clock failure
0 = No COP timeout and no internal clock failure
This read/write bit enables the clock monitor. The clock monitor sets
the COPF bit and generates a reset if it detects an absent internal
clockfor a period offrom 5 µsto 100 µs. CMEis readable andwritable
at any time. Reset clears the CME bit.
NOTE:Do not enable the clock monitor in applications with an internal clock
frequency of 200 kHz or less.
If the clock monitor detects a slow clock, it drives the bidirectional
RESET pin low for four clock cycles. If the clock monitor detects an
absent clock, it drives the
PCOPE — Programmable COP Enable Bit
RESET pin low until the clock recovers.
This read/write bit enables the programmable COP watchdog.
PCOPE is readable at any time but can be written only once after
reset. Reset clears the PCOPE bit.
NOTE:Programming the non-programmable COP enable bit (NCOPE) in mask
option register 2 (MOR2) to logic 1 enables the non-programmable COP
watchdog. Setting the PCOPE bit while the NCOPE bit is programmed
to logic 1 enables both COP watchdogs to operate at the same time.
(See 9.5.3 Mask Option Register 2.)
CM1 and CM0 — COP Mode Bits
These read/write bits select the timeout period of the programmable
COP watchdog. (See Table 5-1.) CM1 and CM0 can be read anytime
but can be written only once. They can be cleared only by reset.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAResets 63
Page 64
Resets
CM1:CM0
Table 5-1. Programmable COP Timeout Period Selection
Programmable COP Timeout Period
COP
Timeout Rate
= 4.0 MHz
f
OSC
f
= 2.0 MHz
OP
= 3.5795 MHz
f
OSC
f
= 1.7897 MHz
OP
= 2.0 MHz
f
OSC
f
= 1.0 MHz
OP
= 1.0 MHz
f
OSC
f
= 0.5 MHz
OP
00
01
10
11
fOP÷ 2
fOP÷ 2
fOP÷ 2
fOP÷ 2
15
17
19
21
16.38 ms18.31 ms32.77 ms65.54 ms
65.54 ms73.24 ms131.07 ms262.14 ms
262.14 ms292.95 ms524.29 ms1.048 s
1.048 s1.172 s2.097 s4.194 s
5.3.3.2 Non-Programmable COP Watchdog
A timeout of the 18-stage ripple counter in the non-programmable COP
watchdog generates a reset. The timeout period is 65.536 ms when
f
= 4 MHz. The timeout period for the non-programmable COP timer
OSC
is a direct function of the crystal frequency. The equation is:
Two memory locations control operation of the non-programmable COP
watchdog:
Timeout period =
262,144
f
OSC
1.Non-programmable COP enable bit (NCOPE) in mask option
register 2 (MOR2)
Programming the NCOPE bit in MOR2 to a logic 1 enables the
non-programmable COP watchdog. See 9.5.3 Mask Option
Register 2.
NOTE:Writing a logic 1 to the programmable COP enable bit (PCOPE) in the
COPcontrol register enables theprogrammable COP watchdog.Setting
the PCOPE bit while the NCOPE bit is programmed to logic 1 enables
both COP watchdogs to operate at the same time.
2.COP clear bit (COPC) at address $1FF0
To clear the non-programmable COP watchdog and start a new
COP timeout period, write a logic 0 to bit 0 of address $1FF0.
Reading address $1FF0 returns the mask option register 1
(MOR1) data at that location. See 9.5.2 Mask Option Register 1.
NOTE:The non-programmable watchdog COP is disabled in bootloader mode,
even if the NCOPE bit is programmed.
Figure 5-4 is a diagram of the non-programmable COP.
NON-PROGRAMMABLE COP WATCHDOG (MC68HC05C4A TYPE)
5.3.4 Clock Monitor Reset
When the CME bit in the COP control register is set, the clock monitor
detects the absence of the internal bus clock for a certain period of time.
The timeout period depends on processing parameters and varies from
5 µs to 100 µs, which implies that systems using a bus clock rate of
200 kHz or less should not use the clock monitor function.
If a slow or absent clock is detected, the clock monitor causes a system
reset.The reset is issuedto the external systemfor four bus cyclesusing
the bidirectional
Special consideration is required when using the STOP instruction with
the clock monitor. Since STOP causes the system clocks to halt, the
clock monitor issues a system reset when STOP is executed.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAResets 65
Page 66
Resets
The clock monitor is a useful backup to the COP watchdog system.
Because the watchdog timer requires a clock to function, it cannot
indicate a system clock failure. The clock monitor would detect such a
condition and force the MCU to a reset state. Clocks are not required for
theMCU to reach a reset condition. They are,however, required to bring
the MCU through the reset sequence and back to run condition.
The STOP instruction places the microcontroller unit (MCU) in its lowest
power consumption mode. In stop mode, the internal oscillator is turned
off, halting all internal processing including timer, serial communications
interface (SCI), and master mode serial peripheral interface (SPI)
operation. See Figure 6-1.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLALow-Power Modes 67
Page 68
Low-Power Modes
NO
EXTERNAL
INTERRUPT
(IRQ)
YES
STOP
STOP OSCILLATOR
AND ALL CLOCKS
CLEAR I BIT
NO
RESET
TURN ON OSCILLATOR
WAIT FOR TIME
DELAY TO STABILIZE
YES
WAIT
OSCILLATOR ACTIVE
TIMER, SCI, AND SPI
CLOCKS ACTIVE
CPU CLOCKS STOPPED
CLEAR I BIT
RESET
YES
RESTART CPU CLOCK
NO
EXTERNAL
INTERRUPT
(
IRQ)
YES
YES
YES
NO
INTERNAL TIMER
INTERRUPT
NO
INTERNAL SCI
INTERRUPT
1. FETCH RESET VECTOR
2. SERVICE INTERRUPT:
OR
a. STACK
b. SET I BIT
c. VECTOR TO
INTERRUPT ROUTINE
1. FETCH RESET VECTOR
2. SERVICE INTERRUPT:
OR
a. STACK
b. SET I BIT
c. VECTOR TO
INTERRUPT ROUTINE
YES
NO
INTERNAL SPI
INTERRUPT
NO
Figure 6-1. Stop/Wait Mode Function Flowchart
During stop mode, the I bit in the condition code register (CCR) is
cleared to enable external interrupts. All other registers and memory
remain unaltered. All input/output (I/O) lines remain unchanged. The
processor can be brought out of stop mode only by an external interrupt
or reset.
When the MCU enters stop mode, the baudrate generator stops, halting
all SCI activity. If the STOP instruction is executed during a transmitter
transfer, that transfer is halted.If a low input to the
stop mode, the transfer resumes.
If the SCI receiver is receiving data and stop mode is entered, received
data sampling stops because the baud rate generator stops, and all
subsequent data is lost. Therefore, all SCI transfers should be in the idle
state when the STOP instruction is executed.
6.3.2 SPI During Stop Mode
When the MCU enters stop mode, the baud rate generator stops,
terminating all master mode SPI operations. If the STOP instruction is
executed during an SPI transfer, that transfer halts until the MCU exits
stop mode by a low signal on the
mode, the SPI control and status bits are cleared, and the SPI is
disabled.
Low-Power Modes
Stop Mode
IRQ pin is used toexit
IRQ pin. If reset is used to exit stop
If the MCU is in slave mode when the STOP instruction is executed, the
slave SPI continues to operate and can still accept data and clock
information in addition to transmitting its own data back to a master
device. At the end of a possible transmission with a slave SPI in stop
mode, no flags are set until a low on the
NOTE:Although a slave SPI in stop mode can exchange data with a master
SPI, the status bits of a slave SPI are inactive in stop mode.
6.3.3 Programmable COP Watchdog in Stop Mode
The STOP instruction turns off the internal oscillator and suspends the
computer operating properly (COP) watchdog counter. If the
brings the MCU out of stop mode, the reset function clears and disables
the COP watchdog.
If the
resumes counting from its suspended value after the 4064-t
stabilization delay. See Figure 6-2.
IRQ pin brings the MCU out of stop mode, the COP counter
IRQ pin wakes up the MCU.
RESET pin
clock
CYC
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLALow-Power Modes 69
Page 70
Low-Power Modes
NOTE:If the clock monitor is enabled (CME = 1), the STOP instruction causes
the clock monitor to time out and reset the MCU.
STOP
CLEAR I BIT IN CCR
TURN OFF INTERNAL OSCILLATOR
SUSPEND COP COUNTER
EXTERNAL
RESET?
NO
NO
EXTERNAL
INTERRUPT?
YES
TURN ON INTERNAL OSCILLATOR
END OF
STABILIZATION
DELAY?
NO
TURN ON INTERNAL CLOCK
RESUME COP WATCHDOG COUNT
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
OR
YES
YES
TURN ON INTERNAL OSCILLATOR
CLEAR COP COUNTER
CLEAR PCOPE BIT IN COPCR
END OF
STABILIZATION
DELAY?
NO
TURN ON INTERNAL CLOCK
1. LOAD PC WITH RESET VECTOR
OR
2. SERVICE INTERRUPT:
a. SAVE CPU REGISTERS ON STACK
b. SET I BIT IN CCR
c. LOAD PC WITH INTERRUPT VECTOR
The STOP instruction has these effects on the non-programmable COP
watchdog:
•Turns off the oscillator and the COP watchdog counter
•Clears the COP watchdog counter
Low-Power Modes
Wait Mode
NOTE:If the clock monitor is enabled (CME = 1), the STOP instruction causes
6.4 Wait Mode
If the
RESET pin brings the MCU out of stop mode, the COP watchdog
begins counting immediately. The reset function clearsthe COP counter
again after the 4064-t
If the
IRQ pin brings the MCU out of stop mode, the COP watchdog
clock stabilization delay.
CYC
begins counting immediately. The IRQ function does not clear the
COP counter again after the 4064-t
clock stabilization delay. See
CYC
Figure 6-3.
it to time out and reset the MCU.
The WAIT instruction places the MCU in an intermediate power
consumption mode. All central processor unit (CPU) activity is
suspended, but the oscillator, capture/compare timer, SCI, and SPI
remain active. Any interrupt or reset brings the MCU out of wait mode.
See Figure 6-1.
The WAIT instruction has these effects on the CPU:
•Clears the I bit in the condition code register, enabling interrupts
•Stops the CPU clock, but allows the internal clock to drive the
capture/compare timer, SCI, and SPI
TheWAIT instruction does not affect any other registersor I/O lines. The
capture/compare timer, SCI, and SPI can be enabled to allow a periodic
exit from wait mode.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLALow-Power Modes 71
Page 72
Low-Power Modes
STOP
CLEAR I BIT IN CCR
CLEAR COP COUNTER
TURN OFF INTERNAL OSCILLATOR
TURN OFF COP COUNTER
EXTERNAL
RESET?
NO
NO
EXTERNAL
INTERRUPT?
YES
TURN ON INTERNAL OSCILLATOR
TURN ON COP WATCHDOG
END OF
STABILIZATION
DELAY?
NO
TURN ON INTERNAL CLOCK
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
OR
YES
YES
TURN ON INTERNAL OSCILLATOR
TURN ON COP WATCHDOG
END OF
STABILIZATION
DELAY?
NO
CLEAR COP COUNTER
TURN ON INTERNAL CLOCK
1. LOAD PC WITH RESET VECTOR
OR
2. SERVICE INTERRUPT:
a. SAVE CPU REGISTERS ON STACK
b. SET I BIT IN CCR
c. LOAD PC WITH INTERRUPT VECTOR
The programmable COP watchdog is active during wait mode. Software
must periodically bring the MCU out of wait mode to clear the
programmable COP watchdog.
6.4.2 Non-Programmable COP Watchdog in Wait Mode
The non-programmable COP watchdog is active during wait mode.
Software must periodically bring the MCU out of wait mode to clear the
non-programmable COP watchdog.
6.5 Data-Retention Mode
Indata-retentionmode,theMCUretains random-access memory (RAM)
contents and CPU register contents at V
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.
Low-Power Modes
Data-Retention Mode
voltages as low as 2.0 Vdc.
DD
To put the MCU in data-retention mode:
1.Drive the
2.Lower V
RESET pin to logic 0.
voltage.The RESET pin must remain low continuously
DD
during data-retention mode.
To take the MCU out of data-retention mode:
1.Return V
2.Return the
to normal operating voltage.
DD
RESET pin to logic 1.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLALow-Power Modes 73
This section describes the programming of ports A, B, C, and D.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAParallel Input/Output (I/O) 75
Page 76
Parallel Input/Output (I/O)
7.3 Port A
Port A is an 8-bit, general-purpose, bidirectional input/output (I/O) port.
7.3.1 Port A Data Register
The port A data register (PORTA) shown in Figure 7-1 contains a data
latch for each of the eight port A pins. When a port A pin is programmed
to be an output, the state of its data register bit determines the state of
the output pin. When a port A pin is programmed to be an input, reading
the port A data register returns the logic state of the pin.
Address:$0000
Read:
Write:
Bit 7654321Bit 0
PA7PA6PA5PA4PA3PA2PA1PA0
Reset:Unaffected by reset
Figure 7-1. Port A Data Register (PORTA)
PA7–PA0 — Port A Data Bits
These read/write bits are software programmable. Data direction of
each bit is under the control of the corresponding bit in data direction
register A. Reset has no effect on port A data.
The contents of data direction register A (DDRA) shown in Figure 7-2
determine whether each port A pin is an input or an output. Writing a
logic 1 to a DDRA bit enables the output buffer for the associated port A
pin; a logic 0 disables the output buffer. A reset clears all DDRA bits,
configuring all port A pins as inputs.
Address:$0004
Read:
DDRA7DDRA6DDRA5DDRA4DDRA3DDRA2DDRA1DDRA0
Write:
Reset:00000000
Parallel Input/Output (I/O)
Port A
Bit 7654321Bit 0
Figure 7-2. Data Direction Register A (DDRA)
DDRA7–DDRA0 — Port A Data Direction Bits
These read/write bits control port A data direction. Reset clears bits
DDRA7–DDRA0.
1 = Corresponding port A pin configured as output
0 = Corresponding port A pin configured as input
NOTE:Avoid glitches on port A pins by writing to the port A data register before
changing DDRA bits from logic 0 to logic 1.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAParallel Input/Output (I/O) 77
Page 78
Parallel Input/Output (I/O)
7.3.3 Port A Logic
Figure 7-3 is a diagram of the port A I/O logic.
READ $0004
WRITE $0004
RESET
WRITE $0000
INTERNAL DATA BUS
READ $0000
DATA DIRECTION
REGISTER A
BIT DDRAx
PORT A DATA
REGISTER
BIT PAx
PAx
Figure 7-3. Port A I/O Logic
When a port A pin is programmed to be an output, the state of its data
register bit determines the state of the output pin. When a port A pin is
programmed to be an input, reading the port A data register returns the
logic state of the pin.
The data latchcan always be written, regardless of the state of its DDRA
bit. Table 7-1 summarizes the operation of the port A pins.
Table 7-1. Port A Pin Functions
Accesses to DDRAAccesses to PORTA
DDRA BitI/O Pin Mode
Read/WriteReadWrite
0
1OutputDDRA7–DDRA0PA7–PA0PA7–PA0
1. Hi-Z = high impedance
2. Writing affects data register but does not affect input.
Input, Hi-Z
(1)
DDRA7–DDRA0Pin
NOTE:To avoid excessive current draw, tie all unused input pins to V
PA7–PA0
DD
(2)
or VSS,
or change I/O pins to outputs by writing to DDRA in user code as early
as possible.
Port B is an 8-bit, general-purpose, bidirectional I/O port. PortB pins can
also be configured to function as external interrupts. The port B pullup
devices are enabled in mask option register 1 (MOR1). See 9.5.2 Mask
Option Register 1 and 4.3.3 Port B Interrupts.
7.4.1 Port B Data Register
The port B data register (PORTB) shown in Figure 7-4 contains a data
latch for each of the eight port B pins.
Address:$0001
Parallel Input/Output (I/O)
Port B
Bit 7654321Bit 0
Read:
PB7PB6PB5PB4PB3PB2PB1PB0
Write:
Reset:Unaffected by reset
Figure 7-4. Port B Data Register (PORTB)
PB7–PB0 — Port B Data Bits
These read/write bits are software programmable. Data direction of
each bit is under the control of the corresponding bit in data direction
register B. Reset has no effect on port B data.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAParallel Input/Output (I/O) 79
Page 80
Parallel Input/Output (I/O)
7.4.2 Data Direction Register B
The contents of data direction register B (DDRB) shown in Figure 7-5
determine whether each port B pin is an input or an output. Writing a
logic 1 to a DDRB bit enables the output buffer for the associated port B
pin; a logic 0 disables the output buffer. A reset clears all DDRB bits,
configuring all port B pins as inputs. If the pullup devices are enabled by
mask option, setting a DDRB bit to a logic 1 turns off the pullup device
for that pin.
Address:$0005
Read:
Write:
Reset:00000000
Bit 7654321Bit 0
DDRB7DDRB6DDRB5DDRB4DDRB3DDRB2DDRB1DDRB0
Figure 7-5. Data Direction Register B (DDRB)
DDRB7–DDRB0 — Port B Data Direction Bits
These read/write bits control port B data direction. Reset clears bits
DDRB7–DDRB0.
1 = Corresponding port B pin configured as output
0 = Corresponding port B pin configured as input
NOTE:Avoid glitches on port B pins by writing to the port B data register before
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAParallel Input/Output (I/O) 81
Page 82
Parallel Input/Output (I/O)
Whena port B pin isprogrammed as an output,readingthe port bit reads
the value of the data latch and not the voltage on the pin itself. When a
port B pin is programmed as an input, reading the port bit reads the
voltagelevel on thepin. The data latchcan always bewritten, regardless
of the state of its DDRB bit.
DDRB BitI/O Pin Mode
Table 7-2. Port B Pin Functions
Accesses to DDRBAccesses to PORTB
Read/WriteReadWrite
0
1OutputDDRB7–DDRB0PB7–PB0PB7–PB0
1. Hi-Z = high impedance
2. Writing affects data register but does not affect input.
Input, Hi-Z
(1)
DDRB7–DDRB0Pin
NOTE:To avoid excessive current draw, tie all unused input pins to V
orforI/O pins change tooutputsby writing to DDRB inuser code as early
as possible.
PortC is an8-bit, general-purpose, bidirectional I/Oport. PC7 hasa high
current sink and source capability.
7.5.1 Port C Data Register
The port C data register (PORTC) shown in Figure 7-7 contains a data
latch for each of the eight port C pins. When a port C pin is programmed
to be an output, the state of its data register bit determines the state of
the output pin. When a port C pin is programmed to be an input, reading
the port C data register returns the logic state of the pin.
Address:$0002
Parallel Input/Output (I/O)
Port C
Bit 7654321Bit 0
Read:
PC7PC6PC5PC4PC3PC2PC1PC0
Write:
Reset:Unaffected by reset
Figure 7-7. Port C Data Register (PORTC)
PC7–PC0 — Port C Data Bits
These read/write bits are software programmable. Data direction of
each bit is under the control of the corresponding bit in data direction
register C. PC7 has a high current sink and source capability. Reset
has no effect on port C data.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAParallel Input/Output (I/O) 83
Page 84
Parallel Input/Output (I/O)
7.5.2 Data Direction Register C
The contents of data direction register C (DDRC) shown in Figure 7-8
determine whether each port C pin is an input or an output. Writing a
logic 1 to a DDRC bit enables the output buffer for the associated port C
pin; a logic 0 disables the output buffer. A reset clears all DDRC bits,
configuring all port C pins as inputs.
Address:$0006
Read:
Write:
Reset:00000000
Bit 7654321Bit 0
DDRC7DDRC6DDRC5DDRC4DDRC3DDRC2DDRC1DDRC0
Figure 7-8. Data Direction Register C (DDRC)
DDRC7–DDRC0 — Port C Data Direction Bits
These read/write bits control port C data direction. Reset clears bits
DDRC7–DDRC0.
1 = Corresponding port C pin configured as output
0 = Corresponding port C pin configured as input
NOTE:Avoid glitches on port C pins by writing to the port C data register before
When a port C pin is programmed as an output, reading the port bit
reads the value of the data latch and not the voltage on the pin. When a
port C pin is programmed as an input, reading the port bit reads the
voltagelevelon the pin. Thedata latch can alwaysbe written, regardless
of the state of its DDRC bit. Table 7-3 summarizes the operation of the
port C pins.
Table 7-3. Port C Pin Functions
Accesses to DDRCAccesses to PORTC
DDRC BitI/O Pin Mode
Read/WriteReadWrite
0
Input, Hi-Z
(1)
DDRC7–DDRC0Pin
PC7–PC0
(2)
1OutputDDRC7–DDRC0PC7–PC0PC7–PC0
1. Hi-Z = high impedance
2. Writing affects data register but does not affect input.
NOTE:To avoid excessive current draw, tie all unused input pins to V
DD
or V
SS
or change I/O pins to outputs by writing to DDRC in user code as early
as possible.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLAParallel Input/Output (I/O) 85
Page 86
Parallel Input/Output (I/O)
7.6 Port D
Port D is a 7-bit, special-purpose, input-only port that has no data
register. Reading address $0003 returns the logic states of the port D
pins.
Port D shares pins PD5–PD2 with the serial peripheral interface module
(SPI). When the SPI is enabled, PD5–PD2 read as logic 0s. When the
SPI is disabled, reading address $0003 returns the logic states of the
PD5–PD2 pins.
Port D shares pins PD1 and PD0 with the SCI module. When the SCI is
enabled, PD1 and PD0 read as logic 0s. When the SCI is disabled,
reading address $0003 returns the logic states of the PD1 and PD0 pins.
Address:$0003
Bit 7654321Bit 0
Read:PD7SSSCKMOSIMISOTDORDI
Write:
Figure 8-1 shows the structure of the timer module. Figure 8-2 is a
summary of the timer input/output (I/O) registers.
8.3 Timer Operation
The core of the capture/compare timer is a 16-bit free-running counter.
The counter is the timing reference for the input capture and output
compare functions. The input captureand output compare functions can
latch the times at which external events occur, measure input
waveforms,andgenerateoutputwaveformsand timing delays. Software
can read the value in the counter at any time without affecting the
counter sequence.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLACapture/Compare Timer 87
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLACapture/Compare Timer 89
Page 90
Capture/Compare Timer
Because of the 16-bit timer architecture, the I/O registers for the input
capture and output compare functions are pairs of 8-bit registers.
Because the counter is 16 bits long and preceded by a fixed
divide-by-four prescaler, the counter rolls over every 262,144 internal
clock cycles. Timer resolution with a 4-MHz crystal is 2 µs.
8.3.1 Input Capture
Theinputcapture function can record thetimeat which an external event
occurs. When the input capture circuitry detects an active edge on the
input capture pin (TCAP), it latches the contents of the timer registers
into the input capture registers. The polarity of the active edge is
programmable.
Latching values into the input capture registers at successive edges of
the same polarity measures the period of the input signal on the TCAP
pin.Latching the counter valuesat successive edges ofopposite polarity
measuresthe pulse widthof the signal.Figure 8-3 showsthe logic of the
input capture function.
The output compare function can generate an output signal when the
16-bit counter reaches a selected value. Software writes the selected
value into the output compare registers. On every fourth internal clock
cycle the output compare circuitry compares the value of the counter to
the value written in the output compare registers. When a match occurs,
the timer transfers the programmable output level bit (OLVL) from the
timer control register to the output compare pin (TCMP).
Software can use the output compare register to measure time periods,
to generate timing delays, or to generate a pulse of specific duration or
a pulse train of specific frequency and duty cycle on the TCMP pin.
Figure 8-4 shows the logic of the output compare function.
The state of this read/write bit determines whether a positive or
negative transition on the TCAP pin triggers a transfer of the contents
of the timer register to the input capture registers. Reset has no effect
on the IEDG bit.
The state of this read/write bit determines whether a logic 1 or a
logic 0 appears on the TCMP pin when a successful output compare
occurs. Reset clears the OLVL bit.
1 = TCMP goes high on output compare
0 = TCMP goes low on output compare
Bits 4–2 — Not used; these bits always read 0
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLACapture/Compare Timer 93
Page 94
Capture/Compare Timer
8.4.2 Timer Status Register
The timer status register (TSR) is a read-only register shown in
Figure 8-6 contains flags for these events:
•An active signal on the TCAP pin, transferring the contents of the
•A match between the 16-bit counter and the output compare
•A timer rollover from $FFFF to $0000
Address:$0013
Read:ICFOCFTOF00000
Write:
timer registers to the input capture registers
registers, transferring the OLVL bit to the TCMP pin
Bit 7654321Bit 0
Reset:UUU00000
= UnimplementedU = Unaffected
Figure 8-6. Timer Status Register (TSR)
ICF — Input Capture Flag
The ICF bit is set automatically when an edge of the selected polarity
occurs on the TCAP pin. Clear the ICF bit by reading the timer status
register with ICF set and then reading the low byte ($0015) of the
input capture registers. Reset has no effect on ICF.
1 = Input capture
0 = No input capture
OCF — Output Compare Flag
The OCF bit is set automatically when the value of the timer registers
matches the contents of the output compare registers. Clear the OCF
bit by reading the timer status register with OCF set and then reading
the low byte ($0017) of the output compare registers. Reset has no
effect on OCF.
The TOF bit is automatically set when the 16-bit counter rolls over
from $FFFF to $0000. Clear the TOF bit by reading the timer status
register with TOF set and then reading the low byte ($0019) of the
timer registers. Reset has no effect on TOF.
1 = Timer overflow
0 = No timer overflow
Bits 4–0 — Not used; these bits always read 0
The read-only timer registers (TRH and TRL) shown in Figure 8-7
contain the current high and low bytes of the 16-bit counter. Reading
TRH before reading TRL causes TRL to be latched until TRL is read.
Reading TRL after reading the timer status register clears the timer
overflow flag bit (TOF). Writing to the timer registers has no effect.
Bit 7654321Bit 0
Register Name and Address: Timer Register High — $0018
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLACapture/Compare Timer 95
Page 96
Capture/Compare Timer
Reading TRH returns the current value of the high byte of the counter
and causes the low byte to be latched into a buffer, as shown in
Figure 8-8. The buffer value remains fixed even if the high byte is read
more than once. Reading TRL reads the transparent low byte buffer and
completes the read sequence of the timer registers.
INTERNAL DATA BUS
$0018
NOTE:To prevent interrupts from occurring between readings of TRH and TRL,
set the interrupt mask (I bit) in the condition code register before reading
TRH, and clear the mask after reading TRL.
8.4.4 Alternate Timer Registers
The alternate timer registers (ATRH and ATRL) shown in Figure 8-9
contain the current high and low bytes of the 16-bit counter. Reading
ATRH before reading ATRL causes ATRL to be latched until ATRL is
read. Reading does not affect the timer overflow flag (TOF). Writing to
the alternate timer registers has no effect.
NOTE:To prevent interrupts from occurring between readings of ATRH and
ATRL, set the interrupt mask (I bit) in the condition code register before
reading ATRH, and clear the mask after reading ATRL.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLACapture/Compare Timer 97
Page 98
Capture/Compare Timer
8.4.5 Input Capture Registers
When a selected edge occurs on the TCAP pin, the current high and low
bytes of the 16-bit counter are latched into the read-only input capture
registers (ICRH and ICRL) shown in Figure 8-11. Reading ICRH before
reading ICRL inhibits further captures until ICRL is read. Reading ICRL
after reading the timer status register clears the input capture flag (ICF).
Writing to the input capture registers has no effect.
Register Name and Address: Input Capture Register High — $0014
When the value of the 16-bit counter matches the value in the read/write
output compare registers (OCRH and OCRL) shown in Figure 8-12, the
planned TCMP pin action takes place. Writing to OCRH before writing to
OCRL inhibits timer compares until OCRL is written. Reading or writing
to OCRL after reading the timer status register clears the output
compare flag (OCF).
Bit 7654321Bit 0
Register Name and Address: Output Compare Register High — $0016
Read:
Bit 15Bit 14Bit 13Bit 12Bit 11Bit 10Bit 9Bit 8
Write:
Reset:Unaffected by reset
Register Name and Address: Output Compare Register Low — $0017
Capture/Compare Timer
Timer I/O Registers
Read:
Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
Write:
Reset:Unaffected by reset
Figure 8-12. Output Compare Registers (OCRH and OCRL)
To prevent OCF from being set between the time it is read and the time
the output compare registers are updated, use this procedure:
1.Disable interrupts by setting the I bit in the condition code register.
2.Write to OCRH. Compares are now inhibited until OCRL is written.
3.Clear bit OCF by reading the timer status register (TSR).
4.Enable the output compare function by writing to OCRL.
5.Enable interrupts by clearing the I bit in the condition code
register.
MC68HC705C8A — Rev. 2.0Technical Data
MOTOROLACapture/Compare Timer 99