The MC68HC(7)08KH12 is a member of the low-cost, high-performance
M68HC08 Family of 8-bit microcontroller units (MCUs). The M68HC08
Family is based on the customer-specified integrated circuit (CSIC)
design strategy. All MCUs in the family use the enhanced M68HC08
central processor unit (CPU08) and are available with a variety of
modules, memory sizes and types, and package types.
Features of the MC68HC(7)08KH12 include the following:
•High-Performance M68HC08 Architecture
•Fully Upward-Compatible Object Code with M6805, M146805,
and M68HC05 Families
•6 MHz Internal Bus Operation
•Low-Power Design (Fully Static with Stop and Wait Modes)
•12 KBytes of User ROM (MC68HC08KH12) or One-Time
Programmable (OTP) ROM (MC68HC708KH12)
•On-Chip Programming Firmware for Use with Host Personal
Computer
•ROM/OTPROM Data Security
1
•384 Bytes of On-Chip Random Access Memory (RAM)
•42 General Purpose I/O, 29 with Software Configurable Pullups
•16-Bit, 2-Channel Timer Interface Module (TIM)
•20-Bit Keyboard Interrupt Port
•5 LED Direct Drive Port Pins
•48MHz Phase-Locked Loop
1. No security feature is absolutely secure. However, Freescale’s strategy is to make reading or
copying the ROM/OTPROM difficult for unauthorized users.
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
24Freescale Semiconductor
•Full Universal Serial Bus Specification 1.1 Composite HUB with
Embedded1 Functions:
–1 × 12MHz Upstream Port
–4 × 12MHz/1.5MHz Downstream Ports
–1 × Hub Control Endpoint (Endpoint0) with 8 byte transmit
buffer and 8 byte receive buffer
–1 × Hub Interrupt Endpoint (Endpoint1) with 1 byte transmit
buffer
–1 × Device Control Endpoint (Endpoint0) with 8 byte transmit
buffer and 8 byte receive buffer
–D evice Interrupt Endpoints (Endpoint1 and Endpoint2) share
with 8 byte transmit buffer
•On-chip 3.3V regulator for USB Transceiver
•System Protection Features
–Optional Computer Operating Properly (COP) Reset
–Illegal Opcode Detection with Optional Reset
–Illegal Address Detection with Optional Reset
•Master Reset Pin with Internal Pullup and Power-On Reset
•An External Asynchronous Interrupt Pin with Internal Pullup
(IRQ1)
•64-pin plastic quad flatpack (QFP) package
1. Embedded device supports only bulk and interrupt transfers, and does not support
isochronous transfers.
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
25
1.4 MCU Block Diagram
Features of the CPU08 include the following:
•Enhanced HC05 Programming Model
•Extensive Loop Control Functions
•16 Addressing Modes (Eight More Than the HC05)
•16-Bit Index Register and Stack Pointer
•Memory-to-Memory Data Transfers
•Fast 8 × 8 Multiply Instruction
•Fast 16/8 Divide Instruction
•Binary-Coded Decimal (BCD) Instructions
•Optimization for Controller Applications
•Third Party C Language Support
Figure 1-1 shows the structure of the MC68HC(7)08KH12.
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
26Freescale Semiconductor
Freescale Semiconductor
MC68HC(7)08KH12 — Rev. 1.1Advance Information
PTD7/KBD7–
PTD0/KBD0
PTE3/KBE3–
PTE0/KBE0
PTF7/KBF7–
PTF0/KBF0
DPLUS4
DMINUS4
DPLUS3
DMINUS3
DPLUS2
DMINUS2
DPLUS1
DMINUS1
DPLUS0
DMINUS0
PTE4
➀➃➅
➀➃
PTC4–PTC0
➄
DS Port 4
DS Port 3
DS Port 2
DS Port 1
PORT D
PORT E
PORT F
US Port
DDRD
DDRE
DDRF
PORT C
DDRC
Embedded USB Function384 bytes RAM12k-bytes ROM/OTPROM
➀➁
CPU CONTROLALU
CPU REGISTERS
CONDITION CODE REGISTER
PTB7–PTB0
PORT B
68HC08 CPU
STACK POINTER
PROGRAM COUNTER
➀
DDRB
ACCUMULATOR
INDEX REGISTER
V11H I NZ C
PTA7–PTA0
PORT A
DDRA
POWER SUPPLY
AND
VOLTAGE REGULATION
CLOCK GENERATION
MODULE AND PLL
SYSTEM INTEGRATION
MODULE
IRQ MODULE
BREAK MODULE
POWER-ON RESET
MODULE
TIMER INTERFACE
MODULE
VDD1
VSS1
VDD2
VSS2
REGOUT
OSC2
OSC1
VDDA
VSSA
CGMXFC
➂
RST
IRQ1/VPP
TCLK/PTE0
TCH0/PTE1
TCH1/PTE2
➂➃
27
➀ PORTS ARE SOFTWARE CONFIGURABLE WITH PULLUP DEVICE IF INPUT PORT
➁ SOFTWARE CONFIGURABLE LED DIRECT DRIVE 3mA SOURCE /10mA SINK or STANDARD DRIVE
➂ PIN CONTAINS INTEGRATED PULLUP DEVICE
➃ PIN HAS INTERRUPT CAPABILITY
➄ PIN HAS INTERRUPT AND INTEGRATED PULLUP DEVICE.
➅ PIN HAS OPTICAL COUPLING INTERFACE
Figure 1-1. MCU Block Diagram
COP MODULE
MONITOR ROM
240 bytes
1.5 Pin Assignments
1.5.1 Quad Flat Pack (QFP) Package
Figure 1-2 Shows the 64-pin QFP assignments.
PTF0/KBF0
RST
IRQ1/VPP
64
63
VDDA
CGMXFC
OSC1
OSC2
VSSA
REGOUT
DPLUS0
DMINUS0
DPLUS1
DMINUS1
DPLUS2
DMINUS2
DPLUS3
DMINUS3
DPLUS4
DMINUS4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
62
18
19
PTF5/KBF5
PTF4/KBF4
PTF3/KBF3
PTF2/KBF2
PTF1/KBF1
61
60
59
58
57
68HC(7)08KH12
20
21
22
23
24
PTF6/KBF6
PTF7/KBF7
56
55
25
VSS2
VDD2
PTA7
PTA6
PTA5
PTA4
54
53
52
51
26
27
28
30
29
49
50
48
47
46
45
44
42
42
41
40
39
38
37
36
35
34
33
31
32
PTA3
PTA2
PTA1
PTA0
PTB7
PTB6
PTB5
PTB4
PTB3
PTB2
PTB1
PTB0
PTD7/KBD7
PTD6/KBD6
PTD5/KBD5
PTD4/KBD4
PTE4
VSS1
PTE3/KBE3
PTE0/KBE0/TCLK
PTE1/KBE1/TCH0
PTE2/KBE2/TCH1
VDD1
PTC0
PTC1
PTC2
PTC3
PTC4
PTD0/KBD0
PTD1/KBD1
PTD2/KBD2
PTD3/KBD3
Figure 1-2. 64-Pin QFP Assignments (Top View)
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
28Freescale Semiconductor
1.5.2 Power Supply Pins (V
V
DDA
the on-chip Phase-Locked Loop circuit.
V
DD2
internal circuitry of the chip.
V
DD1
The MCU operates from a single power supply.
Fast signal transitions on MCU pins place high, short-duration current
demands on the power supply. To prevent noise problems, take special
care to provide power supply bypassing at the MCU as Figure 1-3
shows. Place the bypass capacitors as close to the MCU power pins as
possible. Use high-frequency-response ceramic capacitors for C
C
BULK
that require the port pins to source high current levels.
, V
DDA
and V
and V
and V
, V
SSA
are the analog power supply and ground pins used by
SSA
are the power supply and ground pins used by the
SS2
are the power supply and ground pins to the I/O pads.
SS1
DD1
, V
SS1
, V
DD2
, and V
SS2
)
BYPASS
are optional bulk current bypass capacitors for use in applications
.
V
DDA
C
BYPASS
10nF
NOTE: Values shown are typical values.
V
SSA
Figure 1-3. Power Supply Bypassing
MCU
V
DD2
C
BYPASS
10nF
V
SS2
V
DD2
Vbus
C
BYPASS
10nF
+
C
BULK
V
SS1
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
29
1.5.3 Oscillator Pins (OSC1 and OSC2)
The OSC1 and OSC2 pins are the connections for the on-chip oscillator
circuit. (See Section 8. Clock Generator Module (CGM).)
1.5.4 External Reset Pin (RST)
A logic zero on the RST pin forces the MCU to a known start-up state.
RST is bidirectional, allowing a reset of the entire system. It is driven low
when any internal reset source is asserted. The RST pin contains an
internal pullup device. ((See Section 7. System Integration Module
(SIM).)
1.5.5 External Interrupt Pin (IRQ1/VPP)
IRQ1/VPP is an asynchronous external interrupt pin. IRQ1/VPP is also
the OTPROM programming power pin. The IRQ1/V
internal pullup device. (See Section 14. External Interrupt (IRQ).)
pin contain an
PP
1.5.6 USB Data Pins (DPLUS0–DPLUS4 and DMINUS0–DMINUS4)
DPLUS0–DPLUS4 and DMINUS0–DMINUS4 are the differential data
lines used by the USB module. (See Section 9. Universal Serial Bus
Module (USB).)
1.5.7 Voltage Regulator Out (REGOUT)
REGOUT is the 3.3V output of the on-chip voltage regulator. It is used to
supply the voltage for the external pullup resistor required by the USB on
either DPLUS or DMINUS lines, depending on type of USB function.
REGOUT is also used internally for the USB data driver and the Phaselocked Loop circuit. The REGOUT pin requires an external bulk
capacitor 1µF or larger and a bypass capacitor. (See Section 9.
Universal Serial Bus Module (USB).)
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
30Freescale Semiconductor
1.5.8 Port A Input/Output (I/O) Pins (PTA7–PTA0)
PTA7–PTA0 are general-purpose bidirectional I/O port pins. (See
Section 12. I/O Ports.) Each pin contains a software configurable pull-
up device when the pin is configured as an input. (See 12.9 Port
Options.)
1.5.9 Port B I/O Pins (PTB7–PTB0)
PTB7–PTB0 are general-purpose bidirectional I/O port pins. (See
Section 12. I/O Ports.) Each pin contains a software configurable pull-
up device when the pin is configured as an input. (See 12.9 Port
Options.)
1.5.10 Port C I/O Pins (PTC4–PTC0)
PTC4–PTC0 are general-purpose bidirectional I/O port pins. (See
Section 12. I/O Ports.) Port C pins are software configurable to be LED
Direct Drive ports. Each pin contains a software configurable pull-up
device when the pin is configured as an input. (See 12.9 Port Options.)
1.5.11 Port D I/O Pins (PTD7/KBD7–PTD0/KBD0)
PTD7/KBD7–PTD0/KBD0 are general-purpose bidirectional I/O port
pins. (See Section 12. I/O Ports.) Any or all of the port D pins can be
programmed to serve as external interrupt pins. (See Section 15.
Keyboard Interrupt Module (KBI).)
1.5.12 Port E I/O Pins (PTE4, PTE3/KBE3, PTE2/KBE2/TCH1,
PTE1/KBE1/TCH0, PTE0/KBE0/TCLK)
Port-E is a 5-bit special function port which shares three of its pins with
the Timer Interface Module and four of its pins with Keyboard Interrupt
Module (see Section 12. I/O Ports, Section 15. Keyboard Interrupt
Module (KBI) and Section 11. Timer Interface Module (TIM)). In
addition, PTE3-PTE0 has built-in optical coupling interface for optical
mouse application. (See Section 12. I/O Ports.)
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
31
1.5.13 Port F I/O Pins (PTF7/KBF7–PTF0/KBF0)
PTF7/KBF7–PTF0/KBF0 are general-purpose bidirectional I/O port pins.
(See Section 12. I/O Ports.) Any or all of the port F pins can be
programmed to serve as external interrupt pins. (See Section 15.
The CPU08 can address 64 Kbytes of memory space. The memory
map, shown in Figure 2-1, includes:
Section 2. Memory Map
•11776 bytes of ROM or OTPROM
•384 bytes of RAM
•26 bytes of user-defined vectors
•240 bytes of Monitor ROM
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
33
$0000
↓
$005F
$0060
↓
$01DF
$01E0
↓
$CDFF
$D000
↓
$FDFF
$FE00BREAK STATUS REGISTER (BSR)
$FE01RESET STATUS REGISTER (RSR)
$FE02RESERVED
$FE03BREAK FLAG CONTROL REGISTER (BFCR)
$FE04INTERRUPT STATUS REGISTER 1 (INT1)
$FE05INTERRUPT STATUS REGISTER 2 (INT2)
$FE06RESERVED
$FE07RESERVED
$FE08
↓
$FE0B
$FE0CBREAK ADDRESS HIGH REGISTER (BRKH)
$FE0DBREAK ADDRESS LOW REGISTER (BRKL)
$FE0EBREAK STATUS AND CONTROL REGISTER (BSCR)
$FE0FRESERVED
$FE10
↓
$FEFF
$FF00
↓
$FF8DRESERVED
↓
$FFE5
$FFE6
↓
$FFFF
I/O REGISTERS (80 BYTES)
RAM (384 BYTES)
UNIMPLEMENTED (52, 256 BYTES)
ROM/OTPROM (11776 BYTES)
RESERVED (4 BYTES)
MONITOR ROM (240 BYTES)
$FF00 to $FF8C
UNIMPLEMENTED (141 BYTES)
$FF8E to $FFE5
UNIMPLEMENTED (88 BYTES)
VECTORS (26 BYTES)
Figure 2-1. Memory Map
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
34Freescale Semiconductor
2.3 I/O Section
Addresses $0000–$005F, shown in Figure 2-2, contain most of the
control, status, and data registers. Additional I/O registers have the
following addresses:
•$FE00 (Break Status Register, BSR)
•$FE01 (Reset Status Register, RSR)
•$FE02 (Reserved)
•$FE03 (Break Flag Control Register, BFCR)
•$FE04 (Interrupt Status Register 1, INT1)
•$FE05 (Interrupt Status Register 2, INT2)
•$FE06 (Reserved)
•$FE07 (Reserved)
•$FE08 (Reserved)
•$FE09 (Reserved)
•$FE0A (Reserved)
•$FE0B (Reserved)
•$FE0C and $FE0D (Break Address Registers, BRKH and BRKL)
Addresses $0060 through $01DF are RAM locations. The location of the
stack RAM is programmable. The 16-bit stack pointer allows the stack to
be anywhere in the 64-Kbyte memory space.
NOTE:For correct operation, the stack pointer must point only to RAM
locations.
Within page zero are 160 bytes of RAM. Because the location of the
stack RAM is programmable, all page zero RAM locations can be used
for I/O control and user data or code. When the stack pointer is moved
from its reset location at $00FF, direct addressing mode instructions can
access efficiently all page zero RAM locations. Page zero RAM,
therefore, provides ideal locations for frequently accessed global
variables.
Before processing an interrupt, the CPU uses five bytes of the stack to
save the contents of the CPU registers.
NOTE:For M6805 compatibility, the H register is not stacked.
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
45
During a subroutine call, the CPU uses two bytes of the stack to store
the return address. The stack pointer decrements during pushes and
increments during pulls.
NOTE:Be careful when using nested subroutines. The CPU may overwrite data
in the RAM during a subroutine or during the interrupt stacking
operation.
This section describes the 11,776 bytes of read-only memory (ROM)
and 26 bytes of user vectors, available on the MC68HC08KH12 device
(ROM part).
On the MC68HC708KH12 (OTP part), the ROM is replaced with 11,776
bytes One-Time Programmable (OTP) ROM. Programming tools are
available from Freescale. Contact your local Freescale representative
for more information.
4.3 Functional Description
These addresses are user ROM locations:
$D000 – $FDFF
$FFE6 – $FFFF (These locations are reserved for user-defined interrupt
and reset vectors.)
NOTE:A secutiry feature prevents viewing of the ROM contents.
1
1. No security feature is absolutely secure. However, Freescale’s strategy is to make reading or
copying the ROM contents difficult for unauthorized users.
This section describes the configuration register (CONFIG). The
configuration register enables or disables the following options:
•Stop mode recovery time (32 CGMXCLK cycles or 4096
CGMXCLK cycles)
•STOP instruction
•Computer operating properly module (COP)
•COP reset period (COPRS), (213–24)×CGMXCLK or
(218–24)×CGMXCLK
5.3 Functional Description
The configuration register is used in the initialization of various options.
The configuration register can be written once after each reset. All of the
configuration register bits are cleared during reset. Since the various
options affect the operation of the MCU it is recommended that this
register be written immediately after reset. The configuration register is
located at $001F. The configuration register may be read at anytime.
This configuration register exists on both the MC68HC708KH12
(OTP part) and MC68HC08KH12 (ROM part).
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
49
NOTE:The CONFIG register is a special register containing one-time writable
latches after each reset. Upon a reset, the CONFIG register defaults to
the predetermined settings as shown in Figure 5-1.
Address:$001F
Bit 7654321Bit 0
Read:0000
Write:
Reset:00000000
= Unimplemented
Figure 5-1. Configuration Register (CONFIG)
SSREC — Short stop recovery bit
SSREC enables the CPU to exit stop mode with a delay of 32
CGMXCLK cycles instead of a 4096 CGMXCLK cycle delay.
1 = Stop mode recovery after 32 CGMXCLK cycles
0 = Stop mode recovery after 4096 CGMXCLK cycles
SSRECCOPRSSTOPCOPD
NOTE:Exiting stop mode by pulling reset will result in the long stop recovery.
If using an external crystal, do not set the SSREC bit.
COPRS — COP reset period selection bit
1 = COP reset cycle is (213–24)×CGMXCLK
0 = COP reset cycle is (2
This section describes the central processor unit. The M68HC08 CPU is
an enhanced and fully object-code-compatible version of the M68HC05
CPU. The CPU08 Reference Manual (Freescale document number
CPU08RM/AD) contains a description of the CPU instruction set,
addressing modes, and architecture.
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
51
6.3 Features
Features of the CPU include the following:
•Full Upward, Object-Code Compatibility with M68HC05 Family
•16-Bit Stack Pointer with Stack Manipulation Instructions
•16-Bit Index Register with X-Register Manipulation Instructions
•8-MHz CPU Internal Bus Frequency
•64-Kbyte Program/Data Memory Space
•16 Addressing Modes
•Memory-to-Memory Data Moves Without Using Accumulator
•Fast 8-Bit by 8-Bit Multiply and 16-Bit by 8-Bit Divide Instructions
•Enhanced Binary-Coded Decimal (BCD) Data Handling
•Modular Architecture with Expandable Internal Bus Definition for
Extension of Addressing Range Beyond 64 Kbytes
6.4 CPU Registers
•Low-Power Stop and Wait Modes
Figure 6-1 shows the five CPU registers. CPU registers are not part of
the memory map.
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
52Freescale Semiconductor
6.4.1 Accumulator (A)
7
15
HX
15
15
70
V11HINZC
0
ACCUMULATOR (A)
0
INDEX REGISTER (H:X)
0
STACK POINTER (SP)
0
PROGRAM COUNTER (PC)
CONDITION CODE REGISTER (CCR)
CARRY/BORROW FLAG
ZERO FLAG
NEGATIVE FLAG
INTERRUPT MASK
HALF-CARRY FLAG
TWO’S COMPLEMENT OVERFLOW FLAG
Figure 6-1. CPU Registers
The accumulator is a general-purpose 8-bit register. The CPU uses the
accumulator to hold operands and the results of arithmetic/logic
operations.
Bit 7654321Bit 0
Read:
Write:
Reset:Unaffected by reset
Figure 6-2. Accumulator (A)
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
53
6.4.2 Index Register (H:X)
The 16-bit index register allows indexed addressing of a 64-Kbyte
memory space. H is the upper byte of the index register, and X is the
lower byte. H:X is the concatenated 16-bit index register.
In the indexed addressing modes, the CPU uses the contents of the
index register to determine the conditional address of the operand.
Bit
151413121110987654321
Read:
Write:
Reset:00000000XXXXXXXX
X = Indeterminate
Bit
0
Figure 6-3. Index Register (H:X)
The index register can serve also as a temporary data storage location.
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
54Freescale Semiconductor
6.4.3 Stack Pointer (SP)
The stack pointer is a 16-bit register that contains the address of the next
location on the stack. During a reset, the stack pointer is preset to
$00FF. The reset stack pointer (RSP) instruction also sets the least
significant byte to $FF but does not affect the most significant byte. The
stack pointer decrements as data is pushed onto the stack and
increments as data is pulled from the stack.
In the stack pointer 8-bit offset and 16-bit offset addressing modes, the
stack pointer can function as an index register to access data on the
stack. The CPU uses the contents of the stack pointer to determine the
conditional address of the operand.
Bit
151413121110987654321
Read:
Write:
Reset:0000000011111111
Bit
0
Figure 6-4. Stack Pointer (SP)
NOTE:The location of the stack is arbitrary and may be relocated anywhere in
RAM. Moving the SP out of page zero ($0000 to $00FF) frees direct
address (page zero) space. For correct operation, the stack pointer must
point only to RAM locations.
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
55
6.4.4 Program Counter (PC)
The program counter is a 16-bit register that contains the address of the
next instruction or operand to be fetched.
Normally, 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.
During reset, the program counter is loaded with the reset vector
address located at $FFFE and $FFFF. The vector address is the
address of the first instruction to be executed after exiting the reset state.
Bit
151413121110987654321
Read:
Write:
Reset:Loaded with vector from $FFFE and $FFFF
Bit
0
Figure 6-5. Program Counter (PC)
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
56Freescale Semiconductor
6.4.5 Condition Code Register (CCR)
The 8-bit condition code register contains the interrupt mask and five
flags that indicate the results of the instruction just executed. Bits 6 and
5 are set permanently to logic one. The following paragraphs describe
the functions of the condition code register.
Bit 76 5 4 3 2 1Bit 0
Read:
V11HI NZC
Write:
Reset:X11X1XXX
X = Indeterminate
Figure 6-6. Condition Code Register (CCR)
V — Overflow Flag
The CPU sets the overflow flag when a two's complement overflow
occurs. The signed branch instructions BGT, BGE, BLE, and BLT use
the overflow flag.
1 = Overflow
0 = No overflow
H — Half-Carry Flag
The CPU sets the half-carry flag when a carry occurs between
accumulator bits 3 and 4 during an ADD or ADC operation. The halfcarry flag is required for binary-coded decimal (BCD) arithmetic
operations. The DAA instruction uses the states of the H and C flags
to determine the appropriate correction factor.
1 = Carry between bits 3 and 4
0 = No carry between bits 3 and 4
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
57
I — Interrupt Mask
When the interrupt mask is set, all maskable CPU interrupts are
disabled. CPU interrupts are enabled when the interrupt mask is
cleared. When a CPU interrupt occurs, the interrupt mask is set
automatically after the CPU registers are saved on the stack, but
before the interrupt vector is fetched.
1 = Interrupts disabled
0 = Interrupts enabled
NOTE:To maintain M6805 compatibility, the upper byte of the index register (H)
is not stacked automatically. If the interrupt service routine modifies H,
then the user must stack and unstack H using the PSHH and PULH
instructions.
After the I bit is cleared, the highest-priority interrupt request is
serviced first.
A return from interrupt (RTI) instruction pulls the CPU registers from
the stack and restores the interrupt mask from the stack. After any
reset, the interrupt mask is set and can only be cleared by the clear
interrupt mask software instruction (CLI).
N — Negative flag
The CPU sets the negative flag when an arithmetic operation, logic
operation, or data manipulation produces a negative result, setting bit
7 of the result.
1 = Negative result
0 = Non-negative result
Z — Zero flag
The CPU sets the zero flag when an arithmetic operation, logic
operation, or data manipulation produces a result of $00.
1 = Zero result
0 = Non-zero result
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
58Freescale Semiconductor
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 instructions — such as bit test and
branch, shift, and rotate — also clear or set the carry/borrow flag.
1 = Carry out of bit 7
0 = No carry out of bit 7
6.5 Arithmetic/Logic Unit (ALU)
The ALU performs the arithmetic and logic operations defined by the
instruction set.
Refer to the CPU08 Reference Manual (Freescale document number
CPU08RM/AD) for a description of the instructions and addressing
modes and more detail about CPU architecture.
This section describes the system integration module (SIM), which
supports up to 24 external and/or internal interrupts. Together with the
CPU, the SIM controls all MCU activities. A block diagram of the SIM is
shown in Figure 7-1. Figure 7-2 is a summary of the SIM I/O registers.
The SIM is a system state controller that coordinates CPU and exception
timing. The SIM is responsible for:
•Bus clock generation and control for CPU and peripherals
–top/wait/reset/break entry and recovery
–Internal clock control
•Master reset control, including power-on reset (POR) and COP
timeout
•Interrupt control:
–Acknowledge timing
–Arbitration control timing
–Vector address generation
•CPU enable/disable timing
•Modular architecture expandable to 128 interrupt sources
Table 7-1 shows the internal signal names used in this section.
Table 7-1. Signal Name Conventions
Signal NameDescription
CGMXCLKBuffered OSC1 from the oscillator
The CGMXCLK frequency divided by two . This signal is again
CGMOUT
IABInternal address bus
IDBInternal data bus
PORRSTSignal from the power-on reset module to the SIM
IRSTInternal reset signal
divided by two in the SIM to generate the internal bus clocks
(Bus clock = CGMXCLK divided by four)
R/W
Read/write signal
7.3 SIM Bus Clock Control and Generation
The bus clock generator provides system clock signals for the CPU and
peripherals on the MCU. The system clocks are generated from an
incoming clock, CGMOUT, as shown in Figure 7-3.
From
PLL/OSCILLATOR
From
PLL/OSCILLATOR
Figure 7-3. SIM Clock Signals
CGMXCLK
CGMOUT
SIM COUNTER
÷ 2
SIM
BUS CLOCK
GENERATORS
7.3.1 Bus Timing
In user mode, the internal bus frequency is the oscillator frequency
(CGMXCLK) divided by four.
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
65
7.3.2 Clock Start-Up from POR
When the power-on reset module generates a reset, the clocks to the
CPU and peripherals are inactive and held in an inactive phase until after
the 4096 CGMXCLK cycle POR timeout has completed. The RST pin is
driven low by the SIM during this entire period. The IBUS clocks start
upon completion of the timeout.
7.3.3 Clocks in Stop Mode and Wait Mode
Upon exit from stop mode by an interrupt, break, or reset, the SIM allows
CGMXCLK to clock the SIM counter. The CPU and peripheral clocks do
not become active until after the stop delay timeout. This timeout is
selectable as 4096 or 32 CGMXCLK cycles. (See 7.7.2 Stop Mode.)
In wait mode, the CPU clocks are inactive. The SIM also produces two
sets of clocks for other modules. Refer to the wait mode subsection of
each module to see if the module is active or inactive in wait mode.
Some modules can be programmed to be active in wait mode.
7.4 Reset and System Initialization
The MCU has these reset sources:
•Power-on reset module (POR)
•External reset pin (RST
•Computer operating properly module (COP)
•Illegal opcode
•Illegal address
•Universal Serial Bus module (USB)
All of these resets produce the vector $FFFE–FFFF ($FEFE–FEFF in
monitor mode) and assert the internal reset signal (IRST). IRST causes
all registers to be returned to their default values and all modules to be
returned to their reset states.
)
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
66Freescale Semiconductor
An internal reset clears the SIM counter (see 7.5 SIM Counter), but an
external reset does not. Each of the resets sets a corresponding bit in
the reset status register (RSR). (See 7.8 SIM Registers.)
7.4.1 External Pin Reset
The RST pin circuits include an internal pullup device. Pulling the
asynchronous RST pin low halts all processing. The PIN bit of the reset
status register (RSR) is set as long as RST is held low for a minimum of
67 CGMXCLK cycles, assuming that the POR was not the source of the
reset. See Table 7-2 for details. Figure 7-4 shows the relative timing.
Table 7-2. PIN Bit Set Timing
Reset TypeNumber of Cycles Required to Set PIN
POR4163 (4096 + 64 + 3)
All others67 (64 + 3)
CGMOUT
RST
IAB
PC
Figure 7-4. External Reset Timing
7.4.2 Active Resets from Internal Sources
All internal reset sources actively pull the RST
cycles to allow resetting of external peripherals. The internal reset signal
IRST continues to be asserted for an additional 32 cycles. See Figure 7-
5. An internal reset can be caused by an illegal address, illegal opcode,
COP timeout, or POR. (See Figure 7-6. Sources of Internal Reset.)
Note that for POR resets, the SIM cycles through 4096 CGMXCLK
cycles during which the SIM forces the RST pin low. The internal reset
signal then follows the sequence from the falling edge of RST shown in
Figure 7-5.
VECT HVECT L
pin low for 32 CGMXCLK
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
67
IRST
7.4.2.1 Power-On Reset
RST
CGMXCLK
IAB
RST PULLED LOW BY MCU
32 CYCLES32 CYCLES
VECTOR HIGH
Figure 7-5. Internal Reset Timing
The COP reset is asynchronous to the bus clock.
ILLEGAL ADDRESS RST
ILLEGAL OPCODE RST
COPRST
POR
USB
INTERNAL RESET
Figure 7-6. Sources of Internal Reset
The active reset feature allows the part to issue a reset to peripherals
and other chips within a system built around the MCU.
When power is first applied to the MCU, the power-on reset module
(POR) generates a pulse to indicate that power-on has occurred. The
external reset pin (RST) is held low while the SIM counter counts out
4096 CGMXCLK cycles. Sixty-four CGMXCLK cycles later, the CPU and
memories are released from reset to allow the reset vector sequence to
occur. At power-on, the following events occur:
•A POR pulse is generated.
•The internal reset signal is asserted.
•The SIM enables the oscillator to drive CGMXCLK.
•Internal clocks to the CPU and modules are held inactive for 4096
CGMXCLK cycles to allow stabilization of the oscillator.
•The RST pin is driven low during the oscillator stabilization time.
•The POR bit of the reset status register (RSR) is set and all other
bits in the register are cleared.
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
68Freescale Semiconductor
OSC1
PORRST
CGMXCLK
CGMOUT
RST
IAB
4096
CYCLES
32
CYCLES
32
CYCLES
Figure 7-7. POR Recovery
7.4.2.2 Computer Operating Properly (COP) Reset
An input to the SIM is reserved for the COP reset signal. The overflow of
the COP counter causes an internal reset and sets the COP bit in the
reset status register (RSR). The SIM actively pulls down the RST pin for
all internal reset sources.
$FFFE$FFFF
To prevent a COP module timeout, write any value to location $FFFF.
Writing to location $FFFF clears the COP counter and stages 12 through
5 of the SIM counter. The SIM counter output, which occurs at least
12
every 2
– 24 CGMXCLK cycles, drives the COP counter. The COP
should be serviced as soon as possible out of reset to guarantee the
maximum amount of time before the first timeout.
The COP module is disabled if the RST
at V
+VHI while the MCU is in monitor mode. The COP module can
DD
pin or the IRQ1/VPP pin is held
be disabled only through combinational logic conditioned with the high
voltage signal on the RST
or the IRQ1/VPP pin. This prevents the COP
from becoming disabled as a result of external noise. During a break
state, V
MC68HC(7)08KH12 — Rev. 1.1Advance Information
+VHI on the RST pin disables the COP module.
DD
Freescale Semiconductor
69
7.4.2.3 Illegal Opcode Reset
7.4.2.4 Illegal Address Reset
The SIM decodes signals from the CPU to detect illegal instructions. An
illegal instruction sets the ILOP bit in the reset status register (RSR) and
causes a reset.
If the stop enable bit, STOP, in the mask option register is logic zero, the
SIM treats the STOP instruction as an illegal opcode and causes an
illegal opcode reset. The SIM actively pulls down the RST pin for all
internal reset sources.
An opcode fetch from an unmapped address generates an illegal
address reset. The SIM verifies that the CPU is fetching an opcode prior
to asserting the ILAD bit in the reset status register (RSR) and resetting
the MCU. A data fetch from an unmapped address does not generate a
reset. The SIM actively pulls down the RST pin for all internal reset
sources.
7.4.2.5 Universal Serial Bus Reset
The USB module will detect a reset signal on the bus by the presence of
an extended SE0 at the USB data pins of the upstream port. The reset
signaling is specified to be present for a minimum of 10 ms. An active
device (powered and not in the suspend state) seeing a single-ended
zero on its USB data inputs for more than 2.5
a reset, but must have interpreted the signaling as a reset within 5.5 µs.
For USB device, an SE0 condition between 4 and 8 low speed bit times
or 32 and 64 high speed bit times represents a valid USB reset. After the
reset is removed, the device will be in the attached, but not yet
addressed or configured state (refer to Section 9.1 of the USB
specification). The device must be able to accept device address via a
SET_ADDRESS command (refer to section 9.4 of the USB specification)
no later than 10 ms after the reset is removed.
Reset can wake a device from the suspended mode. A device may take
up to 10 ms to wake up from the suspended state.
µs may treat that signal as
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
70Freescale Semiconductor
7.5 SIM Counter
The SIM counter is used by the power-on reset module (POR) and in
stop mode recovery to allow the oscillator time to stabilize before
enabling the internal bus (IBUS) clocks. The SIM counter also serves as
a prescalar for the computer operating properly module (COP). The SIM
counter uses 12 stages for counting, followed by a 13th stage that
triggers a reset of SIM counters and supplies the clock for the COP
module. The SIM counter is clocked by the falling edge of CGMXCLK.
7.5.1 SIM Counter During Power-On Reset
The power-on reset module (POR) detects power applied to the MCU.
At power-on, the POR circuit asserts the signal PORRST. Once the SIM
is initialized, it enables the oscillator to drive the bus clock state machine.
7.5.2 SIM Counter During Stop Mode Recovery
The SIM counter also is used for stop mode recovery. The STOP
instruction clears the SIM counter. After an interrupt, break, or reset, the
SIM senses the state of the short stop recovery bit, SSREC, in the mask
option register. If the SSREC bit is a logic one, then the stop recovery is
reduced from the normal delay of 4096 CGMXCLK cycles down to 32
CGMXCLK cycles. This is ideal for applications using canned oscillators
that do not require long start-up times from stop mode. External crystal
applications should use the full stop recovery time, that is, with SSREC
cleared in the configuration register (CONFIG).
7.5.3 SIM Counter and Reset States
External reset has no effect on the SIM counter. (See 7.7.2 Stop Mode
for details.) The SIM counter is free-running after all reset states. (See
7.4.2 Active Resets from Internal Sources for counter control and
internal reset recovery sequences.)
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
71
7.6 Exception Control
7.6.1 Interrupts
Normal, sequential program execution can be changed in three different
ways:
•Interrupts
–Maskable hardware CPU interrupts
–Non-maskable software interrupt instruction (SWI)
•Reset
•Break interrupts
An interrupt temporarily changes the sequence of program execution to
respond to a particular event. Figure 7-8 flow charts the handling of
system interrupts.
Interrupts are latched, and arbitration is performed in the SIM at the start
of interrupt processing. The arbitration result is a constant that the CPU
uses to determine which vector to fetch. Once an interrupt is latched by
the SIM, no other interrupt can take precedence, regardless of priority,
until the latched interrupt is serviced (or the I bit is cleared).
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
72Freescale Semiconductor
FROM RESET
YES
BREAK
INTERRUPT?
NO
I BIT SET?
I BIT SET?
NO
IRQ1
INTERRUPT?
NO
USB
INTERRUPT?
NO
OTHER
INTERRUPTS?
NO
YES
YES
YES
YES
STACK CPU REGISTERS
LOAD PC WITH INTERRUPT VECTOR
SET I BIT
FETCH NEXT
INSTRUCTION
SWI
INSTRUCITON?
NO
RTI
INSTRUCITON?
NO
YES
YES
UNSTACK CPU REGISTERS.
EXECUTE INSTRUCTION.
Figure 7-8. Interrupt Processing
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
73
MODULE
INTERRUPT
I BIT
At the beginning of an interrupt, the CPU saves the CPU register
contents on the stack and sets the interrupt mask (I bit) to prevent
additional interrupts. At the end of an interrupt, the RTI instruction
recovers the CPU register contents from the stack so that normal
processing can resume. Figure 7-9 shows interrupt entry timing. Figure
DUMMYPC – 1[7:0] PC – 1[15:8]XACCRV DATA HV DATA LOPCODE
Figure 7-9. Interrupt Entry
SP – 4SP – 3SP – 2SP – 1SPPCPC + 1
CCRAXPC – 1[7:0] PC – 1 [15:8] OPCODE OPERAND
Figure 7-10. Interrupt Recovery
7.6.1.1 Hardware Interrupts
A hardware interrupt does not stop the current instruction. Processing of
a hardware interrupt begins after completion of the current instruction.
When the current instruction is complete, the SIM checks all pending
hardware interrupts. If interrupts are not masked (I bit clear in the
condition code register), and if the corresponding interrupt enable bit is
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
74Freescale Semiconductor
set, the SIM proceeds with interrupt processing; otherwise, the next
instruction is fetched and executed.
If more than one interrupt is pending at the end of an instruction
execution, the highest priority interrupt is serviced first. Figure 7-11
demonstrates what happens when two interrupts are pending. If an
interrupt is pending upon exit from the original interrupt service routine,
the pending interrupt is serviced before the LDA instruction is executed.
CLI
INT1
INT2
LDA
PSHH
INT1 INTERRUPT SERVICE ROUTINE
PULH
RTI
PSHH
INT2 INTERRUPT SERVICE ROUTINE
PULH
RTI
BACKGROUND ROUTINE#$FF
Figure 7-11. Interrupt Recognition Example
The LDA opcode is prefetched by both the INT1 and INT2 RTI
instructions. However, in the case of the INT1 RTI prefetch, this is a
redundant operation.
NOTE:To maintain compatibility with the M6805 Family, the H register is not
pushed on the stack during interrupt entry. If the interrupt service routine
modifies the H register or uses the indexed addressing mode, software
should save the H register and then restore it prior to exiting the routine.
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
75
7.6.1.2 SWI Instruction
The SWI instruction is a non-maskable instruction that causes an
interrupt regardless of the state of the interrupt mask (I bit) in the
condition code register.
NOTE:A software interrupt pushes PC onto the stack. A software interrupt does
not push PC – 1, as a hardware interrupt does.
7.6.2 Interrupt Status Registers
The flags in the interrupt status registers identify maskable interrupt
sources. Table 7-3 summarizes the interrupt sources and the interrupt
status register flags that they set. The interrupt status registers can be
useful for debugging.
IRQ1
HUB Start of Frame InterruptSOFFSOFIE
HUB 2nd End of Frame Point InterruptEOF2FEOF2IE
HUB End of Packet InterruptEOPFEOPIE
HUB Bus Signal Tr ansition Dete ct Int erruptTRANFTRANIE
HUB Endpoint0 Transmit InterruptTXDFTXDIE
HUB Endpoint0 Receive InterruptRXDFRXDIE
Device Endpoint 0 Transmit InterruptTXD0FTXD0IE
USB Endpoint1/2 Transmit InterruptTXD1FTXD1IE
TIM Channel 0CH0FCH0IEIF55$FFF2–$FFF3
TIM Channel 1CH1FCH1IEIF66$FFF0–$FFF1
SourceFlag
Mask
(1)
TIM OverflowTOFTOIEIF77$FFEE–$FFEF
Port-E Keyboard Pin InterruptKEYEFIMASKEIF88$FFEC–$FFED
All reset sources always have equal and highest priority and cannot be
arbitrated.
7.6.4 Break Interrupts
The break module can stop normal program flow at a softwareprogrammable break point by asserting its break interrupt output. (See
Section 16. Break Module (BREAK).) The SIM puts the CPU into the
break state by forcing it to the SWI vector location. Refer to the break
interrupt subsection of each module to see how each module is affected
by the break state.
7.6.5 Status Flag Protection in Break Mode
The SIM controls whether status flags contained in other modules can
be cleared during break mode. The user can select whether flags are
protected from being cleared by properly initializing the break clear flag
enable bit (BCFE) in the break flag control register (BFCR).
Protecting flags in break mode ensures that set flags will not be cleared
while in break mode. This protection allows registers to be freely read
and written during break mode without losing status flag information.
Setting the BCFE bit enables the clearing mechanisms. Once cleared in
break mode, a flag remains cleared even when break mode is exited.
Status flags with a two-step clearing mechanism — for example, a read
of one register followed by the read or write of another — are protected,
even when the first step is accomplished prior to entering break mode.
Upon leaving break mode, execution of the second step will clear the flag
as normal.
7.7 Low-Power Modes
Executing the WAIT or STOP instruction puts the MCU in a low-powerconsumption mode for standby situations. The SIM holds the CPU in a
non-clocked state. The operation of each of these modes is described
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
79
7.7.1 Wait Mode
below. Both STOP and WAIT clear the interrupt mask (I) in the condition
code register, allowing interrupts to occur.
In wait mode, the CPU clocks are inactive while the peripheral clocks
continue to run. Figure 7-15 shows the timing for wait mode entry.
A module that is active during wait mode can wake up the CPU with an
interrupt if the interrupt is enabled. Stacking for the interrupt begins one
cycle after the WAIT instruction during which the interrupt occurred. In
wait mode, the CPU clocks are inactive. Refer to the wait mode
subsection of each module to see if the module is active or inactive in
wait mode. Some modules can be programmed to be active in wait
mode.
Wait mode can also be exited by a reset or break. A break interrupt
during wait mode sets the SIM break stop/wait bit, SBSW, in the break
status register (BSR). If the COP disable bit, COPD, in the mask option
register is logic zero, then the computer operating properly module
(COP) is enabled and remains active in wait mode.
WAIT ADDR
IDB
R/W
NOTE: Previous data can be operand data or the WAIT opcode, depending on the
last instruction.
PREVIOUS DATANEXT OPCODESAME
WAIT ADDR + 1SAMESAMEIAB
SAME
Figure 7-15. Wait Mode Entry Timing
Figure 7-16 and Figure 7-17 show the timing for WAIT recovery.
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
80Freescale Semiconductor
IAB
$6E0C$6E0B$00FF$00FE$00FD$00FC
IDB
EXITSTOPWAIT
NOTE: EXITSTOPWAIT = RST
Figure 7-16. Wait Recovery from Interrupt or Break
IAB
IDB
$A6
RST
CGMXCLKCGMXCLK
Figure 7-17. Wait Recovery from Internal Reset
$A6$A6$01$0B$6E$A6
pin OR CPU interrupt OR break interrupt
32
Cycles
$6E0B
$A6$A6
32
Cycles
RST VCT HRST VCT L
7.7.2 Stop Mode
In stop mode, the SIM counter is reset and the system clocks are
disabled. An interrupt request from a module can cause an exit from stop
mode. Stacking for interrupts begins after the selected stop recovery
time has elapsed. Reset or break also causes an exit from stop mode.
The SIM disables the oscillator signals (CGMOUT and CGMXCLK) in
stop mode, stopping the CPU and peripherals. Stop recovery time is
selectable using the SSREC bit in the configuration register (CONFIG).
If SSREC is set, stop recovery is reduced from the normal delay of 4096
CGMXCLK cycles down to 32. This is ideal for applications using canned
oscillators that do not require long startup times from stop mode.
NOTE:External crystal applications should use the full stop recovery time by
clearing the SSREC bit.
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
81
A break interrupt during stop mode sets the SIM break stop/wait bit
(SBSW) in the break status register (BSR).
The SIM counter is held in reset from the execution of the STOP
instruction until the beginning of stop recovery. It is then used to time the
recovery period. Figure 7-18 shows stop mode entry timing.
NOTE:To minimize stop current, all pins configured as inputs should be driven
to a logic 1 or logic 0.
CPUSTOP
STOP ADDR
IDB
R/W
NOTE: Previous data can be operand data or the STOP opcode, depending on the last
instruction.
PREVIOUS DATANEXT OPCODESAME
STOP ADDR + 1SAMESAMEIAB
SAME
Figure 7-18. Stop Mode Entry Timing
STOP RECOVERY PERIOD
CGMXCLK
INT/BREAK
IAB
STOP +1
Figure 7-19. Stop Mode Recovery from Interrupt or Break
STOP + 2STOP + 2SPSP – 1SP – 2SP – 3
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
82Freescale Semiconductor
7.8 SIM Registers
The SIM has three memory mapped registers. Table 7-4 shows the
mapping of these registers.
AddressRegisterAccess Mode
$FE00BSRUser
$FE01RSRUser
$FE03BFCRUser
7.8.1 Break Status Register (BSR)
The break status register contains a flag to indicate that a break caused
an exit from stop or wait mode.
Address:$FE00
Table 7-4. SIM Registers
Bit 7654321Bit 0
Read:
RRRRRR
Write:Note 1
Reset:0
R= Reserved1. Writing a logic zero clears SBSW
SBSW
R
Figure 7-20. Break Status Register (BSR)
SBSW — SIM Break Stop/Wait
This status bit is useful in applications requiring a return to wait
or stop mode after exiting from a break interrupt. Clear SBSW
by writing a logic zero to it. Reset clears SBSW.
1 = Stop mode or wait mode was exited by break interrupt
0 = Stop mode or wait mode was not exited by break
interrupt
SBSW can be read within the break state SWI routine. The user can
modify the return address on the stack by subtracting one from it. The
following code is an example of this. Writing zero to the SBSW bit clears
it.
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
83
;
This code works if the H register has been pushed onto the stack in the break
;
service routine software. This code should be executed at the end of the
;
break service routine software.
HIBYTEEQU5
LOBYTEEQU6
;If not SBSW, do RTI
BRCLRSBSW,BSR, RETURN;;See if wait mode or stop mode was exited
by break
TSTLOBYTE,SP; If RETURNLO is not zero,
BNEDOLO; then just decrement low byte.
DECHIBYTE,SP; Else deal with high byte, too.
DOLODECLOBYTE,SP; Point to WAIT/STOP opcode.
RETURNPULH
RTI
7.8.2 Reset Status Register (RSR)
This register contains six flags that show the source of the last reset.
Clear the SIM reset status register by reading it. A power-on reset sets
the POR bit and clears all other bits in the register.
Address:$FE01
Read:PORPINCOPILOPILADUSB00
Write:
POR:10000000
; Restore H register.
Bit 7654321Bit 0
= Unimplemented
Figure 7-21. Reset Status Register (RSR)
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
84Freescale Semiconductor
POR — Power-On Reset Bit
1 = Last reset caused by POR circuit
0 = Read of RSR
PIN — External Reset Bit
1 = Last reset caused by external reset pin (RST)
0 = POR or read of RSR
COP — Computer Operating Properly Reset Bit
1 = Last reset caused by COP counter
0 = POR or read of RSR
ILOP — Illegal Opcode Reset Bit
1 = Last reset caused by an illegal opcode
0 = POR or read of RSR
ILAD — Illegal Address Reset Bit (opcode fetches only)
1 = Last reset caused by an opcode fetch from an illegal
address
0 = POR or read of RSR
USB —Universal Serial Bus Reset Bit
1 = Last reset caused by an USB module
0 = POR or read of RSR
7.8.3 Break Flag Control Register (BFCR)
The break control register contains a bit that enables software to clear
status bits while the MCU is in a break state.
Address:$FE03
Bit 7654321Bit 0
Read:
Write:
Reset:00000000
BCFERRRRRRR
R= Reserved
Figure 7-22. Break Flag Control Register (BFCR)
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
85
BCFE — Break Clear Flag Enable Bit
This read/write bit enables software to clear status bits by
accessing status registers while the MCU is in a break state.
To clear status bits during the break state, the BCFE bit must
be set.
1 = Status bits clearable during break
0 = Status bits not clearable during break
This section describes the clock generator module (CGM). The CGM
generates the crystal clock signal, CGMXCLK, which operates at the
frequency of the crystal. The CGM also generates the base clock signal,
CGMOUT, which is based on either the crystal clock divided by two or
the phase-locked loop (PLL) clock, CGMPCLK, divided by two. This is
the clock from which the SIM derives the system clocks, including the
bus clock, which is at a frequency of CGMOUT/2. The PLL also
generates a CGMVCLK clock, at 48MHz, for use as the USBCLK. The
PLL is a fully functional frequency generator designed for use with
crystals or ceramic resonators.
This CGM is optimized to generate a 48MHz reference frequency for the
USB module, from a 6MHz crystal.
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
88Freescale Semiconductor
8.3 Features
Features of the CGM include:
•VCO Center-Of-Range Frequuency tuned to 48MHz for Low-Jitter
Clock Reference for USB Module
•Low-Frequency Crystal Operation with Low-Power Operation and
High-Output Frequency Resolution
•Programmable Reference Divider for Even Greater Resolution
•Programmable Prescaler for Power-of-Two Increases in Bus
Frequency
•Automatic Bandwidth Control Mode for Low-Jitter Operation
•Automatic Frequency Lock Detector
•CPU Interrupt on Entry or Exit from Locked Condition
8.4 Functional Description
The CGM consists of three major submodules:
•Crystal oscillator circuit — The crystal oscillator circuit generates
the constant crystal frequency clock, CGMXCLK.
•Phase-locked loop (PLL) — The PLL generates the
programmable VCO frequency clock, CGMVCLK and CGMPCLK.
•Base clock selector circuit — This software-controlled circuit
selects either CGMXCLK divided by two or the PLL clock,
CGMPCLK, divided by two as the base clock, CGMOUT. The SIM
derives the system clocks from CGMOUT.
Figure 8-1 shows the structure of the CGM.
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
89
OSC2
OSC1
SIMOSCEN
OSCILLATOR (OSC)
CGMXCLK
CGMRDV
REFERENCE
DIVIDER
RDS[3:0]
PHASE
DETECTOR
LOCK
DETECTOR
V
R
DDA
CGMRCLK
CGMXFCV
LOOP
FILTER
AUTOMATIC
MODE
CONTROL
SSA
PLL ANALOG
BCS
VOLTAGE
CONTROLLED
OSCILLATOR
INTERRUPT
CONTROL
CLOCK
SELECT
CIRCUIT
48MHz
CLOCK
SELECT
CIRCUIT
÷ 2
CGMOUT
USBCLK
CGMINT
LOCKAUTOACQPLLIEPLLF
MUL[11:0]
CGMVDV
PHASE-LOCKED LOOP (PLL)
FREQUENCY
DIVIDER
PRE[1:0]
FREQUENCY
DIVIDER
PN
CGMVCLK
CGMPCLK
Figure 8-1. CGM Block Diagram
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
90Freescale Semiconductor
8.4.1 Crystal Oscillator Circuit
The crystal oscillator circuit consists of an inverting amplifier and an
external crystal. The OSC1 pin is the input to the amplifier and the OSC2
pin is the output. The SIMOSCEN signal from the system integration
module (SIM) enables the crystal oscillator circuit.
The CGMXCLK signal is the output of the crystal oscillator circuit and
runs at a rate equal to the crystal frequency. CGMXCLK is then buffered
to produce CGMRCLK, the PLL reference clock.
CGMXCLK can be used by other modules which require precise timing
for operation. The duty cycle of CGMXCLK is not guaranteed to be 50%
and depends on external factors, including the crystal and related
external components. An externally generated clock also can feed the
OSC1 pin of the crystal oscillator circuit. Connect the external clock to
the OSC1 pin and let the OSC2 pin float.
8.4.2 Phase-Locked Loop Circuit (PLL)
The PLL is a frequency generator that can operate in either acquisition
mode or tracking mode, depending on the accuracy of the output
frequency. The PLL can change between acquisition and tracking
modes either automatically or manually.
8.4.3 PLL Circuits
The PLL consists of these circuits:
•Voltage-controlled oscillator (VCO)
•Reference divider
•Frequency prescaler
•Modulo VCO frequency divider
•Phase detector
•Loop filter
•Lock detector
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
91
The operating range of the VCO is programmable for a wide range of
frequencies and for maximum immunity to external noise, including
supply and CGM/XFC noise. The VCO frequency is bound to a range
from roughly 40MHz to 56MHz, f
CGM/XFC pin changes the frequency within this range. By design, f
. Modulating the voltage on the
VRS
VRS
is tuned to a nominal center-of-range frequency of 48MHz.
CGMRCLK is the PLL reference clock, a buffered version of CGMXCLK.
CGMRCLK runs at a frequency, f
programmable modulo reference divider, which divides f
, and is fed to the PLL through a
RCLK
by a factor
RCLK
R. This feature allows frequency steps of higher resolution. The divider’s
output is the final reference clock, CGMRDV, running at a frequency
f
RDV=fRCLK
/R.
The VCO’s output clock, CLK, running at a frequency f
is fed back
VCLK
through a programmable prescale divider and a programmable modulo
divider. The prescaler divides the VCO clock by a power-of-two factor P
and the modulo divider reduces the VCO clock by a factor, N. The
dividers’ output is the VCO feedback clock, CGMVDV, running at a
frequency f
VDV=fVCLK
/(N × 2P). (See 8.4.6 Programming the PLL for
more information.)
The phase detector then compares the VCO feedback clock, CGMVDV,
with the final reference clock, CGMRDV. A correction pulse is generated
based on the phase difference between the two signals. The loop filter
then slightly alters the DC voltage on the external capacitor connected
to CGM/XFC based on the width and direction of the correction pulse.
The filter can make fast or slow corrections depending on its mode,
described in 8.4.4 Acquisition and Tracking Modes. The value of the
external capacitor and the reference frequency determines the speed of
the corrections and the stability of the PLL.
The lock detector compares the frequencies of the VCO feedback clock,
CGMVDV, and the final reference clock, CGMRDV. Therefore, the
speed of the lock detector is directly proportional to the final reference
frequency, f
. The circuit determines the mode of the PLL and the lock
RDV
condition based on this comparison.
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
92Freescale Semiconductor
8.4.4 Acquisition and Tracking Modes
The PLL filter is manually or automatically configurable into one of two
operating modes:
•Acquisition mode — In acquisition mode, the filter can make large
frequency corrections to the VCO. This mode is used at PLL
startup or when the PLL has suffered a severe noise hit and the
VCO frequency is far off the desired frequency. When in
acquisition mode, the ACQ bit is clear in the PLL bandwidth control
register. (See 8.6.2 PLL Bandwidth Control Register
(PBWC).)
•Tracking mode — In tracking mode, the filter makes only small
corrections to the frequency of the VCO. PLL jitter is much lower
in tracking mode, but the response to noise is also slower. The
PLL enters tracking mode when the VCO frequency is nearly
correct, such as when the PLL is selected as the base clock
source. (See 8.4.8 Base Clock Selector Circuit.) The PLL is
automatically in tracking mode when not in acquisition mode or
when the ACQ bit is set.
8.4.5 Manual and Automatic PLL Bandwidth Modes
This CGM is optimized for Automatic PLL Bandwidth Mode, and is the
mode recommended for most users.
In automatic bandwidth control mode (AUTO=1), the lock detector
automatically switches between acquisition and tracking modes.
Automatic bandwidth control mode also is used to determine when the
VCO clock, CGMVCLK, is safe to use as the source for the base clock,
CGMOUT. (See 8.6.2 PLL Bandwidth Control Register (PBWC).) If
PLL interrupts are enabled, the software can wait for a PLL interrupt
request and then check the LOCK bit. If interrupts are disabled, software
can poll the LOCK bit continuously (during PLL startup, usually) or at
periodic intervals. In either case, when the LOCK bit is set, the VCO
clock is safe to use as the source for the base clock. (See 8.4.8 Base
Clock Selector Circuit.) If the VCO is selected as the source for the
base clock and the LOCK bit is clear, the PLL has suffered a severe
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
93
noise hit and the software must take appropriate action, depending on
the application. (See 8.7 Interrupts for information and precautions on
using interrupts.) The following conditions apply when the PLL is in
automatic bandwidth control mode:
•The ACQ bit (See 8.6.2 PLL Bandwidth Control Register
(PBWC).) is a read-only indicator of the mode of the filter. (See
8.4.4 Acquisition and Tracking Modes.)
•The ACQ bit is set when the VCO frequency is within a certain
tolerance, ∆
a certain tolerance, ∆
, and is cleared when the VCO frequency is out of
TRK
. (See 8.9 Acquisition/Lock Time
UNT
Specifications for more information.)
•The LOCK bit is a read-only indicator of the locked state of the
PLL.
•The LOCK bit is set when the VCO frequency is within a certain
tolerance, ∆
a certain tolerance ∆
, and is cleared when the VCO frequency is out of
LOCK
. (See 8.9 Acquisition/Lock Time
UNL
Specifications for more information.)
8.4.6 Programming the PLL
•CPU interrupts can occur if enabled (PLLIE = 1) when the PLL’s
lock condition changes, toggling the LOCK bit. (See 8.6.1 PLL
Control Register (PCTL).)
The following procedure shows how to program the PLL.
×=
BUS
BUS
.
and the bus
VCLK
1.Choose the desired bus frequency, f
The relationship between the VCO frequency f
frequency f
BUS
is
f
VCLK
-------------4f
P
2
The VCO frequency need to be at 48MHz for the USB module
reference clock.
48MHz
--------------------4f
P
2
×=
BUS
Choose P = 0, 1, 2, or 3 for a bus frequency of 12MHz, 6MHz,
3MHz, or 1.5MHz respectively.
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
94Freescale Semiconductor
2.Choose a practical PLL (crystal) reference frequency, f
the reference clock divider, R.
RCLK
, and
Frequency errors to the PLL are corrected at a rate of f
RCLK
stability and lock time reduction, this rate must be as fast as
possible. The VCO frequency must be an integer multiple of this
rate. The relationship between the VCO frequency f
reference frequency f
hence: 48MHz
RCLK
is
f
VCLK
2PN×
----------------- f
R
P
2
N×
----------------- f
R
()=
()=
RCLK
RCLK
VCLK
Choose the reference divider R = 1 for fast lock. Choose a f
frequency with an integer divisor of f
and solve for N.
BUS
3.Program the PLL registers accordingly:
a. In the PRE bits of the PLL control register (PCTL), program
the binary equivalent of P.
b.In the PLL multiplier select register low (PMSL) and the PLL
multiplier select register high (PMSH), program the binary
equivalent of N.
/R. For
and the
RCLK
c.In the PLL reference divider select register (PRDS), program
the binary coded equivalent of R.
Table 8-1 provides a numeric example (numbers are in hexadecimal
notation):
Table 8-1. CGM Numeric Example
f
BUS
6MHz6MHz10041
8.4.7 Special Programming Exceptions
The programming method described in 8.4.6 Programming the PLL
does not account for three possible exceptions. A value of zero for R, N,
or L is meaningless when used in the equations given. To account for
these exceptions:
MC68HC(7)08KH12 — Rev. 1.1Advance Information
f
RCLK
PNR
Freescale Semiconductor
95
A zero value for R or N is interpreted exactly the same as a value of one.
A zero value for L disables the PLL and prevents its selection as the
source for the base clock. (See 8.4.8 Base Clock Selector Circuit.)
8.4.8 Base Clock Selector Circuit
This circuit is used to select either the crystal clock, CGMXCLK, or the
PLL clock, CGMPCLK, as the source of the base clock, CGMOUT. The
two input clocks go through a transition control circuit that waits up to
three CGMXCLK cycles and three CGMPCLK cycles to change from
one clock source to the other. During this time, CGMOUT is held in
stasis. The output of the transition control circuit is then divided by two
to correct the duty cycle. Therefore, the bus clock frequency, which is
one-half of the base clock frequency, is one-fourth the frequency of the
selected clock (CGMXCLK or CGMPCLK).
The BCS bit in the PLL control register (PCTL) selects which clock drives
CGMOUT. The VCO clock cannot be selected as the base clock source
if the PLL is not turned on. The PLL cannot be turned off if the VCO clock
is selected. The PLL cannot be turned on or off simultaneously with the
selection or deselection of the VCO clock.
This circuit is also used to select either the crystal clock, CGMXCLK or
the VCO clock, CGMVCLK, as the source of the USB clock, USBCLK.
8.4.9 CGM External Connections
In its typical configuration, the CGM requires seven external
components. Five of these are for the crystal oscillator and two are for
the PLL.
The crystal oscillator is normally connected in a Pierce oscillator
configuration, as shown in Figure 8-2. Figure 8-2 shows only the logical
representation of the internal components and may not represent actual
circuitry. The oscillator configuration uses five components:
•Crystal, X
•Fixed capacitor, C
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
1
1
96Freescale Semiconductor
•Tuning capacitor, C2 (can also be a fixed capacitor)
•Feedback resistor, R
B
•Series resistor, RS (optional)
The series resistor (RS) is included in the diagram to follow strict Pierce
oscillator guidelines and may not be required for all ranges of operation,
especially with high frequency crystals. Refer to the crystal
manufacturer’s data for more information.
Figure 8-2 also shows the external components for the PLL:
•Bypass capacitor, C
•Filter capacitor, C
BYP
F
Routing should be done with great care to minimize signal cross talk and
noise.
See Section 17. Preliminary Electrical Specifications for capacitor
and resistor values.
SIMOSCEN
OSC1OSC2V
RS*
R
B
X
1
C
1
*RS can be zero (shorted) when used with higher-frequency crystals. Refer to manufacturer’s data.
C
2
CGMXCLK
SSA
CGMXFCV
C
F
Figure 8-2. CGM External Connections
DDA
V
DD
C
BYP
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
97
8.5 I/O Signals
The following paragraphs describe the CGM I/O signals.
8.5.1 Crystal Amplifier Input Pin (OSC1)
The OSC1 pin is an input to the crystal oscillator amplifier.
8.5.2 Crystal Amplifier Output Pin (OSC2)
The OSC2 pin is the output of the crystal oscillator inverting amplifier.
8.5.3 External Filter Capacitor Pin (CGMXFC)
The CGMXFC pin is required by the loop filter to filter out phase
corrections. A small external capacitor is connected to this pin.
NOTE:To prevent noise problems, C
CGMXFC pin as possible, with minimum routing distances and no
routing of other signals across the CF connection.
8.5.4 PLL Analog Power Pin (V
V
DDA
V
DDA
NOTE:Route V
capacitors as close as possible to the package.
8.5.5 PLL Analog Ground Pin (V
V
SSA
the V
NOTE:Route V
capacitors as close as possible to the package.
should be placed as close to the
F
)
DDA
is a power pin used by the analog portions of the PLL. Connect the
pin to the same voltage potential as the V
carefully for maximum noise immunity and place bypass
DDA
)
SSA
DD
pin.
is a ground pin used by the analog portions of the PLL. Connect
pin to the same voltage potential as the V
SSA
carefully for maximum noise immunity and place bypass
SSA
SS
pin.
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
98Freescale Semiconductor
8.5.6 Buffered Crystal Clock Output (CGMVOUT)
CGMVOUT buffers the OSC1 clock for external use.
8.5.7 CGMVSEL
CGMVSEL must be tied low or floated.
8.5.8 Oscillator Enable Signal (SIMOSCEN)
The SIMOSCEN signal comes from the system integration module (SIM)
and enables the oscillator and PLL.
8.5.9 Crystal Output Frequency Signal (CGMXCLK)
CGMXCLK is the crystal oscillator output signal. It runs at the full speed
of the crystal (f
) and comes directly from the crystal oscillator circuit.
XCLK
Figure 8-2 shows only the logical relation of CGMXCLK to OSC1 and
OSC2 and may not represent the actual circuitry. The duty cycle of
CGMXCLK is unknown and may depend on the crystal and other
external factors. Also, the frequency and amplitude of CGMXCLK can be
unstable at startup.
8.5.10 CGM Base Clock Output (CGMOUT)
CGMOUT is the clock output of the CGM. This signal goes to the SIM,
which generates the MCU clocks. CGMOUT is a 50 percent duty cycle
clock running at twice the bus frequency. CGMOUT is software
programmable to be either the oscillator output, CGMXCLK, divided by
two or the VCO clock, CGMVCLK, divided by two.
8.5.11 CGM CPU Interrupt (CGMINT)
CGMINT is the interrupt signal generated by the PLL lock detector.
MC68HC(7)08KH12 — Rev. 1.1Advance Information
Freescale Semiconductor
99
8.6 CGM Registers
These registers control and monitor operation of the CGM:
•PLL control register (PCTL) (See 8.6.1 PLL Control Register
(PCTL).)
•PLL bandwidth control register (PBWC) (See 8.6.2 PLL
Bandwidth Control Register (PBWC).)
•PLL multiplier select registers (PMSH:PMSL) (See 8.6.3 PLL
Multiplier Select Registers (PMSH:PMSL).)
•PLL reference divider select register (PRDS) (See 8.6.4 PLL
Reference Divider Select Register (PRDS).)
Table 8-2 is a summary of the CGM registers.
Advance InformationMC68HC(7)08KH12 — Rev. 1.1
100Freescale Semiconductor
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.