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://freescale.com
The following revision history table summarizes changes contained in this document. For your
convenience, the page number designators have been linked to the appropriate location.
Revision History (Sheet 1 of 2)
Date
March,
2002
May,
2002
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
This product incorporates SuperFlash® technology licensed from SST.
7.2 Features — Corrected third bulleted item to reflect ±4 percent variability 75
Figure 15-1. Forced Monitor Mode (Low) — Reworked for clarity211
Figure 15-2. Forced Monitor Mode (High) — Reworked for clarity211
Figure 15-3. Standard Monitor Mode — Reworked for clarity212
1.0
Table 15-1. Monitor Mode Signal Requirements and Op tions — Reworked for
clarity
Figure 12-4. Port A I/O Circuit — Reworked to correct pullup resistor 143
Figure 12-11. Port C I/O Circuit — Reworked to correct pullup resistor 148
Figure 12-15. Port D I/O Circuit — Reworked to correct pullup resistor 151
Description
Page
Number(s)
214
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor3
Revision History
Revision History (Sheet 2 of 2)
Date
June,
2002
September,
2004
Revision
Level
2.0
3.0
Description
Figure 2-2. Control, Status, and Data Registers — Corrected ESCI arbiter data
register (SCIADAT) to reflect read-only status
Figure 14-19. ESCI Arbiter Control Register (SCIACTL) — Corrected address
location designator from $0018 to $000A
Figure 14-20. ESCI Arbiter Data Register (SCIADAT) — Corrected address
location designator from $0019 to $000B
Page
Number(s)
50
170
171
Reformatted to meet current publications standardsThroughout
2.6.6 FLASH Block Protection — Description updated for clarity43
3.3.5 Conversion — Updated for clarity 50
3.6.3 ADC Voltage Reference High Pin (V
3.6.4 ADC Voltage Reference Low Pin (V
) — Corrected connections51
REFH
) — Corrected connections51
REFL
3.7.1 ADC Status and Control Register — Updated description of the COCO bit52
Chapter 4 Configuration Register (CONFIG) — Updated COP tmeout selecti ons55, 57
Chapter 4 Configuration Register (CONFIG) — Updted SSREC bit usage58
Chapter 5 Computer Operating Properly (COP) Module — Updated timeout
selections
60
Figure 5-1. COP Block Diagram — Updated illustration for clarity59
Table 6-1. Instruction Set Summary — Updated definitions for STOP and WAIT68
Figure 7-9. Code Example for Switching Clock Sources — Replaced example
code
Figure 7-10. Code Example for Enabling the Clock Monitor — Replaced example
code
87
88
Figure 14-18. ESCI Prescaler Register (SCPSC) — Corrected address location170
Chapter 15 System Integration Module (SIM) — Clarified SIM features and
functionality
177, 180,
181, 182
15.7.2 SIM Reset Status Register — Clarified SRSR operation192
Table 19-1. Monitor Mode Signal Requirements and Op tions — Reworked245
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
18Freescale Semiconductor
Chapter 1
General Description
1.1 Introduction
The MC68HC908GT16 and the MC68HC908GT8 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.
All references to the MC68HC908GT16 in this data book apply equally to the MC68HC908GT8, unless
otherwise stated.
1.2 Features
For convenience, features have been organized to reflect:
•Standard features of the MC68HC908GT16/MC68HC908GT8
•Features of the CPU08
1.2.1 Standard Features of the MC68HC908GT16/MC68HC908GT8
•High-performance M68HC08 architecture optimized for C-compilers
•Fully upward-compatible object code with M6805, M146805, and M68HC05 Families
•8-MHz internal bus frequency
•Internal oscillator requiring no external components:
–Software selectable bus frequencies
–±25 percent accuracy with trim capability to ±4 percent
–Clock monitor
–Option to allow use of external clock source or external crystal/ceramic resonator
•FLASH program memory security
•On-chip programming firmware for use with host personal computer which does not require high
voltage for entry
•In-system programming (ISP)
•System protection features:
–Optional computer operating properly (COP) reset
–Low-voltage detection with optional reset and selectable trip points for 3.0-V and 5.0-V
operation
–Illegal opcode detection with reset
–Illegal address detection with reset
•Low-power design; fully static with stop and wait modes
•Standard low-power modes of operation:
–Wait mode
–Stop mode
(1)
1. No security feature is absolutely secure. However, Freescale’s strategy is to make reading or copying the FLASH difficult for
unauthorized users.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor19
General Description
•Master reset pin and power-on reset (POR)
•16 Kbytes of on-chip 100k cycle write/erase capable FLASH memory (8 Kbytes on
MC68HC908GT8)
•512 bytes of on-chip random-access memory (RAM)
•720 bytes of FLASH programming routines ROM
•Serial peripheral interface module (SPI)
•Serial communications interface module (SCI)
•Two 16-bit, 2-channel timer interface modules (TIM1 and TIM2) with selectable input capture,
output compare, and pulse-width modulation (PWM) capability on each channel
•Break module (BRK) to allow single breakpoint setting during in-circuit debugging
•Internal pullups on IRQ
and RST to reduce customer system cost
•Up to 36 general-purpose input/output (I/O) pins, including:
–28 shared-function I/O pins
–Six or eight dedicated I/O pins, depending on package choice
•Selectable pullups on inputs only on ports A, C, and D. Selection is on a n individual port bit basis.
During output mode, pullups are disengaged.
•High current 10-mA sink/10-mA source capability on all port pins
•Higher current 20-mA sink/source capability on PTC0–PTC4
•Timebase module with clock prescaler circuitry for eight user selectable periodic real-time
interrupts with optional active clock source during stop mode for periodic wakeup from stop using
an external 32-kHz crystal or internal oscillator
•User selection of having the oscillator enabled or disabled during stop mode
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
22Freescale Semiconductor
RST
PTC0
PTC1
PTC2
PTC3
PTC4
PTC5
PTC6
PTE0/TxD
PTE1/RxD
IRQ
Pin Functions
DDA
SSA
PTE4/OSC1
PTE3/OSC2
PTE2
43
44
1
2
3
4
5
6
7
8
9
10
11
12
42
13
14
V
V
41
40
15
16
PTA7/KBD7
39
17
18
PTA6/KBD6
38
PTA5/KBD5
37
19
20
PTA4/KBD4
PTA3/KBD3
36
21
35
PTA2/KBD2
34
33
32
31
30
29
28
27
26
25
24
23
22
PTA1/KBD1
PTA0/KBD0
V
REFL
V
REFH
PTB7/AD7
PTB6/AD6
PTB5/AD5
PTB4/AD4
PTB3/AD3
PTB2/AD2
PTB1/AD1
SS
DD
V
V
PTD0/SS
PTD1/MISO
PTD2/MOSI
PTD3/SPSCK
PTD5/T1CH1
PTD4/T1CH0
PTD6/T2CH0
PTB0/AD0
PTD7/T2CH1
Figure 1-3. 44-Pin QFP Pin Assignments
1.5 Pin Functions
Descriptions of the pin functions are provided here.
1.5.1 Power Supply Pins (VDD and VSS)
VDD and VSS are the power supply and ground pins. The MCU operates from a single power supply.
Fast signal transitions on MCU pins place high, short-duration current demands on the power supply. To
prevent noise problems, take special care to provide power supply bypassing at the MCU as Figure 1-4
shows. Place the C1 bypass capacitor as close to the MCU as possible. Use a high-frequency-response
ceramic capacitor for C1. C2 is an optional bulk current bypass capacitor for use in applications that
require the port pins to source high current levels.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
PTE4/OSC1 and PTE3/OSC2 are general-purpose, bidirectional I/O port pins. These pins can also be
programmed to be the connections for an external crystal, resonator or clock circuit. See Chapter 7
Internal Clock Generator (ICG) Module).
1.5.3 External Reset Pin (RST)
A logic 0 on the RST pin forces the MCU to a known startup state. RST is bidirectional, allowing a reset
of the entire system. It is driven low when any internal reset source is asserted. This pin contains an
internal pullup resistor. See Chapter 15 System Integration Module (SIM).
1.5.4 External Interrupt Pin (IRQ)
IRQ is an asynchronous external interrupt pin. This pin contains an internal pullup resistor. See
Chapter 8 External Interrupt (IRQ).
1.5.5 ADC and ICG Power Supply Pins (V
V
and V
DDA
generator (ICG). Connect the V
same voltage potential as V
V
high reference supply for the ADC and should be filtered. V
potential as the analog supply pin, V
externally filtered. V
See Chapter 3 Analog-to-Digital Converter (ADC).
24Freescale Semiconductor
REFH
and V
are the power supply pins for the analog-to-digital converter (ADC) and the internal clock
SSA
pin to the same voltage potential as VDD, and theV
DDA
. Decoupling of these pins should be as per the digital supply. See
SS
and V
REFH
are the reference voltage pins for the analog-to-digital converter (ADC). V
REFL
. V
DDA
must be connected to the same voltage potential as the analog supply pin V
REFL
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
REFL
REFL
DDA
and V
SSA
)
pin to the
SSA
)
is the
REFH
must be connected to the same voltage
REFH
is the low reference supply for the ADC and should be
SSA
.
Pin Functions
1.5.7 Port A Input/Output (I/O) Pins (PTA7/KBD7–PTA0/KBD0)
PTA7–PTA0 are general-purpose, bidirectional I/O port pins. Any or all of the port A pins can be
programmed to serve as keyboard interrupt pins. See Chapter 12 I nput/Output (I/O) Ports (PORTS) and
Chapter 9 Keyboard Interrupt Module (KBI).
These port pins also have selectable pullups when configured for input mode. The pullups are disengaged
when configured for output mode. The pullups are selectable on an individual port bit basis.
1.5.8 Port B I/O Pins (PTB7/AD7–PTB0/AD0)
PTB7–PTB0 are general-purpose, bidirectional I/O port pins that can also be used for analog-to-digital
converter (ADC) inputs. See Chapter 12 Input/Output (I/O) Ports (PORTS) and Chapter 3
Analog-to-Digital Converter (ADC).
1.5.9 Port C I/O Pins (PTC6–PTC0)
PTC6–PTC0 are general-purpose, bidirectional I/O port pins. PTC0–PTC4 have higher current
sink/source capability. PTC5 and PTC6 are only available on the 44-pin QFP package.
These port pins also have selectable pullups when configured for input mode. The pullups are disengaged
when configured for output mode. The pullups are selectable on an individual port bit basis. See
Chapter 12 Input/Output (I/O) Ports (PORTS).
1.5.10 Port D I/O Pins (PTD7/T2CH1–PTD0/SS)
PTD7–PTD0 are special-function, bidirectional I/O port pins. PTD0–PTD3 can be programmed to be
serial peripheral interface (SPI) pins, while PTD4–PTD7 can be individually programmed to be timer
interface module (TIM1 and TIM2) pins. See Chapter 18 Timer Interface Module (TIM), Chapter 16 Serial
These port pins also have selectable pullups when configured for input mode. The pullups are disengaged
when configured for output mode. The pullups are selectable on an individual port bit basis.
1.5.11 Port E I/O Pins (PTE4–PTE2, PTE1/RxD, and PTE0/TxD)
PTE0–PTE4 are general-purpose, bidirectional I/O port pins. PTE0–PTE1 can also be programmed to be
serial communications interface (SCI) pins. See Chapter 14 Enhanced Serial Communications In terface
(ESCI) Module and Chapter 12 Input/Output (I/O) Ports (PORTS).
PTE3 and PTE4 can also be programmed to be clock or oscillator pins. See Chapter 4 Configuration
Register (CONFIG) and Chapter 12 Input/Output (I/O) Ports (PORTS).
NOTE
Any unused inputs and I/O ports should be tied to an appropriate logic level
(either V
termination is recommended to reduce the possibility of static damage.
or VSS). Although the I/O ports do not require termination,
DD
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor25
General Description
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
26Freescale Semiconductor
Chapter 2
Memory
2.1 Introduction
The CPU08 can address 64 Kbytes of memory space. The memory map, shown in Figure 2-1, includes:
•720 bytes of FLASH programming routines read-only memory (ROM)
•36 bytes of user-defined vectors
•304 bytes of monitor ROM
2.2 Unimplemented Memory Locations
Accessing an unimplemented location can cause an illegal address reset. In the memory map (Figure 2-1)
and in register figures in this document, unimplemented locations are shaded.
2.3 Reserved Memory Locations
Accessing a reserved location can have unpredictable effects on MCU operation. In the Figure 2-1 and
in register figures in this document, reserved locations are marked with the word Reserved or with the
letter R.
2.4 Input/Output (I/O) Section
Most of the control, status, and data registers are in the zero page area of $0000–$003F. Additional I/O
registers have these addresses:
•$FE00; SIM break status register, SBSR
•$FE01; SIM reset status register, SRSR
•$FE02; reserved, SUBAR
•$FE03; SIM break flag control register, SBFCR
•$FE04; interrupt status register 1, INT1
•$FE05; interrupt status register 2, INT2
•$FE06; interrupt status register 3, INT3
•$FE07; reserved
•$FE08; FLASH control register, FLCR
•$FE09; break address register high, BRKH
•$FE0A; break address register low, BRKL
•$FE0B; break status and control register, BRKSCR
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor27
Memory
•$FE0C; LVI status register, LVISR
•$FF7E; FLASH block protect register, FLBPR
•$FF80; ICG user trim register 5V ICGTR5
•$FF81; ICG user trim register 3V ICGTR3
•$FFFF; COP control register, COPCTL
Data registers are shown in Figure 2-2. Table 2-1 is a list of vector locations.
$0000
↓
$003F
$0040
↓
$023F
$0240
↓
$1B4F
$1B50
↓
$1E1F
$1E20
↓
$BFFF
$C000
↓
$FE00SIM BREAK STATUS REGISTER (SBSR)1. Inadvertent access to
$FE01SIM RESET STATUS REGISTER (SRSR)
$FE02RESERVED (SUBAR)
$FE03SIM BREAK FLAG CONTROL REGISTER (SBFCR)
$FE04INTERRUPT STATUS REGISTER 1 (INT1)
$FE05INTERRUPT STATUS REGISTER 2 (INT2)
$FE06INTERRUPT STATUS REGISTER 3 (INT3)
$FE07RESERVED
$FE08FLASH CONTROL REGISTER (FLCR)
$FE09BREAK ADDRESS REGISTER HIGH (BRKH)
$FE0ABREAK ADDRESS REGISTER LOW (BRKL)
$FE0BBREAK STATUS AND CONTROL REGISTER (BRKSCR)
FLASH PROGRAMMING ROUTINES ROM
I/O REGISTERS
64 BYTES
RAM
512 BYTES
UNIMPLEMENTED
6416 BYTES
720 BYTES
UNIMPLEMENTED
41,440 BYTES
FLASH MEMORY
MC68HC908GT16
15,872 BYTES
RESERVED
FLASH MEMORY
MC68HC908GT8
7,680 BYTES
these locations will not
cause an illegal address
reset.
(1)
$C000
↓
$DFFF
$E000
↓
$FDFF$FDFF
Figure is continued on the next page
Figure 2-1. Memory Map
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
28Freescale Semiconductor
$FE0CLVI STATUS REGISTER (LVISR)
$FE0D
↓
$FE0F
$FE10
↓
$FE1F
$FE20
↓
$FF4F
$FF50
↓
$FF7D
$FF7EFLASH BLOCK PROTECT REGISTER (FLBPR)
$FF7F
$FF80ICG USER TRIM REGISTER 5V (ICGTR5)
$FF81ICG USER TRIM REGISTER 3V (ICGTR3)
$FF82
↓
$FFDB
$FFDC
↓
(2)
$FFFF
2. $FFF6–$FFFD reserved for eight security bytes
RESERVED FOR COMPATIBILITY WITH MONITOR CODE
UNIMPLEMENTED
3 BYTES
UNIMPLEMENTED
16 BYTES
FOR A-FAMILY PART
MONITOR ROM
304 BYTES
UNIMPLEMENTED
46 BYTES
UNIMPLEMENTED 1 BYTE
UNIMPLEMENTED
90 BYTES
FLASH VECTORS
36 BYTES
Input/Output (I/O) Section
Figure 2-1. Memory Map (Continued)
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor29
Memory
Addr.Register NameBit 7654321Bit 0
$0000
$0001
$0002
$0003
$0004
$0005
$0006
$0007
$0008
$0009
$000A
$000B
$000C
Port A Data Register
See page 124.
Port B Data Register
See page 126.
Port C Data Register
See page 128.
Port D Data Register (
See page 130.
Data Direction Register A
(DDRA)
See page 124.
Data Direction Register B
(DDRB)
See page 126.
Data Direction Register C
(DDRC)
See page 128.
Data Direction Register D
(DDRD)
See page 131.
Port E Data Register
See page 133.
ESCI Prescaler Register
(SCPSC)
See page 170.
ESCI Arbiter Control
Register (SCIACTL)
See page 174.
ESCI Arbiter Data
Register (SCIADAT)
See page 175.
Data Direction Register E
(DDRE)
See page 134.
(PTA)
Read:
Write:
PTA7PTA6PTA5PTA4PTA3PTA2PTA1PTA0
Reset:Unaffected by reset
(PTB)
Read:
Write:
PTB7PTB6PTB5PTB4PTB3PTB2PTB1PTB0
Reset:Unaffected by reset
(PTC)
Read:0
Write:
PTC6PTC5PTC4PTC3PTC2PTC1PTC0
Reset:Unaffected by reset
PTD)
Read:
Write:
PTD7PTD6PTD5PTD4PTD3PTD2PTD1PTD0
Reset:Unaffected by reset
Read:
Write:
DDRA7DDRA6DDRA5DDRA4DDRA3DDRA2DDRA1DDRA0
Reset:00000000
Read:
Write:
DDRB7DDRB6DDRB5DDRB4DDRB3DDRB2DDRB1DDRB0
Reset:00000000
Read:0
Write:
DDRC6DDRC5DDRC4DDRC3DDRC2DDRC1DDRC0
Reset:00000000
Read:
Write:
DDRD7DDRD6DDRD5DDRD4DDRD3DDRD2DDRD1DDRD0
Reset:00000000
Read:000
Write:
(PTE)
PTE4PTE3PTE2PTE1PTE0
Reset:Unaffected by reset
Read:
Write:
PDS2PDS1PDS0PSSB4PSSB3PSSB2PSSB1PSSB0
Reset:00000000
Read:
Write:
AM1
ALOST
AM0ACLK
AFINARUNAOVFLARD8
Reset:00000000
Read:ARD7ARD6ARD5ARD4ARD3ARD2ARD1ARD0
Write:
Reset:00000000
Read:000
Write:
DDRE4DDRE3DDRE2DDRE1DDRE0
Reset:00000000
= UnimplementedR = ReservedU = Unaffected
Figure 2-2. Control, Status, and Data Registers (Sheet 1 of 7)
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
$FFFBIRQ
$FFFCSWI Vector (High)
$FFFDSWI Vector (Lo w)
$FFFEReset Vector (High)
Vector (High)
Vector (Low)
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor37
Memory
2.5 Random-Access Memory (RAM)
Addresses $0040 through $023F are RAM locations. The location of the stack RAM is programmable.
The 16-bit stack pointer allows the stack to be anywhere in the 64-Kbyte memory space.
NOTE
For correct operation, the stack pointer must point only to RAM locations.
Within page zero are 192 bytes of RAM. Because the location of the stack RAM is programmable, all page
zero RAM locations can be used for I/O control and user data or code. When the stack pointer is moved
from its reset location at $00FF out of page zero, direct addressing mode instructions can efficiently
access all page zero RAM locations. Page zero RAM, therefore, provides ideal locations for frequently
accessed global variables.
Before processing an interrupt, the CPU uses five bytes of the stack to save the contents of the CPU
registers.
NOTE
For M6805 compatibility, the H register is not stacked.
During a subroutine call, the CPU uses two bytes of the stack to store the return address. The stack
pointer decrements during pushes and increments during pulls.
NOTE
Be careful when using nested subroutines. The CPU may overwrite data in
the RAM during a subroutine or during the interrupt stacking operation.
2.6 FLASH Memory
This sub-section describes the operation of the embedded FLASH memory. This memory can be read,
programmed, and erased from a single external supply. The program, erase, and read operations are
enabled through the use of an internal charge pump.
2.6.1 Functional Description
The FLASH memory is an array of 15,872 bytes (7,680 bytes on MC68HC908GT8) with an additional
36 bytes of user vectors, one byte of block protection and two bytes of ICG user trim storage. An erased bit reads as 1 and a programmed bit reads as a 0. Memory in the FLASH array is organized into two rows
per page basis. The page size is 64 bytes per page and the row size is 32 bytes per row. Hence the
minimum erase page size is 64 bytes and the minimum program row size is 32 bytes. Program and erase
operation operations are facilitated through control bits in FLASH control register (FLCR). Details for
these operations appear later in this section.
The address ranges for the user memory and vectors are:
•$C000–$FDFF; user memory ($E000–$FDFF on MC68HC908GT8)
•$FE08
•$FF7E; FLASH block protect register
•$FF80
•$FF81
•$FFDC–$FFFF; these locations are reserved for user-defined interrupt and reset vectors
; FLASH control register
; ICG user trim register (ICGTR5)
; ICG user trim register (ICGTR3)
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
38Freescale Semiconductor
FLASH Memory
2.6.2 FLASH Control Register
The FLASH control register (FLCR) controls FLASH program and erase operations.
Address:$FE08
Bit 7654321Bit 0
Read:0000
Write:
Reset:00000000
= Unimplemented
Figure 2-3. FLASH Control Register (FLCR)
HVEN — High-Voltage Enable Bit
This read/write bit enables the charge pump to drive high voltages for program and erase operations
in the array. HVEN 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
Setting this read/write bit configures the 16 Kbyte FLASH array for mass erase operation.
1 = MASS erase operation selected
0 = MASS erase operation unselected
HVENMASSERASEPGM
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.
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.3 FLASH Page Erase Operation
Use the following procedure to erase a page (64 bytes) of FLASH memory. A page consists of 64
consecutive bytes starting from addresses $XX00, $XX40, $XX80, or $XXC0. The 36-byte user interrupt
vectors area also forms a page. Any FLASH memory page can be erased alone.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor39
Memory
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
(minimum10 µs).
NVS
5.Set the HVEN bit.
6.Wait for a time, t
(minimum 1 ms or 4 ms).
Erase
7.Clear the ERASE bit.
8.Wait for a time, t
(minimum5 µs).
NVH
9.Clear the HVEN bit.
10.After time, t
(typical1 µs), the memory can be accessed in read mode again.
RCV
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, but other unrelated operations
may occur between the steps.
CAUTION
A page erase of the vector page will erase the internal oscillator trim values
at $FF80 and $FF81.
In applications that require more than 1000 program/erase cycles, use the 4 ms page erase specification
to get improved long-term reliability. Any application can use this 4 ms page erase specification. However,
in applications where a FLASH location will be erased and reprogrammed less than 1000 times, and
speed is important, use the 1 ms page erase specification to get a shorter cycle time.
2.6.4 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
(minimum10 µs).
NVS
5.Set the HVEN bit.
6.Wait for a time, t
MErase
(minimum4 ms).
7.Clear the ERASE and MASS bits.
Mass erase is disabled whenever any block is protected (FLBPR does not
equal $FF).
8.Wait for a time, t
(minimum100 µs).
NVHL
9.Clear the HVEN bit.
10.After time, t
(typical1 µs), the memory can be accessed in read mode again.
RCV
Programming and erasing of FLASH locations cannot be performed by
code being executed from the FLASH memory. While these operations
1. When in monitor mode, with security sequence failed (see 19.3.2 Security), write to the FLASH block protect register instead of any FLASH address.
(1)
within the FLASH memory address range.
NOTE
NOTE
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
40Freescale Semiconductor
FLASH Memory
must be performed in the order as shown, but other unrelated operations
may occur between the steps.
CAUTION
A mass erase will erase the internal oscillator trim values at $FF80 and
$FF81.
2.6.5 FLASH Program/Read 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 is a flowchart of the programming algorithm.
NOTE
Only bytes which are currently $FF may be programmed.
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
The COP register at location $FFFF should not be written between steps
5-12, when the HVEN bit is set. Since this register is located at a valid
FLASH address, unpredictable behavior may occur if this location is written
while HVEN is set.
(minimum10 µs).
NVS
(minimum5 µs).
PGS
(minimum30 µs).
PROG
(1)
.
(minimum5 µs).
NVH
(1)
.
(typical1 µs), the memory can be accessed in read mode again.
NOTE
This program sequence is repeated throughout the memory until all data is programmed.
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, see20.20
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
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor41
PROG
maximum.
Memory
Algorithm for programming
a row (32 bytes) of FLASH memory
1
2
READ THE FLASH BLOCK PROTECT REGISTER
3
WRITE ANY DATA TO ANY FLASH ADDRESS
WITHIN THE ROW ADDRESS RANGE DESIRED
4
5
6
7
WRITE DATA TO THE FLASH ADDRESS
SET PGM BIT
WAIT FOR A TIME, t
SET HVEN BIT
WAIT FOR A TIME, t
TO BE PROGRAMMED
NVS
PGS
8
WAIT FOR A TIME, t
COMPLETED
PROGRAMMING
THIS ROW?
Note:
The time between each FLASH address change (step 7 to step 7),
or the time between the last FLASH address programmed
to clearing PGM bit (step 7 to step 10)
must not exceed the maximum programming
PROG
max.
time, t
This row program algorithm assumes the row/s
to be programmed are initially erased.
Figure 2-4. FLASH Programming Flowchart
PROG
Y
N
10
11
12
13
CLEAR PGM BIT
WAIT FOR A TIME, t
CLEAR HVEN BIT
WAIT FOR A TIME, t
END OF PROGRAMMING
NVH
RCV
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
42Freescale Semiconductor
FLASH Memory
2.6.6 FLASH Block 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 for protecting a block of memory from unintentional erase or program
operations due to system malfunction. This protection is done by using 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 at 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 program 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, address ranges as shown in
2.6.7 FLASH Block Protect Register. Once the FLBPR is programmed with a value other than $FF or $FE,
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.7 FLASH Block Protect Register
The FLASH block protect register (FLBPR) 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 location of the protected range within the FLASH memory.
Address:$FF7E
Bit 7654321Bit 0
Read:
Write:
Reset:Unaffected by reset. Initial value from factory is 1.
BPR[7:0] — FLASH Block Protect Bits
These eight bits represent bits [13:6] of a 16-bit memory addre ss. Bit 15 and Bit 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, and $XXC0 (64 bytes
page boundaries) within the FLASH memory.
BPR7BPR6BPR5BPR4BPR3BPR2BPR1BPR0
Write to this register is by a programming sequence to the FLASH memory.
Figure 2-5. FLASH Block Protect Register (FLBPR)
16-BIT MEMORY ADDRESS
START ADDRESS OF FLASH
BLOCK PROTECT
1
1
FLBPR VALUE
000000
Figure 2-6. FLASH Block Protect Start Address
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
The ICG user trim register are two normal bytes of FLASH memory which are allocated for the user to
store copies of the ICG trim register (ICGTR) value. ICGTR5 is allocated for storage of the trim value
when a 5-V supply is used, ICGTR3 for storage of the trim value when a 3-V supply is used.
Representative trim values are programmed into these locations by Freescale but they may be erased
and reprogrammed by the user at any time.
Storage and retrieval of data in these registers is not automatic and must be performed programmatically.
Typically, these locations are programmed by the user during an in-system calibration procedure and one
of them, depending on the application supply voltage, is subsequently used by the user’s initialization
code to configure the ICG each time following a reset.
ICGTR5 is used by the MC68HC908GT16 monitor ROM program during its initialization sequence if
monitor mode was entered while clocking from the ICG. If the contents of ICGTR5 are not $FF then the
contents are copied to ICGTR.
NOTE
The contents of ICGTR3 are not utilized by the monitor ROM program.
Address: ICGTR5, $FF80 and ICGTR3, $FF81
Bit 7654321Bit 0
Read:
Write:
Reset:Unaffected by reset. Initial value from factory is 1.
TRIM7TRIM6TRIM5TRIM4TRIM3TRIM2TRIM1TRIM0
Write to this register is by a programming sequence to the FLASH memory.
Figure 2-7. ICG User Trim Registers (ICGTR5 and ICGTR3)
TRIM[7:0] — ICG Trim Factor Bits
These bits are copied by the monitor ROM program following a reset, if monitor mode was entered
while clocking from the ICG and may be copied by the user’s initialization co de to the ICG trim register
(ICGTR).
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
44Freescale Semiconductor
FLASH Memory
2.6.9 Wait Mode
Putting the MCU into wait mode while the FLASH is in read mode does not affect the operation of the
FLASH memory directly, but there will not be any memory activity since the CPU is inactive.
The WAIT instruction should not be executed while performing a program or erase operation on the
FLASH, otherwise the operation will discontinue, and the FLASH will be on standby mode.
2.6.10 Stop Mode
Putting the MCU into stop mode while the FLASH is in read mode does not affect the operation of the
FLASH memory directly, but there will not be any memory activity since the CPU is inactive.
The STOP instruction should not be executed while performing a program or erase operation on the
FLASH, otherwise the operation will discontinue, and the FLASH will be on standby mode
NOTE
Standby mode is the power saving mode of the FLASH module in which all
internal control signals to the FLASH are inactive and the current
consumption of the FLASH is at a minimum.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor45
Memory
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
46Freescale Semiconductor
Chapter 3
Analog-to-Digital Converter (ADC)
3.1 Introduction
This section describes the 8-bit analog-to-digital converter (ADC).
3.2 Features
Features of the ADC module include:
•Eight channels with multiplexed input
•Linear successive approximation with monotonicity
•8-bit resolution
•Single or continuous conversion
•Conversion complete flag or conversion complete interrupt
•Selectable ADC clock
3.3 Functional Description
The ADC provides eight pins for sampling external sources at pins PTB7/AD7–PTB0/AD0. An analog
multiplexer allows the single ADC converter to select one of eight ADC channels as ADC voltage in
(V
When the conversion is completed, ADC places the result in the ADC data register and sets a flag or
generates an interrupt. See Figure 3-2.
ADIN
). V
is converted by the successive approximation register-based analog-to-digital converter.
ADIN
3.3.1 ADC Port I/O Pins
PTB7/AD7–PTB0/AD0 are general-purpose I/O (input/output) pins that share with the ADC channels. The
channel select bits define which ADC channel/port pin will be used as the input signal. The ADC overrides
the port I/O logic by forcing that pin as input to the ADC. The remaining ADC channels/port pins are
controlled by the port I/O logic and can be used as ge neral-purpose I/O. Writes to the port register or data
direction register (DDR) will not have any affect on the port pin that is selected by the ADC. Read of a port
pin in use by the ADC will return a logic 0.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor47
Analog-to-Digital Converter (ADC)
M68HC08 CPU
CPU
REGISTERS
ARITHMETIC/LOGIC
UNIT (ALU)
INTERNAL BUS
PROGRAMMABLE TIMEBASE
MODULE
DDRA
PORTA
PTA7/KBD7–
PTA0/KBD0
(1)
CONTROL AND STATUS
REGISTERS — 64 BYTES
USER FLASH
MC68HC908GT16 — 15,872 BYTES
MC68HC908GT8 — 7,680 BYTES
USER RAM — 512 BYTES
MONITOR ROM — 304 BYTES
FLASH PROGRAMMING ROUTINES
ROM — 720 BYTES
USER FLASH VECTOR SPACE — 36 BYTES
PTE4/OSC1
PTE3/OSC2
RST
IRQ
V
REFH
V
REFL
(3)
(3)
INTERNAL CLOCK
GENERATOR MODULE
SYSTEM INTEGRATION
MODULE
SINGLE EXTERNAL
INTERRUPT MODULE
8-BIT ANALOG-TO-DIGITAL
CONVERTER MODULE
POWER-ON RESET
MODULE
V
DD
V
SS
V
DDA
V
SSA
POWER
SINGLE BREAKPOINT BREAK
LOW-VOLTAGE INHIBIT MODULE
2-CHANNEL TIMER INTERFACE
2-CHANNEL TIMER INTERFACE
MODULE
DUAL VOLTAGE
8-BIT KEYBOARD
INTERRUPT MODULE
MODULE 1
MODULE 2
SERIAL COMMUNICATIONS
INTERFACE MODULE
COMPUTER OPERATING
PROPERLY MODULE
SERIAL PERIPHERAL
INTERFACE MODULE
MONITOR MODULE
MEMORY MAP
MODULE
CONFIGURATION REGISTER 1
MODULE
CONFIGURATION REGISTER 2
MODULE
PTB7/AD7
PTB6/AD6
PTB5/AD5
PTB4/AD4
DDRB
PTB3/AD3
PORTB
PTB2/AD2
PTB1/AD1
PTB0/AD0
(1)
PTC6
(1)
PTC5
(1)(2)
PTC4
(1)(2)
DDRC
PTC3
PTC2
PTC1
PTC0
(1)(2)
(1)(2)
(1)(2)
PORTC
PTD7/T2CH1
PTD6/T2CH0
PTD5/T1CH1
PTD4/T1CH0
PORTD
PTD3/SPSCK
PTD2/MOSI
DDRD
PTD1/MISO
PTD0/SS
PTE2
DDRE
PTE1/RxD
PORTE
PTE0/TxD
SECURITY
MODULE
MONITOR MODE ENTRY
MODULE
(1)
(1)
(1)
(1)
(1)
(1)
(1)
(1)
1. Ports are software configurable with pullup device if input port.
2. Higher current drive port pins
3. Pin contains integrated pullup device
Figure 3-1. Block Diagram Highlighting ADC Block and Pins
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
48Freescale Semiconductor
INTERNAL DATA BUS
READ DDRBx
Functional Description
WRITE DDRBx
WRITE PTBx
READ PTBx
INTERRUPT
LOGIC
AIENCOCO
RESET
CONVERSION
COMPLETE
CGMXCLK
BUS CLOCK
DDRBx
PTBx
ADC DATA REGISTER
ADC
ADC CLOCK
CLOCK
GENERATOR
DISABLE
ADC
VOLTAGE IN
)
(V
ADIN
V
REFH
V
REFL
DISABLE
CHANNEL
SELECT
PTBx
ADC CHANNEL x
ADCH4–ADCH0
ADIV2–ADIV0ADICLK
Figure 3-2. ADC Block Diagram
3.3.2 ADC Port I/O Pins
PTB7/AD7–PTB0/AD0 are general-purpose I/O pins that share with the ADC channels. The channel
select bits define which ADC channel/port pin will be used as the input signal. The ADC overrides the port
I/O logic by forcing that pin as input to the ADC. The remaining ADC channels/port pins are contro lled by
the port I/O logic and can be used as general-purpose I/O. Writes to the port register or data direction
register (DDR) will not have any affect on the port pin that is selected by the ADC. Read of a port pin in
use by the ADC will return a logic 0.
3.3.3 Voltage Conversion
When the input voltage to the ADC equals V
input voltage equals V
, the ADC converts it to $00. Input voltages between V
REFL
straight-line linear conversion.
The ADC input voltage must always be greater than V
V
DDA
. V
must always be greater than or equal to V
REFH
, the ADC converts the signal to $FF (full scale). If the
REFH
and V
REFH
NOTE
and less than
SSA
.
REFL
REFL
are a
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor49
Analog-to-Digital Converter (ADC)
NOTE
Connect the V
connect the V
pin should be routed carefully for maximum noise immunity.
V
DDA
pin to the same voltage potential as the VDD pin, and
DDA
pin to the same voltage potential as the VSS pin. The
SSA
3.3.4 Conversion Time
Conversion starts after a write to the ADC status and control register (ADSCR). One co nversion will take
between 16 and 17 ADC clock cycles. The ADIVx and ADICLK bits should be set to provide a 1-MHz ADC
clock frequency.
Conversion time =
16 to 17 ADC cycles
ADC frequency
×
Number of bus cycles = conversion time
bus frequency
3.3.5 Conversion
In continuous conversion mode, the ADC data register will be filled with new dat a after each conversion.
Data from the previous conversion will be overwritten whether that data has been read or not.
Conversions will continue until the ADCO bit is cleared. The COCO bit is set after the first conversion and
will stay set until the next read of the ADC data register.
In single conversion mode, conversion begins with a write to the ADSCR. Only one conversion occurs
between writes to the ADSCR.
When a conversion is in process and the ADSCR is written, the current conversion data should be
discarded to prevent an incorrect reading.
3.3.6 Accuracy and Precision
The conversion process is monotonic and has no missing codes.
3.4 Interrupts
When the AIEN bit is set, the ADC module is capable of generating CPU interrupts after each ADC
conversion. A CPU interrupt is generated if the COCO bit is at 0. The COCO bit is not used as a
conversion complete flag when interrupts are enabled.
3.5 Low-Power Modes
The WAIT and STOP instruction can put the MCU in low power-consumption standby modes.
3.5.1 Wait Mode
The ADC continues normal operation during wait mode. Any enabled CPU interrupt request from the ADC
can bring the MCU out of wait mode. If the ADC is not required to bring the MCU out of wait mode, power
down the ADC by setting ADCH4–ADCH0 bits in the ADC status and control register before executing the
WAIT instruction.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
50Freescale Semiconductor
I/O Signals
3.5.2 Stop Mode
The ADC module is inactive after the execution of a STOP instruction. Any pending conversion is aborted.
ADC conversions resume when the MCU exits stop mode after an external interrupt. Allow one
conversion cycle to stabilize the analog circuitry.
3.6 I/O Signals
The ADC module has eight pins shared with port B, PTB7/AD7–PTB0/AD0.
3.6.1 ADC Analog Power Pin (V
The ADC analog portion uses V
as V
. External filtering may be necessary to ensure clean V
DD
DDA
)
DDA
as its power pin. Connect the V
DDA
pin to the same voltage potential
DDA
for good results.
NOTE
For maximum noise immunity, route V
carefully and place bypass
DDA
capacitors as close as possible to the package.
3.6.2 ADC Analog Ground Pin (V
The ADC analog portion uses V
as V
SS
.
as its ground pin. Connect the V
SSA
SSA
)
pin to the same voltage potential
SSA
NOTE
Route V
3.6.3 ADC Voltage Reference High Pin (V
The ADC analog portion uses V
to the same voltage potential as V
cleanly to avoid any offset errors.
SSA
REFH
as its upper voltage reference pin. The V
REFH
. External filtering is often necessary to ensure a clean V
DDA
)
pin must be connected
REFH
for
REFH
good results. Any noise present on this pin will be reflected and possibly magnified in A/D conversion
values.
NOTE
For maximum noise immunity, route V
capacitors as close as possible to the package. Routing V
parallel to V
may improve common mode noise rejection.
REFL
carefully and place bypass
REFH
REFH
close and
3.6.4 ADC Voltage Reference Low Pin (V
The ADC analog portion uses V
to the same voltage potential as V
as its lower voltage reference pin. The V
REFL
. External filtering is often necessary to ensure a clean V
SSA
REFL
)
pin must be connected
REFL
for
REFL
good results. Any noise present on this pin will be reflected and possibly magnified in A/D conversion
values.
NOTE
For maximum noise immunity, route V
to V
Routing V
, place bypass capacitors as close as possible to the package.
SS
close and parallel to V
REFH
carefully and, if not connected
REFL
may improve common mode
REFL
noise rejection.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor51
Analog-to-Digital Converter (ADC)
3.6.5 ADC Voltage In (V
V
is the input voltage signal from one of the eight ADC channels to the ADC module.
ADIN
ADIN
)
3.7 I/O Registers
These I/O registers control and monitor ADC operation:
•ADC status and control register (ADSCR)
•ADC data register (ADR)
•ADC clock register (ADCLK)
3.7.1 ADC Status and Control Register
Function of the ADC status and control register (ADSCR) is described here.
Address:$003C
Bit 7654321Bit 0
Read:COCO
Write:R
Reset:00011111
R= Reserved
Figure 3-3. ADC Status and Control Register (ADSCR)
AIENADCOADCH4ADCH3ADCH2ADCH1ADCH0
COCO — Conversions Complete Bit
In non-interrupt mode (AIEN = 0), COCO is a read-only bit that is set at the end of each conversion.
COCO will stay set until cleared by a read of the ADC data register. Reset clears this bit.
In interrupt mode (AIEN = 1), COCO is a read-only bit that is not set at the end of a conversion. It
always reads as a 0.
1 = Conversion completed (AIEN = 0)
0 = Conversion not completed (AIEN = 0) or CPU interrupt enabled (AIEN = 1)
NOTE
The write function of the COCO bit is reserved. When writing to the ADSCR
register, always have a 0 in the COCO bit position.
AIEN — ADC Interrupt Enable Bit
When this bit is set, an interrupt is generated at the end of an ADC conversion. The interrupt signal is
cleared when the data register is read or the status/control register is written. Reset clears the AIEN bit.
When set, the ADC will convert samples continuously and update the ADR register at the end of each
conversion. Only one conversion is completed between writes to the ADSCR when this bit is cleared.
Reset clears the ADCO bit.
1 = Continuous ADC conversion
0 = One ADC conversion
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
52Freescale Semiconductor
I/O Registers
ADCH4–ADCH0 — ADC Channel Select Bits
ADCH4–ADCH0 form a 5-bit field which is used to select one of 16 ADC channels. Only eight
channels, AD7–AD0, are available on this MCU. The channels are detailed in Table 3-1. Care should
be taken when using a port pin as both an analog and digital input simultaneously to prevent switching
noise from corrupting the analog signal. See Table 3-1.
The ADC subsystem is turned off when the channel select bits are all set to 1. Th is feature allows fo r
reduced power consumption for the MCU when the ADC is not being used.
NOTE
Recovery from the disabled state requires one conversion cycle to stabilize.
The voltage levels supplied from internal reference nodes, as specified in
Table 3-1, are used to verify the operation of the ADC converter both in production test and for user
1. If any unused channels are selected, the resulting ADC conversion will be unknown or
reserved.
1
↓
1
0
↓
1
0
↓
0
(1)
0
↓
0
Reserved
REFH
REFL
3.7.2 ADC Data Register
One 8-bit result register, ADC data register (ADR), is provided. This register is updated each time an ADC
conversion completes.
Address:$003D
Bit 7654321Bit 0
Read:AD7AD6AD5AD4AD3AD2AD1AD0
Write:
Reset:00000000
= Unimplemented
Figure 3-4. ADC Data Register (ADR)
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor53
Analog-to-Digital Converter (ADC)
3.7.3 ADC Clock Register
The ADC clock register (ADCLK) selects the clock frequency for the ADC.
Address:$003E
Bit 7654321Bit 0
Read:
Write:
Reset:00000000
ADIV2ADIV1ADIV0ADICLK
= Unimplemented
Figure 3-5. ADC Clock Register (ADCLK)
ADIV2–ADIV0 — ADC Clock Prescaler Bits
ADIV2–ADIV0 form a 3-bit field which selects the divide ratio used by the ADC to generate the in ternal
ADC clock. Table 3-2 shows the available clock configurations. The ADC clock should be set to
approximately 1 MHz.
Table 3-2. ADC Clock Divide Ratio
ADIV2ADIV1ADIV0ADC Clock Rate
000ADC input clock ÷ 1
001ADC input clock ÷ 2
0000
010ADC input clock ÷ 4
011ADC input clock ÷ 8
1X
1. X = Don’t care
(1)
(1)
X
ADC input clock ÷ 16
ADICLK — ADC Input Clock Select Bit
ADICLK selects either the bus clock or the oscillator output clock (CGMXCLK) as the input clock
source to generate the internal ADC clock. Reset selects CGMXCLK as the ADC clock source.
The ADC requires a clock rate of approximately 1 MHz for correct operation. If the selected clock source
is not fast enough, the ADC will generate incorrect conversions. See 20.16 ADC Characteristics.
or bus frequency
≅ 1 MHz
ADIV[2:0]
f
ADIC
=
f
CGMXCLK
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
54Freescale Semiconductor
Chapter 4
Configuration Register (CONFIG)
4.1 Introduction
This section describes the configuration registers, CONFIG1 and CONFIG2. The configuration registers
enable or disable these options:
•Stop mode recovery time (32 CGMXCLK cycles or 4096 CGMXCLK cycles)
•COP timeout period (262,128 or 8176 COPCLK cycles)
•STOP instruction
•Computer operating properly module (COP)
•Low-voltage inhibit (LVI) module control and voltage trip point selection
•Enable/disable the oscillator (OSC) during stop mode
•External clock, external crystal, or ICG clock source
4.2 Functional Description
The configuration registers are used in the initialization of various options. The configuration registers ca n
be written once after each reset. All of the configuration register bits are cleared during reset. Since the
various options affect the operation of the microcontroller unit (MCU), it is recommended that these
registers be written immediately after reset. The configuration registers are located at $001E and $001F
and may be read at anytime.
NOTE
On a FLASH device, the options except LVI5OR3 are one-time writable by
the user after each reset. The LVI5OR3 bit is one-time writable by the user
only after each POR (power-on reset). The CONFIG registers are n ot in the
FLASH memory but are special registers containing one-time writable
latches after each reset. Upon a reset, the CONFIG registers default to
predetermined settings as shown in Figure 4-1 and Figure 4-2.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor55
Configuration Register (CONFIG)
Address:$001E
Bit 76 5 432 1 Bit 0
Read:00
Write:
Reset:00000000
= UnimplementedR = Reserved
EXTXTALEN EXTSLOW EXTCLKEN
0
OSCENINSTOPR
Figure 4-1. Configuration Register 2 (CONFIG2)
Address:$001F
Bit 7654321Bit 0
Read:
Write:
Reset:0000See Note000
Note: LVI5OR3 bit is only reset via POR (power-on reset)
COPRSLVISTOPLVIRSTDLVIPWRDLVI5OR3SSRECSTOPCOPD
Figure 4-2. Configuration Register 1 (CONFIG1)
EXTXTALEN — External Crystal Enable Bit
EXTXTALEN enables the external oscillator circuits to be configured for a crystal configuration where
the PTE4/OSC1 and PTE3/OSC2 pins are the connections for an external crystal.
Clearing the EXTXTALEN bit (default setting) allows the PTE3/OSC2 pin to function as a
general-purpose I/O pin. Refer to Table 4-1 for configuration options for the external source. See
Chapter 7 Internal Clock Generator (ICG) Module) for a more detailed description of the external clock
operation.
EXTXTALEN, when set, also configures the clock monitor to expect an external clock source in the
valid range of crystals (30 kHz to 100 kHz or 1 MHz to 8 MHz). When EXTXTALEN is clear, the clock
monitor will expect an external clock source in the valid range for externally generated clocks when
using the clock monitor (60 Hz to 32 MHz).
EXTXTALEN, when set, also configures the external clock stabilization divider in the clock monitor fo r
a 4096-cycle timeout to allow the proper stabilization time for a crystal. When EXTXTALEN is clear,
the stabilization divider is configured to 16 cycles since an external clock source does not need a
startup time.
1 = Allows PTE3/OSC2 to be an external crystal connection.
0 = PTE3/OSC2 functions as an I/O port pin (default).
EXTSLOW — Slow External Crystal Enable Bit
The EXTSLOW bit has two functions. It configures the ICG module for a fast (1 MHz to 8 MHz) or slow
(30 kHz to 100 kHz) speed crystal. The option also configures the clock monitor operation in the ICG
module to expect an external frequency higher (307.2 kHz to 32 MHz) or lower (60 Hz to 307.2 kHz)
than the base frequency of the internal oscillator. See Chapter 7 Internal Clock Generator (ICG)
Module).
1 = ICG set for slow external crystal operation
0 = ICG set for fast external crystal operation
NOTE
This bit does not function without setting the EXTCLKEN bit also.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
56Freescale Semiconductor
Functional Description
EXTCLKEN — External Clock Enable Bit
EXTCLKEN enables an external clock source or crystal/ceramic resonator to be used as a clock input.
Setting this bit enables PTE4/OSC1 pin to be a clock input pin. Clearing this bit (default setting) a llows
the PTE4/OSC1 and PTE3/OSC2 pins to function as a general-purpose input/output (I/O) pin. Refer
to Table 4-1 for configuration options for the external source. See Chapter 7 Internal Clock Generator
(ICG) Module) for a more detailed description of the external clock operation.
1 = Allows PTE4/OSC1 to be an external clock connection
0 = PTE4/OSC1 and PTE3/OSC2 function as I/O port pins (default).
Table 4-1. External Clock Option Settings
External Clock
Configuration Bits
EXTCLKENEXTXTALENPTE4/OSC1PTE3/OSC2
00PTE4PTE3Default setting — external oscillator disabled
01PTE4PTE3External oscillator disabled since EXTCLKEN not set
10OSC1PTE3
11OSC1OSC2
Pin
Function
Description
External oscillator configured for an external clock source
input (square wave) on OSC1
External oscillator configured for an external crystal
configuration on OSC1 and OSC2. System will also
operate with square-wave clock source in OSC1.
OSCENINSTOP — Oscillator Enable In Stop Mode Bit
OSCENINSTOP, when set, will enable the internal clock generator module to continue to generate
clocks (either internal, ICLK, or external, ECLK) in stop mode. See Chapter 7 Internal Clock Generator
(ICG) Module). This function is used to keep the timebase running while the re st of the microcontroller
stops. See Chapter 17 Timebase Module (TBM). When clear, all clock generation will cease and both
ICLK and ECLK will be forced low during stop mode. The default state for this option is clear, disabling
the ICG in stop mode.
1 = Oscillator enabled to operate during stop mode
0 = Oscillator disabled during stop mode (default)
NOTE
This bit has the same functionality as the OSCSTOPENB CONFIG bit in
MC68HC908GP32 and MC68HC908GR8 parts.
COPRS — COP Rate Select Bit
COPD selects the COP timeout period. Reset clears COPRS. See Chapter 5 Computer Operating
Properly (COP) Module
1 = COP timeout period = 262,128 COPCLK cycles
0 = COP timeout period = 8176 COPCLK cycles
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. See Chapter 10 Low-Voltage Inhibit (LVI).
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor57
Configuration Register (CONFIG)
LVIPWRD — LVI Power Disable Bit
LVIPWRD disables the LVI module. See Chapter 10 Low-Voltage Inhibit (LVI).
1 = LVI module power disabled
0 = LVI module power enabled
LVI5OR3 — LVI 5-V or 3-V Operating Mode Bit
LVI5OR3 selects the voltage operating mode of the LVI module. See Chapter 10 Low-Vo ltage Inhibit
(LVI) The voltage mode selected for the LVI should match the operating V
. See Chapter 20
DD
Electrical Specifications for the LVI’s voltage trip points for each of the modes.
1 = LVI operates in 5-V mode.
0 = LVI operates in 3-V mode.
NOTE
The LVI5OR3 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 CGMXCLK cycles instead of a
4096-CGMXCLK cycle delay.
1 = Stop mode recovery after 32 CGMXCLK cycles
0 = Stop mode recovery after 4096 CGMXCLCK cycles
NOTE
Exiting stop mode by an LVI reset will result in the long stop recovery.
The short stop recovery delay can be enabled when using the internal oscillator, a crystal, or a ceramic
resonator and the OSCENINSTOP bit is set. The short stop recovery delay can be enabled when an
external oscillator is used, regardless of the OSCENINSTOP setting.
The short stop recovery delay must be disabled (SSREC = 0) when the OSCENINSTOP bit is cleared.
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
CONFIG register.
5.2 Functional Description
Figure 5-1 shows the structure of the COP module.
SIM MODULE
BUSCLKX4
INTERNAL RESET SOURCES
RESET VECTOR FETCH
COPCTL WRITE
COPEN (FROM SIM)
COPD (FROM CONFIG1)
RESET
COPCTL WRITE
COP RATE SELECT
(COPRS FROM CONFIG1)
12-BIT SIM COUNTER
CLEAR ALL STAGES
COP CLOCK
COP COUNTER
SIM RESET CIRCUIT
RESET STATUS REGISTER
CLEAR STAGES 5–12
COP TIMEOUT
COP MODULE
6-BIT COP COUNTER
CLEAR
Figure 5-1. COP Block Diagram
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor59
Computer Operating Properly (COP) Module
The COP counter is a free-running 6-bit counter preceded by a 12-bit prescaler counter. If not cleared by
software, the COP counter overflows and generates an asynchronous reset after 262,128 or 8176
COPCLK cycles, depending on the state of the COP rate select bit, COPRS, in th e configuration register.
With a 8176 COPCLK cycle overflow option, a 32.768-kHz crystal gives a COP timeout period of 250 ms.
Writing any value to location $FFFF before an overflow occurs prevents a COP reset by clearing the COP
counter and stages 12 through 5 of the prescaler.
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
pin low for 32 COPCLK cycles and sets the COP bit in the reset status register
(RSR).
In monitor mode, the COP is disabled if the RST
on the RST pin disables the COP.
V
TST
pin or the IRQ1 is held at V
. During the break state,
TST
NOTE
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.
5.3 I/O Signals
The following paragraphs describe the signals shown in Figure 5-1.
5.3.1 COPCLK
COPCLK is a clock generated by the clock selection circuit in the internal clock generator (ICG). See 7.3.5
Clock Selection Circuit for more details.
5.3.2 STOP Instruction
The STOP instruction clears the COP prescaler.
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 bits 12 through 5 of the prescaler. 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 clears the COP prescaler 4096 CGMXCLK cycles after power-up.
5.3.5 Internal Reset
An internal reset clears the COP prescaler and the COP counter.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
60Freescale Semiconductor
COP Control Register
5.3.6 Reset Vector Fetch
A reset vector fetch occurs when the vector address appears on the data bus. A reset vector fetch clears
the COP prescaler.
5.3.7 COPD (COP Disable)
The COPD signal reflects the state of the COP disable bit (COPD) in the configuration register. See
Chapter 4 Configuration Register (CONFIG).
5.3.8 COPRS (COP Rate Select)
The COPRS signal reflects the state of the COP rate select bit (COPRS) in the configuration register. See
Chapter 4 Configuration Register (CONFIG).
5.4 COP Control Register
The COP control register 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.
Address: $FFFF
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 central processor unit (CPU) interrupt requests.
5.6 Monitor Mode
When monitor mode is entered with V
on the IRQ
having V
pin or the RST pin. When monitor mode is entered by having blank reset vectors and not
on the IRQ pin, the COP is automatically disabled until a POR occurs.
TST
on the IRQ pin, the COP is disabled as long as V
TST
remains
TST
5.7 Low-Power Modes
The WAIT and STOP instructions put the microcontroller unit (MCU) in low power-consumption standby
modes.
5.7.1 Wait Mode
The COP remains active during wait mode. To prevent a COP reset during wait mode, periodically clea r
the COP counter in a CPU interrupt routine.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor61
Computer Operating Properly (COP) Module
5.7.2 Stop Mode
Stop mode turns off the COPCLK input to the COP and clears the COP prescaler. Service the COP
immediately before entering or after exiting stop mode to ensure a full COP timeout period after entering
or exiting stop mode.
To prevent inadvertently turning off the COP with a STOP instruction, a configuration option is available
that disables the STOP instruction. When the STOP bit in the configuration register has the STOP
instruction is disabled, execution of a STOP instruction results in an illegal opcode reset.
5.8 COP Module During Break Mode
The COP is disabled during a break interrupt when V
is present on the RST pin.
TST
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
62Freescale Semiconductor
Chapter 6
Central Processor Unit (CPU)
6.1 Introduction
The M68HC08 CPU (central processor unit) is an enhanced a nd fu lly object-code- compatib le version o f
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.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor63
Central Processor Unit (CPU)
7
15
HX
15
15
70
V11H I NZC
0
ACCUMULATOR (A)
0
INDEX REGISTER (H:X)
0
STACK POINTER (SP)
0
PROGRAM COUNTER (PC)
CONDITION CODE REGISTER (CCR)
CARRY/BORROW FLAG
ZERO FLAG
NEGATIVE FLAG
INTERRUPT MASK
HALF-CARRY FLAG
TWO’S COMPLEMENT OVERFLOW FLAG
Figure 6-1. CPU Registers
6.3.1 Accumulator
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
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
64Freescale 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)
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor65
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 t he
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
V11H I 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 interru pts 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
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
66Freescale 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.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor67
Central Processor Unit (CPU)
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)
0
b0
C0
b0
Source
on CCR
VHI 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
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
ii
AA
dd
BA
hh ll
CA
ee ff
DA
ff
EA
FA
ff
9EEA
ee ff
9EDA
Operand
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
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor71
Central Processor Unit (CPU)
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
C
b7
b7
SP ← (SP) + 1; Pull (CCR)
SP ← (SP) + 1; Pull (A)
SP ← (SP) + 1; Pull (X)
SP ← (SP) + 1; Pull (PCH)
SP ← (SP) + 1; Pull (PCL)
SP ← SP + 1; Pull (PCH)
SP ← SP + 1; Pull (PCL)
I ← 0; Stop Processing––0–––INH8E1
b0
b0
C
on CCR
VHI 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
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
72Freescale 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 bitopr Operand (one or two bytes)
CCRCondition code registerPCProgram 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⊕Logical EXCLUSIVE OR
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«Sign extend
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 – – –
The internal clock generator module (ICG) is used to create a stable clock source for the microcontroller
without using any external components. The ICG generates the oscillator output clock (CGMXCLK),
which is used by the low-voltage inhibit (LVI) and other modules. The ICG also generates the clock
generator output (CGMOUT), which is fed to the system integration module (SIM) to create the bus
clocks. The bus frequency will be one-fourth the frequency of CGMXCLK and one-half the frequency of
CGMOUT. Finally, the ICG generates the timebase clock (TBMCLK), which is used in the timebase
module (TBM) and the computer operating properly (COP) clock (COPCLK) which is used by the COP
module.
7.2 Features
The ICG has these features:
•Selectable external clock generator, either 1-pin external source or 2-pin crystal, multiplexed with
port pins
•Internal clock generator with programmable frequency output in integer multiples of a nominal
frequency (307.2 kHz ± 25 percent)
•Frequency adjust (trim) register to improve variability to ±4 percent
•Bus clock software selectable from either internal or external clock (bus frequency range from
76.8 kHz ± 25 percent to 9.75 MHz ± 25 percent in 76.8-kHz increments
NOTE
Do not exceed the maximum bus frequency of 8 MHz at 5.0 V and 4 MHz
at 3.0 V.
•Timebase clock automatically selected from external if external clock is available
•Clock monitor for both internal and external clocks
7.3 Functional Description
The ICG, shown in Figure 7-2, contains these major submodules:
•Clock enable circuit
•Internal clock generator
•External clock generator
•Clock monitor circuit
•Clock selection circuit
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor75
Internal Clock Generator (ICG) Module)
M68HC08 CPU
CPU
REGISTERS
ARITHMETIC/LOGIC
UNIT (ALU)
INTERNAL BUS
PROGRAMMABLE TIMEBASE
MODULE
DDRA
PORTA
PTA7/KBD7–
PTA0/KBD0
(1)
CONTROL AND STATUS
REGISTERS — 64 BYTES
USER FLASH
MC68HC908GT16 — 15,872 BYTES
MC68HC908GT8 — 7,680 BYTES
USER RAM — 512 BYTES
MONITOR ROM — 304 BYTES
FLASH PROGRAMMING ROUTINES
ROM — 720 BYTES
USER FLASH VECTOR SPACE — 36 BYTES
PTE4/OSC1
PTE3/OSC2
RST
IRQ
V
REFH
V
REFL
(3)
(3)
INTERNAL CLOCK
GENERATOR MODULE
SYSTEM INTEGRATION
MODULE
SINGLE EXTERNAL
INTERRUPT MODULE
8-BIT ANALOG-TO-DIGITAL
CONVERTER MODULE
POWER-ON RESET
MODULE
V
DD
V
SS
V
DDA
V
SSA
POWER
SINGLE BREAKPOINT BREAK
LOW-VOLTAGE INHIBIT MODULE
2-CHANNEL TIMER INTERFACE
2-CHANNEL TIMER INTERFACE
MODULE
DUAL VOLTAGE
8-BIT KEYBOARD
INTERRUPT MODULE
MODULE 1
MODULE 2
SERIAL COMMUNICATIONS
INTERFACE MODULE
COMPUTER OPERATING
PROPERLY MODULE
SERIAL PERIPHERAL
INTERFACE MODULE
MONITOR MODULE
MEMORY MAP
MODULE
CONFIGURATION REGISTER 1
MODULE
CONFIGURATION REGISTER 2
MODULE
PTB7/AD7
PTB6/AD6
PTB5/AD5
PTB4/AD4
DDRB
PTB3/AD3
PORTB
PTB2/AD2
PTB1/AD1
PTB0/AD0
(1)
PTC6
(1)
PTC5
(1)(2)
PTC4
(1)(2)
DDRC
PTC3
PTC2
PTC1
PTC0
(1)(2)
(1)(2)
(1)(2)
PORTC
PTD7/T2CH1
PTD6/T2CH0
PTD5/T1CH1
PTD4/T1CH0
PORTD
PTD3/SPSCK
PTD2/MOSI
DDRD
PTD1/MISO
PTD0/SS
PTE2
DDRE
PTE1/RxD
PORTE
PTE0/TxD
SECURITY
MODULE
MONITOR MODE ENTRY
MODULE
(1)
(1)
(1)
(1)
(1)
(1)
(1)
(1)
1. Ports are software configurable with pullup device if input port.
2. Higher current drive port pins
3. Pin contains integrated pullup device
Figure 7-1. Block Diagram Highlighting ICG Module and Pins
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
76Freescale Semiconductor
Functional Description
CSCGMOUT
RESET
CLOCK
SELECTION
CIRCUIT
CGMXCLK
TBMCLK
COPCLK
IOFF
EOFF
CMON
N[6:0}
TRIM[7:0]
SIMOSCEN
OSCENINSTOP
EXTCLKEN
ECGON
ICGON
EXTXTALEN
EXTSLOW
CLOCK
MONITOR
CIRCUIT
INTERNAL CLOCK
GENERATOR
CLOCK/PIN
ENABLE
CIRCUIT
EXTERNAL CLOCK
GENERATOR
ECGS
ICGS
FICGS
DDIV[3:0]
DSTG[7:0]
ICLK
IBASE
ICGEN
ECGEN
ECLK
INTERNAL
TO MCU
EXTERNAL
NAME
NAMETOP LEVEL SIGNAL
PTE4
LOGIC
OSC1
PTE4
OSC2
PTE3
PTE3
LOGIC
NAMECONFIG2 REGISTER BITREGISTER BIT
NAME
MODULE SIGNAL
Figure 7-2. ICG Module Block Diagram
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor77
Internal Clock Generator (ICG) Module)
7.3.1 Clock Enable Circuit
The clock enable circuit is used to enable the internal clock (ICLK) or external clock (ECLK) and the port
logic which is shared with the oscillator pins (OSC1 and OSC2). The clock enable circuit generates an
ICG stop (ICGSTOP) signal which stops all clocks (ICLK, ECLK, and the low-frequency base clock,
IBASE). ICGSTOP is set and the ICG is disabled in stop mode if the oscillator enable stop bit
(OSCENINSTOP) in the CONFIG2 register is clear. The ICG clocks will be enabled in stop mode if
OSCENINSTOP is high.
The internal clock enable signal (ICGEN) turns on the internal clock generator which generates ICLK.
ICGEN is set (active) whenever the ICGON bit is set and the ICGSTOP signal is clear. When ICGEN is
clear, ICLK and IBASE are both low.
The external clock enable signal (ECGEN) turns on the external clock generator which generates ECLK.
ECGEN is set (active) whenever the ECGON bit is set and the ICGSTOP signal is clear. ECGON cannot
be set unless the external clock enable (EXTCLKEN) bit in the CONFIG2 register is set. when ECGEN is
clear, ECLK is low.
The port E4 enable signal (PE4EN) turns on the port E4 logic. Since po rt E4 is on the same pin as OSC1,
this signal is only active (set) when the external clock function is not desired. Therefore, PE4EN is clear
when ECGON is set. PE4EN is not gated with ICGSTOP, which means that if the ECGON bit is set, the
port E4 logic will remain disabled in stop mode.
The port E3 enable signal (PE3EN) turns on the port E3 logic. Since po rt E3 is on the same pin as OSC2,
this signal is only active (set) when 2-pin oscillator function is not desired. Therefore, PE3EN is clear when
ECGON and the external crystal enable (EXTXTALEN) bit in the CONFIG2 register are both set. PE3EN
is not gated with ICGSTOP, which means that if ECGON and EXTXTALEN are set, the port E3 logic will
remain disabled in stop mode.
7.3.2 Internal Clock Generator
The internal clock generator, shown in Figure 7-3, creates a low frequency base clock (IBASE), which
operates at a nominal frequency (f
an integer multiple of IBASE. This multiple is the ICG multiplier factor (N), which is programmed in the
ICG multiplier register (ICGMR). The internal clock generator is turned off and the output clocks (IBASE
and ICLK) are held low when the internal clock generator enable signal (ICGEN) is clear.
The internal clock generator contains:
•A digitally controlled oscillator
•A modulo N divider
•A frequency comparator, which contains voltage and current references, a frequency to voltage
converter, and comparators
•A digital loop filter
) of 307.2 kHz ± 25 percent, and an internal clock (ICLK) which is
NOM
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
The digitally controlled oscillator (DCO) is an inaccurate oscillator which generates the internal clock
(ICLK). The clock period of ICLK is dependent on the digital loo p filter outputs (DSTG[7:0] and DDIV[3:0]).
Because of only a limited number of bits in DDIV and DSTG, the precision of the output (ICLK) is restricted
to a precision of approximately ±0.202 percent to ±0.368 percent when measured over several cycles (of
the desired frequency). Additionally, since the propagation delays of the devices used in the DCO ring
oscillator are a measurable fraction of the bus clock period, reaching the long-term precision may require
alternately running faster and slower than desired, making the worst case cycle-to-cycle frequency
variation ±6.45 percent to ±11.8 percent (of the desired frequency). The valid values of DDIV:DSTG range
from $000 to $9FF. For more information on the quantization error in the DCO, see 7.4.4 Quantization
Error in DCO Output.
7.3.2.2 Modulo N Divider
The modulo N divider creates the low-frequency base clock (IBASE) by dividing the internal clock (ICLK)
by the ICG multiplier factor (N), contained in the ICG multiplier register (ICGMR). When N is programmed
to a $01 or $00, the divider is disabled and ICLK is passed through to IBASE undivided. When the internal
clock generator is stable, the frequency of IBASE will be equal to the nominal frequency (f
) of 307.2
NOM
kHz ± 25 percent.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor79
Internal Clock Generator (ICG) Module)
7.3.2.3 Frequency Comparator
The frequency comparator effectively compares the low-frequency base clock (IBASE) to a nominal
frequency, f
. First, the frequency comparator converts IBASE to a voltage by charging a known
NOM
capacitor with a current reference for a period dependent on IBASE. This voltage is compared to a voltage
reference with comparators, whose outputs are fed to the digital loop filter. The dependence of these
outputs on the capacitor size, current reference, and voltage reference causes up to ±25 percent error in
f
.
NOM
7.3.2.4 Digital Loop Filter
The digital loop filter (DLF) uses the outputs of the frequency comparator to adjust the internal clock
(ICLK) clock period. The DLF generates the DCO divider control bits (DDIV[3:0]) and the DCO stage
control bits (DSTG[7:0]), which are fed to the DCO. The DLF first concatenates the DDIV and DSTG
registers (DDIV[3:0]:DSTG[7:0]) and then adds or subtracts a value dependent on the relative error in the
low-frequency base clock’s period, as shown in Table 7-1. In some extreme error conditions, such as
operating at a V
level which is out of specification, the DLF may attempt to use a value above the
DD
maximum ($9FF) or below the minimum ($000). In both cases, the value for DDIV will be between $A and
$F. In this range, the DDIV value will be interpreted the same as $9 (the slowest condition). Recovering
from this condition requires subtracting (increasing frequency) in the normal fashion until the value is
again below $9FF. (If the desired value is $9xx, the value may settle at $Axx through $Fxx. This is an
acceptable operating condition.) If the error is less than ±5 percent, the internal clock generator’s filter
stable indicator (FICGS) is set, indicating relative frequency accuracy to the clock monitor.
Table 7-1. Correction Sizes from DLF to DCO
Frequency Error of IBASE
Compared to f
IBASE < 0.85 f
0.85 f
NOM
IBASE < 0.95 f
0.95 f
NOM
IBASE < f
< IBASE
f
NOM
IBASE < 1.05 f
1.05 f
NOM
IBASE < 1.15 f
1.15 f
NOM
1. x = Maximum error is independent of value in DDIV[3:0]. DDIV increments or decrements when an addition to DSTG[7:0]
carries or borrows.
NOM
NOM
< IBASE
NOM
< IBASE
NOM
NOM
< IBASE
NOM
< IBASE+32 (+$020)
DDVI[3:0]:DSTG[7:0]
Correction
–32 (–$020)
–8 (–$008)
–1 (–$001)
+1 (+$001)
+8 (+$008)
Current to New
DDIV[3:0]:DSTG[7:0]
Minimum$xFF to $xDF–2/31–6.45%
Maximum$x20 to $x00 –2/19–10.5%
Minimum$xFF to $xF7–0.5/31–1.61%
Maximum$x08 to $x00–0.5/17.5–2.86%
Minimum$xFF to $xFE–0.0625/31–0.202%
Maximum$x01 to $x00–0.0625/17.0625–0.366%
Minimum$xFE to $xFF+0.0625/30.9375+0.202%
Maximum$x00 to $x01+0.0625/17+0.368%
Minimum$xF7 to $xFF+0.5/30.5+1.64%
Maximum$x00 to $x08+0.5/17+2.94%
Minimum$xDF to $xFF+2/29+6.90%
Maximum$x00 to $x20+2/17+11.8%
(1)
Relative Correction
in DCO
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
80Freescale Semiconductor
Functional Description
7.3.3 External Clock Generator
The ICG also provides for an external oscillator or external clock source, if desired. The external clock
generator, shown in Figure 7-4, contains an external oscillator amplifier and an external clock input path.
ECGEN
EXTXTALEN
R
AMPLIFIER
B
R
*
S
X
1
C
2
These components are required
for external crystal use only.
when used with higherfrequency crystals. Refer
to manufacturer’s data.
ECLK
7.3.3.1 External Oscillator Amplifier
The external oscillator amplifier provides the gain required by an external crystal connected in a Pierce
oscillator configuration. The amount of this gain is controlled by the slow external (EXTSLOW) bit in the
CONFIG2 register. When EXTSLOW is set, the amplifier gain is reduced for operating low-frequency
crystals (32 kHz to 100 kHz). When EXTSLOW is clear, the amplifier gain will be sufficient for 1-MHz to
8-MHz crystals. EXTSLOW must be configured correctly for the given crystal or the circuit may not
operate.
The amplifier is enabled when the external clock generator enable (ECGEN) signal is set and when the
external crystal enable (EXTXTALEN) bit in the CONFIG2 register is set. ECGEN is controlled by the
clock enable circuit (see 7.3.1 Clock Enable Circuit) and indicates that the external clock function is
desired. When enabled, the amplifier will be connected between the PTE4/OSC1 and PTE3/OSC2 pins.
Otherwise, the PTE3/OSC2 pin reverts to its port function.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor81
Internal Clock Generator (ICG) Module)
In its typical configuration, the external oscillator requires five external components:
1.Crystal, X
2.Fixed capacitor, C
1
1
3.Tuning capacitor, C2 (can also be a fixed capacitor)
4.Feedback resistor, RB
5.Series resistor, R
(Included in Figure 7-4 to follow strict Pierce oscillator guidelines and may not
S
be required for all ranges of operation, especially with high frequency crystals. Refer to the crystal
manufacturer’s data for more information.)
7.3.3.2 External Clock Input Path
The external clock input path is the means by which the microcontroller uses an external clock source.
The input to the path is the PTE4/OSC1 pin and the output is the external clock (ECLK). The path, which
contains input buffering, is enabled when the external clock generator enable signal (ECGEN) is set.
When not enabled, the PTE4/OSC1 pin reverts to its port function.
7.3.4 Clock Monitor Circuit
The ICG contains a clock monitor circuit which, when enabled, will continuou sly monitor both the external
clock (ECLK) and the internal clock (ICLK) to determine if either clock source has been corrupted. The
clock monitor circuit, shown in Figure 7-5, contains these blocks:
•Clock monitor reference generator
•Internal clock activity detector
•External clock activity detector
7.3.4.1 Clock Monitor Reference Generator
The clock monitor uses a reference based on one clock source to monitor the other clock source. The
clock monitor reference generator generates the external reference clock (EREF) based on the externa l
clock (ECLK) and the internal reference clock (IREF) based on the internal clock (ICLK). To simplify the
circuit, the low-frequency base clock (IBASE) is used in place of ICLK because it always operates at or
near 307.2 kHz. For proper operation, EREF must be at least twice as slow as IBASE and IREF must be
at least twice as slow as ECLK.
To guarantee that IREF is slower than ECLK and EREF is slower than IBASE, one of the signals is divided
down. Which signal is divided and by how much is determined by the external slow (EXTSLOW) and
external crystal enable (EXTXTALEN) bits in the CONFIG2 register, according to the rules in Table 7-2.
NOTE
Each signal (IBASE and ECLK) is always divided by four. A longer divider
is used on either IBASE or ECLK based on the EXTSLOW bit.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
82Freescale Semiconductor
Functional Description
CMON
FICGS
IBASE
ICGEN
EXTXTALEN
EXTSLOW
ECGEN
ECLK
CMON
FICGS
IBASE
ICGEN
EREF
IBASE
ICGON
EXTXTALEN
EXTSLOW
ECGS
ECLK
ECGEN
ESTBCLK
IREF
ECGEN
ECLK
ICLK
ACTIVITY
DETECTOR
REFERENCE
GENERATOR
ECLK
ACTIVITY
DETECTOR
IOFF
ICGS
EREF
ESTBCLK
IREF
ECGS
IOFF
ICGS
ECGS
EOFF
MODULE SIGNAL
NAME
NAMETOP LEVEL SIGNAL
CMON
EOFF
NAMECONFIG2 REGISTER BITREGISTER BIT
NAME
Figure 7-5. Clock Monitor Block Diagram
To conserve size, the long divider (divide by 4096) is also used as an external crystal stabilization divider.
The divider is reset when the external clock generator is turned off or in stop mode (ECGEN is clear).
When the external clock generator is first turned on, the external clock generator stable bit (ECGS) will
be clear. This condition automatically selects ECLK as the input to the long divider. The external
stabilization clock (ESTBCLK) will be ECLK divided by 16 when EXTXTALEN is low or 4096 when
EXTXTALEN is high. This timeout allows the crystal to stabilize. The falling edge of ESTBCLK is used to
set ECGS, which will set after a full 16 or 4096 cycles. When ECGS is set, the divider returns to its normal
function. ESTBCLK may be generated by either IBASE or ECLK, but any clocking will only reinforce the
set condition. If ECGS is cleared because the clock monitor determined that ECLK was inactive, the
divider will revert to a stabilization divider. Since this will change the EREF and IREF divide ratios, it is
important to turn the clock monitor off (CMON = 0) after inactivity is detected to ensure valid recovery.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor83
Internal Clock Generator (ICG) Module)
7.3.4.2 Internal Clock Activity Detector
The internal clock activity detector, shown in Figure 7-6, looks for at least one falling edge on the
low-frequency base clock (IBASE) every time the external reference (EREF) is low. Since EREF is less
than half the frequency of IBASE, this should occur every time. If it does not occur two consecutive times,
the internal clock inactivity indicator (IOFF) is set. IOFF will be cleared the next time there is a falling edge
of IBASE while EREF is low.
CMON
EREF
CKQ
1/4
R
IOFF
R
DQ
DFFRR
CK
R
R
DQ
DFFRR
CK
R
NAMECONFIG2 REGISTER BIT
NAME
ICGS
REGISTER BIT
MODULE SIGNAL
IBASE
DLF MEASURE
OUTPUT CLOCK
ICGEN
FICGS
NAME
NAME
R
D
DFFRS
CK
Q
S
TOP LEVEL SIGNAL
Figure 7-6. Internal Clock Activity Detector
The internal clock stable bit (ICGS) is also generated in the internal clock activity detector. ICGS is set
when the internal clock generator’s filter stable signal (FICGS) indicates that IBASE is within about 5
percent of the target 307.2 kHz ± 25 percent for two consecutive measurements. ICGS is cleared when
FICGS is clear, the internal clock generator is turned off or is in stop mode (ICGEN is clear), or when IOFF
is set.
7.3.4.3 External Clock Activity Detector
The external clock activity detector, shown in Figure 7-7, looks for at least one falling edg e on the external
clock (ECLK) every time the internal reference (IREF) is low. Since IREF is less than half the frequency
of ECLK, this should occur every time. If it does not occur two consecutive times, the external clock
inactivity indicator (EOFF) is set. EOFF will be cleared the next time there is a falling edge of ECLK while
IREF is low.
The external clock stable bit (E CGS) is also generated in the external clock activity detector. ECGS is set
on a falling edge of the external stabilization clock (ESTBCLK). This will be 4096 ECLK cycles after the
external clock generator on bit is set, or the MCU exits stop mode (ECGEN = 1) if the external crystal
enable (EXTXTALEN) in the CONFIG2 register is set, or 16 cycles when EXTXTALEN is clear. ECGS is
cleared when the external clock generator is turned off or in stop mode (ECGEN is clear) or when EOFF
is set.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
84Freescale Semiconductor
CMON
IREF
CKQ
1/4
R
Functional Description
EOFF
D
DFFRR
CK
R
Q
R
NAMECONFIG2 REGISTER BIT
NAME
REGISTER BIT
MODULE SIGNAL
EGGS
ECLK
ESTBCLK
ECGEN
NAME
NAME
R
D
DFFRS
CK
Q
S
TOP LEVEL SIGNAL
Figure 7-7. External Clock Activity Detector
7.3.5 Clock Selection Circuit
The clock selection circuit, shown in Figure 7-8, contains two clock switches which generate the oscillator
output clock (CGMXCLK) and the timebase clock (TBMCLK) from either the internal clock (ICLK) or the
external clock (ECLK). The COP clock (COPCLK) is identical to TBMCLK. The clock selection circuit also
contains a divide-by-two circuit which creates the clock generator output clock (CGMOUT), which
generates the bus clocks.
ICLK
ECLK
IOFF
EOFF
RESET
V
ECGON
CS
SS
NAME
NAME
SELECT
ICLK
ECLK
IOFF
EOFF
FORCE_I
FORCE_E
SELECT
ICLK
ECLK
IOFF
EOFF
FORCE_I
FORCE_E
TOP LEVEL SIGNAL
SYNCHRONIZING
SWITCHER
SYNCHRONIZING
SWITCHER
OUTPUT
CLOCK
OUTPUT
CLOCK
Figure 7-8. Clock Selection Circuit Block Diagram
DIV2
NAMECONFIG2 REGISTER BIT
NAME
CGMXCLK
CGMOUT
TBMCLK
COPCLK
REGISTER BIT
MODULE SIGNAL
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor85
Internal Clock Generator (ICG) Module)
7.3.5.1 Clock Selection Switches
The first switch creates the oscillator output clock (CGMXCLK) from either the internal clock (ICLK) or the
external clock (ECLK), based on the clock select bit (CS; set selects ECLK, clear selects ICLK). When
switching the CS bit, both ICLK and ECLK must be on (ICGON and ECGON set). The clock being
switched to also must be stable (ICGS or ECGS set).
The second switch creates the timebase clock (TBMCLK) and the COP clock (COPCLK) from ICLK or
ECLK based on the external clock on bit. When ECGON is set, the switch automatically selects the
external clock, regardless of the state of the ECGS bit.
7.3.5.2 Clock Switching Circuit
To robustly switch between the internal clock (ICLK) and the external clock (ECLK), the switch assumes
the clocks are completely asynchronous, so a synchronizing circuit is required to make the transition.
When the select input (the clock select bit for the oscillator output clock switch or the external clock on bit
for the timebase clock switch) is changed, the switch will continue to operate off the original clock for
between one and two cycles as the select input is transitioned through one side o f the synchronizer. Next,
the output will be held low for between one and two cycles of the new clock as the select input transitions
through the other side. Then the output starts switching at the new clock’s frequency. This transition
guarantees that no glitches will be seen on the output even though the select input may change
asynchronously to the clocks. The unpredictably of the transition period is a necessary result of the
asynchronicity.
The switch automatically selects ICLK during reset. When the clock monitor is on (CMON is set) and it
determines one of the clock sources is inactive (as indicated by the IOFF or EOFF signa ls) , the circuit is
forced to select the active clock. There are no clocks for the inactive side of the synchronizer to properly
operate, so that side is forced deselected. However, the active side will not be selected until one to two
clock cycles after the IOFF or EOFF signal transitions.
7.4 Usage Notes
The ICG has several features which can provide protection to the microcontroller if properly used. Other
features can greatly simplify usage of the ICG if certain techniques are employed. This section describes
several possible ways to use the ICG and its features. These techniques a re not the only ways to use the
ICG and may not be optimum for all environments. In any case, these techniques should be used only as
a template, and the user should modify them according to the application’s requirements.
These notes include:
•Switching clock sources
•Enabling the clock monitor
•Using clock monitor interrupts
•Quantization error in digitally controlled oscillator (DCO) output
•Switching internal clock frequencies
•Nominal frequency settling time
•Improving frequency settling time
•Trimming frequency
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
86Freescale Semiconductor
Usage Notes
7.4.1 Switching Clock Sources
•Switching from one clock source to another requires both clock sources to be enabled and stable.
A simple flow requires:
•Enable desired clock source
•Wait for it to become stable
•Switch clocks
•Disable previous clock source
The key point to remember in this flow is that the clock source cannot be switched (CS cannot be written)
unless the desired clock is on and stable. A short assembly code example of how to employ this flow is
shown in Figure 7-9.
;* Clock Switching Code Example
;* This code switches from internal to external clock
;* Clock monitor and interrupts are not enabled
;* ICG Clock Switch
SwitchItoE:
bset ECGON,ICGCR ; turn on external oscillator
brclr ECGS,ICGCR,* ; wait until external clock engaged
bset CS,ICGCR ; select external clock for bus
bclr ICGON,ICGCR ; turn off internal clock (if desired)
Figure 7-9. Code Example for Switching Clock Sources
7.4.2 Enabling the Clock Monitor
Many applications require the clock monitor to determine if one of the clock sources has become inactive,
so the other can be used to recover from a potentially dangerous situation. Using the clock monitor
requires both clocks to be active (ECGON and ICGON both set). To enable the clock monitor, both clocks
also must be stable (ECGS and ICGS both set). This is to prevent the use of the clock monitor when a
clock is first turned on and potentially unstable.
Enabling the clock monitor and clock monitor interrupts requires a flow similar to this:
•Enable the alternate clock source
•Wait for both clock sources to be stable
•Switch to the desired clock source if necessary
•Enable the clock monitor
•Enable clock monitor interrupts
These events must happen in sequence. A short assembly code example of how to employ this flow is
shown in Figure 7-10.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor87
Internal Clock Generator (ICG) Module)
;* Clock Monitor Enable Code Example
;* This code turns on both clocks, selects the desired one,
;* then turns on the Clock Monitor and CM Interrupt
;* ICG Clock Monitor Enable
CMEnable:
bset ECGON,ICGCR ; turn on external oscillator
; (assumes internal osc is on)
brclr ECGS,ICGCR,* ; wait until external clock engaged
bset CS,ICGCR ; select external clock for bus
bset CMON,ICGCR ; enable Clock Monitor
bset CMIE,ICGCR ; enable CM interrupt
Figure 7-10. Code Example for Enabling the Clock Monitor
7.4.3 Using Clock Monitor Interrupts
The clock monitor circuit can be used to recover from perilous situations such as crystal loss. To use th e
clock monitor effectively, these points should be observed:
•Enable the clock monitor and clock monitor interrupts.
•The first statement in the clock monitor interrupt service routine (CMISR) should be a read to the
ICG control register (ICGCR) to verify that the clock monitor flag (CMF) is set. This is also the first
step in clearing the CMF bit.
•The second statement in the CMISR should be a write to the ICGCR to clear the CMF bit (write the
bit low). Writing the bit high will not affect it. This statement does not need to immediately follow
the first, but must be contained in the CMISR.
•The third statement in the CMISR should be to clear the CMON bit. This is required to ensure
proper reconfiguration of the reference dividers. This statement also must be contained in the
CMISR.
•Although the clock monitor can be enabled only when both clocks are stable (ICGS is set or ECGS
is set), it will remain set if one of the clocks goes unstable.
•The clock monitor only works if the external slow (EXTSLOW) bit in the CONFIG2 register is set to
the correct value.
•The internal and external clocks must both be enabled and running to use the clock monitor.
•When the clock monitor detects inactivity, the inactive clock is automatically deselected and the
active clock selected as the source for CGMXCLK and TBMCLK. The CMISR can use the state of
the CS bit to check which clock is inactive.
•When the clock monitor detects inactivity, the application may have been subjected to extreme
conditions which may have affected other circuits. The CMISR should take any appropriate
precautions.
7.4.4 Quantization Error in DCO Output
The digitally controlled oscillator (DCO) is comprised of three major sub-blocks:
1.Binary weighted divider
2.Variable-delay ring oscillator
3.Ring oscillator fine-adjust circuit
Each of these blocks affects the clock period of the internal clock (ICLK). Since these blocks are controlled
by the digital loop filter (DLF) outputs DDIV and DSTG, the output of the DCO can change only in
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
88Freescale Semiconductor
Usage Notes
quantized steps as the DLF increments or decrements its output. The following sections describe how
each block will affect the output frequency.
7.4.4.1 Digitally Controlled Oscillator
The digitally controlled oscillator (DCO) is an inaccurate oscillator which generates the internal clock
(ICLK), whose clock period is dependent on the digital loop filter outputs (DSTG[7:0] and DDIV[3:0]).
Because of the digital nature of the DCO, the clock period of ICLK will change in quantized steps. This
will create a clock period difference or quantization error (Q-ERR) from one cycle to the next. Over several
cycles or for longer periods, this error is divided out until it reaches a minimum error of 0.202 percent to
0.368 percent. The dependence of this error on the DDIV[3:0 ] value and the number of cycles the error is
measured over is shown in Table 7-2.
The binary weighted divider divides the output of the ring oscillator by a power of two, specified by the
DCO divider control bits (DDIV[3:0]). DDIV maximizes at %1001 (values of %1010 through %1111 are
interpreted as %1001), which corresponds to a divide by 512. When DDIV is %0000, the ring oscillator ’s
output is divided by 1. Incrementing DDIV by one will double the period; decrementing DDIV will halve the
period. The DLF cannot directly increment or decrement DDIV; DDIV is only incremented or decremented
when an addition or subtraction to DSTG carries or borrows.
7.4.4.3 Variable-Delay Ring Oscillator
The variable-delay ring oscillator’s period is adjustable from 17 to 31 stage delays, in in crements of two,
based on the upper three DCO stage control bits (DSTG[7:5]). A DSTG[7:5] of %000 corresponds to 17
stage delays; DSTG[7:5] of %111 corresponds to 31 sta ge delays. Adjust ing the DSTG[5] b it has a 6.45
percent to 11.8 percent effect on the output frequency. This also corresponds to the size correction ma de
when the frequency error is greater than ±15 percent. The value of the binary weighted divider does not
affect the relative change in output clock period for a given change in DSTG[7:5].
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor89
Internal Clock Generator (ICG) Module)
7.4.4.4 Ring Oscillator Fine-Adjust Circuit
The ring oscillator fine-adjust circuit causes the ring oscillator to effectively operate at non-integer
numbers of stage delays by operating at two different points fo r a variable numb er of cycles specifie d by
the lower five DCO stage control bits (DSTG[4:0]). For example:
•When DSTG[7:5] is %011, the ring oscillator nominally operates at 23 stage delays.
•When DSTG[4:0] is %00000, the ring will always operate at 23 stage delays.
•When DSTG[4:0] is %00001, the ring will operate at 25 stage delays for one of 32 cycles and at 23
stage delays for 31 of 32 cycles.
•Likewise, when DSTG[4:0] is %11111, the ring operates at 25 stage delays for 31 of 32 cycles and
at 23 stage delays for one of 32 cycles.
•When DSTG[7:5] is %111, similar results are achieved by including a variable divide-by-two, so the
ring operates at 31 stages for some cycles and at 17 stage delays, with a divide-by-two for an
effective 34 stage delays, for the remainder of the cycles.
Adjusting the DSTG[0] bit has a 0.202 percent to 0.368 percent effect on the output clock period. This
corresponds to the minimum size correction made by the DLF, and the inherent, long-term quantization
error in the output frequency.
7.4.5 Switching Internal Clock Frequencies
The frequency of the internal clock (ICLK) may need to be changed for some applications. For example,
if the reset condition does not provide the correct frequency, or if the clock is slowed down for a low-power
mode (or sped up after a low-power mode), the frequency must be changed by programming the internal
clock multiplier factor (N). The frequency of ICLK is N times the frequency of IBASE, which is 307.2 kHz
±25 percent.
Before switching frequencies by changing the N value, the clock monitor must be disabled. This is
because when N is changed, the frequency of the low-frequency base clock (IBASE) will change
proportionally until the digital loop filter has corrected the error. Since the clock monitor uses IBASE, it
could erroneously detect an inactive clock. The clock monitor cannot be re-enabled until the internal clock
is stable again (ICGS is set).
The following flow is an example of how to change the clock frequency:
•Verify there is no clock monitor interrupt by reading the CMF bit.
•Turn off the clock monitor.
•If desired, switch to the external clock (see 7.4.1 Switching Clock Sources).
•Change the value of N.
•Switch back to internal (see 7.4.1 Switching Clock Sources), if desired.
•Turn on the clock monitor (see 7.4.2 Enabling the Clock Monitor), if desired.
7.4.6 Nominal Frequency Settling Time
Because the clock period of the internal clock (ICLK) is dependent on the digital loop filter outputs (DDIV
and DSTG) which cannot change instantaneously, ICLK temporarily will operate at an incorrect clock
period when any operating condition changes. This happens whenever the part is reset, the ICG multiply
factor (N) is changed, the ICG trim factor (TRIM) is changed, or the internal clock is enabled after inactivity
(stop mode or disabled operation). The time that the ICLK takes to adjust to the correct period is known
as the settling time.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
90Freescale Semiconductor
Usage Notes
Settling time depends primarily on how many corrections it takes to change the clock period and the
period of each correction. Since the corrections require four periods of the low-frequency base clock
(4*τ
IBASE, each correction takes 4*N*τ
), and since ICLK is N (the ICG multiply factor for the desired frequency) times faster than
IBASE
. The period of ICLK, however, will vary as the corrections occur.
ICLK
7.4.6.1 Settling to Within 15 Percent
When the error is greater than 15 percent, the filter takes eight corrections to double or halve the clock
period. Due to how the DCO increases or decreases the clock period, the total period of these eight
corrections is approximately 11 times the period of the fastest correction. (If the corrections were perfectly
linear, the total period would be 11.5 times the minimum period; however, the ring must be slightly
nonlinear.) Therefore, the total time it takes to double or halve the clock period is 44*N*τ
ICLKFAST
.
If the clock period needs more than doubled or halved, the same relationship applies, only for each time
the clock period needs doubled, the total number of cycles doubles. That is, when transitioning from fast
to slow, going from the initial speed to half speed takes 44*N*τ
takes 88*N*τ
ICLKFAST
series can be expressed as (2
doubled or halved. Since 2
44*N*(τ
ICLKSLOW–τICLKFAST
; going from quarter speed to eighth speed takes 176*N*τ
x
–1)*44*N*τ
x
happens to be equal to τ
ICLKFAST
, where x is the number of times the speed needs
ICLKSLOW/τICLKFAST
).
ICLKFAST
; from half speed to quarter speed
ICLKFAST
; and so on. This
, the equation reduces to
Note that increasing speed takes much longer than decreasing speed since N is higher. This can be
expressed in terms of the initial clock period (τ
τ
15
) minus the final clock period (τ2) as such:
1
abs 44N τ
–()[]=
1τ2
7.4.6.2 Settling to Within 5 Percent
Once the clock period is within 15 percent of the desired clock period, the filter starts making smaller
adjustments. When between 15 percent and 5 percent error, each correction will adjust the clo ck perio d
between 1.61 percent and 2.94 percent. In this mode, a maximum of eight corrections will be required to
get to less than 5 percent error. Since the clock period is relatively close to desired, each correction takes
approximately the same period of time, or 4*τ
. At this point, the internal clock stable bit (ICGS) will
IBASE
be set and the clock frequency is usable, although the error will be as high as 5 percent. The total time to
this point is:
τ
abs 44N τ
5
–()[]32τ
1τ2
+=
IBASE
7.4.6.3 Total Settling Time
Once the clock period is within 5 percent of the desired clock period, the filter starts making minimum
adjustments. In this mode, each correction will adjust the frequency between 0.202 percent and 0.368
percent. A maximum of 24 corrections will be required to get to the minimum error. Each correction takes
approximately the same period of time, or 4*τ
this makes 32 corrections (128*τ
) to get from 15 percent to the minimum error. The total time to the
IBASE
. Added to the corrections for 15 percent to 5 percent,
IBASE
minimum error is:
The equations for τ
, τ5, and τ
15
τ
are dependent on the actual initial and final clock periods τ1 and τ2, not
tot
tot
abs 44N τ
–()[]128τ
1τ2
+=
IBASE
the nominal. This means the variability in the ICLK frequency due to process, temperature, and voltage
must be considered. Additionally, other process factors and noise can affect the actual tolerances of the
points at which the filter changes modes. This means a worst case adjustment of up to 35 percent (ICLK
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor91
Internal Clock Generator (ICG) Module)
clock period tolerance plus 10 percent) must be added. This adjustment can be reduced with trimming.
Table 7-3 shows some typical values for settling time.
1/ (307.2 kHz)1/ (25.8 MHz)8411.9 ms12.0 ms12.3 ms
τ
2
N
τ
15
τ
5
τ
tot
7.4.7 Trimming Frequency on the Internal Clock Generator
The unadjusted frequency of the low-frequency base clock (IBASE), when the comparators in the
frequency comparator indicate zero error, will vary as much as ±25 percent due to process, temperature,
and voltage dependencies. These dependencies are in the voltage and current references, the offset of
the comparators, and the internal capacitor.
The method of changing the unadjusted operating point is by changing the size of the capacitor. This
capacitor is designed with 639 equally sized units. Of that number, 384 of these units are always
connected. The remaining 255 units are put in by adjusting the ICG trim factor (TRIM). The default value
for TRIM is $80, or 128 units, making the default capacitor size 512. Each unit added or removed will
adjust the output frequency by about ±0.195 percent of the unadjusted frequency (adding to TRIM will
decrease frequency). Therefore, the frequency of IBASE can be changed to ±25 percent of its unadjusted
value, which is enough to cancel the process variability mentioned before.
The best way to trim the internal clock is to use the timer to measure the width of an input pulse on an
input capture pin (this pulse must be supplied by the application and should be as long or wide as
possible). Considering the prescale value of the timer and the theoretical (zero error) frequency of the bus
(307.2 kHz *N/4), the error can be calculated. This error, expressed as a percentage, can be divided by
0.195 percent and the resultant factor added or subtracted from TRIM. This process shou ld be repeated
to eliminate any residual error.
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 ICG remains active in wait mode. If enabled, the ICG interrupt to th e CPU can bring th e MCU out of
wait mode.
In some applications, low power-consumption is desired in wait mode and a high-frequency clock is not
needed. In these applications, reduce power consumption by either selecting a low-frequency external
clock and turn the internal clock generator off or reduce the bus frequency by minimizing the ICG multiplier
factor (N) before executing the WAIT instruction.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
92Freescale Semiconductor
CONFIG2 Options
7.5.2 Stop Mode
The value of the oscillator enable in stop (OSCENINSTOP) bit in the CONFIG2 register determines the
behavior of the ICG in stop mode. If OSCENINSTOP is low, the ICG is disabled in stop and, upon
execution of the STOP instruction, all ICG activity will cease and the output clocks (CGMXCLK,
CGMOUT, COPCLK, and TBMCLK) will be held low. Power consumption will be minimal.
If OSCENINSTOP is high, the ICG is enabled in stop and activity will continue. This is useful if the
timebase module (TBM) is required to bring the MCU out of stop mode. ICG interrupts will not bring the
MCU out of stop mode in this case.
During stop mode, if OSCENINSTOP is low, several functions in the ICG are affected. The stable bits
(ECGS and ICGS) are cleared, which will enable the external clock stabilization divider upon recovery.
The clock monitor is disabled (CMON = 0) which will also clear the clock monitor interrupt enable (CMIE)
and clock monitor flag (CMF) bits. The CS, ICGON, ECGON, N, TRIM, DDIV, and DSTG bits are
unaffected.
7.6 CONFIG2 Options
Four CONFIG2 register options affect the functionality of the ICG. These options are:
1.EXTCLKEN, external clock enable
2.EXTXTALEN, external crystal enable
3.EXTSLOW, slow external clock
4.OSCENINSTOP, oscillator enable in stop
All CONFIG2 options will have a default setting. Refer to Chapter 4 Configuration Register (CONFIG) on
how the CONFIG2 register is used.
7.6.1 External Clock Enable (EXTCLKEN)
External clock enable (EXTCLKEN), when set, enables the ECGON bit to be set. ECGON turns on the
external clock input path through the PTE4/OSC1 pin. When EXTCLKEN is clear, ECGON cannot be set
and PTE4/OSC1 will always perform the PTE4 function.
The default state for this option is clear.
7.6.2 External Crystal Enable (EXTXTALEN)
External crystal enable (EXTXTALEN), when set, will enable an amplifier to drive the PTE3/OSC2 pin
from the PTE4/OSC1 pin. The amplifier will drive only if the external clock enable (EXTCLKEN) bit and
the ECGON bit are also set. If EXTCLKEN or ECGON are clear, PTE3/OSC2 will perform the PTE3
function. When EXTXTALEN is clear, PTE3/OSC2 will always perform the PTE3 function.
EXTXTALEN, when set, also configures the clock monitor to expect an external clock source in the valid
range of crystals (30 kHz to 100 kHz or 1 MHz to 8 MHz). When EXTXTALEN is clear, the clock monitor
will expect an external clock source in the valid range for externally generated clocks when using the clock
monitor (60 Hz to 32 MHz).
EXTXTALEN, when set, also configures the external clock stabilization divider in the clock monitor for a
4096 cycle timeout to allow the proper stabilization time for a crystal. When EXTXTALEN is clear, the
stabilization divider is configured to 16 cycles since an external clock source does not need a startup time.
The default state for this option is clear.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor93
Internal Clock Generator (ICG) Module)
7.6.3 Slow External Clock (EXTSLOW)
Slow external clock (EXTSLOW), when set, will decrease the drive strength of the oscillator amplifier,
enabling low-frequency crystal operation (30 kHz–100 kHz) if properly enabled with the external clock
enable (EXTCLKEN) and external crystal enable (EXTXTALEN) bits. When clear, EXTSLOW enables
high-frequency crystal operation (1 MHz to 8 MHz).
EXTSLOW, when set, also configures the clock monitor to expect an external clock source that is slo wer
than the low-frequency base clock (60 Hz to 307.2 kHz). When EXTSLOW is clear, the clock monitor will
expect an external clock faster than the low-frequency base clock (307.2 kHz to 32 MHz).
The default state for this option is clear.
7.6.4 Oscillator Enable In Stop (OSCENINSTOP)
Oscillator enable in stop (OSCENINSTOP), when set, will enable the ICG to continue to generate clocks
(either CGMXCLK, CGMOUT, COPCLK, or TBMCLK) in stop mode. This function is used to keep the
timebase and COP running while the rest of the microcontroller stops. The clock monitor and
autoswitching functions remain operative.
When OSCENINSTOP is clear, all clock generation will cease and CGMXCLK, CGMOUT, COPCLK, and
TBMCLK will be forced low during stop mode. The clock monitor and autoswitching functions become
inoperative.
The default state for this option is clear.
7.7 Input/Output (I/O) Registers
The ICG contains five registers, summarized in Figure 7-11. These registers are:
1.ICG control register (ICGCR)
2.ICG multiplier register (ICGMR)
3.ICG trim register (ICGTR)
4.ICG DCO divider control register (ICGDVR)
5.ICG DCO stage control register (ICGDSR)
Several of the bits in these registers have interaction where the state of one bit may force another bit to
a particular state or prevent another bit from being set or cleared. A su mmary of this interaction is shown
in Table 7-4.
Addr.Register NameBit 7654321Bit 0
ICG Control Register
$0036
1. See 7.7.1 ICG Control Register for method of clearing the CMF bit.
ICG Multiply Register
$0037
(ICGCR)
See page 96.
(ICGMR)
See page 97.
Read:
Write:0
Reset:00001000
Read:
Write:
Reset:00010101
CMIE
CMF
(1)
N6N5N4N3N2N1N0
CMONCSICGON
ICGS
ECGON
ECGS
= UnimplementedR = ReservedU = Unaffected
Figure 7-11. ICG Module I/O Register Summary
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
—Register bit is unaffected by the given condition.
0, 1Register bit is forced clear or set (respectively) in the given condition.
0*, 1*Register bit is temporarily forced clear or set (respectively) in the given condition.
(0), (1)Register bit must be clear or set (respectively) for the given condition to occur.
us, uc, uw Register bit cannot be set, cleared, or writ ten (respectively) in the given condition.
CS
ICGON
ICGS
ECGON
ECGS
N[6:0]
TRIM[7:0]
DDIV[3:0]
DSTG[7:0]
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor95
Internal Clock Generator (ICG) Module)
7.7.1 ICG Control Register
The ICG control register (ICGCR) contains the control and status bits for the internal clock generator,
external clock generator, and clock monitor as well as the clock select and interrupt enable bits.
Address:
$0036
Bit 7654321Bit 0
Read:
Write:0
Reset:00001000
CMIE
1. See CMF bit description for method of clearing CMF bit.
CMF
(1)
= Unimplemented
CMONCSICGON
ICGS
ECGON
ECGS
Figure 7-12. ICG Control Register (ICGCR)
CMIE — Clock Monitor Interrupt Enable Bit
This read/write bit enables clock monitor interrupts. An interrupt will occur whe n both CMIE and CMF
are set. CMIE can be set when the CMON bit has been set for at least one cycle. CMIE is forced clea r
when CMON is clear or during reset.
This read-only bit is set when the clock monitor determines that either ICLK or ECLK becomes inactive
and the CMON bit is set. This bit is cleared by first reading the bit while it is set, followed by writing the
bit low. This bit is forced clear when CMON is clear or during reset.
1 = Either ICLK or ECLK has become inactive.
0 = ICLK and ECLK have not become inactive since the last read of the ICGCR, or the clock monitor
is disabled.
CMON — Clock Monitor On Bit
This read/write bit enables the clock monitor. CMON can be set when both ICLK and ECLK have been
on and stable for at least one bus cycle. (ICGON, ECGON, ICGS, and ECGS are all set.) CMON is
forced set when CMF is set, to avoid inadvertent clearing of CMF. CMON is forced clear when either
ICGON or ECGON is clear, during stop mode with OSCENINSTOP low, or during reset.
This read/write bit determines which clock will generate the oscillator output clock (CGMXCLK). This
bit can be set when ECGON and ECGS have been set for at least one bus cycle and can be cleared
when ICGON and ICGS have been set for at least one bus cycle. This bit is forced set when the clock
monitor determines the internal clock (ICLK) is inactive or when ICGON is clear. This bit is forced clear
when the clock monitor determines that the external clock (ECLK) is inactive, when ECGON is clear,
or during reset.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
96Freescale Semiconductor
Input/Output (I/O) Registers
ICGON — Internal Clock Generator On Bit
This read/write bit enables the internal clock generator. ICGON can be cleared when the CS bit has
been set and the CMON bit has been clear for at least one bus cycle. ICGON is forced set when the
CMON bit is set, the CS bit is clear, or during reset.
This read-only bit indicates when the internal clock generator has determined that the internal clock
(ICLK) is within about 5 percent of the desired value. This bit is forced clear when the clock monitor
determines the ICLK is inactive, when ICGON is clear, when the ICG multiplier register (ICGMR) is
written, when the ICG TRIM register (ICGTR) is written, during stop mode with OSCENINSTOP low,
or during reset.
1 = Internal clock is within 5 percent of the desired value.
0 = Internal clock may not be within 5 percent of the desired value.
ECGON — External Clock Generator On Bit
This read/write bit enables the external clock generator. ECGON can be cleared when the CS and
CMON bits have been clear for at least one bus cycle. ECGON is fo rced set when the CMON bit or the
CS bit is set. ECGON is forced clear during reset.
This read-only bit indicates when at least 4096 external clock (ECLK) cycles have elapsed since the
external clock generator was enabled. This is not an assurance of the stability of ECLK but is meant
to provide a startup delay. This bit is forced clear when the clock monitor determines ECLK is inactive,
when ECGON is clear, during stop mode with OSCENINSTOP low, or during reset.
1 = 4096 ECLK cycles have elapsed since ECGON was set.
0 = External clock is unstable, inactive, or disabled.
7.7.2 ICG Multiplier Register
Address:
N6:N0 — ICG Multiplier Factor Bits
These read/write bits change the multiplier used by the internal clock generator. The internal clock
(ICLK) will be:
(307.2 kHz ± 25 percent) * N
A value of $00 in this register is interpreted the same as a value of $01. This register cannot be writt en
when the CMON bit is set. Reset sets this factor to $15 (decimal 21) for default frequency of 6.45 MHz
± 25 percent (1.613 MHz ± 25 percent bus).
$0037
Bit 7654321Bit 0
Read:
Write:
Reset:00010101
N6N5N4N3N2N1N0
= Unimplemented
Figure 7-13. ICG Multiplier Register (ICGMR)
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor97
Internal Clock Generator (ICG) Module)
7.7.3 ICG Trim Register
Address: $0038
Bit 7654321Bit 0
Read:
Write:
Reset:10000000
TRIM7TRIM6TRIM5TRIM4TRIM3TRIM2TRIM1TRIM0
Figure 7-14. ICG Trim Register (ICGTR)
TRIM7:TRIM0 — ICG Trim Factor Bits
These read/write bits change the size of the internal capacitor used by the internal clock generator. By
testing the frequency of the internal clock and incrementing or decrementing this factor accordingly,
the accuracy of the internal clock can be improved to ± 2 percent. Incrementing this register by one
decreases the frequency by 0.195 percent of the unadjusted value. Decre menting this register by one
increases the frequency by 0.195 percent. This register cannot be written when the CMON bit is set.
Reset sets these bits to $80, centering the range of possible adjustment.
7.7.4 ICG DCO Divider Register
Address: $0039
Bit 7654321Bit 0
Read:
Write:
Reset:0000UUUU
= UnimplementedU = Unaffected
DDIV3DDIV2DDIV1DDIV0
Figure 7-15. ICG DCO Divider Control Register (ICGDVR)
DDIV3:DDIV0 — ICG DCO Divider Control Bits
These bits indicate the number of divide-by-twos (DDIV) that follow the digitally controlled oscillator.
When ICGON is set, DDIV is controlled by the digital loop filter. The range of valid values for DDIV is
from $0 to $9. Values of $A through $F are interpreted the same as $9. Since the DCO is active during
reset, reset has no effect on DSTG and the value may vary.
7.7.5 ICG DCO Stage Register
Address: $003A
Bit 7654321Bit 0
Read:DSTG7DSTG6DSTG5DSTG4DSTG3DSTG2DSTG1DSTG0
Write:RRRRRRRR
Reset:Unaffected by reset
R = Reserved
Figure 7-16. ICG DCO Stage Control Register (ICGDSR)
DSTG7:DSTG0 — ICG DCO Stage Control Bits
These bits indicate the number of stages (above the minimum) in the digitally controlled oscillator. The
total number of stages is approximately equal to $1FF, so changing DSTG from $00 to $FF will
approximately double the period. Incrementing DSTG will increase the period (decrease the
frequency) by 0.202 percent to 0.368 percent (decrementing has the opposite effect). DSTG cannot
be written when ICGON is set to prevent inadvertent frequency shifting. When ICGON is set, DSTG is
controlled by the digital loop filter. Since the DCO is active during reset, reset has no effect on DSTG
and the value may vary.
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
98Freescale Semiconductor
Chapter 8
External Interrupt (IRQ)
8.1 Introduction
The IRQ (external interrupt) module provides a maskable interrupt input.
8.2 Features
Features of the IRQ module include:
•A dedicated external interrupt pin (IRQ
•IRQ interrupt control bits
•Hysteresis buffer
•Programmable edge-only or edge and level interrupt sensitivity
•Automatic interrupt acknowledge
•Internal pullup resistor
8.3 Functional Description
A logic 0 applied to the external interrupt pin can latch a central processor unit (CPU) interrupt request.
Figure 8-2 shows the structure of the IRQ module.
)
Interrupt signals on the IRQ
the following actions occurs:
•Vector fetch — A vector fetch automatically generates an interrupt acknowledge signal that clears
the latch that caused the vector fetch.
•Software clear — Software can clear an interrupt latch by writing to the appropriate acknowledge
bit in the interrupt status and control register (INTSCR). Writing a 1 to the ACK bit clears the IRQ
latch.
•Reset — A reset automatically clears the interrupt latch.
The external interrupt pin is falling-edge triggered and is software-configurable to be either falling-edge
or falling-edge and low-level triggered. The MODE bit in the INTSCR controls the triggering sensitivity of
the IRQ
When an interrupt pin is edge-triggered only, the interrupt remains set until a vector fetch, software clear,
or reset occurs.
When an interrupt pin is both falling-edge and low-level triggered, the interrupt remains set until both of
these events occur:
pin.
•Vector fetch or software clear
•Return of the interrupt pin to logic 1
pin are latched into the IRQ latch. An interrupt latch remains set until one of
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , Rev. 3
Freescale Semiconductor99
External Interrupt (IRQ)
M68HC08 CPU
CPU
REGISTERS
ARITHMETIC/LOGIC
UNIT (ALU)
INTERNAL BUS
PROGRAMMABLE TIMEBASE
MODULE
DDRA
PORTA
PTA7/KBD7–
PTA0/KBD0
(1)
CONTROL AND STATUS
REGISTERS — 64 BYTES
USER FLASH
MC68HC908GT16 — 15,872 BYTES
MC68HC908GT8 — 7,680 BYTES
USER RAM — 512 BYTES
MONITOR ROM — 304 BYTES
FLASH PROGRAMMING ROUTINES
ROM — 720 BYTES
USER FLASH VECTOR SPACE — 36 BYTES
PTE4/OSC1
PTE3/OSC2
RST
IRQ
V
REFH
V
REFL
(3)
(3)
INTERNAL CLOCK
GENERATOR MODULE
SYSTEM INTEGRATION
MODULE
SINGLE EXTERNAL
INTERRUPT MODULE
8-BIT ANALOG-TO-DIGITAL
CONVERTER MODULE
POWER-ON RESET
MODULE
V
DD
V
SS
V
DDA
V
SSA
POWER
SINGLE BREAKPOINT BREAK
LOW-VOLTAGE INHIBIT MODULE
2-CHANNEL TIMER INTERFACE
2-CHANNEL TIMER INTERFACE
MODULE
DUAL VOLTAGE
8-BIT KEYBOARD
INTERRUPT MODULE
MODULE 1
MODULE 2
SERIAL COMMUNICATIONS
INTERFACE MODULE
COMPUTER OPERATING
PROPERLY MODULE
SERIAL PERIPHERAL
INTERFACE MODULE
MONITOR MODULE
MEMORY MAP
MODULE
CONFIGURATION REGISTER 1
MODULE
CONFIGURATION REGISTER 2
MODULE
PTB7/AD7
PTB6/AD6
PTB5/AD5
PTB4/AD4
DDRB
PTB3/AD3
PORTB
PTB2/AD2
PTB1/AD1
PTB0/AD0
(1)
PTC6
(1)
PTC5
(1)(2)
PTC4
(1)(2)
DDRC
PTC3
PTC2
PTC1
PTC0
(1)(2)
(1)(2)
(1)(2)
PORTC
PTD7/T2CH1
PTD6/T2CH0
PTD5/T1CH1
PTD4/T1CH0
PORTD
PTD3/SPSCK
PTD2/MOSI
DDRD
PTD1/MISO
PTD0/SS
PTE2
DDRE
PTE1/RxD
PORTE
PTE0/TxD
SECURITY
MODULE
MONITOR MODE ENTRY
MODULE
(1)
(1)
(1)
(1)
(1)
(1)
(1)
(1)
1. Ports are software configurable with pullup device if input port.
2. Higher current drive port pins
3. Pin contains integrated pullup device
Figure 8-1. Block Diagram Highlighting IRQ Block and Pins
MC68HC908GT16 • MC68HC908GT 8 Da ta She e t , 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.