To provide the most up-to-date information, the revision of our documents on the World Wide Web will be
the most current. Your printed copy may be an earlier revision. To verify you have the latest information
available, refer to:
http://www.freescale.com
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
This product incorporates SuperFlash® technology licensed from SST.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor3
Revision History
The following revision history table summarizes changes contained in this document. For your
convenience, the page number designators have been linked to the appropriate location.
Revision History
Date
April, 20061.0Initial releaseN/A
May, 20061.1
October, 20062.0
Revision
Level
Description
19.5 5-V DC Electrical Characteristics — Updated values237
19.8 3.3-V DC Electrical Characteristics — Updated values240
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
16Freescale Semiconductor
Chapter 1
General Description
1.1 Introduction
The MC68HC908QC16, MC68HC908QC8, and MC68HC908QC4 are members of the low-cost,
high-performance M68HC08 Family of 8-bit microcontroller units (MCUs). 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.
0.4
Table 1-1. Summary of Device Variations
Device
MC68HC908QC1616 Kbytes512 bytes16, 20, 28 pins
MC68HC908QC88 Kbytes384 bytes16, 20, 28 pins
MC68HC908QC44 Kbytes384 bytes16, 20, 28 pins
FLASH
Memory Size
RAMPin Count
1.2 Features
Features include:
•High-performance M68HC08 CPU core
•Fully upward-compatible object code with M68HC05 Family
(1)
DD
)
•5.0-V and 3.3-V operating voltages (V
•8-MHz internal bus operation at 5 V, 4-MHz at 3.3 V
•Trimmable internal oscillator
–Software selectable 1 MHz, 2 MHz, 3.2 MHz, or 6.4 MHz internal bus operation
–8-bit trim capability
–± 25% untrimmed
–Trimmable to approximately 0.4%
•Up to 24 bidirectional input/output (I/O) lines and two input only:
–Six shared with keyboard interrupt function
–Ten shared with ADC
–Four shared with TIM1
–Two shared with TIM2
–Two shared with ESCI
–Four shared with SPI
–One input only shared with external interrupt (IRQ)
–High current sink/source capability on all port pins
–Selectable pullups on all ports, selectable on an individual bit basis
–Three-state ability on all port pins
•6-bit keyboard interrupt with wakeup feature (KBI)
–Programmable for rising/falling edge or high/low level detection
•Low-voltage inhibit (LVI) module features:
–Software selectable trip point in CONFIG register
•System protection features:
–Computer operating properly (COP) watchdog
–Low-voltage detection with reset
–Illegal opcode detection with reset
–Illegal address detection with reset
•External asynchronous interrupt pin with internal pullup (IRQ
) shared with general-purpose input
pin
•Master asynchronous reset pin with internal pullup (RST
) shared with general-purpose input/output
(I/O) pin
•Memory mapped I/O registers
•Power saving stop and wait modes
•MC68HC908QC16, MC68HC908QC8, and MC68HC908QC4 are available in these packages:
–28-pin small outline integrated circuit package (SOIC)
–28-pin thin shrink small outline package (TSSOP)
–20-pin SOIC
–20-pin TSSOP
–16-pin SOIC
–16-pin TSSOP
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
18Freescale Semiconductor
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
•Efficient C language support
1.3 MCU Block Diagram
Figure 1-1 shows the structure of the MC68HC908QC16, MC68HC908QC8, and MC68HC908QC4.
1.4 Pin Assignments
The MC68HC908QC16, MC68HC908QC8, and MC68HC908QC4 are available in 16-pin, 20-pin, and
28-pin packages. Figure 1-2 shows the pin assignment for these packages.
1.5 Pin Functions
Table 1-2 provides a description of the pin functions.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor19
General Description
All port pins can be configured with internal pullup
PTC not available on 16-pin devices (see note in 11.1 Introduction)
PTD not available on 16-pin or 20-pin devices (see note in 11.1 Introduction)
PTA0/T1CH0/AD0/KBI0
PTA1/T1CH1/AD1/KBI1
PTA2/IRQ
/KBI2/T1CLK
PTA3/RST
/KBI3
PTA4/OSC2/AD2/KBI4
PTA5/OSC1/AD3/KBI5
4-CHANNEL 16-BIT
TIMER MODULE
KEYBOARD INTERRUPT
MODULE
SINGLE INTERRUPT
MODULE
PERIODIC WAKEUP
LOW-VOLTAGE
INHIBIT
COP
MODULE
10-CHANNEL
10-BIT ADC
ENHANCED SERIAL
PTB0/SPSCK/AD4
PTB
DDRB
M68HC08 CPU
PTA
DDRA
PTB1/MOSI/T2CH1/AD5
PTB2/MISO/T2CH0/AD6
PTB3/SS
/T2CLK/AD7
PTB4/RxD/T2CH0/AD8
PTB5/TxD/T2CH1/AD9
PTB6/T1CH2
PTB7/T1CH3
POWER SUPPLY
V
DD
V
SS
CLOCK
GENERATOR
COMMUNICATIONS
INTERFACE MODULE
MODULE
SERIAL PERIPHERAL
INTERFACE
16,384 BYTES
MC68HC908QC16
8192 BYTES
MC68HC908QC8
512 BYTES
MC68HC908QC16
384 BYTES
MC68HC908QC8
BREAK
MODULE
MONITOR ROM
2-CHANNEL 16-BIT
TIMER MODULE
PTC0
PTC1
PTC2
PTC3
PTC
DDRC
PTD0
PTD
DDRD
PTD1
PTD2
PTD3
PTD4
PTD5
PTD6
PTD7
MC68HC908QC4
USER RAM
USER FLASH
4096 BYTES
384 BYTES
MC68HC908QC4
Figure 1-1. Block Diagram
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
NOTE: T2CH0 and T2CH1 can be repositioned using TIM2POS in CONFIG2.
Figure 1-2. MC68HC908QC16, MC68HC908QC8, and MC68HC908QC4 Pin Assignments
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor21
General Description
Table 1-2. Pin Functions
Pin NameDescriptionInput/Output
V
V
PTA0
PTA1
PTA2
PTA3
PTA4
PTA5
PTB0
PTB1
DD
SS
(1)
Power supplyPower
Power supply groundPower
PTA0 — General purpose I/O portInput/Output
T1CH0 — Timer Channel 0 I/OInput/Output
AD0 — A/D channel 0 inputInput
KBI0 — Keyboard interrupt input 0Input
PTA1 — General purpose I/O portInput/Output
T1CH1 — Timer Channel 1 I/OInput/Output
AD1 — A/D channel 1 inputInput
KBI1 — Keyboard interrupt input 1Input
PTA2 — General purpose input-only portInput
IRQ — External interrupt with programmable pullup and Schmitt trigger inputInput
KBI2 — Keyboard interrupt input 2Input
T1CLK — TIM1 timer clock inputInput
PTA3 — General purpose I/O portInput/Output
RST
— Reset input, active low with internal pullup and Schmitt triggerInput
KBI3 — Keyboard interrupt input 3Input
PTA4 — General purpose I/O portInput/Output
OSC2 —XTAL oscillator output (XTAL option only)
RC or internal oscillator output (OSC2EN = 1 in PTAPUE register)
Output
Output
AD2 — A/D channel 2 inputInput
KBI4 — Keyboard interrupt input 4Input
PTA5 — General purpose I/O portInput/Output
OSC1 — XTAL, RC, or external oscillator inputInput
AD3 — A/D channel 3 inputInput
KBI5 — Keyboard interrupt input 5Input
PTB0 — General-purpose I/O portInput/Output
SPSCK— SPI serial clockInput/Output
AD4 — A/D channel 4 inputInput
PTB1 — General-purpose I/O portInput/Output
MOSI — SPI data transmittedInput/Output
T2CH1
(2)
— TIM2 channel 1
Input/Output
AD5 — A/D channel 5 inputInput
— Continued on next page
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
22Freescale Semiconductor
Pin Functions
Table 1-2. Pin Functions (Continued)
Pin NameDescriptionInput/Output
PTB2 — General-purpose I/O portInput/Output
PTB2
PTB3
PTB4
PTB5
PTB6
PTB7
PTC0–PTC2
(1, 3)
PTC3
PTD0–PTD7
MISO — SPI data receivedInput/Output
T2CH0
(2)
— TIM2 channel 0
Input/Output
AD6 — A/D channel 6 inputInput
PTB3 — General-purpose I/O portInput/Output
SS
— SPI slave selectInput
T2CLK — TIM2 timer clock inputInput
AD7 — A/D channel 7 inputInput
PTB4 — General-purpose I/O portInput/Output
RxD — ESCI receive data I/OInput
T2CH0
(2)
— TIM2 channel 0
Input/Output
AD8 — A/D channel 8 inputInput
PTB5 — General-purpose I/O portInput/Output
TxD — ESCI transport data I/OOutput
T2CH1
(2)
— TIM2 channel 1
Input/Output
AD9 — A/D channel 9 inputInput
PTB6 — General-purpose I/O portInput/Output
T1CH2 — Timer channel 2 I/OInput/Output
PTB7 — General-purpose I/O portInput/Output
T1CH3 — Timer channel 3 I/OInput/Output
(3)
General-purpose I/O portInput/Output
General-purpose input portInput
(4)
General-purpose I/O portInput/Output
1. PTA2 and PTC3 pins have high voltage detectors to enter special modes.
2. T2CH0 and T2CH1 can be repositioned using TIM2POS in CONFIG2.
3. Pins not available on 16-pin devices (see note in 11.1 Introduction).
4. Pins not available on 16-pin or 20-pin devices (see note in 11.1 Introduction).
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor23
General Description
1.6 Pin Function Priority
Table 1-3 is meant to resolve the priority if multiple functions are enabled on a single pin.
NOTE
Upon reset all pins come up as input ports regardless of the priority table.
Table 1-3. Function Priority in Shared Pins
Pin NameHighest-to-Lowest Priority Sequence
(1)
PTA0
(1)
PTA1
PTA2IRQ → T1CLK → KBI2 → PTA2
PTA3RST
(1)
PTA4
(1)
PTA5
(1)
PTB0
(1)
PTB1
(1)
PTB2
(1)
PTB3
(1)
PTB4
(1)
PTB5
PTB6T1CH2 → PTB6
PTB7T1CH3 → PTB7
PTCxPTCx
PTDxPTDx
1. When a pin is to be used as an ADC pin, the I/O port function should be left as
an input and all other shared modules should be disabled. The ADC does not
override additional modules using the pin.
2. T2CH0 and T2CH1 can be repositioned using TIM2POS in CONFIG2
(see Figure 2-2. Control, Status, and Data Registers).
AD0 → T1CH0 → KBI0 → PTA0
AD1 → T1CH1 → KBI1 → PTA1
→ KBI3 → PTA3
OSC2 → AD2 → KBI4 → PTA4
OSC1 → AD3 → KBI5 → PTA5
AD4 → SPSCK → PTB0
AD5 → MOSI → T2CH1
AD6 → MISO → T2CH0
AD7 → SS → T2CLK → PTB3
AD8 → RxD → T2CH0
AD9 → TxD → T2CH1
(2)
→ PTB1
(2)
→ PTB2
(2)
→ PTB4
(2)
→ PTB5
1.7 Unused Pin Termination
Input pins and I/O port pins that are not used in the application must be terminated. This prevents excess
current caused by floating inputs, and enhances immunity during noise or transient events. Termination
methods include:
1.Configuring unused pins as outputs and driving high or low;
2.Configuring unused pins as inputs and enabling internal pull-ups;
3.Configuring unused pins as inputs and using external pull-up or pull-down resistors.
Never connect unused pins directly to V
Since some general-purpose I/O pins are not available on all packages, these pins must be terminated
as well. Either method 1 or 2 above are appropriate.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
24Freescale Semiconductor
or VSS.
DD
Chapter 2
Memory
2.1 Introduction
The central processor unit (CPU08) can address 64 Kbytes of memory space. The memory map is shown
in Figure 2-1.
2.2 Unimplemented Memory Locations
Executing code from an unimplemented location will cause an illegal address reset. In Figure 2-1,
unimplemented locations are shaded.
2.3 Reserved Memory Locations
Accessing a reserved location can have unpredictable effects on MCU operation. In Figure 2-1, reserved
locations are marked with the word reserved or with the letter R.
2.4 Direct Page Registers
Figure 2-2 shows the memory mapped registers. Registers with addresses between $0000 and $00FF
are considered direct page registers and all instructions including those with direct page addressing
modes can access them. Registers between $0100 and $FFFF require non-direct page addressing
modes. See Chapter 6 Central Processor Unit (CPU) for more information on addressing modes.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Figure 2-2. Control, Status, and Data Registers (Sheet 5 of 8)
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor31
Memory
Addr.Register NameBit 7654321Bit 0
TIM2 Counter Register Low
$0242
TIM2 Counter Modulo
$0243
$0244
$0245
$0246
$0247
$0248
$0249
$024A
$024B
Register High (T2MODH)
TIM2 Counter Modulo
Register Low (T2MODL)
TIM2 Channel 0 Status and
Control Register (T2SC0)
TIM2 Channel 0 Register
TIM2 Channel 0 Register
TIM2 Channel 1 Status and
Control Register (T2SC1)
TIM2 Channel 1 Register
TIM2 Channel 1 Register
(T2CNTL)
See page 214.
See page 215.
See page 215.
See page 215.
High (T2CH0H)
See page 218.
Low (T2CH0L)
See page 218.
See page 215.
High (T2CH1H)
See page 218.
Low (T2CH1L)
See page 218.
Reserved
Read:Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
Write:
Reset:00000000
Read:
Write:
Reset:11111111
Read:
Write:
Reset:11111111
Read:CH0F
Write:0
Reset:00000000
Read:
Write:
Reset:Indeterminate after reset
Read:
Write:
Reset:Indeterminate after reset
Read:CH1F
Write:0
Reset:00000000
Read:
Write:
Reset:Indeterminate after reset
Read:
Write:
Reset:Indeterminate after reset
Bit 15Bit 14Bit 13Bit 12Bit 11Bit 10Bit 9Bit 8
Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
CH0IEMS0BMS0AELS0BELS0ATOV0CH0MAX
Bit 15Bit 14Bit 13Bit 12Bit 11Bit 10Bit 9Bit 8
Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
CH1IE
Bit 15Bit 14Bit 13Bit 12Bit 11Bit 10Bit 9Bit 8
Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
0
MS1AELS1BELS1ATOV1CH1MAX
$024C
$024D
$024E
Periodic Wakeup Status
and Control Register
(PWUSC)
See page 119.
Periodic Wakeup Prescaler
Register (PWUP)
See page 120.
Periodic Wakeup Modulo
Register (PWUMOD)
See page 121.
Read:00
Write:
Reset:00000000
Read:0000
Write:
Reset:00000000
Read:
Write:
Reset:00000000
Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
= UnimplementedR= ReservedU = Unaffected
PWUON
PWUCLK-
SEL
PWUF0
PWUACK
PS3PS2PS1PS0
PWUIESMODE
Figure 2-2. Control, Status, and Data Registers (Sheet 6 of 8)
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
32Freescale Semiconductor
Direct Page Registers
Addr.Register NameBit 7654321Bit 0
$024F
Reserved
Break Status Register
$FE00
SIM Reset Status Register
$FE01
Break Auxiliary Register
$FE02
Break Flag Control Register
$FE03
Interrupt Status Register 1
$FE04
Interrupt Status Register 2
$FE05
Interrupt Status Register 3
$FE06
$FE07
(BSR)
See page 223.
(SRSR)
See page 167.
(BRKAR)
See page 223.
(BFCR)
See page 223.
(INT1)
See page 163.
(INT2)
See page 163.
(INT3)
See page 163.
Reserved
Read:
Write:0
Reset:0
Read:PORPINCOPILOPILADMODRSTLVI0
Write:
POR:10000000
Read:0000000
Write:
Reset:00000000
Read:
Write:
Reset:0
Read:IF6IF5IF4IF3IF2IF100
Write:RRRRRRRR
Reset:00000000
Read:IF14IF13IF12IF11IF10IF9IF8IF7
Write:RRRRRRRR
Reset:00000000
Read:IF22IF21IF20IF19IF18IF17IF16IF15
Write:RRRRRRRR
Reset:00000000
RRRRRR
BCFERRRRRRR
SBSW
R
BDCOP
Read:0000
Write:
Reset:00000000
Read:
Write:
Reset:00000000
Read:
Write:
Reset:00000000
Read:
Write:
Reset:00000000
Bit 15Bit 14Bit 13Bit 12Bit 11Bit 10Bit 9Bit 8
Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
BRKEBRKA
= UnimplementedR= ReservedU = Unaffected
000000
HVENMASSERASEPGM
$FE08
$FE09
$FE0A
$FE0B
FLASH Control Register
(FLCR)
See page 36.
Break Address High
Register (BRKH)
See page 222.
Break Address low
Register (BRKL)
See page 222.
Break Status and Control
Register (BRKSCR)
See page 223.
Figure 2-2. Control, Status, and Data Registers (Sheet 7 of 8)
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor33
Memory
Addr.Register NameBit 7654321Bit 0
Read:LVIOUT000000R
Write:
Reset:00000000
$FE0C
$FE0D
↓
$FE0F
LVI Status Register
(LVISR)
See page 95.
Reserved
$FFBE
$FFBF
$FFC0
$FFC1
$FFFF
FLASH Block Protect
Register (FLBPR)
See page 41.
Internal Oscillator
Trim Value
COP Control Register
(COPCTL)
See page 65.
Figure 2-2. Control, Status, and Data Registers (Sheet 8 of 8)
Read:
Write:
Reset:Unaffected by reset
Read:
Write:
Reset:FLASH location with factory programmed trim value.
Read:LOW BYTE OF RESET VECTOR
Write:WRITING CLEARS COP COUNTER (ANY VALUE)
Reset:Unaffected by reset
BPR7BPR6BPR5BPR4BPR3BPR2BPR1BPR0
TRIM7TRIM6TRIM5TRIM4TRIM3TRIM2TRIM1TRIM0
= UnimplementedR= ReservedU = Unaffected
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
34Freescale Semiconductor
Random-Access Memory (RAM)
Table 2-1. Vector Addresses
Vector PriorityVectorAddressVector
Lowest
Highest
IF22-
IF20
IF19$FFD6,7PWU vector
IF18$FFD8,9TIM2 overflow vector
IF17$FFDA,BTIM2 channel 1 vector
IF16$FFDC,DTIM2 channel 0 vector
IF15$FFDE,FADC conversion complete vector
IF14$FFE0,1Keyboard vector
IF13$FFE2,3SPI transmit vector
IF12$FFE4,5SPI receive vector
IF11$FFE6,7ESCI transmit vector
IF10$FFE8,9ESCI receive vector
IF9$FFEA,BESCI error vector
IF8—Not used
IF7$FFEE,FTIM1 Channel 3 vector
IF6$FFF0,1TIM1 Channel 2 vector
IF5$FFF2,3TIM1 overflow vector
IF4$FFF4,5TIM1 Channel 1 vector
IF3$FFF6,7TIM1 Channel 0 vector
IF2—Not used
IF1$FFFA,BIRQ
—$FFFC,DSWI vector
—$FFFE,FReset vector
$FFD0-
$FFD5
.
Unused vectors (available for user program)
vector
2.5 Random-Access Memory (RAM)
This MCU includes static RAM. The locations in RAM below $0100 can be accessed using the more
efficient direct addressing mode, and any single bit in this area can be accessed with the bit manipulation
instructions (BCLR, BSET, BRCLR, and BRSET). Locating the most frequently accessed program
variables in this area of RAM is preferred.
The RAM retains data when the MCU is in low-power wait or stop mode. At power-on, the contents of
RAM are uninitialized. RAM data is unaffected by any reset provided that the supply voltage does not drop
below the minimum value for RAM retention.
For compatibility with older M68HC05 MCUs, the HC08 resets the stack pointer to $00FF. In the devices
that have RAM above $00FF, it is usually best to reinitialize the stack pointer to the top of the RAM so the
direct page RAM can be used for frequently accessed RAM variables and bit-addressable program
variables. Include the following 2-instruction sequence in your reset initialization routine (where RamLast
is equated to the highest address of the RAM).
LDHX #RamLast+1 ;point one past RAM
TXS ;SP<-(H:X-1)
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor35
Memory
2.6 FLASH Memory (FLASH)
The FLASH memory is intended primarily for program storage. In-circuit programming allows the
operating program to be loaded into the FLASH memory after final assembly of the application product.
It is possible to program the entire array through the single-wire monitor mode interface. Because no
special voltages are needed for FLASH erase and programming operations, in-application programming
is also possible through other software-controlled communication paths.
This subsection describes the operation of the embedded FLASH memory. The FLASH memory can be
read, programmed, and erased from the internal V
enabled through the use of an internal charge pump.
The minimum size of FLASH memory that can be erased is 64 bytes; and the maximum size of FLASH
memory that can be programmed in a program cycle is 32 bytes (a row). Program and erase operations
are facilitated through control bits in the FLASH control register (FLCR). Details for these operations
appear later in this section.
An erased bit reads as a 1 and a programmed bit reads as a 0. A security
feature prevents viewing of the FLASH contents.
2.6.1 FLASH Control Register
supply. The program and erase operations are
DD
NOTE
(1)
The FLASH control register (FLCR) controls FLASH program and erase operations.
Bit 7654321Bit 0
Read:0000
Write:
Reset:00000000
= Unimplemented
HVENMASSERASEPGM
Figure 2-3. FLASH Control Register (FLCR)
HVEN — High Voltage Enable Bit
This read/write bit enables high voltage from the charge pump to the memory for either program or
erase operation. It can only be set if either PGM =1 or ERASE = 1 and the proper sequence for
program or erase is followed.
1 = High voltage enabled to array and charge pump on
0 = High voltage disabled to array and charge pump off
MASS — Mass Erase Control Bit
This read/write bit configures the memory for mass erase operation.
1 = Mass erase operation selected
0 = Mass erase operation unselected
ERASE — Erase Control Bit
This read/write bit configures the memory for erase operation. ERASE is interlocked with the PGM bit
such that both bits cannot be equal to 1 or set to 1 at the same time.
1. No security feature is absolutely secure. However, Freescale’s strategy is to make reading or copying the FLASH difficult
for unauthorized users.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
36Freescale Semiconductor
FLASH Memory (FLASH)
PGM — Program Control Bit
This read/write bit configures the memory for program operation. PGM is interlocked with the ERASE
bit such that both bits cannot be equal to 1 or set to 1 at the same time.
1 = Program operation selected
0 = Program operation unselected
2.6.2 FLASH Page Erase Operation
Use the following procedure to erase a page of FLASH memory. A page consists of 64 consecutive bytes
starting from addresses $XX00, $XX40, $XX80, or $XXC0. The 48-byte user interrupt vectors area also
forms a page. Any FLASH memory page can be erased alone.
1.Set the ERASE bit and clear the MASS bit in the FLASH control register.
2.Read the FLASH block protect register.
3.Write any data to any FLASH location within the address range of the block to be erased.
4.Wait for a time, t
5.Set the HVEN bit.
6.Wait for a time, t
7.Clear the ERASE bit.
8.Wait for a time, t
9.Clear the HVEN bit.
10.After time, t
RCV,
.
NVS
.
Erase
.
NVH
the memory can be accessed in read mode again.
NOTE
Programming and erasing of FLASH locations cannot be performed by
code being executed from the FLASH memory. While these operations
must be performed in the order as shown, other unrelated operations may
occur between the steps.
NOTE
A page erase of the vector page will erase the internal oscillator trim value
at $FFC0.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor37
Memory
2.6.3 FLASH Mass Erase Operation
Use the following procedure to erase the entire FLASH memory to read as a 1:
1.Set both the ERASE bit and the MASS bit in the FLASH control register.
2.Read the FLASH block protect register.
3.Write any data to any FLASH address
4.Wait for a time, t
NVS
.
5.Set the HVEN bit.
6.Wait for a time, t
MErase
.
7.Clear the ERASE and MASS bits.
Mass erase is disabled whenever any block is protected (FLBPR does not
equal $FF).
(1)
within the FLASH memory address range.
NOTE
8.Wait for a time, t
9.Clear the HVEN bit.
10.After time, t
RCV,
Programming and erasing of FLASH locations cannot be performed by
code being executed from the FLASH memory. While these operations
must be performed in the order as shown, other unrelated operations may
occur between the steps.
A mass erase will erase the internal oscillator trim value at $FFC0.
.
NVHL
the memory can be accessed in read mode again.
NOTE
CAUTION
1. When in monitor mode, with security sequence failed (see 18.3.2 Security), write to the FLASH block protect register instead of any FLASH address.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
38Freescale Semiconductor
FLASH Memory (FLASH)
2.6.4 FLASH Program Operation
Programming of the FLASH memory is done on a row basis. A row consists of 32 consecutive bytes
starting from addresses $XX00, $XX20, $XX40, $XX60, $XX80, $XXA0, $XXC0, or $XXE0. Use the
following step-by-step procedure to program a row of FLASH memory
Figure 2-4 shows a flowchart of the programming algorithm.
NOTE
Do not program any byte in the FLASH more than once after a successful
erase operation. Reprogramming bits to a byte which is already
programmed is not allowed without first erasing the page in which the byte
resides or mass erasing the entire FLASH memory. Programming without
first erasing may disturb data stored in the FLASH.
1.Set the PGM bit. This configures the memory for program operation and enables the latching of
address and data for programming.
2.Read the FLASH block protect register.
3.Write any data to any FLASH location within the address range desired.
4.Wait for a time, t
5.Set the HVEN bit.
6.Wait for a time, t
7.Write data to the FLASH address being programmed
8.Wait for time, t
9.Repeat step 7 and 8 until all desired bytes within the row are programmed.
10.Clear the PGM bit
11.Wait for time, t
12.Clear the HVEN bit.
13.After time, t
RCV
This program sequence is repeated throughout the memory until all data is programmed.
.
NVS
.
PGS
PROG
NVH
(1)
.
.
.
(1)
.
, the memory can be accessed in read mode again.
NOTE
Programming and erasing of FLASH locations cannot be performed by
code being executed from the FLASH memory. While these operations
must be performed in the order shown, other unrelated operations may
occur between the steps. Do not exceed t
maximum, see19.17
PROG
Memory Characteristics.
1. The time between each FLASH address change, or the time between the last FLASH address programmed to clearing
PGM bit, must not exceed the maximum programming time, t
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor39
PROG
maximum.
Memory
SET HVEN BIT
WRITE ANY DATA TO ANY FLASH ADDRESS
WITHIN THE ROW ADDRESS RANGE DESIRED
WAIT FOR A TIME, t
NVS
SET PGM BIT
WAIT FOR A TIME, t
PGS
WRITE DATA TO THE FLASH ADDRESS
TO BE PROGRAMMED
WAIT FOR A TIME, t
PROG
CLEAR PGM BIT
WAIT FOR A TIME, t
NVH
CLEAR HVEN BIT
WAIT FOR A TIME, t
RCV
COMPLETED
PROGRAMMING
THIS ROW?
Y
N
END OF PROGRAMMING
The time between each FLASH address change (step 7 to step 7 loop),
must not exceed the maximum programming
time, t
PROG
max.
or the time between the last FLASH address programmed
to clearing PGM bit (step 7 to step 10)
NOTES:
1
3
4
5
6
7
8
10
11
12
13
Algorithm for Programming
a Row (32 Bytes) of FLASH Memory
This row program algorithm assumes the row/s
to be programmed are initially erased.
9
READ THE FLASH BLOCK PROTECT REGISTER
2
Figure 2-4. FLASH Programming Flowchart
40Freescale Semiconductor
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
FLASH Memory (FLASH)
2.6.5 FLASH Protection
Due to the ability of the on-board charge pump to erase and program the FLASH memory in the target
application, provision is made to protect blocks of memory from unintentional erase or program operations
due to system malfunction. This protection is done by use of a FLASH block protect register (FLBPR).
The FLBPR determines the range of the FLASH memory which is to be protected. The range of the
protected area starts from a location defined by FLBPR and ends to the bottom of the FLASH memory
($FFFF). When the memory is protected, the HVEN bit cannot be set in either ERASE or PROGRAM
operations.
NOTE
In performing a program or erase operation, the FLASH block protect
register must be read after setting the PGM or ERASE bit and before
asserting the HVEN bit.
When the FLBPR is programmed with all 0 s, the entire memory is protected from being programmed and
erased. When all the bits are erased (all 1’s), the entire memory is accessible for program and erase.
When bits within the FLBPR are programmed, they lock a block of memory. The address ranges are
shown in 2.6.6 FLASH Block Protect Register. Once the FLBPR is programmed with a value other than
$FF, any erase or program of the FLBPR or the protected block of FLASH memory is prohibited. Mass
erase is disabled whenever any block is protected (FLBPR does not equal $FF). The FLBPR itself can be
erased or programmed only with an external voltage, V
allows entry from reset into the monitor mode.
, present on the IRQ pin. This voltage also
TST
2.6.6 FLASH Block Protect Register
The FLASH block protect register is implemented as a byte within the FLASH memory, and therefore can
only be written during a programming sequence of the FLASH memory. The value in this register
determines the starting address of the protected range within the FLASH memory.
Bit 7654321Bit 0
Read:
Write:
Reset:Unaffected by reset. Initial value from factory is 1.
Write to this register is by a programming sequence to the FLASH memory.
BPR[7:0] — FLASH Protection Register Bits [7:0]
These eight bits in FLBPR represent bits [13:6] of a 16-bit memory address. Bits [15:14] are 1s and
bits [5:0] are 0s.
The resultant 16-bit address is used for specifying the start address of the FLASH memory for block
protection. The FLASH is protected from this start address to the end of FLASH memory, at $FFFF.
With this mechanism, the protect start address can be $XX00, $XX40, $XX80, or $XXC0 within the
FLASH memory. See Figure 2-6 and Table 2-2.
BPR7BPR6BPR5BPR4BPR3BPR2BPR1BPR0
Figure 2-5. FLASH Block Protect Register (FLBPR)
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor41
Memory
0
0
00011
FLBPR VALUE
START ADDRESS OF
16-BIT MEMORY ADDRESS
FLASH BLOCK PROTECT
0
Figure 2-6. FLASH Block Protect Start Address
Table 2-2. Examples of Protect Start Address
BPR[7:0]
(2)
$00
$01 (0000 0001)$C040 (1100 0000 0100 0000)
$02 (0000 0010)$C080 (1100 0000 1000 0000)
$03 (0000 0011)$C0C0 (1100 0000 1100 0000)
and so on...
$FD (1111 1101)$FF40 (1111 1111 0100 0000)
$FE (1111 1110)$FF80 (1111 1111 1000 0000)
$FFThe entire FLASH memory is not protected.
1. The end address of the protected range is always $FFFF.
2. $BE00–$BFFF is always protected unless the entire FLASH memory is unprotected, BPR[7:0] = $FF.
Start of Address of Protect Range
The entire FLASH memory is protected.
(1)
2.6.7 EEPROM Memory Emulation Using FLASH Memory
In some applications, the user may want to repeatedly store and read a set of data from an area of
nonvolatile memory. This is easily implemented in EEPROM memory because single byte erase is
allowed in EEPROM.
When using FLASH memory, the minimum erase size is a page. However, the FLASH can be used as
EEPROM memory. This technique is called “EEPROM emulation”.
The basic concept of EEPROM emulation using FLASH is that a page is continuously programmed with
a new data set without erasing the previously programmed locations. Once the whole page is completely
programmed or the page does not have enough bytes to program a new data set, the user software
automatically erases the page and then programs a new data set in the erased page.
In EEPROM emulation when data is read from the page, the user software must find the latest data set
in the page since the previous data still remains in the same page. There are many ways to monitor the
page erase timing and the latest data set. One example is unprogrammed FLASH bytes are detected by
checking programmed bytes (non-$FF value) in a page. In this way, the end of the data set will contain
unprogrammed data ($FF value).
A couple of application notes, describing how to emulate EEPROM using FLASH, are available on our
web site. Titles and order numbers for these application notes are given at the end of this subsection.
42Freescale Semiconductor
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
FLASH Memory (FLASH)
For EEPROM emulation software to work successfully, the following items must be taken care of in the
user software:
1.Each FLASH byte in a page must be programmed only one time until the page is erased.
2.A page must be erased before the FLASH cumulative program HV period (t
maximum t
. tHV is defined as the cumulative high-voltage programming time to the same row
HV
) is beyond the
HV
before the next erase. For more detailed information, refer to 19.17 Memory Characteristics.
3.FLASH row erase and program cycles should not exceed 10,000 cycles, respectively.
The above EEPROM emulation software can be easily developed by using the on-chip FLASH routines
implemented in the MCU. These routines are located in the ROM memory and support FLASH program
and erase operations. Proper utilization of the on-chip FLASH routines guarantee conformance to the
FLASH specifications.
In the on-chip FLASH programming routine called PRGRNGE, the high-voltage programming time is
enabled for less than 125 μs when programming a single byte at any operating bus frequency between
1.0 MHz and 8.4 MHz. Therefore, even when a row is programmed by 32 separate single-byte
programming operations, t
is less than the maximum tHV. Hence, item 2 listed above is already taken
HV
care of by using this routine.
A page erased operation is provided in the FLASH erase routine called ERARNGE.
Application note AN2635 (On-Chip FLASH Programming Routines) describes how to use these routines.
The following application notes, available at www.freescale.com, describe how EERPOM emulation is
implemented using FLASH:
AN2183 — Using FLASH as EEPROM on the MC68HC908GP32
AN2346 — EEPROM Emulation Using FLASH in MC68HC908QY/QT MCUs
AN2690 — Low Frequency EEPROM Emulation on the MC68HC908QY4
An EEPROM emulation driver, available at www.freescale.com, has been developed and qualified:
AN3040 — M68HC08 EEPROM Emulation Driver
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor43
Memory
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
This section describes the 10-bit successive approximation analog-to-digital converter (ADC10).
The ADC10 module shares its pins with general-purpose input/output (I/O) port pins. See Figure 3-1 for
port location of these shared pins. The ADC10 on this MCU uses V
pins. This MCU uses BUSCLKX4 as its alternate clock source for the ADC. This MCU does not have a
hardware conversion trigger.
3.2 Features
Features of the ADC10 module include:
•Linear successive approximation algorithm with 10-bit resolution
•Output formatted in 10- or 8-bit right-justified format
•Single or continuous conversion (automatic power-down in single conversion mode)
•Configurable sample time and conversion speed (to save power)
•Conversion complete flag and interrupt
•Input clock selectable from up to three sources
•Operation in wait and stop modes for lower noise operation
The ADC10 uses successive approximation to convert the input sample taken from ADVIN to a digital
representation. The approximation is taken and then rounded to the nearest 10- or 8-bit value to provide
greater accuracy and to provide a more robust mechanism for achieving the ideal code-transition voltage.
Figure 3-2 shows a block diagram of the ADC10
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor45
Analog-to-Digital Converter (ADC10) Module
All port pins can be configured with internal pullup
PTC not available on 16-pin devices (see note in 11.1 Introduction)
PTD not available on 16-pin or 20-pin devices (see note in 11.1 Introduction)
PTA0/T1CH0/AD0/KBI0
PTA1/T1CH1/AD1/KBI1
PTA2/IRQ
/KBI2/T1CLK
PTA3/RST
/KBI3
PTA4/OSC2/AD2/KBI4
PTA5/OSC1/AD3/KBI5
4-CHANNEL 16-BIT
TIMER MODULE
KEYBOARD INTERRUPT
MODULE
SINGLE INTERRUPT
MODULE
PERIODIC WAKEUP
LOW-VOLTAGE
INHIBIT
COP
MODULE
10-CHANNEL
10-BIT ADC
ENHANCED SERIAL
PTB0/SPSCK/AD4
PTB
DDRB
M68HC08 CPU
PTA
DDRA
PTB1/MOSI/T2CH1/AD5
PTB2/MISO/T2CH0/AD6
PTB3/SS
/T2CLK/AD7
PTB4/RxD/T2CH0/AD8
PTB5/TxD/T2CH1/AD9
PTB6/T1CH2
PTB7/T1CH3
POWER SUPPLY
V
DD
V
SS
CLOCK
GENERATOR
COMMUNICATIONS
INTERFACE MODULE
MODULE
SERIAL PERIPHERAL
INTERFACE
16,384 BYTES
MC68HC908QC16
8192 BYTES
MC68HC908QC8
512 BYTES
MC68HC908QC16
384 BYTES
MC68HC908QC8
BREAK
MODULE
MONITOR ROM
2-CHANNEL 16-BIT
TIMER MODULE
PTC0
PTC1
PTC2
PTC3
PTC
DDRC
PTD0
PTD
DDRD
PTD1
PTD2
PTD3
PTD4
PTD5
PTD6
PTD7
MC68HC908QC4
USER RAM
USER FLASH
4096 BYTES
384 BYTES
MC68HC908QC4
Figure 3-1. Block Diagram Highlighting ADC10 Block and Pins
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
46Freescale Semiconductor
Functional Description
AD0
• • •
ADn
V
REFH
V
REFL
ADVIN
ADCH
CONTROL SEQUENCER
INITIALIZE
SAMPLE
CONVERT
TRANSFER
ABORT
ADCK
BUS CLOCK
ALTERNATE CLOCK SOURCE
ADICLK
ADIV
ACLK
ADCO
ADSCR
ADLSMP
ADLPC
MODE
COMPLETE
DATA REGISTERS ADRH:ADRL
SAR CONVERTER
AIEN
COCO
INTERRUPT
AIEN
COCO
1
2
1 2
MCU STOP
ADHWT
ADCLK
ACLKEN
ASYNC
CLOCK
GENERATOR
CLOCK
DIVIDE
Figure 3-2. ADC10 Block Diagram
The ADC10 can perform an analog-to-digital conversion on one of the software selectable channels. The
output of the input multiplexer (ADVIN) is converted by a successive approximation algorithm into a 10-bit
digital result. When the conversion is completed, the result is placed in the data registers (ADRH and
ADRL). In 8-bit mode, the result is rounded to 8 bits and placed in ADRL. The conversion complete flag
is then set and an interrupt request is generated if AIEN has been set.
3.3.1 Clock Select and Divide Circuit
The clock select and divide circuit selects one of three clock sources and divides it by a configurable value
to generate the input clock to the converter (ADCK). The clock can be selected from one of the following
sources:
•The asynchronous clock source (ACLK) — This clock source is generated from a dedicated clock
source which is enabled when the ADC10 is converting and the clock source is selected by setting
ACLKEN. When ADLPC is clear, this clock operates from 1–2 MHz; when ADLPC is set, it operates
at 0.5–1 MHz. This clock is not disabled in STOP and allows conversions in stop mode for lower
noise operation.
•Alternate Clock Source — This clock source is equal to the external oscillator clock or four times
the bus clock. The alternate clock source is MCU specific, see 3.1 Introduction to determine source
and availability of this clock source option. This clock is selected when ADICLK and ACLKEN are
both clear.
•The bus clock — This clock source is equal to the bus frequency. This clock is selected when
ADICLK is set and ACLKEN is clear.
Whichever clock is selected, its frequency must fall within the acceptable frequency range for ADCK. If
the available clocks are too slow, the ADC10 will not perform according to specifications. If the available
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor47
Analog-to-Digital Converter (ADC10) Module
clocks are too fast, then the clock must be divided to the appropriate frequency. This divider is specified
by ADIV[1:0] and can be divide-by 1, 2, 4, or 8.
3.3.2 Input Select and Pin Control
Only one analog input may be used for conversion at any given time. The channel select bits in ADSCR
are used to select the input signal for conversion.
3.3.3 Conversion Control
Conversions can be performed in either 10-bit mode or 8-bit mode as determined by the MODE bits.
Conversions can be initiated by either a software or hardware trigger. In addition, the ADC10 module can
be configured for low power operation, long sample time, and continuous conversion.
3.3.3.1 Initiating Conversions
A conversion is initiated:
•Following a write to ADSCR (with ADCH bits not all 1s) if software triggered operation is selected.
•Following a hardware trigger event if hardware triggered operation is selected.
•Following the transfer of the result to the data registers when continuous conversion is enabled.
If continuous conversions are enabled a new conversion is automatically initiated after the completion of
the current conversion. In software triggered operation, continuous conversions begin after ADSCR is
written and continue until aborted. In hardware triggered operation, continuous conversions begin after a
hardware trigger event and continue until aborted.
3.3.3.2 Completing Conversions
A conversion is completed when the result of the conversion is transferred into the data result registers,
ADRH and ADRL. This is indicated by the setting of COCO. An interrupt request is generated if AIEN is
set at the time that COCO is set.
A blocking mechanism prevents a new result from overwriting previous data in ADRH and ADRL if the
previous data is in the process of being read while in 10-bit mode (ADRH has been read but ADRL has
not). In this case the data transfer is blocked, COCO is not set, and the new result is lost. When a data
transfer is blocked, another conversion is initiated regardless of the state of ADCO (single or continuous
conversions enabled). If single conversions are enabled, this could result in several discarded
conversions and excess power consumption. To avoid this issue, the data registers must not be read after
initiating a single conversion until the conversion completes.
3.3.3.3 Aborting Conversions
Any conversion in progress will be aborted when:
•A write to ADSCR occurs (the current conversion will be aborted and a new conversion will be
initiated, if ADCH are not all 1s).
•A write to ADCLK occurs.
•The MCU is reset.
•The MCU enters stop mode with ACLK not enabled.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
48Freescale Semiconductor
Functional Description
21 ADCK cycles
Conversion time =
16 MHz/8
Number of bus cycles = 11.25 μs x 4 MHz = 45 cycles
3 bus cycles
4 MHz
+
= 11.25 μs
When a conversion is aborted, the contents of the data registers, ADRH and ADRL, are not altered but
continue to be the values transferred after the completion of the last successful conversion. In the case
that the conversion was aborted by a reset, ADRH and ADRL return to their reset states.
Upon reset or when a conversion is otherwise aborted, the ADC10 module will enter a low power, inactive
state. In this state, all internal clocks and references are disabled. This state is entered asynchronously
and immediately upon aborting of a conversion.
3.3.3.4 Total Conversion Time
The total conversion time depends on many factors such as sample time, bus frequency, whether
ACLKEN is set, and synchronization time. The total conversion time is summarized in Table 3-1.
Table 3-1. Total Conversion Time versus Control Conditions
Conversion ModeACLKENMaximum Conversion Time
8-Bit Mode (short sample — ADLSMP = 0):
Single or 1st continuous
Single or 1st continuous
Subsequent continuous (f
8-Bit Mode (long sample — ADLSMP = 1):
Single or 1st continuous
Single or 1st continuous
Subsequent continuous (f
10-Bit Mode (short sample — ADLSMP = 0):
Single or 1st continuous
Single or 1st continuous
Subsequent continuous (f
10-Bit Mode (long sample — ADLSMP = 1):
Single or 1st continuous
Single or 1st continuous
Subsequent continuous (f
Bus
Bus
Bus
Bus
≥ f
≥ f
≥ f
≥ f
ADCK
ADCK
ADCK
ADCK
)
)
)
)
0
1
X
0
1
X
0
1
X
0
1
X
18 ADCK + 3 bus clock
18 ADCK + 3 bus clock + 5 μs
16 ADCK
38 ADCK + 3 bus clock
38 ADCK + 3 bus clock + 5 μs
36 ADCK
21 ADCK + 3 bus clock
21 ADCK + 3 bus clock + 5 μs
19 ADCK
41 ADCK + 3 bus clock
41 ADCK + 3 bus clock + 5 μs
39 ADCK
The maximum total conversion time for a single conversion or the first conversion in continuous
conversion mode is determined by the clock source chosen and the divide ratio selected. The clock
source is selectable by ADICLK and ACLKEN, and the divide ratio is specified by ADIV. For example, if
the alternative clock source is 16 MHz and is selected as the input clock source, the input clock
divide-by-8 ratio is selected and the bus frequency is 4 MHz, then the conversion time for a single 10-bit
conversion is:
NOTE
The ADCK frequency must be between f
minimum and f
ADCK
ADCK
maximum to meet A/D specifications.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor49
Analog-to-Digital Converter (ADC10) Module
3.3.4 Sources of Error
Several sources of error exist for ADC conversions. These are discussed in the following sections.
3.3.4.1 Sampling Error
For proper conversions, the input must be sampled long enough to achieve the proper accuracy. Given
the maximum input resistance of approximately 15 kΩ and input capacitance of approximately 10 pF,
sampling to within 1/4
cycles / 2 MHz maximum ADCK frequency) provided the resistance of the external analog source (R
is kept below 10 kΩ. Higher source resistances or higher-accuracy sampling is possible by setting
ADLSMP (to increase the sample window to 23.5 cycles) or decreasing ADCK frequency to increase
sample time.
3.3.4.2 Pin Leakage Error
LSB (at 10-bit resolution) can be achieved within the minimum sample window (3.5
AS
)
Leakage on the I/O pins can cause conversion error if the external analog source resistance (R
If this error cannot be tolerated by the application, keep R
LSB leakage error (at 10-bit resolution).
1/4
lower than V
AS
ADVIN
/ (4096*I
Leak
) is high.
AS
) for less than
3.3.4.3 Noise-Induced Errors
System noise which occurs during the sample or conversion process can affect the accuracy of the
conversion. The ADC10 accuracy numbers are guaranteed as specified only if the following conditions
are met:
•There is a 0.1μF low-ESR capacitor from V
•There is a 0.1μF low-ESR capacitor from V
REFH
DDA
to V
to V
(if available).
REFL
(if available).
SSA
•If inductive isolation is used from the primary supply, an additional 1μF capacitor is placed from
V
DDA
•V
SSA
to V
and V
(if available).
SSA
(if available) is connected to VSS at a quiet point in the ground plane.
REFL
•The MCU is placed in wait mode immediately after initiating the conversion (next instruction after
write to ADSCR).
•There is no I/O switching, input or output, on the MCU during the conversion.
There are some situations where external system activity causes radiated or conducted noise emissions
or excessive V
noise is coupled into the ADC10. In these cases, or when the MCU cannot be placed
DD
in wait or I/O activity cannot be halted, the following recommendations may reduce the effect of noise on
the accuracy:
•Place a 0.01 μF capacitor on the selected input channel to V
REFL
or V
(if available). This will
SSA
improve noise issues but will affect sample rate based on the external analog source resistance.
•Operate the ADC10 in stop mode by setting ACLKEN, selecting the channel in ADSCR, and
executing a STOP instruction. This will reduce V
noise but will increase effective conversion time
DD
due to stop recovery.
•Average the input by converting the output many times in succession and dividing the sum of the
results. Four samples are required to eliminate the effect of a 1
LSB, one-time error.
•Reduce the effect of synchronous noise by operating off the asynchronous clock (ACLKEN=1) and
averaging. Noise that is synchronous to the ADCK cannot be averaged out.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
50Freescale Semiconductor
Functional Description
3.3.4.4 Code Width and Quantization Error
The ADC10 quantizes the ideal straight-line transfer function into 1024 steps (in 10-bit mode). Each step
ideally has the same height (1 code) and width. The width is defined as the delta between the transition
points from one code to the next. The ideal code width for an N bit converter (in this case N can be 8 or
10), defined as 1
LSB, is:
1
LSB = (V
REFH–VREFL
) / 2
N
Because of this quantization, there is an inherent quantization error. Because the converter performs a
conversion and then rounds to 8 or 10 bits, the code will transition when the voltage is at the midpoint
between the points where the straight line transfer function is exactly represented by the actual transfer
function. Therefore, the quantization error will be ± 1/2
however, the code width of the first ($000) conversion is only 1/2
or $3FF) is 1.5
LSB.
LSB in 8- or 10-bit mode. As a consequence,
LSB and the code width of the last ($FF
3.3.4.5 Linearity Errors
The ADC10 may also exhibit non-linearity of several forms. Every effort has been made to reduce these
errors but the user should be aware of them because they affect overall accuracy. These errors are:
•Zero-Scale Error (E
the actual code width of the first conversion and the ideal code width (1/2
) (sometimes called offset) — This error is defined as the difference between
ZS
LSB). Note, if the first
conversion is $001, then the difference between the actual $001 code width and its ideal (1
used.
•Full-Scale Error (E
the last conversion and the ideal code width (1.5
difference between the actual $3FE code width and its ideal (1
) — This error is defined as the difference between the actual code width of
FS
LSB). Note, if the last conversion is $3FE, then the
LSB) is used.
•Differential Non-Linearity (DNL) — This error is defined as the worst-case difference between the
actual code width and the ideal code width for all conversions.
•Integral Non-Linearity (INL) — This error is defined as the highest-value the (absolute value of the)
running sum of DNL achieves. More simply, this is the worst-case difference of the actual transition
voltage to a given code and its corresponding ideal transition voltage, for all codes.
•Total Unadjusted Error (TUE) — This error is defined as the difference between the actual transfer
function and the ideal straight-line transfer function, and therefore includes all forms of error.
3.3.4.6 Code Jitter, Non-Monotonicity and Missing Codes
Analog-to-digital converters are susceptible to three special forms of error. These are code jitter,
non-monotonicity, and missing codes.
•Code jitter is when, at certain points, a given input voltage converts to one of two values when
sampled repeatedly. Ideally, when the input voltage is infinitesimally smaller than the transition
voltage, the converter yields the lower code (and vice-versa). However, even very small amounts
of system noise can cause the converter to be indeterminate (between two codes) for a range of
input voltages around the transition voltage. This range is normally around ±1/2
LSB but will
increase with noise.
•Non-monotonicity is defined as when, except for code jitter, the converter converts to a lower code
for a higher input voltage.
•Missing codes are those which are never converted for any input value. In 8-bit or 10-bit mode, the
ADC10 is guaranteed to be monotonic and to have no missing codes.
LSB) is
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor51
Analog-to-Digital Converter (ADC10) Module
3.4 Interrupts
When AIEN is set, the ADC10 is capable of generating an interrupt request after each conversion. An
interrupt request is generated when the conversion completes (indicated by COCO being set). COCO will
set at the end of a conversion regardless of the state of AIEN.
3.5 Low-Power Modes
The WAIT and STOP instructions put the MCU in low power-consumption standby modes.
3.5.1 Wait Mode
The ADC10 will continue the conversion process and will generate an interrupt request following a
conversion if AIEN is set. If the ADC10 is not required in wait mode, power down the ADC by setting the
channel select bits (ADCH[4:0]) to all 1s to enter a low power state before executing the WAIT instruction.
3.5.2 Stop Mode
If ACLKEN is clear, executing a STOP instruction will abort the current conversion and place the ADC10
in a low-power state. Upon return from stop mode, a write to ADSCR is required to resume conversions,
and the result stored in ADRH and ADRL will represent the last completed conversion until the new
conversion completes.
If ACLKEN is set, the ADC10 continues normal operation during stop mode. The ADC10 will continue the
conversion process and will generate an interrupt following a conversion if AIEN is set. If the ADC10 is
not required to bring the MCU out of stop mode, ensure that the ADC10 is not in continuous conversion
mode by clearing ADCO in the ADC10 status and control register before executing the STOP instruction.
In single conversion mode the ADC10 automatically enters a low-power state when the conversion is
complete. It is not necessary to set the channel select bits (ADCH[4:0]) to all 1s to enter a low-power state.
If ACLKEN is set, a conversion can be initiated while in stop using the external hardware trigger
ADEXTCO when in external convert mode. The ADC10 will operate in a low-power mode until the trigger
is asserted, at which point it will perform a conversion and assert the interrupt when complete (if AIEN is
set).
3.6 ADC10 During Break Interrupts
The system integration module (SIM) controls whether status bits in other modules can be cleared during
the break state. BCFE in the break flag control register (BFCR) enables software to clear status bits during
the break state. See BFCR in the SIM section of this data sheet.
To allow software to clear status bits during a break interrupt, write a 1 to BCFE. If a status bit is cleared
during the break state, it remains cleared when the MCU exits the break state.
To protect status bits during the break state, write a 0 to BCFE. With BCFE cleared (its default state),
software can read and write registers during the break state without affecting status bits. Some status bits
have a two-step read/write clearing procedure. If software does the first step on such a bit before the
break, the bit cannot change during the break state as long as BCFE is cleared. After the break, doing the
second step clears the status bit.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
52Freescale Semiconductor
I/O Signals
3.7 I/O Signals
The ADC10 module shares its pins with general-purpose input/output (I/O) port pins. See Figure 3-1 for
port location of these shared pins. The ADC10 on this MCU uses V
pins. This MCU does not have an external trigger source.
and VSS as its supply and reference
DD
3.7.1 ADC10 Analog Power Pin (V
The ADC10 analog portion uses V
to V
. If externally available, connect the V
DD
may be necessary to ensure clean V
DDA
DDA
)
DDA
as its power pin. In some packages, V
pin to the same voltage potential as VDD. External filtering
DDA
for good results.
is connected internally
DDA
NOTE
If externally available, route V
carefully for maximum noise immunity
DDA
and place bypass capacitors as near as possible to the package.
3.7.2 ADC10 Analog Ground Pin (V
The ADC10 analog portion uses V
to V
. If externally available, connect the V
SS
as its ground pin. In some packages, V
SSA
SSA
)
SSA
pin to the same voltage potential as VSS.
SSA
is connected internally
In cases where separate power supplies are used for analog and digital power, the ground connection
between these supplies should be at the V
these supplies if possible. The V
pin makes a good single point ground location.
SSA
3.7.3 ADC10 Voltage Reference High Pin (V
V
V
potential as V
the V
is the power supply for setting the high-reference voltage for the converter. In some packages,
REFH
is connected internally to V
REFH
, or may be driven by an external source that is between the minimum V
DDA
potential (V
DDA
REFH
must never exceed V
. If externally available, V
DDA
pin. This should be the only ground connection between
SSA
)
REFH
may be connected to the same
REFH
spec and
DDA
).
DDA
NOTE
Route V
carefully for maximum noise immunity and place bypass
REFH
capacitors as near as possible to the package.
AC current in the form of current spikes required to supply charge to the capacitor array at each
successive approximation step is drawn through the V
REFH
and V
loop. The best external component
REFL
to meet this current demand is a 0.1 μF capacitor with good high frequency characteristics. This capacitor
is connected between V
REFH
and V
and must be placed as close as possible to the package pins.
REFL
Resistance in the path is not recommended because the current will cause a voltage drop which could
result in conversion errors. Inductance in this path must be minimum (parasitic only).
3.7.4 ADC10 Voltage Reference Low Pin (V
V
is the power supply for setting the low-reference voltage for the converter. In some packages,
REFL
is connected internally to V
V
REFL
potential as V
. There will be a brief current associated with V
SSA
charging. If externally available, connect the V
. If externally available, connect the V
SSA
REFL
)
REFL
REFL
when the sampling capacitor is
REFL
pin to the same potential as V
pin to the same voltage
at the single point
SSA
ground location.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor53
Analog-to-Digital Converter (ADC10) Module
3.7.5 ADC10 Channel Pins (ADn)
The ADC10 has multiple input channels. Empirical data shows that capacitors on the analog inputs
improve performance in the presence of noise or when the source impedance is high. 0.01 μF capacitors
with good high-frequency characteristics are sufficient. These capacitors are not necessary in all cases,
but when used they must be placed as close as possible to the package pins and be referenced to V
SSA
3.8 Registers
These registers control and monitor operation of the ADC10:
•ADC10 status and control register, ADSCR
•ADC10 data registers, ADRH and ADRL
•ADC10 clock register, ADCLK
3.8.1 ADC10 Status and Control Register
This section describes the function of the ADC10 status and control register (ADSCR). Writing ADSCR
aborts the current conversion and initiates a new conversion (if the ADCH[4:0] bits are equal to a value
other than all 1s).
.
Bit 7654321Bit 0
Read:COCO
Write:
Reset:00011111
AIENADCOADCH4ADCH3ADCH2ADCH1ADCH0
= Unimplemented
Figure 3-3. ADC10 Status and Control Register (ADSCR)
COCO — Conversion Complete Bit
COCO is a read-only bit which is set each time a conversion is completed. This bit is cleared whenever
the status and control register is written or whenever the data register (low) is read.
1 = Conversion completed
0 = Conversion not completed
AIEN — ADC10 Interrupt Enable Bit
When this bit is set, an interrupt is generated at the end of a conversion. The interrupt signal is cleared
when the data register is read or the status/control register is written.
When this bit is set, the ADC10 will begin to convert samples continuously (continuous conversion
mode) and update the result registers at the end of each conversion, provided ADCH[4:0] do not
decode to all 1s. The ADC10 will continue to convert until the MCU enters reset, the MCU enters stop
mode (if ACLKEN is clear), ADCLK is written, or until ADSCR is written again. If stop is entered (with
ACLKEN low), continuous conversions will cease and can be restarted only with a write to ADSCR.
Any write to ADSCR with ADCO set and the ADCH bits not all 1s will abort the current conversion and
begin continuous conversions.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
54Freescale Semiconductor
Registers
If the bus frequency is less than the ADCK frequency, precise sample time for continuous conversions
cannot be guaranteed in short-sample mode (ADLSMP = 0). If the bus frequency is less than 1/11th
of the ADCK frequency, precise sample time for continuous conversions cannot be guaranteed in
long-sample mode (ADLSMP = 1).
When clear, the ADC10 will perform a single conversion (single conversion mode) each time ADSCR
is written (assuming ADCH[4:0] do not decode all 1s).
1 = Continuous conversion following a write to ADSCR
0 = One conversion following a write to ADSCR
ADCH[4:0] — Channel Select Bits
The ADCH[4:0] bits form a 5-bit field that is used to select one of the input channels. The input
channels are detailed in Table 3-2. The successive approximation converter subsystem is turned off
when the channel select bits are all set to 1. This feature allows explicit disabling of the ADC10 and
isolation of the input channel from the I/O pad. Terminating continuous conversion mode this way will
prevent an additional, single conversion from being performed. It is not necessary to set the channel
select bits to all 1s to place the ADC10 in a low-power state, however, because the module is
automatically placed in a low-power state when a conversion completes.
Table 3-2. Input Channel Select
ADCH4ADCH3ADCH2ADCH1ADCH0
00000AD0
00001AD1
00010AD2
00011AD3
00100AD4
00101AD5
00110AD6
00111AD7
01000 Unused
Continuing throughUnused
10111 Unused
11000AD8
11001AD9
11010BANDGAP REF
11011 Reserved
11100 Reserved
11101 V
11110V
11111Low-power state
1. If any unused or reserved channels are selected, the resulting conversion will
be unknown.
2. Requires LVI to be powered (LVIPWRD =0, in CONFIG1)
Input Select
(1)
(2)
REFH
REFL
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor55
Analog-to-Digital Converter (ADC10) Module
3.8.2 ADC10 Result High Register (ADRH)
This register holds the MSBs of the result and is updated each time a conversion completes. All other bits
read as 0s. Reading ADRH prevents the ADC10 from transferring subsequent conversion results into the
result registers until ADRL is read. If ADRL is not read until the after next conversion is completed, then
the intermediate conversion result will be lost. In 8-bit mode, this register contains no interlocking with
ADRL.
Bit 7654321Bit 0
Read:00000000
Write:
Reset:00000000
= Unimplemented
Figure 3-4. ADC10 Data Register High (ADRH), 8-Bit Mode
Bit 7654321Bit 0
Read:000000AD9AD8
Write:
Reset:00000000
= Unimplemented
Figure 3-5. ADC10 Data Register High (ADRH), 10-Bit Mode
3.8.3 ADC10 Result Low Register (ADRL)
This register holds the LSBs of the result. This register is updated each time a conversion completes.
Reading ADRH prevents the ADC10 from transferring subsequent conversion results into the result
registers until ADRL is read. If ADRL is not read until the after next conversion is completed, then the
intermediate conversion result will be lost. In 8-bit mode, there is no interlocking with ADRH.
Bit 7654321Bit 0
Read:AD7AD6AD5AD4AD3AD2AD1AD0
Write:
Reset:00000000
= Unimplemented
Figure 3-6. ADC10 Data Register Low (ADRL)
3.8.4 ADC10 Clock Register (ADCLK)
This register selects the clock frequency for the ADC10 and the modes of operation.
Bit 7654321Bit 0
Read:
Write:
Reset:00000000
ADLPCADIV1ADIV0ADICLKMODE1MODE0ADLSMPACLKEN
Figure 3-7. ADC10 Clock Register (ADCLK)
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
56Freescale Semiconductor
Registers
ADLPC — ADC10 Low-Power Configuration Bit
ADLPC controls the speed and power configuration of the successive approximation converter. This
is used to optimize power consumption when higher sample rates are not required.
1 = Low-power configuration: The power is reduced at the expense of maximum clock speed.
0 = High-speed configuration
ADIV[1:0] — ADC10 Clock Divider Bits
ADIV1 and ADIV0 select the divide ratio used by the ADC10 to generate the internal clock ADCK.
Table 3-3 shows the available clock configurations.
Table 3-3. ADC10 Clock Divide Ratio
ADIV1ADIV0Divide Ratio (ADIV) Clock Rate
001Input clock ÷ 1
012Input clock ÷ 2
104Input clock ÷ 4
118Input clock ÷ 8
ADICLK — Input Clock Select Bit
If ACLKEN is clear, ADICLK selects either the bus clock or an alternate clock source as the input clock
source to generate the internal clock ADCK. If the alternate clock source is less than the minimum
clock speed, use the internally-generated bus clock as the clock source. As long as the internal clock
ADCK, which is equal to the selected input clock divided by ADIV, is at a frequency (f
ADCK
) between
the minimum and maximum clock speeds (considering ALPC), correct operation can be guaranteed.
1 = The internal bus clock is selected as the input clock source
0 = The alternate clock source is selected
MODE[1:0] — 10- or 8-Bit or Hardware Triggered Mode Selection
These bits select 10- or 8-bit operation. The successive approximation converter generates a result
that is rounded to 8- or 10-bit value based on the mode selection. This rounding process sets the
transfer function to transition at the midpoint between the ideal code voltages, causing a quantization
error of ± 1/2
This bit configures the sample time of the ADC10 to either 3.5 or 23.5 ADCK clock cycles. This adjusts
the sample period to allow higher impedance inputs to be accurately sampled or to maximize
conversion speed for lower impedance inputs. Longer sample times can also be used to lower overall
power consumption in continuous conversion mode if high conversion rates are not required.
1 = Long sample time (23.5 cycles)
0 = Short sample time (3.5 cycles)
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor57
Analog-to-Digital Converter (ADC10) Module
ACLKEN — Asynchronous Clock Source Enable
This bit enables the asynchronous clock source as the input clock to generate the internal clock ADCK,
and allows operation in stop mode. The asynchronous clock source will operate between 1 MHz and
2 MHz if ADLPC is clear, and between 0.5 MHz and 1 MHz if ADLPC is set.
1 = The asynchronous clock is selected as the input clock source (the clock generator is only
enabled during the conversion)
0 = ADICLK specifies the input clock source and conversions will not continue in stop mode
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
58Freescale Semiconductor
Chapter 4
Configuration Registers (CONFIG1 and CONFIG2)
4.1 Introduction
This section describes the configuration registers (CONFIG1 and CONFIG2). The configuration registers
enable or disable the following options:
•Stop mode recovery time (32 × BUSCLKX4 cycles or 4096 × BUSCLKX4 cycles)
•STOP instruction
•Computer operating properly module (COP)
•COP reset period (COPRS): 8176 × BUSCLKX4 or 262,128 × BUSCLKX4
•Low-voltage inhibit (LVI) enable and trip voltage selection
•Allow clock source to remain enabled in STOP
•Enable IRQ
•Disable IRQ
•Enable RST
•Clock source selection for the enhanced serial communication interface (ESCI) module
•Reposition TIM2 timer channels
4.2 Functional Description
pin
pin pullup device
pin
The configuration registers are used in the initialization of various options. The configuration registers can
be written once after each reset. Most of the configuration register bits are cleared during reset. Since the
various options affect the operation of the microcontroller unit (MCU) it is recommended that this register
be written immediately after reset. The configuration registers are located at $001E and $001F, and may
be read at anytime.
NOTE
The CONFIG registers are one-time writable by the user after each reset.
Upon a reset, the CONFIG registers default to predetermined settings as
shown in Figure 4-1 and Figure 4-2.
Bit 7654321Bit 0
Read:
IRQPUDIRQEN
Write:
Reset:000 0 0 0 0U
POR:000 0 0 0 00
= Unimplemented U = Unaffected
00
TIM2POS ESCIBDSRC
OSCENIN
STOP
RSTEN
Figure 4-1. Configuration Register 2 (CONFIG2)
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor59
Configuration Registers (CONFIG1 and CONFIG2)
IRQPUD — IRQ Pin Pullup Control Bit
1 = Internal pullup is disconnected
0 = Internal pullup is connected between IRQ
pin and V
DD
IRQEN — IRQ Pin Function Selection Bit
1 = Interrupt request function active in pin
0 = Interrupt request function inactive in pin
TIM2POS — TIM2 Position Bit
TIM2POS is used to reposition the timer channels for TIM2 to a different pair of pins. This allows the
user to free up one of the communication ports based on application needs.
1 = TIM2 timer channel pins share PTB4 and PTB5
0 = TIM2 timer channel pins share PTB1 and PTB2
ESCIBDSRC — ESCI Baud Rate Clock Source Bit
ESCIBDSRC controls the clock source used for the ESCI. The setting of the bit affects the frequency
at which the ESCI operates.
1 = Internal data bus clock used as clock source for ESCI
0 = BUSCLKX4 used as clock source for ESCI
OSCENINSTOP— Oscillator Enable in Stop Mode Bit
OSCENINSTOP, when set, will allow the clock source to continue to generate clocks in stop mode.
This function can be used to keep the periodic wakeup running while the rest of the microcontroller
stops. When clear, the clock source is disabled when the microcontroller enters stop mode.
1 = Oscillator enabled to operate during stop mode
0 = Oscillator disabled during stop mode
RSTEN — RST
Pin Function Selection
1 = Reset function active in pin
0 = Reset function inactive in pin
The RSTEN bit is cleared by a power-on reset (POR) only. Other resets will
leave this bit unaffected.
Bit 7654321Bit 0
Read:
Write:
Reset:0000U000
COPRSLVISTOPLVIRSTDLVIPWRDLVITRIPSSRECSTOPCOPD
POR:00000000
U = Unaffected
Figure 4-2. Configuration Register 1 (CONFIG1)
COPRS — COP Reset Period Selection Bit
1 = COP reset short cycle = 8176 × BUSCLKX4
0 = COP reset long cycle = 262,128 × BUSCLKX4
NOTE
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
60Freescale Semiconductor
Functional Description
LVISTOP — LVI Enable in Stop Mode Bit
When the LVIPWRD bit is clear, setting the LVISTOP bit enables the LVI to operate during stop mode.
Reset clears LVISTOP.
1 = LVI enabled during stop mode
0 = LVI disabled during stop mode
LVIRSTD — LVI Reset Disable Bit
LVIRSTD disables the reset signal from the LVI module.
1 = LVI module power disabled
0 = LVI module power enabled
LVITRIP — LVI Trip Point Selection Bit
LVITRIP selects the voltage operating mode of the LVI module. The voltage mode selected for the LVI
should match the operating V
for the LVI’s voltage trip points for each of the modes.
DD
1 = LVI operates for a 5-V protection
0 = LVI operates for a 3.3-V protection
NOTE
The LVITRIP bit is cleared by a power-on reset (POR) only. Other resets
will leave this bit unaffected.
SSREC — Short Stop Recovery Bit
SSREC enables the CPU to exit stop mode with a delay of 32 BUSCLKX4 cycles instead of a 4096
BUSCLKX4 cycle delay.
1 = Stop mode recovery after 32 BUSCLKX4 cycles
0 = Stop mode recovery after 4096 BUSCLKX4 cycles
NOTE
Exiting stop mode by an LVI reset will result in the long stop recovery.
When using the LVI during normal operation but disabling during stop mode, the LVI will have an
enable time of t
. The system stabilization time for power-on reset and long stop recovery (both 4096
EN
BUSCLKX4 cycles) gives a delay longer than the LVI enable time for these startup scenarios. There
is no period where the MCU is not protected from a low-power condition. However, when using the
short stop recovery configuration option, the 32 BUSCLKX4 delay must be greater than the LVI’s turn
on time to avoid a period in startup where the LVI is not protecting the MCU.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor61
Configuration Registers (CONFIG1 and CONFIG2)
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
62Freescale Semiconductor
Chapter 5
1. See Chapter 14 System Integration Module (SIM) for more details.
COPCTL WRITE
BUSCLKX4
STOP INSTRUCTION
SIM RESET CIRCUIT
RESET STATUS REGISTER
INTERNAL RESET SOURCES
(1)
SIM MODULE
CLEAR STAGES 5–12
12-BIT SIM COUNTER
CLEAR ALL STAGES
COPD (FROM CONFIG1)
RESET
COPCTL WRITE
CLEAR
COP MODULE
COPEN (FROM SIM)
COP CLOCK
COP TIMEOUT
COP RATE SELECT
(COPRS FROM CONFIG1)
6-BIT COP COUNTER
COP COUNTER
Computer Operating Properly (COP)
5.1 Introduction
The computer operating properly (COP) module contains a free-running counter that generates a reset if
allowed to overflow. The COP module helps software recover from runaway code. Prevent a COP reset
by clearing the COP counter periodically. The COP module can be disabled through the COPD bit in the
configuration 1 (CONFIG1) register.
5.2 Functional Description
Freescale Semiconductor63
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Figure 5-1. COP Block Diagram
Computer Operating Properly (COP)
The COP counter is a free-running 6-bit counter preceded by the 12-bit system integration module (SIM)
counter. If not cleared by software, the COP counter overflows and generates an asynchronous reset after
262,128 or 8176 BUSCLKX4 cycles; depending on the state of the COP rate select bit, COPRS, in
configuration register 1. With a 262,128 BUSCLKX4 cycle overflow option, the internal 12.8-MHz
oscillator gives a COP timeout period of 20.48 ms. Writing any value to location $FFFF before an overflow
occurs prevents a COP reset by clearing the COP counter and stages 12–5 of the SIM counter.
NOTE
Service the COP immediately after reset and before entering or after exiting
stop mode to guarantee the maximum time before the first COP counter
overflow.
A COP reset pulls the RST
cycles and sets the COP bit in the reset status register (RSR). See 14.8.1 SIM Reset Status Register.
Place COP clearing instructions in the main program and not in an interrupt
subroutine. Such an interrupt subroutine could keep the COP from
generating a reset even while the main program is not working properly.
pin low (if the RSTEN bit is set in the CONFIG1 register) for 32 × BUSCLKX4
NOTE
5.3 I/O Signals
The following paragraphs describe the signals shown in Figure 5-1.
5.3.1 BUSCLKX4
BUSCLKX4 is the oscillator output signal. BUSCLKX4 frequency is equal to the crystal frequency, internal
oscillator frequency, or the RC-oscillator frequency.
5.3.2 STOP Instruction
The STOP instruction clears the SIM counter.
5.3.3 COPCTL Write
Writing any value to the COP control register (COPCTL) (see 5.4 COP Control Register) clears the COP
counter and clears stages 12–5 of the SIM counter. Reading the COP control register returns the low byte
of the reset vector.
5.3.4 Power-On Reset
The power-on reset (POR) circuit in the SIM clears the SIM counter 4096 × BUSCLKX4 cycles after power
up.
5.3.5 Internal Reset
An internal reset clears the SIM counter and the COP counter.
5.3.6 COPD (COP Disable)
The COPD signal reflects the state of the COP disable bit (COPD) in the configuration register (CONFIG).
See Chapter 4 Configuration Registers (CONFIG1 and CONFIG2).
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
64Freescale Semiconductor
COP Control Register
5.3.7 COPRS (COP Rate Select)
The COPRS signal reflects the state of the COP rate select bit (COPRS) in the configuration register 1
(CONFIG1). See Chapter 4 Configuration Registers (CONFIG1 and CONFIG2).
5.4 COP Control Register
The COP control register (COPCTL) is located at address $FFFF and overlaps the reset vector. Writing
any value to $FFFF clears the COP counter and starts a new timeout period. Reading location $FFFF
returns the low byte of the reset vector.
Bit 7654321Bit 0
Read:LOW BYTE OF RESET VECTOR
Write:CLEAR COP COUNTER
Reset:Unaffected by reset
Figure 5-2. COP Control Register (COPCTL)
5.5 Interrupts
The COP does not generate CPU interrupt requests.
5.6 Monitor Mode
The COP is disabled in monitor mode when V
is present on the IRQ pin.
TST
5.7 Low-Power Modes
The WAIT and STOP instructions put the MCU in low power-consumption standby modes.
5.7.1 Wait Mode
The COP continues to operate during wait mode. To prevent a COP reset during wait mode, periodically
clear the COP counter.
5.7.2 Stop Mode
Stop mode turns off the BUSCLKX4 input to the COP and clears the SIM counter. Service the COP
immediately before entering or after exiting stop mode to ensure a full COP timeout period after entering
or exiting stop mode.
5.8 COP Module During Break Mode
The COP is disabled during a break interrupt with monitor mode when BDCOP bit is set in break auxiliary
register (BRKAR).
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor65
Computer Operating Properly (COP)
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
66Freescale Semiconductor
Chapter 6
Central Processor Unit (CPU)
6.1 Introduction
The M68HC08 CPU (central processor unit) is an enhanced and fully object-code-compatible version of
the M68HC05 CPU. The CPU08 Reference Manual (document order number CPU08RM/AD) contains a
description of the CPU instruction set, addressing modes, and architecture.
6.2 Features
Features of the CPU include:
•Object code fully upward-compatible 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
•Low-power stop and wait modes
6.3 CPU Registers
Figure 6-1 shows the five CPU registers. CPU registers are not part of the memory map.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor67
Central Processor Unit (CPU)
ACCUMULATOR (A)
INDEX REGISTER (H:X)
STACK POINTER (SP)
PROGRAM COUNTER (PC)
CONDITION CODE REGISTER (CCR)
CARRY/BORROW FLAG
ZERO FLAG
NEGATIVE FLAG
INTERRUPT MASK
HALF-CARRY FLAG
TWO’S COMPLEMENT OVERFLOW FLAG
V11HINZC
HX
0
0
0
0
7
15
15
15
70
6.3.1 Accumulator
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)
6.3.2 Index Register
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.
The index register can serve also as a temporary data storage location.
Bit
151413121110987654321
Read:
Write:
Reset:00000000XXXXXXXX
X = Indeterminate
Figure 6-3. Index Register (H:X)
Bit
0
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
68Freescale Semiconductor
CPU Registers
6.3.3 Stack Pointer
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 sets the least
significant byte to $FF and 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
random-access memory (RAM). Moving the SP out of page 0 ($0000 to
$00FF) frees direct address (page 0) space. For correct operation, the
stack pointer must point only to RAM locations.
6.3.4 Program Counter
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)
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor69
Central Processor Unit (CPU)
6.3.5 Condition Code Register
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 1. The following paragraphs describe the
functions of the condition code register.
Bit 7654321Bit 0
Read:
Write:
Reset:X11X1XXX
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-without-carry (ADD) or add-with-carry (ADC) operation. The half-carry 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
V11HI NZC
X = Indeterminate
Figure 6-6. Condition Code Register (CCR)
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 Family 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 be cleared only 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
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
70Freescale Semiconductor
Arithmetic/Logic Unit (ALU)
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
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.4 Arithmetic/Logic Unit (ALU)
The ALU performs the arithmetic and logic operations defined by the instruction set.
Refer to the CPU08 Reference Manual (document order number CPU08RM/AD) for a description of the
instructions and addressing modes and more detail about the architecture of the CPU.
6.5 Low-Power Modes
The WAIT and STOP instructions put the MCU in low power-consumption standby modes.
6.5.1 Wait Mode
The WAIT instruction:
•Clears the interrupt mask (I bit) in the condition code register, enabling interrupts. After exit from
wait mode by interrupt, the I bit remains clear. After exit by reset, the I bit is set.
•Disables the CPU clock
6.5.2 Stop Mode
The STOP instruction:
•Clears the interrupt mask (I bit) in the condition code register, enabling external interrupts. After
exit from stop mode by external interrupt, the I bit remains clear. After exit by reset, the I bit is set.
•Disables the CPU clock
After exiting stop mode, the CPU clock begins running after the oscillator stabilization delay.
6.6 CPU During Break Interrupts
If a break module is present on the MCU, the CPU starts a break interrupt by:
•Loading the instruction register with the SWI instruction
•Loading the program counter with $FFFC:$FFFD or with $FEFC:$FEFD in monitor mode
The break interrupt begins after completion of the CPU instruction in progress. If the break address
register match occurs on the last cycle of a CPU instruction, the break interrupt begins immediately.
A return-from-interrupt instruction (RTI) in the break routine ends the break interrupt and returns the MCU
to normal operation if the break interrupt has been deasserted.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor71
Central Processor Unit (CPU)
C
b0
b7
0
b0
b7
C
6.7 Instruction Set Summary
Table 6-1 provides a summary of the M68HC08 instruction set.
X ← –(X) = $00 – (X)
M ← –(M) = $00 – (M)
M ← –(M) = $00 – (M)
← (M)
Source
on CCR
VH I NZC
––––––
––
0–––
––
DIR
EXT
IX2
IX1
IX
DIR
EXT
IX2
IX1
IX
IMM
DIR
EXT
IX2
IX1
IX
SP1
SP2
IMM
DIR
IMM
DIR
EXT
IX2
IX1
IX
SP1
SP2
DIR
INH
INH
IX1
IX
SP1
DIR
INH
INH
IX1
IX
SP1
DD
DIX+
IMD
IX+D
DIR
INH
INH
IX1
IX
SP1
IMM
DIR
EXT
IX2
IX1
IX
SP1
SP2
Address
Mode
Opcode
Operand
BC
dd
CC
hh ll
DC
ee ff
EC
ff
FC
BD
dd
CD
hh ll
DD
ee ff
ED
ff
FD
A6
ii
B6
dd
C6
hh ll
D6
ee ff
E6
ff
F6
9EE6
ff
9ED6
ee ff
4555ii jjdd3
AE
ii
BE
dd
CE
hh ll
DE
ee ff
EE
ff
FE
9EEE
ff
9EDE
ee ff
38
dd
48
58
68
ff
78
9E68
ff
34
dd
44
54
64
ff
74
9E64
ff
4E
dd dd
5E
dd
6E
ii dd
7E
dd
30
dd
40
50
60
ff
70
9E60
ff
AA
ii
BA
dd
hh ll
CA
ee ff
DA
ff
EA
FA
ff
9EEA
ee ff
9EDA
2
3
4
3
2
4
5
6
5
4
2
3
4
4
3
2
4
5
4
2
3
4
4
3
2
4
5
4
1
1
4
3
5
4
1
1
4
3
5
5
4
4
4
4
1
1
4
3
5
2
3
4
4
3
2
4
5
Cycles
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor75
Central Processor Unit (CPU)
C
b0
b7
b0
b7
C
Table 6-1. Instruction Set Summary (Sheet 5 of 6)
Effect
Source
Form
PULAPull A from StackSP ← (SP + 1); Pull (A)––––––INH862
PULHPull H from StackSP ← (SP + 1); Pull (H)––––––INH8A2
PULXPull X from StackSP ← (SP + 1); Pull (X)––––––INH882
ROL opr
SUB #opr
SUB opr
SUB opr
SUB opr,X
SUB opr,X
SUB ,X
SUB opr,SP
SUB opr,SP
Rotate Left through Carry ––
Rotate Right through Carry ––
Subtract with Carry A ← (A) – (M) – (C) ––
Store A in MM ← (A)0–––
Enable Interrupts, Stop Processing,
Refer to MCU Documentation
Store X in MM ← (X)0–––
Subtract A ← (A) – (M) ––
OperationDescription
SP ← (SP) + 1; Pull (CCR)
SP ← (SP) + 1; Pull (A)
SP ← (SP) + 1; Pull (X)
SP ←
(SP) + 1; Pull (PCH)
SP ← (SP) + 1; Pull (PCL)
SP ← SP + 1; Pull (PCH)
SP ← SP + 1; Pull (PCL)
I ← 0; Stop Processing––0–––INH8E1
on CCR
VH I NZC
INH807
––––––INH814
DIR
INH
INH
IX1
IX
SP1
DIR
INH
INH
IX1
IX
SP1
IMM
DIR
EXT
IX2
IX1
IX
SP1
SP2
DIR
EXT
IX2
IX1
IX
SP1
SP2
DIR
EXT
IX2
IX1
IX
SP1
SP2
IMM
DIR
EXT
IX2
IX1
IX
SP1
SP2
Address
Mode
9E69
9E66
9EE2
9ED2
9EE7
9ED7
9EEF
9EDF
9EE0
9ED0
39
49
59
69
79
36
46
56
66
76
A2
B2
C2
D2
E2
F2
B7
C7
D7
E7
F7
BF
CF
DF
EF
FF
A0
B0
C0
D0
E0
F0
Opcode
dd
ff
ff
dd
ff
ff
ii
dd
hh ll
ee ff
ff
ff
ee ff
dd
hh ll
ee ff
ff
ff
ee ff
dd
hh ll
ee ff
ff
ff
ee ff
ii
dd
hh ll
ee ff
ff
ff
ee ff
Operand
Cycles
4
1
1
4
3
5
4
1
1
4
3
5
2
3
4
4
3
2
4
5
3
4
4
3
2
4
5
3
4
4
3
2
4
5
2
3
4
4
3
2
4
5
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
76Freescale Semiconductor
Opcode Map
Table 6-1. Instruction Set Summary (Sheet 6 of 6)
Effect
Source
Form
SWISoftware Interrupt
TAPTransfer A to CCRCCR ← (A)INH842
TAXTransfer A to XX ← (A)––––––INH971
TPATransfer CCR to AA ← (CCR)––––––INH851
TST opr
TSTA
TSTX
TST opr,X
TST ,X
TST opr,SP
TSXTransfer SP to H:XH:X ← (SP) + 1––––––INH952
TXATransfer X to AA ← (X)––––––INH9F1
TXSTransfer H:X to SP(SP) ← (H:X) – 1––––––INH942
WAITEnable Interrupts; Wait for Interrupt
AAccumulatornAny bit
CCarry/borrow bitoprOperand (one or two bytes)
CCRCondition code registerPC Program counter
ddDirect address of operandPCH Program counter high byte
dd rrDirect address of operand and relative offset of branch instructionPCL Program counter low byte
DDDirect to direct addressing modeREL Relative addressing mode
DIRDirect addressing moderelRelative program counter offset byte
DIX+Direct to indexed with post increment addressing moderrRelative program counter offset byte
ee ffHigh and low bytes of offset in indexed, 16-bit offset addressingSP1 Stack pointer, 8-bit offset addressing mode
EXTExtended addressing modeSP2 Stack pointer 16-bit offset addressing mode
ffOffset byte in indexed, 8-bit offset addressingSPStack pointer
HHalf-carry bitUUndefined
HIndex register high byteVOverflow bit
hh llHigh and low bytes of operand address in extended addressingXIndex register low byte
IInterrupt maskZZero bit
iiImmediate operand byte&Logical AND
IMDImmediate source to direct destination addressing mode|Logical OR
IMMImmediate addressing mode
INHInherent addressing mode( )Contents of
IXIndexed, no offset addressing mode–( ) Negation (two’s complement)
IX+Indexed, no offset, post increment addressing mode#Immediate value
IX+DIndexed with post increment to direct addressing mode
IX1Indexed, 8-bit offset addressing mode←Loaded with
IX1+Indexed, 8-bit offset, post increment addressing mode?If
IX2Indexed, 16-bit offset addressing mode:Concatenated with
MMemory locationSet or cleared
NNegative bit—Not affected
Test for Negative or Zero(A) – $00 or (X) – $00 or (M) – $000 – – –
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
78Freescale Semiconductor
Chapter 7
External Interrupt (IRQ)
7.1 Introduction
The IRQ (external interrupt) module provides a maskable interrupt input.
functionality is enabled by setting configuration register 2 (CONFIG2) IRQEN bit accordingly. A zero
IRQ
disables the IRQ function and IRQ
function. See Chapter 4 Configuration Registers (CONFIG1 and CONFIG2) for more information on
enabling the IRQ pin.
The IRQ pin shares its pin with general-purpose input/output (I/O) port pins. See Figure 7-1 for port
location of this shared pin.
7.2 Features
Features of the IRQ module include:
•A dedicated external interrupt pin IRQ
•IRQ interrupt control bits
•Programmable edge-only or edge and level interrupt sensitivity
•Automatic interrupt acknowledge
•Internal pullup device
will assume the other shared functionalities. A one enables the IRQ
7.3 Functional Description
A low level applied to the external interrupt request (IRQ) pin can latch a CPU interrupt request. Figure 7-2
shows the structure of the IRQ module.
Interrupt signals on the IRQ
following actions occurs:
•IRQ vector fetch. An IRQ vector fetch automatically generates an interrupt acknowledge signal that
clears the latch that caused the vector fetch.
•Software clear. Software can clear the IRQ latch by writing a 1 to the ACK bit in the interrupt status
and control register (INTSCR).
•Reset. A reset automatically clears the IRQ latch.
The external IRQ
edge or falling edge and low level sensitive. The MODE bit in INTSCR controls the triggering sensitivity
of the IRQ
pin.
pin is falling edge sensitive out of reset and is software-configurable to be either falling
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
pin are latched into the IRQ latch. The IRQ latch remains set until one of the
Freescale Semiconductor79
External Interrupt (IRQ)
All port pins can be configured with internal pullup
PTC not available on 16-pin devices (see note in 11.1 Introduction)
PTD not available on 16-pin or 20-pin devices (see note in 11.1 Introduction)
PTA0/T1CH0/AD0/KBI0
PTA1/T1CH1/AD1/KBI1
PTA2/IRQ
/KBI2/T1CLK
PTA3/RST/KBI3
PTA4/OSC2/AD2/KBI4
PTA5/OSC1/AD3/KBI5
4-CHANNEL 16-BIT
TIMER MODULE
KEYBOARD INTERRUPT
MODULE
SINGLE INTERRUPT
MODULE
PERIODIC WAKEUP
LOW-VOLTAGE
INHIBIT
COP
MODULE
10-CHANNEL
10-BIT ADC
ENHANCED SERIAL
PTB0/SPSCK/AD4
PTB
DDRB
M68HC08 CPU
PTA
DDRA
PTB1/MOSI/T2CH1/AD5
PTB2/MISO/T2CH0/AD6
PTB3/SS
/T2CLK/AD7
PTB4/RxD/T2CH0/AD8
PTB5/TxD/T2CH1/AD9
PTB6/T1CH2
PTB7/T1CH3
POWER SUPPLY
V
DD
V
SS
CLOCK
GENERATOR
COMMUNICATIONS
INTERFACE MODULE
MODULE
SERIAL PERIPHERAL
INTERFACE
16,384 BYTES
MC68HC908QC16
8192 BYTES
MC68HC908QC8
512 BYTES
MC68HC908QC16
384 BYTES
MC68HC908QC8
BREAK
MODULE
MONITOR ROM
2-CHANNEL 16-BIT
TIMER MODULE
PTC0
PTC1
PTC2
PTC3
PTC
DDRC
PTD0
PTD
DDRD
PTD1
PTD2
PTD3
PTD4
PTD5
PTD6
PTD7
MC68HC908QC4
USER RAM
USER FLASH
4096 BYTES
384 BYTES
MC68HC908QC4
Figure 7-1. Block Diagram Highlighting IRQ Block and Pin
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
80Freescale Semiconductor
Functional Description
IMASK
DQ
CK
CLR
IRQ
HIGH
INTERRUPT
TO MODE
SELECT
LOGIC
REQUEST
V
DD
MODE
VOLTAGE
DETECT
IRQF
TO CPU FOR
BIL/BIH
INSTRUCTIONS
INTERNAL ADDRESS BUS
RESET
V
DD
INTERNAL
PULLUP
DEVICE
ACK
IRQ
SYNCHRONIZER
IRQ VECTOR
FETCH
DECODER
IRQ LATCH
When set, the IMASK bit in INTSCR masks the IRQ interrupt request. A latched interrupt request is not
presented to the interrupt priority logic unless IMASK is clear.
NOTE
The interrupt mask (I) in the condition code register (CCR) masks all
interrupt requests, including the IRQ
interrupt request.
A falling edge on the IRQ
pin can latch an interrupt request into the IRQ latch. An IRQ vector fetch,
software clear, or reset clears the IRQ latch.
Figure 7-2. IRQ Module Block Diagram
7.3.1 MODE = 1
If the MODE bit is set, the IRQ pin is both falling edge sensitive and low level sensitive. With MODE set,
both of the following actions must occur to clear the IRQ
•Return of the IRQ
•IRQ vector fetch or software clear. An IRQ vector fetch generates an interrupt acknowledge signal
The IRQ vector fetch or software clear and the return of the IRQ
The interrupt request remains pending as long as the IRQ
the MODE control bit, thereby clearing the interrupt even if the pin stays low.
Use the BIH or BIL instruction to read the logic level on the IRQ
Freescale Semiconductor81
interrupt request:
pin to a high level. As long as the IRQ pin is low, the IRQ request remains active.
to clear the IRQ latch. Software generates the interrupt acknowledge signal by writing a 1 to ACK
in INTSCR. The ACK bit is useful in applications that poll the IRQ
the IRQ latch. Writing to ACK prior to leaving an interrupt service routine can also prevent spurious
interrupts due to noise. Setting ACK does not affect subsequent transitions on the IRQ
edge that occurs after writing to ACK latches another interrupt request. If the IRQ mask bit, IMASK,
is clear, the CPU loads the program counter with the IRQ vector address.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
pin to a high level may occur in any order.
pin is low. A reset will clear the IRQ latch and
pin.
pin and require software to clear
pin. A falling
External Interrupt (IRQ)
7.3.2 MODE = 0
If the MODE bit is clear, the IRQ pin is falling edge sensitive only. With MODE clear, an IRQ vector fetch
or software clear immediately clears the IRQ latch.
The IRQF bit in INTSCR can be read to check for pending interrupts. The IRQF bit is not affected by
IMASK, which makes it useful in applications where polling is preferred.
NOTE
When using the level-sensitive interrupt trigger, avoid false IRQ interrupts
by masking interrupt requests in the interrupt routine.
7.4 Interrupts
The following IRQ source can generate interrupt requests:
•Interrupt flag (IRQF) — The IRQF bit is set when the IRQ
The IRQ interrupt mask bit, IMASK, is used to enable or disable IRQ interrupt requests.
pin is asserted based on the IRQ mode.
7.5 Low-Power Modes
The WAIT and STOP instructions put the MCU in low power-consumption standby modes.
7.5.1 Wait Mode
The IRQ module remains active in wait mode. Clearing IMASK in INTSCR enables IRQ interrupt requests
to bring the MCU out of wait mode.
7.5.2 Stop Mode
The IRQ module remains active in stop mode. Clearing IMASK in INTSCR enables IRQ interrupt requests
to bring the MCU out of stop mode.
7.6 IRQ Module During Break Interrupts
The system integration module (SIM) controls whether status bits in other modules can be cleared during
the break state. The BCFE bit in the break flag control register (BFCR) enables software to clear status
bits during the break state. See BFCR in the SIM section of this data sheet.
To allow software to clear status bits during a break interrupt, write a 1 to BCFE. If a status bit is cleared
during the break state, it remains cleared when the MCU exits the break state.
To protect status bits during the break state, write a 0 to BCFE. With BCFE cleared (its default state),
software can read and write registers during the break state without affecting status bits. Some status bits
have a two-step read/write clearing procedure. If software does the first step on such a bit before the
break, the bit cannot change during the break state as long as BCFE is cleared. After the break, doing the
second step clears the status bit.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
82Freescale Semiconductor
I/O Signals
7.7 I/O Signals
The IRQ module does not share its pin with any module on this MCU.
7.7.1 IRQ Input Pins (IRQ)
The IRQ pin provides a maskable external interrupt source. The IRQ pin contains an internal pullup
device.
7.8 Registers
The IRQ status and control register (INTSCR) controls and monitors operation of the IRQ module. The
INTSCR:
•Shows the state of the IRQ flag
•Clears the IRQ latch
•Masks the IRQ interrupt request
•Controls triggering sensitivity of the IRQ
Bit 7654321Bit 0
Read:0000IRQF0
Write:
Reset:00000000
= Unimplemented
interrupt pin
ACK
IMASKMODE
Figure 7-3. IRQ Status and Control Register (INTSCR)
IRQF — IRQ Flag Bit
This read-only status bit is set when the IRQ interrupt is pending.
1 = IRQ
0 = IRQ
interrupt pending
interrupt not pending
ACK — IRQ Interrupt Request Acknowledge Bit
Writing a 1 to this write-only bit clears the IRQ latch. ACK always reads 0.
IMASK — IRQ Interrupt Mask Bit
Writing a 1 to this read/write bit disables the IRQ interrupt request.
This read/write bit controls the triggering sensitivity of the IRQ
1 = IRQ
0 = IRQ
interrupt request on falling edges and low levels
interrupt request on falling edges only
pin.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor83
External Interrupt (IRQ)
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
84Freescale Semiconductor
Chapter 8
KBI LATCH
KEYBOARD
INTERRUPT
REQUEST
ACKK
INTERNAL BUS
RESET
KBIE0
KBI0
0
1
S
KBIP0
KBIEx
KBIx
0
1
S
KBIPx
DQ
CK
CLR
V
DD
MODEK
IMASKK
SYNCHRONIZER
KEYF
TO PULLUP/
TO PULLUP/
PULLDOWN ENABLE
PULLDOWN ENABLE
VECTOR FETCH
DECODER
Keyboard Interrupt Module (KBI)
8.1 Introduction
The keyboard interrupt module (KBI) provides independently maskable external interrupts. The KBI
shares its pins with general-purpose input/output (I/O) port pins. See Figure 8-2 for port location of these
shared pins.
8.2 Features
Features of the keyboard interrupt module include:
•Keyboard interrupt pins with separate keyboard interrupt enable bits and one keyboard interrupt
mask
•Programmable edge-only or edge and level interrupt sensitivity
•Edge sensitivity programmable for rising or falling edge
•Level sensitivity programmable for high or low level
•Pullup or pulldown device automatically enabled based on the polarity of edge or level detect
•Exit from low-power modes
8.3 Functional Description
The keyboard interrupt module controls the enabling/disabling of interrupt functions on the KBI pins.
These pins can be enabled/disabled independently of each other.
Figure 8-1. Keyboard Interrupt Block Diagram
Freescale Semiconductor85
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Keyboard Interrupt Module (KBI)
All port pins can be configured with internal pullup
PTC not available on 16-pin devices (see note in 11.1 Introduction)
PTD not available on 16-pin or 20-pin devices (see note in 11.1 Introduction)
PTA0/T1CH0/AD0/KBI0
PTA1/T1CH1/AD1/KBI1
PTA2/IRQ
/KBI2/T1CLK
PTA3/RST
/KBI3
PTA4/OSC2/AD2/KBI4
PTA5/OSC1/AD3/KBI5
4-CHANNEL 16-BIT
TIMER MODULE
KEYBOARD INTERRUPT
MODULE
SINGLE INTERRUPT
MODULE
PERIODIC WAKEUP
LOW-VOLTAGE
INHIBIT
COP
MODULE
10-CHANNEL
10-BIT ADC
ENHANCED SERIAL
PTB0/SPSCK/AD4
PTB
DDRB
M68HC08 CPU
PTA
DDRA
PTB1/MOSI/T2CH1/AD5
PTB2/MISO/T2CH0/AD6
PTB3/SS
/T2CLK/AD7
PTB4/RxD/T2CH0/AD8
PTB5/TxD/T2CH1/AD9
PTB6/T1CH2
PTB7/T1CH3
POWER SUPPLY
V
DD
V
SS
CLOCK
GENERATOR
COMMUNICATIONS
INTERFACE MODULE
MODULE
SERIAL PERIPHERAL
INTERFACE
16,384 BYTES
MC68HC908QC16
8192 BYTES
MC68HC908QC8
512 BYTES
MC68HC908QC16
384 BYTES
MC68HC908QC8
BREAK
MODULE
MONITOR ROM
2-CHANNEL 16-BIT
TIMER MODULE
PTC0
PTC1
PTC2
PTC3
PTC
DDRC
PTD0
PTD
DDRD
PTD1
PTD2
PTD3
PTD4
PTD5
PTD6
PTD7
MC68HC908QC4
USER RAM
USER FLASH
4096 BYTES
384 BYTES
MC68HC908QC4
Figure 8-2. Block Diagram Highlighting KBI Block and Pins
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
86Freescale Semiconductor
Functional Description
8.3.1 Keyboard Operation
Writing to the KBIEx bits in the keyboard interrupt enable register (KBIER) independently enables or
disables each KBI pin. The polarity of the keyboard interrupt is controlled using the KBIPx bits in the
keyboard interrupt polarity register (KBIPR). Edge-only or edge and level sensitivity is controlled using the
MODEK bit in the keyboard status and control register (KBISCR).
Enabling a keyboard interrupt pin also enables its internal pullup or pulldown device based on the polarity
enabled. On falling edge or low level detection, a pullup device is configured. On rising edge or high level
detection, a pulldown device is configured.
The keyboard interrupt latch is set when one or more enabled keyboard interrupt inputs are asserted.
•If the keyboard interrupt sensitivity is edge-only, for KBIPx = 0, a falling (for KBIPx = 1, a rising) edge
on a keyboard interrupt input does not latch an interrupt request if another enabled keyboard pin is
already asserted. To prevent losing an interrupt request on one input because another input remains
asserted, software can disable the latter input while it is asserted.
•If the keyboard interrupt is edge and level sensitive, an interrupt request is present as long as any
enabled keyboard interrupt input is asserted.
8.3.1.1 MODEK = 1
If the MODEK bit is set, the keyboard interrupt inputs are both edge and level sensitive. The KBIPx bit will
determine whether a edge sensitive pin detects rising or falling edges and on level sensitive pins whether
the pin detects low or high levels. With MODEK set, both of the following actions must occur to clear a
keyboard interrupt request:
•Return of all enabled keyboard interrupt inputs to a deasserted level. As long as any enabled
keyboard interrupt pin is asserted, the keyboard interrupt remains active.
•Vector fetch or software clear. A KBI vector fetch generates an interrupt acknowledge signal to clear
the KBI latch. Software generates the interrupt acknowledge signal by writing a 1 to ACKK in KBSCR.
The ACKK bit is useful in applications that poll the keyboard interrupt inputs and require software to
clear the KBI latch. Writing to ACKK prior to leaving an interrupt service routine can also prevent
spurious interrupts due to noise. Setting ACKK does not affect subsequent transitions on the
keyboard interrupt inputs. An edge detect that occurs after writing to ACKK latches another interrupt
request. If the keyboard interrupt mask bit, IMASKK, is clear, the CPU loads the program counter with
the KBI vector address.
The KBI vector fetch or software clear and the return of all enabled keyboard interrupt pins to a deasserted
level may occur in any order.
Reset clears the keyboard interrupt request and the MODEK bit, clearing the interrupt request even if a
keyboard interrupt input stays asserted.
8.3.1.2 MODEK = 0
If the MODEK bit is clear, the keyboard interrupt inputs are edge sensitive. The KBIPx bit will determine
whether an edge sensitive pin detects rising or falling edges. A KBI vector fetch or software clear
immediately clears the KBI latch.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor87
Keyboard Interrupt Module (KBI)
The keyboard flag bit (KEYF) in KBSCR can be read to check for pending interrupts. The KEYF bit is not
affected by IMASKK, which makes it useful in applications where polling is preferred.
NOTE
Setting a keyboard interrupt enable bit (KBIEx) forces the corresponding
keyboard interrupt pin to be an input, overriding the data direction register.
However, the data direction register bit must be a 0 for software to read the
pin.
8.3.2 Keyboard Initialization
When a keyboard interrupt pin is enabled, it takes time for the internal pullup or pulldown device to pull
the pin to its deasserted level. Therefore a false interrupt can occur as soon as the pin is enabled.
To prevent a false interrupt on keyboard initialization:
1.Mask keyboard interrupts by setting IMASKK in KBSCR.
2.Enable the KBI polarity by setting the appropriate KBIPx bits in KBIPR.
3.Enable the KBI pins by setting the appropriate KBIEx bits in KBIER.
4.Write to ACKK in KBSCR to clear any false interrupts.
5.Clear IMASKK.
An interrupt signal on an edge sensitive pin can be acknowledged immediately after enabling the pin. An
interrupt signal on an edge and level sensitive pin must be acknowledged after a delay that depends on
the external load.
8.4 Interrupts
The following KBI source can generate interrupt requests:
•Keyboard flag (KEYF) — The KEYF bit is set when any enabled KBI pin is asserted based on the KBI
mode and pin polarity. The keyboard interrupt mask bit, IMASKK, is used to enable or disable KBI
interrupt requests.
8.5 Low-Power Modes
The WAIT and STOP instructions put the MCU in low power-consumption standby modes.
8.5.1 Wait Mode
The KBI module remains active in wait mode. Clearing IMASKK in KBSCR enables keyboard interrupt
requests to bring the MCU out of wait mode.
8.5.2 Stop Mode
The KBI module remains active in stop mode. Clearing IMASKK in KBSCR enables keyboard interrupt
requests to bring the MCU out of stop mode.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
88Freescale Semiconductor
KBI During Break Interrupts
8.6 KBI During Break Interrupts
The system integration module (SIM) controls whether status bits in other modules can be cleared during
the break state. The BCFE bit in the break flag control register (BFCR) enables software to clear status
bits during the break state. See BFCR in the SIM section of this data sheet.
To allow software to clear status bits during a break interrupt, write a 1 to BCFE. If a status bit is cleared
during the break state, it remains cleared when the MCU exits the break state.
To protect status bits during the break state, write a 0 to BCFE. With BCFE cleared (its default state),
software can read and write registers during the break state without affecting status bits. Some status bits
have a two-step read/write clearing procedure. If software does the first step on such a bit before the
break, the bit cannot change during the break state as long as BCFE is cleared. After the break, doing the
second step clears the status bit.
8.7 I/O Signals
The KBI module can share its pins with the general-purpose I/O pins. See Figure 8-2 for the port pins that
are shared.
8.7.1 KBI Input Pins (KBI7:KBI0)
Each KBI pin is independently programmable as an external interrupt source. KBI pin polarity can be
controlled independently. Each KBI pin when enabled will automatically configure the appropriate
pullup/pulldown device based on polarity.
8.8 Registers
The following registers control and monitor operation of the KBI module:
•KBSCR (keyboard interrupt status and control register)
•KBIER (keyboard interrupt enable register)
•KBIPR (keyboard interrupt polarity register)
8.8.1 Keyboard Status and Control Register (KBSCR)
Each of these read/write bits enables the polarity of the keyboard interrupt detection.
1 = Keyboard polarity is high level and/or rising edge
0 = Keyboard polarity is low level and/or falling edge
KBIP5KBIP4KBIP3KBIP2KBIP1KBIP0
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor91
Keyboard Interrupt Module (KBI)
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
92Freescale Semiconductor
Chapter 9
LOW V
DD
DETECTOR
LVIPWRD
STOP INSTRUCTION
LVISTOP
LVI RESET
LVIOUT
0 IF V
DD
> V
TRIPR
1 IF V
DD
≤ V
TRIPF
FROM CONFIGURATION REGISTER
V
DD
LVIRSTD
LVITRIP
FROM CONFIGURATION REGISTER
FROM CONFIGURATION REGISTER
FROM CONFIGURATION REGISTER
Low-Voltage Inhibit (LVI)
9.1 Introduction
The low-voltage inhibit (LVI) module is provided as a system protection mechanism to prevent the MCU
from operating below a certain operating supply voltage level. The module has several configuration
options to allow functionality to be tailored to different system level demands.
The configuration registers (see Chapter 4 Configuration Registers (CONFIG1 and CONFIG2)) contain
control bits for this module.
9.2 Features
Features of the LVI module include:
•Programmable LVI reset
•Selectable LVI trip voltage
•Programmable stop mode operation
9.3 Functional Description
Figure 9-1 shows the structure of the LVI module. LVISTOP, LVIPWRD, LVITRIP, and LVIRSTD are user
selectable options found in the configuration register.
Figure 9-1. LVI Module Block Diagram
Freescale Semiconductor93
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Low-Voltage Inhibit (LVI)
The LVI module contains a bandgap reference circuit and comparator. When the LVITRIP bit is cleared,
the default state at power-on reset, V
is configured for the lower VDD operating range. The actual
TRIPF
trip points are specified in 19.5 5-V DC Electrical Characteristics and 19.8 3.3-V DC Electrical
Characteristics.
Because the default LVI trip point after power-on reset is configured for low voltage operation, a system
requiring high voltage LVI operation must set the LVITRIP bit during system initialization. V
above the LVI trip rising voltage, V
, for the high voltage operating range or the MCU will immediately
TRIPR
must be
DD
go into LVI reset.
After an LVI reset occurs, the MCU remains in reset until V
rises above V
DD
. See Chapter 14 System
TRIPR
Integration Module (SIM) for the reset recovery sequence.
The output of the comparator controls the state of the LVIOUT flag in the LVI status register (LVISR) and
can be used for polling LVI operation when the LVI reset is disabled.
The LVI is enabled out of reset. The following bits located in the configuration register can alter the default
conditions.
•Setting the LVI power disable bit, LVIPWRD, disables the LVI.
•Setting the LVI reset disable bit, LVIRSTD, prevents the LVI module from generating a reset.
•Setting the LVI enable in stop mode bit, LVISTOP, enables the LVI to operate in stop mode.
•Setting the LVI trip point bit, LVITRIP, configures the trip point voltage (V
) for the higher VDD
TRIPF
operating range.
9.3.1 Polled LVI Operation
In applications that can operate at VDD levels below the V
the LVIOUT bit. In the configuration register, LVIPWRD must be cleared to enable the LVI module, and
LVIRSTD must be set to disable LVI resets.
level, software can monitor VDD by polling
TRIPF
9.3.2 Forced Reset Operation
In applications that require VDD to remain above the V
module to reset the MCU when V
falls below the V
DD
TRIPF
and LVIRSTD must be cleared to enable the LVI module and to enable LVI resets.
level, enabling LVI resets allows the LVI
TRIPF
level. In the configuration register, LVIPWRD
9.3.3 LVI Hysteresis
The LVI has hysteresis to maintain a stable operating condition. After the LVI has triggered (by having
V
fall below V
DD
V
. This prevents a condition in which the MCU is continually entering and exiting reset if VDD is
TRIPR
approximately equal to V
), the MCU will remain in reset until VDD rises above the rising trip point voltage,
TRIPF
TRIPF
. V
is greater than V
TRIPR
by the typical hysteresis voltage, V
TRIPF
HYS
.
9.3.4 LVI Trip Selection
LVITRIP in the configuration register selects the LVI protection range. The default setting out of reset is
for the low voltage range. Because LVITRIP is in a write-once configuration register, the protection range
cannot be changed after initialization.
NOTE
The MCU is guaranteed to operate at a minimum supply voltage. The trip
point (V
section for the actual trip point voltages.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
94Freescale Semiconductor
) may be lower than this. See the Electrical Characteristics
TRIPF
LVI Interrupts
9.4 LVI Interrupts
The LVI module does not generate interrupt requests.
9.5 Low-Power Modes
The STOP and WAIT instructions put the MCU in low power-consumption standby modes.
9.5.1 Wait Mode
If enabled, the LVI module remains active in wait mode. If enabled to generate resets, the LVI module can
generate a reset and bring the MCU out of wait mode.
9.5.2 Stop Mode
If the LVIPWRD bit in the configuration register is cleared and the LVISTOP bit in the configuration
register is set, the LVI module remains active. If enabled to generate resets, the LVI module can generate
a reset and bring the MCU out of stop mode.
9.6 Registers
The LVI status register (LVISR) contains a status bit that is useful when the LVI is enabled and LVI reset
is disabled.
Bit 76 5 4 3 2 1Bit 0
Read:LVIOUT000000R
Write:
Reset:00000000
= UnimplementedR= Reserved
Figure 9-2. LVI Status Register (LVISR)
LVIOUT — LVI Output Bit
This read-only flag becomes set when the V
when V
voltage rises above V
DD
TRIPR
Table 9-1. LVIOUT Bit Indication
V
> V
DD
VDD < V
< VDD < V
V
TRIPF
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
voltage falls below the V
DD
. (See Table 9-1.)
V
DD
TRIPR
TRIPF
TRIPR
LVIOUT
0
1
Previous value
trip voltage and is cleared
TRIPF
Freescale Semiconductor95
Low-Voltage Inhibit (LVI)
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
96Freescale Semiconductor
Chapter 10
Oscillator Mode (OSC)
10.1 Introduction
The oscillator (OSC) module is used to provide a stable clock source for the MCU system and bus.
The OSC shares its pins with general-purpose input/output (I/O) port pins. See Figure 10-1 for port
location of these shared pins. The OSC2EN bit is located in the port A pull enable register (PTAPUEN)
on this MCU. See Chapter 11 Input/Output Ports (PORTS) for information on PTAPUEN register.
10.2 Features
The bus clock frequency is one fourth of any of these clock source options:
1.Internal oscillator: An internally generated, fixed frequency clock, trimmable to ± 0.4%. There are
four choices for the internal oscillator, 25.6 MHz, 12.8 MHz, 8 MHz, or 4 MHz. The 4-MHz internal
oscillator is the default option out of reset.
2.External oscillator: An external clock that can be driven directly into OSC1.
3.External RC: A built-in oscillator module (RC oscillator) that requires an external R connection only.
The capacitor is internal to the chip.
4.External crystal: A built-in XTAL oscillator that requires an external crystal or ceramic-resonator.
There are three crystal frequency ranges supported, 8–32 MHz, 1–8 MHz, and 32–100 kHz.
10.3 Functional Description
The oscillator contains these major subsystems:
•Internal oscillator circuit
•Internal or external clock switch control
•External clock circuit
•External crystal circuit
•External RC clock circuit
10.3.1 Internal Signal Definitions
The following signals and clocks are used in the functional description and figures of the OSC module.
10.3.1.1 Oscillator Enable Signal (SIMOSCEN)
The SIMOSCEN signal comes from the system integration module (SIM) and disables the XTAL oscillator
circuit, the RC oscillator, or the internal oscillator in stop mode. OSCENINSTOP in the configuration
register can be used to override this signal.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor97
Oscillator Mode (OSC)
All port pins can be configured with internal pullup
PTC not available on 16-pin devices (see note in 11.1 Introduction)
PTD not available on 16-pin or 20-pin devices (see note in 11.1 Introduction)
PTA0/T1CH0/AD0/KBI0
PTA1/T1CH1/AD1/KBI1
PTA2/IRQ
/KBI2/T1CLK
PTA3/RST
/KBI3
PTA4/OSC2/AD2/KBI4
PTA5/OSC1/AD3/KBI5
4-CHANNEL 16-BIT
TIMER MODULE
KEYBOARD INTERRUPT
MODULE
SINGLE INTERRUPT
MODULE
PERIODIC WAKEUP
LOW-VOLTAGE
INHIBIT
COP
MODULE
10-CHANNEL
10-BIT ADC
ENHANCED SERIAL
PTB0/SPSCK/AD4
PTB
DDRB
M68HC08 CPU
PTA
DDRA
PTB1/MOSI/T2CH1/AD5
PTB2/MISO/T2CH0/AD6
PTB3/SS
/T2CLK/AD7
PTB4/RxD/T2CH0/AD8
PTB5/TxD/T2CH1/AD9
PTB6/T1CH2
PTB7/T1CH3
POWER SUPPLY
V
DD
V
SS
CLOCK
GENERATOR
COMMUNICATIONS
INTERFACE MODULE
MODULE
SERIAL PERIPHERAL
INTERFACE
16,384 BYTES
MC68HC908QC16
8192 BYTES
MC68HC908QC8
512 BYTES
MC68HC908QC16
384 BYTES
MC68HC908QC8
BREAK
MODULE
MONITOR ROM
2-CHANNEL 16-BIT
TIMER MODULE
PTC0
PTC1
PTC2
PTC3
PTC
DDRC
PTD0
PTD
DDRD
PTD1
PTD2
PTD3
PTD4
PTD5
PTD6
PTD7
MC68HC908QC4
USER RAM
USER FLASH
4096 BYTES
384 BYTES
MC68HC908QC4
Figure 10-1. Block Diagram Highlighting OSC Block and Pins
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
98Freescale Semiconductor
10.3.1.2 XTAL Oscillator Clock (XTALCLK)
Functional Description
XTALCLK is the XTAL oscillator output signal. It runs at the full speed of the crystal (f
) and comes
XCLK
directly from the crystal oscillator circuit. Figure 10-2 shows only the logical relation of XTALCLK to OSC1
and OSC2 and may not represent the actual circuitry. The duty cycle of XTALCLK is unknown and may
depend on the crystal and other external factors. The frequency of XTALCLK can be unstable at start up.
10.3.1.3 RC Oscillator Clock (RCCLK)
RCCLK is the RC oscillator output signal. Its frequency is directly proportional to the time constant of the
external R (R
) and internal C. Figure 10-3 shows only the logical relation of RCCLK to OSC1 and may
EXT
not represent the actual circuitry.
10.3.1.4 Internal Oscillator Clock (INTCLK)
INTCLK is the internal oscillator output signal. INTCLK is software selectable to be nominally 25.6 MHz,
12.8 MHz, 8.0 MHz, or 4.0 MHz. INTCLK can be digitally adjusted using the oscillator trimming feature of
the OSCTRIM register (see 10.3.2.1 Internal Oscillator Trimming).
10.3.1.5 Bus Clock Times 4 (BUSCLKX4)
BUSCLKX4 is the same frequency as the input clock (XTALCLK, RCCLK, or INTCLK). This signal is
driven to the SIM module and is used during recovery from reset and stop and is the clock source for the
COP module.
10.3.1.6 Bus Clock Times 2 (BUSCLKX2)
The frequency of this signal is equal to half of the BUSCLKX4. This signal is driven to the SIM for
generation of the bus clocks used by the CPU and other modules on the MCU. BUSCLKX2 will be divided
by two in the SIM. The internal bus frequency is one fourth of the XTALCLK, RCCLK, or INTCLK
frequency.
10.3.2 Internal Oscillator
The internal oscillator circuit is designed for use with no external components to provide a clock source
with a tolerance of less than ±25% untrimmed. An 8-bit register (OSCTRIM) allows the digital adjustment
to a tolerance of ACC
The internal oscillator is capable of generating clocks of 25.6 MHz, 12.8 MHz, 8.0 MHz, or 4.0 MHz
(INTCLK) resulting in a bus frequency (INTCLK divided by 4) of 6.4 MHz, 3.2 MHz, 2.0 MHz, or 1.0 MHz
respectively. The bus clock is software selectable and defaults to the 1.0-MHz bus out of reset. Users can
increase the bus frequency based on the voltage range of their application.
Figure 10-3 shows how BUSCLKX4 is derived from INTCLK and OSC2 can output BUSCLKX4 by setting
OSC2EN.
10.3.2.1 Internal Oscillator Trimming
OSCTRIM allows a clock period adjustment of +127 and –128 steps. Increasing the OSCTRIM value
increases the clock period, which decreases the clock frequency. Trimming allows the internal clock
frequency to be fine tuned to the target frequency.
. See the oscillator characteristics in the Electrical section of this data sheet.
INT
All devices are factory programmed with a trim value that is stored in FLASH memory at location $FFC0.
This trim value is not automatically loaded into OSCTRIM register. User software must copy the trim value
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
Freescale Semiconductor99
Oscillator Mode (OSC)
from $FFC0 into OSCTRIM if needed. The factory trim value provides the accuracy required for
communication using force monitor mode. Trimming the device in the user application board will provide
the most accurate trim value. See Oscillator Characteristics in the Electrical Chapter of this data book for
additional information on factory trim.
10.3.2.2 Internal to External Clock Switching
When external clock source (external OSC, RC, or XTAL) is desired, the user must perform the following
steps:
1.For external crystal circuits only, configure OSCOPT[1:0] to external crystal. To help precharge an
external crystal oscillator, momentarily configure OSC2 as an output and drive it high for several
cycles. This can help the crystal circuit start more robustly.
2.Configure OSCOPT[1:0] and ECFS[1:0] according to 10.8.1 Oscillator Status and Control Register.
The oscillator module control logic will then enable OSC1 as an external clock input and, if the
external crystal option is selected, OSC2 will also be enabled as the clock output. If RC oscillator
option is selected, enabling the OSC2 output may change the bus frequency.
3.Create a software delay to provide the stabilization time required for the selected clock source
(crystal, resonator, RC). A good rule of thumb for crystal oscillators is to wait 4096 cycles of the
crystal frequency; i.e., for a 4-MHz crystal, wait approximately 1 ms.
4.After the stabilization delay has elapsed, set ECGON.
After ECGON set is detected, the OSC module checks for oscillator activity by waiting two external clock
rising edges. The OSC module then switches to the external clock. Logic provides a coherent transition.
The OSC module first sets ECGST and then stops the internal oscillator.
10.3.2.3 External to Internal Clock Switching
After following the procedures to switch to an external clock source, it is possible to go back to the internal
source. By clearing the OSCOPT[1:0] bits and clearing the ECGON bit, the external circuit will be
disengaged. The bus clock will be derived from the selected internal clock source based on the ICFS[1:0]
bits.
10.3.3 External Oscillator
The external oscillator option is designed for use when a clock signal is available in the application to
provide a clock source to the MCU. The OSC1 pin is enabled as an input by the oscillator module. The
clock signal is used directly to create BUSCLKX4 and also divided by two to create BUSCLKX2.
In this configuration, the OSC2 pin cannot output BUSCLKX4. The OSC2EN bit will be forced clear to
enable alternative functions on the pin.
10.3.4 XTAL Oscillator
The XTAL oscillator circuit is designed for use with an external crystal or ceramic resonator to provide an
accurate clock source. In this configuration, the OSC2 pin is dedicated to the external crystal circuit. The
OSC2EN bit has no effect when this clock mode is selected.
In its typical configuration, the XTAL oscillator is connected in a Pierce oscillator configuration, as shown
in Figure 10-2. This figure shows only the logical representation of the internal components and may not
represent actual circuitry.
MC68HC908QC16 • MC68HC908QC8 • MC68HC908QC4 Data Sheet, Rev. 3
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.