To provide the most up-to-date information, the revision of our documents on the World Wide Web will be
the most current. Your printed copy may be an earlier revision. To verify you have the latest information
available, refer to:
http://www.freescale.com
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.
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
This product incorporates SuperFlash® technology licensed from SST.
The MC68HC908AP64 is a member 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.
Table 1-1. Summary of Device Variations
Device
MC68HC908AP642,04862,368
MC68HC908AP322,04832,768
MC68HC908AP161,02416,384
MC68HC908AP81,0248,192
RAM Size
(bytes)
FLASH Memory Size
(bytes)
1.2 Features
Features of the MC68HC908AP64 include the following:
•High-performance M68HC08 architecture
•Fully upward-compatible object code with M6805, M146805, and M68HC05 Families
•Maximum internal bus frequency:
–8-MHz at 5V or 3V operating voltage
•Clock input options:
–RC-oscillator
–32-kHz crystal-oscillator with 32MHz internal PLL
•User program FLASH memory with security
–62,368 bytes for MC68HC908AP64
–32,768 bytes for MC68HC908AP32
–16,384 bytes for MC68HC908AP16
–8,192 bytes for MC68HC908AP8
•On-chip RAM
–2,048 bytes for MC68HC908AP64 and MC68HC908AP32
–1,024 bytes for MC68HC908AP16 and MC68HC908AP8
•Two 16-bit, 2-channel timer interface modules (TIM1 and TIM2) with selectable input capture,
output compare, and PWM capability on each channel
(1)
feature
1. No security feature is absolutely secure. However, Freescale’s strategy is to make reading or copying the FLASH difficult for
unauthorized users.
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor19
General Description
•Timebase module
•Serial communications interface module 1 (SCI)
•Serial communications interface module 2 (SCI) with infrared (IR) encoder/decoder
•Serial peripheral interface module (SPI)
•System management bus (SMBus), version 1.0/1.1 (multi-master IIC bus)
8-bit general purpose I/O port; PTB0–PTB3 are open drain when
configured as output. PTB4–PTB7 have schmitt trigger inputs.
In/Out
PTB0 as SDA of MMIIC.In/Out
PTB0/SDA
PTB1 as SCL of MMIIC.In/Out
PTB1/SCL
PTB2/TxD
PTB2 as TxD of SCI; open drain output.Out
PTB3/RxD
PTB4/T1CH0
PTB3 as RxD of SCI.In
PTB5/T1CH1
PTB6/T2CH0
PTB7/T2CH1
PTB4 as T1CH0 of TIM1.In/Out
PTB5 as T1CH1 of TIM1.In/Out
PTB6 as T2CH0 of TIM2.In/Out
PTB7 as T2CH1 of TIM2.In/Out
8-bit general purpose I/O port; PTC6 and PTC7 are open drain
when configured as output.
In/Out
PTC0 is shared with IRQ2 and has schmitt trigger input.In
PTC0/IRQ2
PTC1
PTC2 as MISO of SPI.In
PTC2/MISO
PTC3/MOSI
PTC3 as MOSI of SPI.Out
PTC4/SS
PTC5/SPSCK
PTC4 as SS of SPI.In
PTC6/SCTxD
PTC7/SCRxD
PTC5 as SPSCK of SPI.In/Out
PTC6 as SCTxD of IRSCI; open drain output.Out
VOLTAGE
LEVEL
V
DD
V
DD
V
DD
V
DD
V
DD
V
DD
V
DD
V
DD
V
DD
V
DD
V
DD
V
DD
V
DD
V
DD
V
DD
V
DD
V
DD
V
DD
PTD0/KBI0
PTC7 as SCRxD of IRSCI.In
8-bit general purpose I/O port with schmitt trigger inputs.In/Out
:
PTD7/KBI7
Pins as keyboard interrupts (with pullup), KBI0–KBI7. In
1. See Chapter 22 Electrical Specifications for V
tolerance.
REG
V
DD
1.6 Power Supply Bypassing (VDD, VDDA, VSS, VSSA)
VDD and VSS are the power supply and ground pins, the MCU operates from a single power supply
together with an on chip voltage regulator.
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-5
shows. Place the bypass capacitors as close to the MCU power pins as possible. Use
high-frequency-response ceramic capacitor for C
BYPASS
capacitors for use in applications that require the port pins to source high current level.
MC68HC908AP Family Data Sheet, Rev. 3
26Freescale Semiconductor
, C
are optional bulk current bypass
BULK
V
DDA
and V
are the power supply and ground pins for the analog circuits of the MCU. These pins
SSA
should be decoupled as per the digital power supply pins.
is the output from the on-chip regulator. All internal logics, except for the I/O pads, are powered by
REG
V
output. V
REG
the bypass capacitor as close to the V
requires an external ceramic bypass capacitor of 100 nF as Figure 1-6 shows. Place
REG
pin as possible.
REG
MCU
V
REG
C
VREGBYPASS
100 nF
Figure 1-6. Regulator Power Supply Bypassing
MC68HC908AP Family Data Sheet, Rev. 3
V
SS
Freescale Semiconductor27
General Description
MC68HC908AP Family Data Sheet, Rev. 3
28Freescale Semiconductor
Chapter 2
Memory
2.1 Introduction
The CPU08 can address 64k-bytes of memory space. The memory map, shown in Figure 2-1, includes:
•62,368 bytes of user FLASH — MC68HC908AP64
32,768 bytes of user FLASH — MC68HC908AP32
16,384 bytes of user FLASH — MC68HC908AP16
8,192 bytes of user FLASH — MC68HC908AP8
•2,048 bytes of RAM — MC68HC908AP64 and MC68HC908AP32
1,024 bytes of RAM — MC68HC908AP16 and MC68HC908AP8
•48 bytes of user-defined vectors
•959 bytes of monitor ROM
2.2 Input/Output (I/O) Section
Most of the control, status, and data registers are in the zero page area of $0000–$005F. Additional I/O
registers have these addresses:
•$FE00; SIM break status register, SBSR
•$FE01; SIM reset status register, SRSR
•$FE02; Reserved
•$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; FLASH block protect register, FLBPR
•$FE0A; Reserved
•$FE0B; Reserved
•$FE0C; Break address register high, BRKH
•$FE0D; Break address register low, BRKL
•$FE0E; Break status and control register, BRKSCR
•$FE0F; LVI Status register, LVISR
•$FFCF; Mask option register, MOR (FLASH register)
•$FFFF; COP control register, COPCTL
2.3 Monitor ROM
The 959 bytes at addresses $FC00–$FDFF and $FE10–$FFCE are reserved ROM addresses that
contain the instructions for the monitor functions. (See Chapter 8 Monitor ROM (MON).)
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor29
Memory
$0000
↓
$005F
$0060
↓
$085F
I/O Registers
96 Bytes
RAM
2,048 Bytes
(MC68HC908AP64)
$0860
FLASH Memory
↓
62,368 Bytes
(MC68HC908AP64)
$FBFF
$FC00
↓
$FDFF
Monitor ROM 2
512 Bytes
$FE00SIM Break Status Register
$FE01SIM Reset Status Register
$FE02Reserved
$FE03SIM Break Flag Control Register
$FE04Interrupt Status Register 1
$FE05Interrupt Status Register 2
$FE06Interrupt Status Register 3
$FE07Reserved
$FE08FLASH Control Register
$FE09FLASH Block Protect Register
$FE0AReserved
$FE0BReserved
$FE0CBreak Address Register High
$FE0DBreak Address Register Low
$FE0EBreak Status and Control Register
$FE0FLVI Status Register
$FE10
↓
$FFCE
Monitor ROM 1
447 Bytes
$FFCFMask Option Register
$FFD0
↓
$FFFF
FLASH Vectors
48 Bytes
MC68HC908AP32MC68HC908AP16MC68HC908AP8
RAM
2,048 Bytes
FLASH Memory
32,768 Bytes
$0060
↓
$085F
$0860
↓
RAM
1,024 Bytes
Unimplemented
1,024 Bytes
FLASH Memory
16,384 Bytes
$0060
$045F
$0860
↓
$485F
$4860
RAM
1,024 Bytes
Unimplemented
1,024 Bytes
FLASH Memory
8,192 Bytes
$885F
Unimplemented
29,600 Bytes
$8860
↓
$FBFF
Unimplemented
45,984 Bytes
↓
$FBFF
Unimplemented
54,176 Bytes
Figure 2-1. Memory Map
$0060
$045F
$0860
$285F
$2860
↓
$FBFF
MC68HC908AP Family Data Sheet, Rev. 3
30Freescale Semiconductor
Monitor ROM
Addr.Register NameBit 7654321Bit 0
$0000
$0001
$0002Port C Data Register (PTC)
$0003Port D Data Register (PTD)
$0004
$0005
$0006
$0007
$0008
$0009 Unimplemented
$000AUnimplemented
$000BUnimplemented
$000C
Port A Data Register
(PTA)
Port B Data Register
(PTB)
Data Direction Register A
(DDRA)
Data Direction Register B
(DDRB)
Data Direction Register C
(DDRC)
Data Direction Register D
(DDRD)
Unimplemented
Port-A LED Control
Register
(LEDA)
U = UnaffectedX = Indeterminate
Read:
Write:
Reset:Unaffected by reset
Read:
Write:
Reset:Unaffected by reset
Read:
Write:
Reset:Unaffected by reset
Read:
Write:
Reset:Unaffected by reset
Read:
Write:
Reset:00000000
Read:
Write:
Reset:00000000
Read:
Write:
Reset:00000000
Read:
Write:
Reset:00000000
Read:
Write:
Reset:
Read:
Write:
Reset:
Read:
Write:
Reset:
Read:
Write:
Reset:
Read:
Write:
Reset:00000000
PTA7PTA6PTA5PTA4PTA3PTA2PTA1PTA0
PTB7PTB6PTB5PTB4PTB3PTB2PTB1PTB0
PTC7PTC6PTC5PTC4PTC3PTC2PTC1PTC0
PTD7PTD6PTD5PTD4PTD3PTD2PTD1PTD0
DDRA7DDRA6DDRA5DDRA4DDRA3DDRA2DDRA1DDRA0
DDRB7DDRB6DDRB5DDRB4DDRB3DDRB2DDRB1DDRB0
DDRC7DDRC6DDRC5DDRC4DDRC3DDRC2DDRC1DDRC0
DDRD7DDRD6DDRD5DDRD4DDRD3DDRD2DDRD1DDRD0
LEDA7 LEDA6 LEDA5 LEDA4 LEDA3 LEDA2 LEDA1 LEDA0
= UnimplementedR= Reserved
Figure 2-2. Control, Status, and Data Registers (Sheet 1 of 9)
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor31
Memory
Addr.Register NameBit 7654321Bit 0
Read:
$000DUnimplemented
$000EUnimplemented
$000FUnimplemented
$0010
$0011
$0012
$0013
$0014
$0015
$0016 SCI Status Register 1 (SCS1)
$0017 SCI Status Register 2 (SCS2)
$0018
$0019
SPI Control Register
(SPCR)
SPI Status and Control
Register
(SPSCR)
SPI Data Register
(SPDR)
SCI Control Register 1
(SCC1)
SCI Control Register 2
(SCC2)
SCI Control Register 3
(SCC3)
SCI Data Register
(SCDR)
SCI Baud Rate Register
(SCBR)
U = UnaffectedX = Indeterminate
Write:
Reset:
Read:
Write:
Reset:
Read:
Write:
Reset:
Read:
Write:
Reset:00101000
Read:SPRF
Write:
Reset:00001000
Read:R7R6R5R4R3R2R1R0
Write:T7T6T5T4T3T2T1T0
Reset:Unaffected by reset
Read:
Write:
Reset:00000000
Read:
Write:
Reset:00000000
Read:R8
Write:
Reset:UU000000
Read:SCTETCSCRFIDLEORNFFEPE
Write:
Reset:11000000
Read:000000BKFRPF
Write:
Reset:00000000
Read:R7R6R5R4R3R2R1R0
Write:T7T6T5T4T3T2T1T0
Reset:Unaffected by reset
Read:00
Write:
Reset:00000000
SPRIERSPMSTRCPOLCPHASPWOMSPESPTIE
ERRIE
LOOPSENSCITXINVMWAKEILTYPENPTY
SCTIETCIESCRIEILIETERERWUSBK
T8DMAREDMATEORIENEIEFEIEPEIE
OVRFMODFSPTE
SCP1SCP0RSCR2SCR1SCR0
= UnimplementedR= Reserved
MODFENSPR1SPR0
Figure 2-2. Control, Status, and Data Registers (Sheet 2 of 9)
MC68HC908AP Family Data Sheet, Rev. 3
32Freescale Semiconductor
Monitor ROM
Addr.Register NameBit 7654321Bit 0
Keyboard Status and Control
$001A
$001B
IRQ2 Status and Control Reg-
$001C
$001D
Configuration Register 2
Register
(KBSCR)
Keyboard Interrupt
Enable Register
(KBIER)
(INTSCR2)
(CONFIG2)
Read:0000KEYF0
Write:
ACK
IMASKMODE
Reset:00000000
Read:
Write:
KBIE7KBIE6KBIE5KBIE4KBIE3KBIE2KBIE1KBIE0
Reset:00000000
ister
Read:0
Write:
PUC0ENB
00IRQ2F0
ACK2
IMASK2MODE2
Reset:00000000
00
SCIBDSRC
†
Read:
Write:
STOP_
ICLKDIS
STOP_
RCLKEN
STOP_
XCLKEN
OSCCLK1 OSCCLK0
Reset:00000000
† One-time writable register after each reset.
IRQ1 Status and Control Reg-
$001E
$001F
Configuration Register 1
(INTSCR1)
(CONFIG1)
Read:0000IRQ1F0
ister
Write:
ACK1
IMASK1MODE1
Reset:00000000
†
Read:
Write:
COPRSLVISTOPLVIRSTDLVIPWRDLVIREGDSSRECSTOPCOPD
Reset:00000000
† One-time writable register after each reset.
$0020
$0021
$0022
Timer 1 Counter Modulo Reg-
$0023
Timer 1 Counter Modulo
$0024
Timer 1 Channel 0 Status and
$0025
Control Register (T1SC0)
Timer 1 Status and
Control Register
(T1SC)
Timer 1 Counter
Register High
(T1CNTH)
Timer 1 Counter
Register Low
(T1CNTL)
ister High
(T1MODH)
Register Low
(T1MODL)
Read:TOF
Write:0TRST
TOIETSTOP
Reset:00100000
Read:Bit 1514131211109Bit 8
Write:
Reset:00000000
Read:Bit 7654321Bit 0
Write:
Reset:00000000
Read:
Write:
Bit 1514131211109Bit 8
Reset:11111111
Read:
Write:
Bit 7654321Bit 0
Reset:11111111
Read:CH0F
Write:0
CH0IEMS0BMS0AELS0BELS0ATOV0CH0MAX
00
PS2PS1PS0
Reset:00000000
U = UnaffectedX = Indeterminate
= UnimplementedR= Reserved
Figure 2-2. Control, Status, and Data Registers (Sheet 3 of 9)
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor33
Memory
Addr.Register NameBit 7654321Bit 0
Read:
Write:
Reset:Indeterminate after reset
Read:
Write:
Reset:Indeterminate after reset
Read:CH1F
Write:0
Reset:00000000
Read:
Write:
Reset:Indeterminate after reset
Read:
Write:
Reset:Indeterminate after reset
Read:TOF
Write:0TRST
Reset:00100000
Read:Bit 1514131211109Bit 8
Write:
Reset:00000000
Read:Bit 7654321Bit 0
Write:
Reset:00000000
Read:
Write:
Reset:11111111
Read:
Write:
Reset:11111111
Read:CH0F
Write:0
Reset:00000000
Read:
Write:
Reset:Indeterminate after reset
Read:
Write:
Reset:Indeterminate after reset
Bit 1514131211109Bit 8
Bit 7654321Bit 0
CH1IE
Bit 1514131211109Bit 8
Bit 7654321Bit 0
TOIETSTOP
Bit 1514131211109Bit 8
Bit 7654321Bit 0
CH0IEMS0BMS0AELS0BELS0ATOV0CH0MAX
Bit 1514131211109Bit 8
Bit 7654321Bit 0
0
MS1AELS1BELS1ATOV1CH1MAX
00
= UnimplementedR= Reserved
PS2PS1PS0
$0026
$0027
Timer 1 Channel 1 Status and
$0028
$0029
$002A
$002B
$002C
$002D
$002E
$002F
$0030
$0031
$0032
Control Register (T1SC1)
Timer 2 Counter Modulo Reg-
Timer 2 Counter Modulo
Timer 2 Channel 0 Status and
Control Register (T2SC0)
Timer 1 Channel 0
Register High
(T1CH0H)
Timer 1 Channel 0
Register Low
(T1CH0L)
Timer 1 Channel 1
Register High
(T1CH1H)
Timer 1 Channel 1
Register Low
(T1CH1L)
Timer 2 Status and
Control Register
(T2SC)
Timer 2 Counter
Register High
(T2CNTH)
Timer 2 Counter
Register Low
(T2CNTL)
ister High
(T2MODH)
Register Low
(T2MODL)
Timer 2 Channel 0
Register High
(T2CH0H)
Timer 2 Channel 0
Register Low
(T2CH0L)
U = UnaffectedX = Indeterminate
Figure 2-2. Control, Status, and Data Registers (Sheet 4 of 9)
MC68HC908AP Family Data Sheet, Rev. 3
34Freescale Semiconductor
Monitor ROM
Addr.Register NameBit 7654321Bit 0
Timer 2 Channel 1 Status and
$0033
$0034
$0035
$0036PLL Control Register (PCTL)
$0037
$0038
$0039
$003A
$003B
$003CUnimplemented
$003DUnimplemented
$003EUnimplemented
$003FUnimplemented
Control Register (T2SC1)
Timer 2 Channel 1
Register High
(T2CH1H)
Timer 2 Channel 1
Register Low
(T2CH1L)
PLL Bandwidth Control Reg-
ister
(PBWC)
PLL Multiplier Select
Register High
(PMSH)
PLL Multiplier Select
Register Low
(PMSL)
PLL VCO Range Select
Register
(PMRS)
PLL Reference Divider
Select Register
(PMDS)
U = UnaffectedX = Indeterminate
Read:CH1F
Write:0
Reset:00000000
Read:
Write:
Reset:Indeterminate after reset
Read:
Write:
Reset:Indeterminate after reset
Read:
Write:
Reset:00100000
Read:
Write:
Reset:00000000
Read:0000
Write:
Reset:00000000
Read:
Write:
Reset:01000000
Read:
Write:
Reset:01000000
Read:0000
Write:
Reset:00000001
Read:
Write:
Reset:
Read:
Write:
Reset:
Read:
Write:
Reset:
Read:
Write:
Reset:
Bit 1514131211109Bit 8
Bit 7654321Bit 0
PLLIE
AUTO
MUL7MUL6MUL5MUL4MUL3MUL2MUL1MUL0
VRS7VRS6VRS5VRS4VRS3VRS2VRS1VRS0
CH1IE
PLLF
LOCK
0
PLLONBCSPRE1PRE0VPR1VPR0
ACQ
MS1AELS1BELS1ATOV1CH1MAX
0000
MUL11MUL10MUL9MUL8
RDS3RDS2RDS1RDS0
= UnimplementedR= Reserved
R
Figure 2-2. Control, Status, and Data Registers (Sheet 5 of 9)
Figure 2-2. Control, Status, and Data Registers (Sheet 7 of 9)
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor37
Memory
Addr.Register NameBit 7654321Bit 0
$005A
$005B
$005CADC Data Register Low 2
$005D
$005E
$005FUnimplemented
ADC Data Register Low 0
(ADRL0)
ADC Data Register Low 1
(ADRL1)
(ADRL2)
ADC Data Register Low 3
(ADRL3)
ADC Auto-scan Control
Register
(ADASCR)
Read:ADxADxADxADxADxADxADxADx
Write:RRRRRRRR
Reset:00000000
Read:AD9AD8AD7AD6AD5AD4AD3AD2
Write:RRRRRRRR
Reset:00000000
Read:AD9AD8AD7AD6AD5AD4AD3AD2
Write:RRRRRRRR
Reset:00000000
Read:AD9AD8AD7AD6AD5AD4AD3AD2
Write:RRRRRRRR
Reset:00000000
Read:
Write:
Reset:00000000
Read:
Write:
Reset:
AUTO1AUTO0ASCA N
$FE00
Note: Writing a logic 0 clears SBSW.
$FE01
$FE02Reserved
$FE03
$FE04
$FE05
SIM Break Status Register
(SBSR)
SIM Reset Status Register
(SRSR)
SIM Break Flag Control Reg-
(SBFCR)
Interrupt Status Register 1
(INT1)
Interrupt Status Register 2
(INT2)
U = UnaffectedX = Indeterminate= UnimplementedR= Reserved
Read:
Write:Note
Reset:0
Read:PORPINCOPILOPILADMODRSTLVI0
Write:
Reset:10000000
Read:
Write:
Reset:
Read:
ister
Write:
Reset:0
Read:IF6IF5IF4IF3IF2IF100
Write:RRRRRRRR
Reset:00000000
Read:IF14IF13IF12IF11IF10IF9IF8IF7
Write:RRRRRRRR
Reset:00000000
RRRRRR
RRRRRRRR
BCFERRRRRRR
SBSW
R
Figure 2-2. Control, Status, and Data Registers (Sheet 8 of 9)
MC68HC908AP Family Data Sheet, Rev. 3
38Freescale Semiconductor
Monitor ROM
Addr.Register NameBit 7654321Bit 0
Read:0IF21IF20IF19IF18IF17IF16IF15
$FE06
Interrupt Status Register 3
(INT3)
Write:RRRRRRRR
Reset:00000000
$FE07Reserved
Read:
Write:
RRRRRRRR
Reset:
$FE08
FLASH Control Register
(FLCR)
Read:0000
Write:
HVENMASSERASEPGM
Reset:00000000
FLASH Block Protect
$FE09
Register
(FLBPR)
$FE0AReserved
Read:
Write:
BPR7BPR6BPR5BPR4BPR3BPR2BPR1BPR0
Reset:00000000
Read:
Write:
RRRRRRRR
Reset:
$FE0BReserved
Read:
Write:
RRRRRRRR
Reset:
Read:
Write:
Bit 1514131211109Bit 8
Reset:00000000
Read:
Write:
Bit 7654321Bit 0
Reset:00000000
Reset:
Read:
BRKEBRKA
000000
Write:00000000
$FE0C
$FE0D
$FE0E
Break Address
Register High
(BRKH)
Break Address
Register Low
(BRKL)
Break Status and Control
Register
(BRKSCR)
Reset:LVIOUT 0000000
$FE0FLVI Status Register (LVISR)
Read:
Write:00000000
Read:
$FFCF
Mask Option Register
(MOR)
#
OSCSEL1OSCSEL0RRRRRR
Write:
Erased:11111111
Reset:UUUUUUUU
Read:Low byte of reset vector
$FFFF
COP Control Register
(COPCTL)
Write:Writing clears COP counter (any value)
Reset:Unaffected by reset
#
MOR is a non-volatile FLASH register; write by programming.
U = UnaffectedX = Indeterminate
= UnimplementedR= Reserved
Figure 2-2. Control, Status, and Data Registers (Sheet 9 of 9)
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor39
Memory
Table 2-1. Vector Addresses
PriorityINT FlagAddressVector
Lowest
—
$FFD0Reserved
$FFD1Reserved
$FFD2TBM Vector (High)
IF21
$FFD3TBM Vector (Low)
$FFD4SCI2 (IRSCI) Transmit Vector (High)
IF20
$FFD5SCI2 (IRSCI) Transmit Vector (Low)
$FFD6SCI2 (IRSCI) Receive Vector (High)
IF19
$FFD7SCI2 (IRSCI) Receive Vector (Low)
$FFD8SCI2 (IRSCI) Error Vector (High)
IF18
$FFD9SCI2 (IRSCI) Error Vector (Low)
$FFDASPI Transmit Vector (High)
IF17
$FFDBSPI Transmit Vector (Low)
$FFDCSPI Receive Vector (High)
IF16
$FFDDSPI Receive Vector (Low)
$FFDEADC Conversion Complete Vector (High)
IF15
$FFDFADC Conversion Complete Vector (Low)
IF14
IF13
IF12
IF11
IF10
IF9
$FFE0Keyboard Vector (High)
$FFE1Keyboard Vector (Low)
$FFE2SCI Transmit Vector (High)
$FFE3SCI Transmit Vector (Low)
$FFE4SCI Receive Vector (High)
$FFE5SCI Receive Vector (Low)
$FFE6SCI Error Vector (High)
$FFE7SCI Error Vector (Low)
$FFE8MMIIC Interrupt Vector (High)
$FFE9MMIIC Interrupt Vector (Low)
$FFEATIM2 Overflow Vector (High)
$FFEBTIM2 Overflow Vector (Low)
MC68HC908AP Family Data Sheet, Rev. 3
40Freescale Semiconductor
Table 2-1. Vector Addresses (Continued)
PriorityINT FlagAddressVector
Random-Access Memory (RAM)
IF8
IF7
IF6
IF5
IF4
IF3
IF2
IF1
$FFECTIM2 Channel 1 Vector (High)
$FFEDTIM2 Channel 1 Vector (Low)
$FFEETIM2 Channel 0 Vector (High)
$FFEFTIM2 Channel 0 Vector (Low)
$FFF0TIM1 Overflow Vector (High)
$FFF1TIM1 Overflow Vector (Low)
$FFF2TIM1 Channel 1 Vector (High)
$FFF3TIM1 Channel 1 Vector (Low)
$FFF4TIM1 Channel 0 Vector (High)
$FFF5TIM1 Channel 0 Vector (Low)
$FFF6PLL Vector (High)
$FFF7PLL Vector (Low)
$FFF8IRQ2
$FFF9IRQ2
$FFFAIRQ1
$FFFBIRQ1
Vector (High)
Vector (Low)
Vector (High)
Vector (Low)
—
—
Highest$FFFFReset Vector (Low)
$FFFCSWI Vector (High)
$FFFDSWI Vector (Low)
$FFFEReset Vector (High)
2.4 Random-Access Memory (RAM)
The following table shows the RAM size and address range:
DeviceRAM Size (Bytes)Memory Address Range
MC68HC908AP64
MC68HC908AP32
MC68HC908AP16
MC68HC908AP8
The location of the stack RAM is programmable. The 16-bit stack pointer allows the stack to be anywhere
in the 64k-byte memory space.
2,048$0060–$085F
1,024$0060–$045F
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor41
Memory
NOTE
For correct operation, the stack pointer must point only to RAM locations.
Within page zero are 160 bytes of RAM. Because the location of the stack RAM is programmable, all page
zero RAM locations can be used for I/O control and user data or code. When the stack pointer is moved
from its reset location at $00FF, direct addressing mode instructions can access efficiently all page zero
RAM locations. Page zero RAM, therefore, provides ideal locations for frequently accessed global
variables.
Before processing an interrupt, the CPU uses five bytes of the stack to save the contents of the CPU
registers.
NOTE
For M6805 compatibility, the H register is not stacked.
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.5 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 and erase operations are enabled
through the use of an internal charge pump. The following table shows the FLASH memory size and
address range:
DeviceFLASH Size (Bytes)Memory Address Range
MC68HC908AP6462,368$0860–$FBFF
MC68HC908AP3232,768$0860–$885F
MC68HC908AP1616,384$0860–$485F
MC68HC908AP88,192$0860–$285F
2.5.1 Functional Description
The FLASH memory consists of an array for user memory plus a block of 48 bytes for user interrupt
vectors and one byte for the mask option register. An erased bit reads as logic 1 and a programmed bit reads as a logic 0. The FLASH memory page size is defined as 512 bytes, and is the minimum size that
can be erased in a page erase operation. Program and erase operations are facilitated through control
bits in FLASH control register (FLCR). The address ranges for the FLASH memory are:
Programming tools are available from Freescale. Contact your local Freescale representative for more
information.
NOTE
A security feature prevents viewing of the FLASH contents.
MC68HC908AP Family Data Sheet, Rev. 3
42Freescale Semiconductor
(1)
FLASH Memory
2.5.2 FLASH Control Register
The FLASH control register (FLCR) controls FLASH program and erase operation.
Address:$FE08
Bit 7654321Bit 0
Read:0000
Write:
Reset:00000000
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
This read/write bit configures the memory for mass erase operation or page erase operation when the
ERASE bit is set.
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 not selected
2.5.3 FLASH Page Erase Operation
Use the following procedure to erase a page of FLASH memory. A page consists of 512 consecutive bytes
starting from addresses $X000, $X200, $X400, $X600, $X800, $XA00, $XC00, or $XE00. The 48-byte
user interrupt vectors cannot be erased by the page erase operation because of security reasons. Mass
erase is required to erase this page.
1.Set the ERASE bit and clear the MASS bit in the FLASH control register.
2.Write any data to any FLASH location within the page address range desired.
3.Wait for a time, t
4.Set the HVEN bit.
5.Wait for a time t
nvs
erase
(5 µs).
(20 ms).
1. No security feature is absolutely secure. However, Freescale’s strategy is to make reading or copying the FLASH difficult for
unauthorized users.
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor43
Memory
6.Clear the ERASE bit.
7.Wait for a time, t
nvh
(5 µs).
8.Clear the HVEN bit.
9.After time, t
(1 µ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.
2.5.4 FLASH Mass Erase Operation
Use the following procedure to erase the entire FLASH memory:
1.Set both the ERASE bit and the MASS bit in the FLASH control register.
2.Write any data to any FLASH location within the FLASH memory address range.
3.Wait for a time, t
4.Set the HVEN bit.
5.Wait for a time t
6.Clear the ERASE bit.
7.Wait for a time, t
8.Clear the HVEN bit.
9.After time, t
rcv
Due to the relatively long mass erase time, user should take care in the
code to prevent a COP reset from happening while the HVEN bit is set.
(5 µs).
nvs
(200 ms). (See NOTE below.)
me
(100 µs).
nvh1
(1 µs), the memory can be accessed in read mode again.
NOTE
Programming and erasing of FLASH locations cannot be performed by
code being executed from the FLASH memory. While these operations
must be performed in the order as shown, but other unrelated operations
may occur between the steps.
2.5.5 FLASH Program Operation
Programming of the FLASH memory is done on a row basis. A row consists of 64 consecutive bytes
starting from addresses $XX00, $XX40, $XX80 or $XXC0. Use the following procedure to program a row
of FLASH memory. (Figure 2-4 shows a flowchart of the programming algorithm.)
1.Set the PGM bit. This configures the memory for program operation and enables the latching of
address and data for programming.
2.Write any data to any FLASH location within the address range of the row to be programmed.
3.Wait for a time, t
4.Set the HVEN bit.
5.Wait for a time, t
6.Write data to the FLASH location to be programmed.
7.Wait for time, t
8.Repeat steps 6 and 7 until all bytes within the row are programmed.
9.Clear the PGM bit.
(5 µs).
nvs
(10 µs).
pgs
(20 µs to 40 µs).
prog
MC68HC908AP Family Data Sheet, Rev. 3
44Freescale Semiconductor
FLASH Memory
10.Wait for time, t
nvh
(5 µs).
11.Clear the HVEN bit.
12.After time, t
(1 µs), the memory can be accessed in read mode again.
rcv
This program sequence is repeated throughout the memory until all data is programmed.
NOTE
The time between each FLASH address change (step 6 to step 6), or the
time between the last FLASH addressed programmed to clearing the PGM
bit (step 6 to step 9), must not exceed the maximum programming time,
t
max.
prog
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.
2.5.6 FLASH Protection
Due to the ability of the on-board charge pump to erase and program the FLASH memory in the target
application, provision is made to protect pages of memory from unintentional erase or program operations
due to system malfunction. This protection is done by use of a FLASH block protect register (FLBPR).
The FLBPR determines the range of the FLASH memory which is to be protected. The range of the
protected area starts from a location defined by FLBPR and ends to the bottom of the FLASH memory
($FFFF). When the memory is protected, the HVEN bit cannot be set in either erase or program
operations.
NOTE
The mask option register ($FFCF) and the 48 bytes of user interrupt vectors
($FFD0–$FFFF) are always protected, regardless of the value in the
FLASH block protect register. A mass erase is required to erase these
locations.
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor45
Memory
Algorithm for programming
a row (64 bytes) of FLASH memory
1
2
Write any data to any FLASH address
Set PGM bit
within the row address range desired
3
4
5
6
Wait for a time, t
Set HVEN bit
Wait for a time, t
Write data to the FLASH address
to be programmed
7
Wait for a time, t
nvs
pgs
prog
Completed
programming
this row?
NOTE:
The time between each FLASH address change (step 6 to step 6), or
the time between the last FLASH address programmed
to clearing PGM bit (step 6 to step 9)
must not exceed the maximum programming
time, t
PROG
max.
This row program algorithm assumes the row/s
to be programmed are initially erased.
Figure 2-4. FLASH Programming Flowchart
Y
N
9
10
11
12
Clear PGM bit
Wait for a time, t
Clear HVEN bit
Wait for a time, t
nvh
rcv
End of Programming
MC68HC908AP Family Data Sheet, Rev. 3
46Freescale Semiconductor
FLASH Memory
2.5.7 FLASH Block Protect Register
The FLASH block protect register is implemented as an 8-bit I/O register. The value in this register
determines the starting address of the protected range within the FLASH memory.
Address:$FE09
Bit 7654321Bit 0
Read:
Write:
Reset:00000000
BPR[7:0] — FLASH Block Protect Bits
BPR[7:1] represent bits [15:9] of a 16-bit memory address. Bits [8:0] are logic 0’s.
Start address of FLASH block protect000000000
BPR0 is used only for BPR[7:0] = $FF, for no block protection.
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 X000, X200, X400, X0600, X800, XA00, XC00,
or XE00 (at page boundaries — 512 bytes) within the FLASH memory.
Examples of protect start address:
BPR7BPR6BPR5BPR4BPR3BPR2BPR1BPR0
Figure 2-5. FLASH Block Protect Register (FLBPR)
16-bit memory address
BPR[7:1]
Table 2-2 FLASH Block Protect Range
BPR[7:0]Protected Range
$00 to $09The entire FLASH memory is protected.
$0A or $0B
(0000 101x)
$0C or $0D
(0000 110x)
and so on...
$FA or $FB
(1111 1101x)
$FC or $FD or $FE$FFCF to $FFFF
$FF
1. Except for the mask option register ($FFCF) and the 48-byte user vectors
($FFD0–$FFFF). These FLASH locations are always protected.
The configuration registers and the mask option register are used in the initialization of various options.
These two types of registers are configured differently:
•Configuration registers — Write-once registers after reset
•Mask option register — FLASH register (write by programming)
The configuration registers can be written once after each reset. All of the configuration register bits are
cleared during reset. Since the various options affect the operation of the MCU, it is recommended that
these registers be written immediately after reset. The configuration registers are located at $001D and
$001F. The configuration registers may be read at anytime.
NOTE
The CONFIG registers are not 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 3-2 and Figure 3-3.
The mask option register (MOR) is used for selecting one of the three clock options for the MCU. The
MOR is a byte located in FLASH memory, and is written to by a FLASH programming routine.
3.3 Configuration Register 1 (CONFIG1)
Address:$001F
Bit 7654321Bit 0
Read:
Write:
Reset:00000000
COPRSLVISTOPLVIRSTDLVIPWRDLVIREGDSSRECSTOPCOPD
Figure 3-2. Configuration Register 1 (CONFIG1)
COPRS — COP Rate Select Bit
COPRS selects the COP time out period. Reset clears COPRS. (See Chapter 19 Computer Operating
Properly (COP).)
13
1 = COP time out period = 2
0 = COP time out period = 2
– 24 ICLK cycles
18
– 24 ICLK cycles
LVISTOP — LVI Enable in Stop Mode Bit
When the LVIPWRD or LVIREGD bit is clear, setting the LVISTOP bit enables the LVI to operate
during stop mode. Reset clears LVISTOP. (See Chapter 20 Low-Voltage Inhibit (LVI).)
1 = LVI enabled during stop mode
0 = LVI disabled during stop mode
NOTE
If LVISTOP=0, set LVIRSTD =1 before entering stop mode.
LVIRSTD — LVI Reset Disable Bit
LVIRSTD disables the reset signal from the LVI module. (See Chapter 20 Low-Voltage Inhibit (LVI).)
LVI circuit. (See Chapter 20 Low-Voltage Inhibit (LVI).)
DD
LVI circuit disabled
LVI circuit enabled
LVI Circuit Disable Bit
REG
LVI circuit. (See Chapter 20 Low-Voltage Inhibit (LVI).)
REG
LVI circuit disabled
LVI circuit enabled
NOTE
If LVIPWRD=1 and LVIREGD=1, set LVIRSTD =1 before entering stop
mode.
SSREC — Short Stop Recovery Bit
SSREC enables the CPU to exit stop mode with a delay of 32 ICLK cycles instead of a 4096 ICLK cycle
delay.
1 = Stop mode recovery after 32 ICLK cycles
0 = Stop mode recovery after 4096 ICLK cycles
NOTE
Exiting stop mode by pulling reset will result in the long stop recovery.
If using an external crystal oscillator, do not set the SSREC bit.
When the LVI is disabled in stop mode (LVISTOP=0), the system
stabilization time for long stop recovery (4096 ICLK cycles) gives a delay
longer than the LVI’s turn-on time. There is no period where the MCU is not
protected from a low power condition. However, when using the short stop
recovery configuration option, the 32 ICLK delay is less than the LVI’s
turn-on time and there exists a period in start-up where the LVI is not
protecting the MCU.
STOP_ICLKDIS disables the internal oscillator during stop mode. Setting the STOP_ICLKDIS bit
disables the oscillator during stop mode. (See Chapter 5 Oscillator (OSC).)
Reset clears this bit.
1 = Internal oscillator disabled during stop mode
0 = Internal oscillator enabled to operate during stop mode
STOP_RCLKEN — RC Oscillator Stop Mode Enable Bit
STOP_RCLKEN enables the RC oscillator to continue operating during stop mode. Setting the
STOP_RCLKEN bit allows the oscillator to operate continuously even during stop mode. This is useful
for driving the timebase module to allow it to generate periodic wake up while in stop mode. (See
Chapter 5 Oscillator (OSC).)
Reset clears this bit.
1 = RC oscillator enabled to operate during stop mode
0 = RC oscillator disabled during stop mode
00
SCIBD-
SRC
STOP_XCLKEN — X-tal Oscillator Stop Mode Enable Bit
STOP_XCLKEN enables the crystal (x-tal) oscillator to continue operating during stop mode. Setting
the STOP_XCLKEN bit allows the x-tal oscillator to operate continuously even during stop mode. This
is useful for driving the timebase module to allow it to generate periodic wake up while in stop mode.
(See Chapter 5 Oscillator (OSC).) Reset clears this bit.
1 = X-tal oscillator enabled to operate during stop mode
0 = X-tal oscillator disabled during stop mode
OSCCLK1, OSCCLK0 — Oscillator Output Control Bits
OSCCLK1 and OSCCLK0 select which oscillator output to be driven out as OSCCLK to the timebase
module (TBM). Reset clears these two bits.
OSCCLK1OSCCLK0Timebase Clock Source
00Internal oscillator (ICLK)
01RC oscillator (RCCLK)
10X-tal oscillator (XTAL)
11Not used
MC68HC908AP Family Data Sheet, Rev. 3
52Freescale Semiconductor
Mask Option Register (MOR)
SCIBDSRC — SCI Baud Rate Clock Source
SCIBDSRC selects the clock source used for the standard SCI module (non-infrared SCI). The setting
of this bit affects the frequency at which the SCI operates.
1 = Internal data bus clock, f
, is used as clock source for SCI
BUS
0 = Oscillator clock, CGMXCLK, is used as clock source for SCI
3.5 Mask Option Register (MOR)
The mask option register (MOR) is used for selecting one of the three clock options for the MCU. The
MOR is a byte located in FLASH memory, and is written to by a FLASH programming routine.
Address:$FFCF
Bit 7654321Bit 0
Read:
OSCSEL1OSCSEL0RRRRRR
Write:
Reset:Unaffected by reset
Erased:11111111
R=Reserved
Figure 3-4. Mask Option Register (MOR)
OSCSEL1, OSCSEL0 — Oscillator Selection Bits
OSCSEL1 and OSCSEL0 select which oscillator is used for the MCU CGMXCLK clock. The erase
state of these two bits is logic 1. These bits are unaffected by reset. (See Table 3-1).
Bits 5–0 — Should be left as 1’s
Table 3-1. CGMXCLK Clock Selection
OSCSEL1OSCSEL0CGMXCLKOSC2 pinComments
00——
01ICLK
10RCCLK
11X-TAL
f
BUS
f
BUS
Inverting
output of XTAL
NOTE
The internal oscillator is a free running oscillator and is available after each
POR or reset. It is turned-off in stop mode by setting the STOP_ICLKDIS
bit in CONFIG2.
Not used
Internal oscillator generates the CGMXCLK.
RC oscillator generates the CGMXCLK.
Internal oscillator is available after each POR
or reset.
X-tal oscillator generates the CGMXCLK.
Internal oscillator is available after each POR
or reset.
The M68HC08 CPU (central processor unit) is an enhanced and fully object-code-compatible version of
the M68HC05 CPU. The CPU08 Reference Manual (Freescale document order number CPU08RM/AD)
contains a description of the CPU instruction set, addressing modes, and architecture.
4.2 Features
•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
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor55
Central Processor Unit (CPU)
4.3 CPU Registers
Figure 4-1 shows the five CPU registers. CPU registers are not part of the memory map.
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 4-1. CPU Registers
4.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 4-2. Accumulator (A)
4.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.
MC68HC908AP Family Data Sheet, Rev. 3
56Freescale Semiconductor
CPU Registers
Bit
1413121110987654321Bit 0
15
Read:
Write:
Reset:00000000XXXXXXXX
X = Indeterminate
Figure 4-3. Index Register (H:X)
4.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
1413121110987654321Bit 0
15
Read:
Write:
Reset:0000000011111111
Figure 4-4. Stack Pointer (SP)
NOTE
The location of the stack is arbitrary and may be relocated anywhere in
RAM. Moving the SP out of page 0 ($0000 to $00FF) frees direct address
(page 0) space. For correct operation, the stack pointer must point only to
RAM locations.
4.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.
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor57
Central Processor Unit (CPU)
Bit
1413121110987654321Bit 0
15
Read:
Write:
Reset:Loaded with Vector from $FFFE and $FFFF
Figure 4-5. Program Counter (PC)
4.3.5 Condition Code Register
The 8-bit condition code register contains the interrupt mask and five flags that indicate the results of the
instruction just executed. Bits 6 and 5 are set permanently to logic 1. The following paragraphs describe
the functions of the condition code register.
Bit 7654321Bit 0
Read:
Write:
Reset:X11X1XXX
V11H I NZC
X = Indeterminate
Figure 4-6. Condition Code Register (CCR)
V — Overflow Flag
The CPU sets the overflow flag when a two's complement overflow occurs. The signed branch
instructions BGT, BGE, BLE, and BLT use the overflow flag.
1 = Overflow
0 = No overflow
H — Half-Carry Flag
The CPU sets the half-carry flag when a carry occurs between accumulator bits 3 and 4 during an
add-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
I — Interrupt Mask
When the interrupt mask is set, all maskable CPU interrupts are disabled. CPU interrupts are enabled
when the interrupt mask is cleared. When a CPU interrupt occurs, the interrupt mask is set
automatically after the CPU registers are saved on the stack, but before the interrupt vector is fetched.
1 = Interrupts disabled
0 = Interrupts enabled
NOTE
To maintain M6805 Family compatibility, the upper byte of the index
register (H) is not stacked automatically. If the interrupt service routine
modifies H, then the user must stack and unstack H using the PSHH and
PULH instructions.
MC68HC908AP Family Data Sheet, Rev. 3
58Freescale Semiconductor
Arithmetic/Logic Unit (ALU)
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
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
4.4 Arithmetic/Logic Unit (ALU)
The ALU performs the arithmetic and logic operations defined by the instruction set.
Refer to the CPU08 Reference Manual (Freescale document order number CPU08RM/AD) for a
description of the instructions and addressing modes and more detail about the architecture of the CPU.
4.5 Low-Power Modes
The WAIT and STOP instructions put the MCU in low power-consumption standby modes.
4.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
4.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.
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor59
Central Processor Unit (CPU)
4.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.
4.7 Instruction Set Summary
Table 4-1 provides a summary of the M68HC08 instruction set.
Test for Negative or Zero(A) – $00 or (X) – $00 or (M) – $000 – – RR–
I ← 0; Inhibit CPU clocking until
interrupted
––0–––INH8F1
DIR
INH
INH
IX1
IX
SP1
3D
4D
5D
6D
7D
9E6D
3
1
1
3
ff
2
4
ff
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor67
Central Processor Unit (CPU)
Table 4-1. Instruction Set Summary
Source
Form
AAccumulatornAny bit
CCarry/borrow bitoprOperand (one or two bytes)
CCR Condition 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
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+D Indexed with post increment to direct addressing mode
IX1Indexed, 8-bit offset addressing mode←Loaded with
IX1+Indexed, 8-bit offset, post increment addressing mode?If
IX2Indexed, 16-bit offset addressing mode:Concatenated with
MMemory locationRSet or cleared
NNegative bit—Not affected
OperationDescription
⊕Logical EXCLUSIVE OR
«Sign extend
CCR
VH I NZC
Address
Mode
Opcode
Effect on
Cycles
Operand
MC68HC908AP Family Data Sheet, Rev. 3
68Freescale Semiconductor
Freescale Semiconductor69
Bit Manipulation BranchRead-Modify-WriteControlRegister/Memory
INH InherentREL RelativeSP1 Stack Pointer, 8-Bit Offset
IMM ImmediateIXIndexed, No OffsetSP2 Stack Pointer, 16-Bit Offset
DIR DirectIX1 Indexed, 8-Bit OffsetIX+ Indexed, No Offset with
EXT ExtendedIX2 Indexed, 16-Bit OffsetPost Increment
DD Direct-DirectIMD Immediate-DirectIX1+ Indexed, 1-Byte Offset with
IX+D Indexed-Direct DIX+ Direct-IndexedPost Increment
01234569E6789ABCD9EDE9EEF
3DIR
3DIR
3DIR
3DIR
3DIR
3DIR
3DIR
3DIR
3DIR
3DIR
3DIR
3DIR
3DIR
3DIR
3DIR
3DIR
4
BSET0
2DIR
4
BCLR0
2DIR
4
BSET1
2DIR
4
BCLR1
2DIR
4
BSET2
2DIR
4
BCLR2
2DIR
4
BSET3
2DIR
4
BCLR3
2DIR
4
BSET4
2DIR
4
BCLR4
2DIR
4
BSET5
2DIR
4
BCLR5
2DIR
4
BSET6
2DIR
4
BCLR6
2DIR
4
BSET7
2DIR
4
BCLR7
2DIR
3
BRA
2REL
3
BRN
2REL
3
BHI
2REL
3
BLS
2REL
3
BCC
2REL
3
BCS
2REL
3
BNE
2REL
3
BEQ
2REL
3
BHCC
2REL
3
BHCS
2REL
3
BPL
2REL
3
BMI
2REL
3
BMC
2REL
3
BMS
2REL
3
BIL
2REL
3
BIH
2REL
4
NEG
2DIR
5
CBEQ
3DIR
4
COM
2DIR
4
LSR
2DIR
4
STHX
2DIR
4
ROR
2DIR
4
ASR
2DIR
4
LSL
2DIR
4
ROL
2DIR
4
DEC
2DIR
5
DBNZ
3DIR
4
INC
2DIR
3
TST
2DIR
3
CLR
2DIR
1
NEGA
1INH
4
CBEQA
3IMM
5
MUL
1INH
1
COMA
1INH
1
LSRA
1INH
3
LDHX
3IMM
1
RORA
1INH
1
ASRA
1INH
1
LSLA
1INH
1
ROLA
1INH
1
DECA
1INH
3
DBNZA
2INH
1
INCA
1INH
1
TSTA
1INH
5
MOV
3DD
1
CLRA
1INH
1
NEGX
1INH
4
CBEQX
3IMM
7
DIV
1INH
1
COMX
1INH
1
LSRX
1INH
4
LDHX
2DIR
1
RORX
1INH
1
ASRX
1INH
1
LSLX
1INH
1
ROLX
1INH
1
DECX
1INH
3
DBNZX
2INH
1
INCX
1INH
1
TSTX
1INH
4
MOV
2DIX+
1
CLRX
1INH
*Pre-byte for stack pointer indexed instructions
4
NEG
2IX1
3IX1+
1INH
2IX1
2IX1
3IMM
2IX1
2IX1
2IX1
2IX1
2IX1
3IX1
2IX1
2IX1
3IMD
2IX1
5
CBEQ
3
NSA
4
COM
4
LSR
3
CPHX
4
ROR
4
ASR
4
LSL
4
ROL
4
DEC
5
DBNZ
4
INC
3
TST
4
MOV
3
CLR
3SP1
4SP1
3SP1
3SP1
3SP1
3SP1
3SP1
3SP1
3SP1
4SP1
3SP1
3SP1
3SP1
Table 4-2. Opcode Map
5
NEG
6
CBEQ
5
COM
5
LSR
ROR
5
ASR
5
LSL
5
ROL
5
DEC
6
DBNZ
5
INC
4
TST
4
CLR
3
NEG
1IX
4
CBEQ
2IX+
2
DAA
1INH
3
COM
1IX
3
LSR
1IX
4
CPHX
2DIR
5
3
ROR
1IX
3
ASR
1IX
3
LSL
1IX
3
ROL
1IX
3
DEC
1IX
4
DBNZ
2IX
3
INC
1IX
2
TST
1IX
4
MOV
2IX+D
2
CLR
1IX
Low Byte of Opcode in Hexadecimal05BRSET0
7
RTI
1INH
4
RTS
1INH
9
SWI
1INH
2
TA P
1INH
1
TPA
1INH
2
PULA
1INH
2
PSHA
1INH
2
PULX
1INH
2
PSHX
1INH
2
PULH
1INH
2
PSHH
1INH
1
CLRH
1INH
1
STOP
1INH
1
WAIT
1INH
3
BGE
2REL
3
BLT
2REL
3
BGT
2REL
3
BLE
2REL
2
TXS
1INH
2
TSX
1INH
1
TA X
1INH
1
CLC
1INH
1
SEC
1INH
2
CLI
1INH
2
SEI
1INH
1
RSP
1INH
1
NOP
1INH
*
1
TXA
1INH
2
SUB
2IMM
2
CMP
2IMM
2
SBC
2IMM
2
CPX
2IMM
2
AND
2IMM
2
BIT
2IMM
2
LDA
2IMM
2
AIS
2IMM
2
EOR
2IMM
2
ADC
2IMM
2
ORA
2IMM
2
ADD
2IMM
4
BSR
2REL
2
LDX
2IMM
2
AIX
2IMM
3
SUB
2DIR
3
CMP
2DIR
3
SBC
2DIR
3
CPX
2DIR
3
AND
2DIR
3
BIT
2DIR
3
LDA
2DIR
3
STA
2DIR
3
EOR
2DIR
3
ADC
2DIR
3
ORA
2DIR
3
ADD
2DIR
2
JMP
2DIR
4
JSR
2DIR
3
LDX
2DIR
3
STX
2DIR
MSB
LSB
4
SUB
3EXT
4
CMP
3EXT
4
SBC
3EXT
4
CPX
3EXT
4
AND
3EXT
4
BIT
3EXT
4
LDA
3EXT
4
STA
3EXT
4
EOR
3EXT
4
ADC
3EXT
4
ORA
3EXT
4
ADD
3EXT
3
JMP
3EXT
5
JSR
3EXT
4
LDX
3EXT
4
STX
3EXT
0High Byte of Opcode in Hexadecimal
3DIR
4
SUB
3IX2
4
CMP
3IX2
4
SBC
3IX2
4
CPX
3IX2
4
AND
3IX2
4
BIT
3IX2
4
LDA
3IX2
4
STA
3IX2
4
EOR
3IX2
4
ADC
3IX2
4
ORA
3IX2
4
ADD
3IX2
4
JMP
3IX2
6
JSR
3IX2
4
LDX
3IX2
4
STX
3IX2
Cycles
Opcode Mnemonic
Number of Bytes / Addressing Mode
5
SUB
4SP2
5
CMP
4SP2
5
SBC
4SP2
5
CPX
4SP2
5
AND
4SP2
5
BIT
4SP2
5
LDA
4SP2
5
STA
4SP2
5
EOR
4SP2
5
ADC
4SP2
5
ORA
4SP2
5
ADD
4SP2
5
LDX
4SP2
5
STX
4SP2
3
SUB
2IX1
3
CMP
2IX1
3
SBC
2IX1
3
CPX
2IX1
3
AND
2IX1
3
BIT
2IX1
3
LDA
2IX1
3
STA
2IX1
3
EOR
2IX1
3
ADC
2IX1
3
ORA
2IX1
3
ADD
2IX1
3
JMP
2IX1
5
JSR
2IX1
3
LDX
2IX1
3
STX
2IX1
4
SUB
3SP1
4
CMP
3SP1
4
SBC
3SP1
4
CPX
3SP1
4
AND
3SP1
4
BIT
3SP1
4
LDA
3SP1
4
STA
3SP1
4
EOR
3SP1
4
ADC
3SP1
4
ORA
3SP1
4
ADD
3SP1
4
LDX
3SP1
4
STX
3SP1
2
SUB
1IX
2
CMP
1IX
2
SBC
1IX
2
CPX
1IX
2
AND
1IX
2
BIT
1IX
2
LDA
1IX
2
STA
1IX
2
EOR
1IX
2
ADC
1IX
2
ORA
1IX
2
ADD
1IX
2
JMP
1IX
4
JSR
1IX
2
LDX
1IX
2
STX
1IX
Opcode Map
Central Processor Unit (CPU)
MC68HC908AP Family Data Sheet, Rev. 3
70Freescale Semiconductor
Chapter 5
Oscillator (OSC)
5.1 Introduction
The oscillator module consist of three types of oscillator circuits:
•Internal oscillator
•RC oscillator
•32.768 kHz crystal (x-tal) oscillator
The reference clock for the CGM and other MCU sub-systems is selected by programming the mask
option register located at $FFCF.
The reference clock for the timebase module (TBM) is selected by the two bits, OSCCLK1 and OSCCLK0,
in the CONFIG2 register.
The internal oscillator runs continuously after a POR or reset, and is always available. The RC and crystal
oscillator cannot run concurrently; one is disabled while the other is selected; because the RC and x-tal
circuits share the same OSC1 pin.
NOTE
The oscillator circuits are powered by the on-chip V
therefore, the output swing on OSC1 and OSC2 is from V
Figure 5-1. shows the block diagram of the oscillator module.
regulator,
REG
SS
to V
REG
.
5.2 Clock Selection
Reference clocks are selectable for the following sub-systems:
•CGMXCLK and CGMRCLK — Reference clock for clock generator module (CGM) and other MCU
sub-systems other than TBM and COP. This is the main reference clock for the MCU.
•OSCCLK — Reference clock for timebase module (TBM).
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor71
Oscillator (OSC)
To CGM and others
CGMXCLKCGMRCLK
MORCONFIG2
OSCSEL1
MUX
OSCSEL0
XCLK
X-TAL OSCILLATORRC OSCILLATORINTERNAL OSCILLATOR
To CGM PLL
RCCLK
To TBM
OSCCLK
OSCCLK1
MUX
OSCCLK0
XRCIXRCI
To SIM
(and COP)
ICLK
BUS CLOCK
OSC1OSC2
From SIM
Figure 5-1. Oscillator Module Block Diagram
5.2.1 CGM Reference Clock Selection
The clock generator module (CGM) reference clock (CGMXCLK) is the reference clock input to the MCU.
It is selected by programming two bits in a FLASH memory location; the mask option register (MOR), at
$FFCF. See 3.5 Mask Option Register (MOR).
Address:$FFCF
Bit 7654321Bit 0
Read:
OSCSEL1OSCSEL0RRRRRR
Write:
Reset:Unaffected by reset
Erased:11111111
R=Reserved
Figure 5-2. Mask Option Register (MOR)
MC68HC908AP Family Data Sheet, Rev. 3
72Freescale Semiconductor
Table 5-1. CGMXCLK Clock Selection
OSCSEL1OSCSEL0CGMXCLKOSC2 PinComments
00——Not used
Clock Selection
01ICLK
10RCCLK
11XCLK
f
BUS
f
BUS
Inverting
output of
X-TAL
Internal oscillator generates the CGMXCLK.
RC oscillator generates the CGMXCLK.
Internal oscillator is available after each POR or
reset.
X-tal oscillator generates the CGMXCLK.
Internal oscillator is available after each POR or
reset.
NOTE
The internal oscillator is a free running oscillator and is available after each
POR or reset. It is turned-off in stop mode by setting the STOP_ICLKDIS
bit in CONFIG2.
5.2.2 TBM Reference Clock Selection
The timebase module reference clock (OSCCLK) is selected by configuring two bits in the CONFIG2
register, at $001D. See Chapter 3 Configuration & Mask Option Registers (CONFIG & MOR).
The RCCLK or XCLK is only available if that clock is selected as the CGM
reference clock, whereas the ICLK is always available.
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor73
Oscillator (OSC)
5.3 Internal Oscillator
The internal oscillator clock (ICLK), with a frequency of f
, is a free running clock that requires no
ICLK
external components. It can be selected as the CGMXCLK for the CGM and MCU sub-systems; and the
OSCCLK clock for the TBM. The ICLK is also the reference clock input to the computer operating properly
(COP) module.
Due to the simplicity of the internal oscillator, it does not have the accuracy and stability of the RC
oscillator or the x-tal oscillator. Therefore, the ICLK is not suitable where an accurate bus clock is required
and it should not be used as the CGMRCLK to the CGM PLL.
The internal oscillator by default is always available and is free running after POR or reset. It can be
turned-off in stop mode by setting the STOP_ICLKDIS bit before executing the STOP instruction.
Figure 5-4 shows the logical representation of components of the internal oscillator circuitry.
CONFIG2
STOP_ICLKDIS
From SIM
SIMOSCEN
To Clock Selection MUX
and COP
ICLK
EN
INTERNAL OSCILLATOR
BUS CLOCK
From SIM
MCU
OSC2
Figure 5-4. Internal Oscillator
MC68HC908AP Family Data Sheet, Rev. 3
74Freescale Semiconductor
RC Oscillator
5.4 RC Oscillator
The RC oscillator circuit is designed for use with an external resistor and a capacitor.
In its typical configuration, the RC oscillator requires two external components, one R and one C.
Component values should have a tolerance of 1% or less, to obtain a clock source with less than 10%
tolerance. The oscillator configuration uses two components:
•C
EXT
•R
EXT
From SIM
SIMOSCEN
CONFIG2
STOP_RCLKEN
MCU
See Chapter 22 for component value requirements.
Figure 5-5. RC Oscillator
To Clock Selection MUX
RCCLK
EN
RC OSCILLATOR
OSC1
V
REG
R
EXT
From SIM
BUS CLOCK
OSC2
C
EXT
5.5 X-tal Oscillator
The crystal (x-tal) oscillator circuit is designed for use with an external 32.768kHz crystal to provide an
accurate clock source.
In its typical configuration, the x-tal oscillator is connected in a Pierce oscillator configuration, as shown
in Figure 5-6. This figure shows only the logical representation of the internal components and may not
represent actual circuitry. The oscillator configuration uses five components:
•Crystal, X
•Fixed capacitor, C
•Tuning capacitor, C2 (can also be a fixed capacitor)
•Feedback resistor, R
•Series resistor, RS (optional)
Freescale Semiconductor75
(32.768kHz)
1
1
B
MC68HC908AP Family Data Sheet, Rev. 3
Oscillator (OSC)
From SIM
SIMOSCEN
CONFIG2
STOP_XCLKEN
MCU
See Chapter 22 for component value requirements.
C
1
To Clock Selection MUX
OSC2OSC1
R
B
R
X
1
32.768kHz
C
XCLK
S
2
Figure 5-6. Crystal Oscillator
The series resistor (R
) is included in the diagram 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.
5.6 I/O Signals
The following paragraphs describe the oscillator I/O signals.
5.6.1 Crystal Amplifier Input Pin (OSC1)
OSC1 pin is an input to the crystal oscillator amplifier or the input to the RC oscillator circuit.
5.6.2 Crystal Amplifier Output Pin (OSC2)
When the x-tal oscillator is selected, OSC2 pin is the output of the crystal oscillator inverting amplifier.
When the RC oscillator or internal oscillator is selected, OSC2 pin is the output of the internal bus clock.
5.6.3 Oscillator Enable Signal (SIMOSCEN)
The SIMOSCEN signal from the system integration module (SIM) enables/disables the x-tal oscillator, the
RC-oscillator, or the internal oscillator circuit.
MC68HC908AP Family Data Sheet, Rev. 3
76Freescale Semiconductor
Low Power Modes
5.6.4 CGM Oscillator Clock (CGMXCLK)
The CGMXCLK clock is output from the x-tal oscillator, RC oscillator or the internal oscillator. This clock
drives to CGM and other MCU sub-systems.
5.6.5 CGM Reference Clock (CGMRCLK)
This is buffered signal of CGMXCLK, it is used by the CGM as the phase-locked-loop (PLL) reference
clock.
5.6.6 Oscillator Clock to Time Base Module (OSCCLK)
The OSCCLK is the reference clock that drives the timebase module. See Chapter 10 Timebase Module
(TBM).
5.7 Low Power Modes
The WAIT and STOP instructions put the MCU in low-power consumption standby modes.
5.7.1 Wait Mode
The WAIT instruction has no effect on the oscillator module. CGMXCLK continues to drive to the clock
generator module, and OSCCLK continues to drive the timebase module.
5.7.2 Stop Mode
The STOP instruction disables the x-tal or the RC oscillator circuit, and hence the CGMXCLK clock stops
running. For continuous x-tal or RC oscillator operation in stop mode, set the STOP_XCLKEN (for x-tal)
or STOP_RCLKEN (for RC) bit to logic 1 before entering stop mode.
The internal oscillator clock continues operation in stop mode. It can be disabled by setting the
STOP_ICLKDIS bit to logic 1 before entering stop mode.
5.8 Oscillator During Break Mode
The oscillator continues to drive CGMXCLK when the device enters the break state.
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor77
Oscillator (OSC)
MC68HC908AP Family Data Sheet, Rev. 3
78Freescale Semiconductor
Chapter 6
Clock Generator Module (CGM)
6.1 Introduction
This section describes the clock generator module (CGM). The CGM generates the base clock signal,
CGMOUT, which is based on either the oscillator clock divided by two or the divided phase-locked loop
(PLL) clock, CGMPCLK, divided by two. CGMOUT is the clock from which the SIM derives the system
clocks, including the bus clock, which is at a frequency of CGMOUT÷2.
The PLL is a frequency generator designed for use with a low frequency crystal (typically 32.768kHz) to
generate a base frequency and dividing to a maximum bus frequency of 8MHz.
6.2 Features
Features of the CGM include:
•Phase-locked loop with output frequency in integer multiples of an integer dividend of the crystal
reference
•Low-frequency crystal operation with low-power operation and high-output frequency resolution
•Programmable prescaler for power-of-two increases in frequency
•Programmable hardware voltage-controlled oscillator (VCO) for low-jitter operation
•Automatic bandwidth control mode for low-jitter operation
•Automatic frequency lock detector
•CPU interrupt on entry or exit from locked condition
•Configuration register bit to allow oscillator operation during stop mode
6.3 Functional Description
The CGM consists of three major sub-modules:
•Oscillator module — The oscillator module generates the constant reference frequency clock,
CGMRCLK (buffered CGMXCLK).
•Phase-locked loop (PLL) — The PLL generates the programmable VCO frequency clock,
CGMVCLK, and the divided VCO clock, CGMPCLK.
•Base clock selector circuit — This software-controlled circuit selects either CGMXCLK divided by
two or the divided VCO clock, CGMPCLK, divided by two as the base clock, CGMOUT. The SIM
derives the system clocks from either CGMOUT or CGMXCLK.
Figure 6-1 shows the structure of the CGM.
Figure 6-2 is a summary of the CGM registers.
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor79
Clock Generator Module (CGM)
OSC2
OSC1
OSCSEL[1:0]
OSCCLK[1:0]
SIMOSCEN
From SIM
CGMRDV
OSCILLATOR (OSC) MODULE
See Chapter 5 Oscillator (OSC).
INTERNAL OSCILLATOR
RC OSCILLATOR
CRYSTAL OSCILLATOR
PHASE-LOCKED LOOP (PLL)
REFERENCE
DIVIDER
R
RDS[3:0]
V
DDA
MUX
CGMRCLK
CGMXFCV
ICLK
OSCCLK
CGMXCLK
CGMRCLK
SSA
VRS[7:0]
BCS
L
VPR[1:0]
E
2
CLOCK
SELECT
CIRCUIT
CGMPCLK
To SIM (and COP)
To Timebase Module (TBM)
To ADC
A
÷ 2
B
*WHEN S = 1,
CGMOUT = B
CGMOUT
1
S*
To SIM
SIMDIV2
From SIM
CGMVDV
PHASE
DETECTOR
LOCK
DETECTOR
LOOP
FILTER
AUTOMATIC
MODE
CONTROL
LOCKAUTOACQ
MUL[11:0]
N
FREQUENCY
DIVIDER
Figure 6-1. CGM Block Diagram
PLL ANALOG
PRE[1:0]
FREQUENCY
DIVIDER
VOLTAGE
CONTROLLED
OSCILLATOR
INTERRUPT
CONTROL
PLLIEPLLF
P
2
CGMVCLK
CGMINT
To SIM
MC68HC908AP Family Data Sheet, Rev. 3
80Freescale Semiconductor
Functional Description
Addr.Register NameBit 7654321Bit 0
$0036
$0037
$0038
$0039
$003A
$003B
NOTES:
1. When AUTO = 0, PLLIE is forced clear and is read-only.
2. When AUTO = 0, PLLF and LOCK read as clear.
3. When AUTO = 1, ACQ is read-only.
4. When PLLON = 0 or VRS7:VRS0 = $0, BCS is forced clear and is read-only.
5. When PLLON = 1, the PLL programming register is read-only.
6. When BCS = 1, PLLON is forced set and is read-only.
PLL Control Register
(PTCL)
PLL Bandwidth Control
Register
(PBWC)
PLL Multiplier Select
Register High
(PMSH)
PLL Multiplier Select
Register Low
(PMSL)
PLL VCO Range Select
Register
(PMRS)
PLL Reference Divider
Select Register
(PMDS)
Read:
Write:
Reset:00100000
Read:
Write:
Reset:0000000
Read:0000
Write:
Reset:00000000
Read:
Write:
Reset:01000000
Read:
Write:
Reset:01000000
Read:0000
Write:
Reset:00000001
PLLIE
AUTO
MUL7MUL6MUL5MUL4MUL3MUL2MUL1MUL0
VRS7VRS6VRS5VRS4VRS3VRS2VRS1VRS0
PLLF
LOCK
PLLONBCSPRE1PRE0VPR1VPR0
ACQ
0000
MUL11MUL10MUL9MUL8
RDS3RDS2RDS1RDS0
= UnimplementedR
R
= Reserved
Figure 6-2. CGM I/O Register Summary
6.3.1 Oscillator Module
The oscillator module provides two clock outputs CGMXCLK and CGMRCLK to the CGM module.
CGMXCLK when selected, is driven to SIM module to generate the system bus clock. CGMRCLK is used
by the phase-lock-loop to provide a higher frequency system bus clock. The oscillator module also
provides the reference clock for the timebase module (TBM). See Chapter 5 Oscillator (OSC) for detailed
oscillator circuit description. See Chapter 10 Timebase Module (TBM) for detailed description on TBM.
6.3.2 Phase-Locked Loop Circuit (PLL)
The PLL is a frequency generator that can operate in either acquisition mode or tracking mode, depending
on the accuracy of the output frequency. The PLL can change between acquisition and tracking modes
either automatically or manually.
6.3.3 PLL Circuits
The PLL consists of these circuits:
•Voltage-controlled oscillator (VCO)
•Reference divider
•Frequency pre-scaler
•Modulo VCO frequency divider
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor81
Clock Generator Module (CGM)
•Phase detector
•Loop filter
•Lock detector
The operating range of the VCO is programmable for a wide range of frequencies and for maximum
immunity to external noise, including supply and CGMXFC noise. The VCO frequency is bound to a range
from roughly one-half to twice the center-of-range frequency, f
CGMXFC pin changes the frequency within this range. By design, f
center-of-range frequency, f
E
)f
(L × 2
NOM
.
, (125 kHz) times a linear factor, L, and a power-of-two factor, E, or
NOM
. Modulating the voltage on the
VRS
is equal to the nominal
VRS
CGMRCLK is the PLL reference clock, a buffered version of CGMXCLK. CGMRCLK runs at a frequency,
, and is fed to the PLL through a programmable modulo reference divider, which divides f
f
RCLK
RCLK
by a
factor, R. The divider’s output is the final reference clock, CGMRDV, running at a frequency,
f
RDV=fRCLK
/R. With an external crystal
(30kHz–100kHz), always set R = 1 for specified performance. With an external high-frequency clock
source, use R to divide the external frequency to between 30kHz and 100 kHz.
The VCO’s output clock, CGMVCLK, running at a frequency, f
, is fed back through a programmable
VCLK
pre-scaler divider and a programmable modulo divider. The pre-scaler divides the VCO clock by a
power-of-two factor P (the CGMPCLK) and the modulo divider reduces the VCO clock by a factor, N. The
dividers’ output is the VCO feedback clock, CGMVDV, running at a frequency, f
VDV=fVCLK
/(N × 2P). (See
6.3.6 Programming the PLL for more information.)
The phase detector then compares the VCO feedback clock, CGMVDV, with the final reference clock,
CGMRDV. A correction pulse is generated based on the phase difference between the two signals. The
loop filter then slightly alters the DC voltage on the external capacitor connected to CGMXFC based on
the width and direction of the correction pulse. The filter can make fast or slow corrections depending on
its mode, described in 6.3.4 Acquisition and Tracking Modes. The value of the external capacitor and the
reference frequency determines the speed of the corrections and the stability of the PLL.
The lock detector compares the frequencies of the VCO feedback clock, CGMVDV, and the final
reference clock, CGMRDV. Therefore, the speed of the lock detector is directly proportional to the final
reference frequency, f
. The circuit determines the mode of the PLL and the lock condition based on
RDV
this comparison.
6.3.4 Acquisition and Tracking Modes
The PLL filter is manually or automatically configurable into one of two operating modes:
•Acquisition mode — In acquisition mode, the filter can make large frequency corrections to the
VCO. This mode is used at PLL start up or when the PLL has suffered a severe noise hit and the
VCO frequency is far off the desired frequency. When in acquisition mode, the ACQ bit is clear in
the PLL bandwidth control register. (See 6.5.2 PLL Bandwidth Control Register.)
•Tracking mode — In tracking mode, the filter makes only small corrections to the frequency of the
VCO. PLL jitter is much lower in tracking mode, but the response to noise is also slower. The PLL
enters tracking mode when the VCO frequency is nearly correct, such as when the PLL is selected
as the base clock source. (See 6.3.8 Base Clock Selector Circuit.) The PLL is automatically in
tracking mode when not in acquisition mode or when the ACQ
bit is set.
MC68HC908AP Family Data Sheet, Rev. 3
82Freescale Semiconductor
Functional Description
6.3.5 Manual and Automatic PLL Bandwidth Modes
The PLL can change the bandwidth or operational mode of the loop filter manually or automatically.
Automatic mode is recommended for most users.
In automatic bandwidth control mode (AUTO = 1), the lock detector automatically switches between
acquisition and tracking modes. Automatic bandwidth control mode also is used to determine when the
VCO clock, CGMVCLK, is safe to use as the source for the base clock, CGMOUT. (See 6.5.2 PLL
Bandwidth Control Register.) If PLL interrupts are enabled, the software can wait for a PLL interrupt
request and then check the LOCK bit. If interrupts are disabled, software can poll the LOCK bit
continuously (during PLL start-up, usually) or at periodic intervals. In either case, when the LOCK bit is
set, the VCO clock is safe to use as the source for the base clock. (See 6.3.8 Base Clock Selector Circuit.)
If the VCO is selected as the source for the base clock and the LOCK bit is clear, the PLL has suffered a
severe noise hit and the software must take appropriate action, depending on the application. (See 6.6
Interrupts for information and precautions on using interrupts.)
The following conditions apply when the PLL is in automatic bandwidth control mode:
•The ACQ
the filter. (See 6.3.4 Acquisition and Tracking Modes.)
•The ACQ
VCO frequency is out of a certain tolerance. (See 6.8 Acquisition/Lock Time Specifications for
more information.)
•The LOCK bit is a read-only indicator of the locked state of the PLL.
•The LOCK bit is set when the VCO frequency is within a certain tolerance and is cleared when the
VCO frequency is out of a certain tolerance. (See 6.8 Acquisition/Lock Time Specifications for
more information.)
•CPU interrupts can occur if enabled (PLLIE = 1) when the PLL’s lock condition changes, toggling
the LOCK bit. (See 6.5.1 PLL Control Register.)
bit (See 6.5.2 PLL Bandwidth Control Register.) is a read-only indicator of the mode of
bit is set when the VCO frequency is within a certain tolerance and is cleared when the
The PLL also may operate in manual mode (AUTO = 0). Manual mode is used by systems that do not
require an indicator of the lock condition for proper operation. Such systems typically operate well below
f
BUSMAX
.
The following conditions apply when in manual mode:
•ACQ
•Before entering tracking mode (ACQ
is a writable control bit that controls the mode of the filter. Before turning on the PLL in manual
mode, the ACQ
bit must be clear.
= 1), software must wait a given time, t
(See 6.8
ACQ
Acquisition/Lock Time Specifications.), after turning on the PLL by setting PLLON in the PLL
control register (PCTL).
•Software must wait a given time, t
, after entering tracking mode before selecting the PLL as the
AL
clock source to CGMOUT (BCS = 1).
•The LOCK bit is disabled.
•CPU interrupts from the CGM are disabled.
6.3.6 Programming the PLL
The following procedure shows how to program the PLL.
NOTE
The round function in the following equations means that the real number
should be rounded to the nearest integer number.
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor83
Clock Generator Module (CGM)
1.Choose the desired bus frequency, f
BUSDES
, or the desired VCO frequency, f
VCLKDES
; and then
solve for the other.
The relationship between f
BUS
f
VCLK
and f
is governed by the equation:
VCLK
2Pf
×2P4×f
CGMPCLK
×==
BUS
where P is the power of two multiplier, and can be 0, 1, 2, or 3
2.Choose a practical PLL reference frequency, f
, and the reference clock divider, R. Typically,
RCLK
the reference is 32.768kHz and R = 1.
Frequency errors to the PLL are corrected at a rate of f
/R. For stability and lock time reduction,
RCLK
this rate must be as fast as possible. The VCO frequency must be an integer multiple of this rate.
The relationship between the VCO frequency, f
f
VCLK
, and the reference frequency, f
VCLK
2PN
()=
----------- f
RCLK
R
RCLK,
where N is the integer range multiplier, between 1 and 4095.
In cases where desired bus frequency has some tolerance, choose f
to a value determined
RCLK
either by other module requirements (such as modules which are clocked by CGMXCLK), cost
requirements, or ideally, as high as the specified range allows. See Chapter 22 Electrical
Specifications.
Choose the reference divider, R = 1.
is
When the tolerance on the bus frequency is tight, choose f
and R = 1. If f
practical choices of f
cannot meet this requirement, use the following equation to solve for R with
RCLK
, and choose the f
RCLK
Rround R
f
⎛⎞
⎧⎫
VCLKDES
--------------------------
×=
⎜⎟
⎨⎬
MAX
f
⎝⎠
RCLK
⎩⎭
that gives the lowest R.
RCLK
integer
–
to an integer divisor of f
RCLK
f
⎛⎞
VCLKDES
--------------------------
⎜⎟
f
⎝⎠
RCLK
3.Calculate N:
×
Rf
⎛⎞
VCLKDES
Nround
=
-------------------------------------
⎜⎟
⎝⎠
f
RCLK
2P×
4.Calculate and verify the adequacy of the VCO and bus frequencies f
2PN
=
----------- f
R
f
VCLK
-----------
2P4×
()=
RCLK
f
VCLK
f
BUS
VCLK
and f
BUS
.
BUSDES
,
MC68HC908AP Family Data Sheet, Rev. 3
84Freescale Semiconductor
5.Select the VCO’s power-of-two range multiplier E, according to this table:
Frequency RangeE
Functional Description
0 < f
9,830,400 ≤ f
19,660,800 ≤ f
NOTE: Do not program E to a value of 3.
6.Select a VCO linear range multiplier, L, where f
< 9,830,400
VCLK
VCLK
VCLK
Lround
=
< 19,660,800
< 39,321,600
= 125kHz
NOM
f
⎛⎞
VCLK
--------------------------
⎜⎟
⎝⎠
2Ef
×
NOM
0
1
2
7.Calculate and verify the adequacy of the VCO programmed center-of-range frequency, f
center-of-range frequency is the midpoint between the minimum and maximum frequencies
attainable by the PLL.
VRS
NOM
E
L2
×()f
=
f
For proper operation,
f
–
VRSfVCLK
f
NOM
--------------------------
≤
2E×
2
VRS
. The
8.Verify the choice of P, R, N, E, and L by comparing f
operation, f
as possible to f
must be within the application’s tolerance of f
VCLK
VCLK.
VCLK
to f
and f
VRS
VCLKDES
NOTE
Exceeding the recommended maximum bus frequency or VCO frequency
can crash the MCU.
9.Program the PLL registers accordingly:
a.In the PRE bits of the PLL control register (PCTL), program the binary equivalent of P.
b.In the VPR bits of the PLL control register (PCTL), program the binary equivalent of E.
c.In the PLL multiplier select register low (PMSL) and the PLL multiplier select register high
(PMSH), program the binary equivalent of N.
d.In the PLL VCO range select register (PMRS), program the binary coded equivalent of L.
e.In the PLL reference divider select register (PMDS), program the binary coded equivalent of
R.
NOTE
The values for P, E, N, L, and R can only be programmed when the PLL is
off (PLLON = 0).
Table 6-1 provides numeric examples (numbers are in hexadecimal notation):
The programming method described in 6.3.6 Programming the PLL does not account for three possible
exceptions. A value of 0 for R, N, or L is meaningless when used in the equations given. To account for
these exceptions:
•A 0 value for R or N is interpreted exactly the same as a value of 1.
•A 0 value for L disables the PLL and prevents its selection as the source for the base clock.
(See 6.3.8 Base Clock Selector Circuit.)
6.3.8 Base Clock Selector Circuit
This circuit is used to select either the oscillator clock, CGMXCLK, or the divided VCO clock, CGMPCLK,
as the source of the base clock, CGMOUT. The two input clocks go through a transition control circuit that
waits up to three CGMXCLK cycles and three CGMPCLK cycles to change from one clock source to the
other. During this time, CGMOUT is held in stasis. The output of the transition control circuit is then
divided by two to correct the duty cycle. Therefore, the bus clock frequency, which is one-half of the base
clock frequency, is one-fourth the frequency of the selected clock (CGMXCLK or CGMPCLK).
The BCS bit in the PLL control register (PCTL) selects which clock drives CGMOUT. The divided VCO
clock cannot be selected as the base clock source if the PLL is not turned on. The PLL cannot be turned
off if the divided VCO clock is selected. The PLL cannot be turned on or off simultaneously with the
selection or deselection of the divided VCO clock. The divided VCO clock also cannot be selected as the
base clock source if the factor L is programmed to a 0. This value would set up a condition inconsistent
with the operation of the PLL, so that the PLL would be disabled and the oscillator clock would be forced
as the source of the base clock.
MC68HC908AP Family Data Sheet, Rev. 3
86Freescale Semiconductor
I/O Signals
6.3.9 CGM External Connections
In its typical configuration, the CGM requires up to four external components.
Figure 6-3 shows the external components for the PLL:
•Bypass capacitor, C
•Filter network
Care should be taken with PCB routing in order to minimize signal cross talk and noise. (See 6.8
Acquisition/Lock Time Specifications for routing information, filter network and its effects on PLL
performance.)
BYP
MCU
CGMXFC
1 kΩ
0.22 µF
Note: Filter network in box can be replaced with a 0.47µF capacitor, but will degrade stability.
10 nF
V
SSA
V
DDA
C
BYP
0.1 µF
V
DD
Figure 6-3. CGM External Connections
6.4 I/O Signals
The following paragraphs describe the CGM I/O signals.
6.4.1 External Filter Capacitor Pin (CGMXFC)
The CGMXFC pin is required by the loop filter to filter out phase corrections. An external filter network is
connected to this pin. (See Figure 6-3.)
NOTE
To prevent noise problems, the filter network should be placed as close to
the CGMXFC pin as possible, with minimum routing distances and no
routing of other signals across the network.
6.4.2 PLL Analog Power Pin (V
V
is a power pin used by the analog portions of the PLL. Connect the V
DDA
potential as the V
DD
pin.
DDA
)
pin to the same voltage
DDA
NOTE
Route V
carefully for maximum noise immunity and place bypass
DDA
capacitors as close as possible to the package.
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor87
Clock Generator Module (CGM)
6.4.3 PLL Analog Ground Pin (V
V
is a ground pin used by the analog portions of the PLL. Connect the V
SSA
potential as the V
SS
pin.
SSA
)
pin to the same voltage
SSA
NOTE
Route V
carefully for maximum noise immunity and place bypass
SSA
capacitors as close as possible to the package.
6.4.4 Oscillator Output Frequency Signal (CGMXCLK)
CGMXCLK is the oscillator output signal. It runs at the full speed of the oscillator, and is generated directly
from the crystal oscillator circuit, the RC oscillator circuit, or the internal oscillator circuit.
6.4.5 CGM Reference Clock (CGMRCLK)
CGMRCLK is a buffered version of CGMXCLK, this clock is the reference clock for the phase-locked-loop
circuit.
6.4.6 CGM VCO Clock Output (CGMVCLK)
CGMVCLK is the clock output from the VCO.
6.4.7 CGM Base Clock Output (CGMOUT)
CGMOUT is the clock output of the CGM. This signal goes to the SIM, which generates the MCU clocks.
CGMOUT is a 50 percent duty cycle clock running at twice the bus frequency. CGMOUT is software
programmable to be either the oscillator output, CGMXCLK, divided by two or the divided VCO clock,
CGMPCLK, divided by two.
6.4.8 CGM CPU Interrupt (CGMINT)
CGMINT is the interrupt signal generated by the PLL lock detector.
6.5 CGM Registers
The following registers control and monitor operation of the CGM:
•PLL control register (PCTL)
(See 6.5.1 PLL Control Register.)
•PLL bandwidth control register (PBWC)
(See 6.5.2 PLL Bandwidth Control Register.)
•PLL multiplier select registers (PMSH and PMSL)
(See 6.5.3 PLL Multiplier Select Registers.)
•PLL VCO range select register (PMRS)
(See 6.5.4 PLL VCO Range Select Register.)
The PLL control register (PCTL) contains the interrupt enable and flag bits, the on/off switch, the base
clock selector bit, the prescaler bits, and the VCO power-of-two range selector bits.
Address:$0036
Bit 7654321Bit 0
Read:
Write:
Reset:00100000
PLLIE
PLLIE — PLL Interrupt Enable Bit
This read/write bit enables the PLL to generate an interrupt request when the LOCK bit toggles, setting
the PLL flag, PLLF. When the AUTO bit in the PLL bandwidth control register (PBWC) is clear, PLLIE
cannot be written and reads as logic 0. Reset clears the PLLIE bit.
This read-only bit is set whenever the LOCK bit toggles. PLLF generates an interrupt request if the
PLLIE bit also is set. PLLF always reads as logic 0 when the AUTO bit in the PLL bandwidth control
register (PBWC) is clear. Clear the PLLF bit by reading the PLL control register. Reset clears the PLLF
bit.
1 = Change in lock condition
0 = No change in lock condition
PLLF
= Unimplemented
PLLONBCSPRE1PRE0VPR1VPR0
Figure 6-4. PLL Control Register (PCTL)
NOTE
Do not inadvertently clear the PLLF bit. Any read or read-modify-write
operation on the PLL control register clears the PLLF bit.
PLLON — PLL On Bit
This read/write bit activates the PLL and enables the VCO clock, CGMVCLK. PLLON cannot be
cleared if the VCO clock is driving the base clock, CGMOUT (BCS = 1). (See 6.3.8 Base Clock Selector
Circuit.) Reset sets this bit so that the loop can stabilize as the MCU is powering up.
1 = PLL on
0 = PLL off
BCS — Base Clock Select Bit
This read/write bit selects either the oscillator output, CGMXCLK, or the divided VCO clock,
CGMPCLK, as the source of the CGM output, CGMOUT. CGMOUT frequency is one-half the
frequency of the selected clock. BCS cannot be set while the PLLON bit is clear. After toggling BCS,
it may take up to three CGMXCLK and three CGMPCLK cycles to complete the transition from one
source clock to the other. During the transition, CGMOUT is held in stasis. (See 6.3.8 Base Clock
Selector Circuit.) Reset clears the BCS bit.
1 = CGMPCLK divided by two drives CGMOUT
0 = CGMXCLK divided by two drives CGMOUT
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor89
Clock Generator Module (CGM)
NOTE
PLLON and BCS have built-in protection that prevents the base clock
selector circuit from selecting the VCO clock as the source of the base clock
if the PLL is off. Therefore, PLLON cannot be cleared when BCS is set, and
BCS cannot be set when PLLON is clear. If the PLL is off (PLLON = 0),
selecting CGMPCLK requires two writes to the PLL control register. (See
6.3.8 Base Clock Selector Circuit.)
PRE1 and PRE0 — Prescaler Program Bits
These read/write bits control a prescaler that selects the prescaler power-of-two multiplier, P. (See
6.3.3 PLL Circuits and 6.3.6 Programming the PLL.) PRE1 and PRE0 cannot be written when the
PLLON bit is set. Reset clears these bits.
These prescaler bits affects the relationship between the VCO clock and the final system bus clock.
Table 6-2. PRE1 and PRE0 Programming
PRE1 and PRE0PPrescaler Multiplier
0001
0112
1024
1138
VPR1 and VPR0 — VCO Power-of-Two Range Select Bits
These read/write bits control the VCO’s hardware power-of-two range multiplier E that, in conjunction
with L (See 6.3.3 PLL Circuits, 6.3.6 Programming the PLL, and 6.5.4 PLL VCO Range Select
Register.) controls the hardware center-of-range frequency, f
. VPR1:VPR0 cannot be written when
VRS
the PLLON bit is set. Reset clears these bits.
Table 6-3. VPR1 and VPR0 Programming
VPR1 and VPR0E
0001
0112
1024
NOTE: Do not program E to a value of 3.
VCO Power-of-Two
Range Multiplier
MC68HC908AP Family Data Sheet, Rev. 3
90Freescale Semiconductor
CGM Registers
6.5.2 PLL Bandwidth Control Register
The PLL bandwidth control register (PBWC):
•Selects automatic or manual (software-controlled) bandwidth control mode
•Indicates when the PLL is locked
•In automatic bandwidth control mode, indicates when the PLL is in acquisition or tracking mode
•In manual operation, forces the PLL into acquisition or tracking mode
Address:$0037
Bit 7654321Bit 0
Read:
Write:
Reset:0000000
AUTO
LOCK
= UnimplementedR=Reserved
ACQ
Figure 6-5. PLL Bandwidth Control Register (PBWCR)
AUTO — Automatic Bandwidth Control Bit
This read/write bit selects automatic or manual bandwidth control. When initializing the PLL for manual
operation (AUTO = 0), clear the ACQ
bit before turning on the PLL. Reset clears the AUTO bit.
1 = Automatic bandwidth control
0 = Manual bandwidth control
0000
R
LOCK — Lock Indicator Bit
When the AUTO bit is set, LOCK is a read-only bit that becomes set when the VCO clock, CGMVCLK,
is locked (running at the programmed frequency). When the AUTO bit is clear, LOCK reads as logic 0
and has no meaning. The write one function of this bit is reserved for test, so this bit must always be
written a 0. Reset clears the LOCK bit.
1 = VCO frequency correct or locked
0 = VCO frequency incorrect or unlocked
ACQ
— Acquisition Mode Bit
When the AUTO bit is set, ACQ
or tracking mode. When the AUTO bit is clear, ACQ
is a read-only bit that indicates whether the PLL is in acquisition mode
is a read/write bit that controls whether the PLL is
in acquisition or tracking mode.
In automatic bandwidth control mode (AUTO = 1), the last-written value from manual operation is
stored in a temporary location and is recovered when manual operation resumes. Reset clears this bit,
enabling acquisition mode.
1 = Tracking mode
0 = Acquisition mode
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor91
Clock Generator Module (CGM)
6.5.3 PLL Multiplier Select Registers
The PLL multiplier select registers (PMSH and PMSL) contain the programming information for the
modulo feedback divider.
Address:$0038
Bit 7654321Bit 0
Read:0000
Write:
Reset:00000000
= Unimplemented
Figure 6-6. PLL Multiplier Select Register High (PMSH)
These read/write bits control the modulo feedback divider that selects the VCO frequency multiplier N.
(See 6.3.3 PLL Circuits and 6.3.6 Programming the PLL.) A value of $0000 in the multiplier select
registers configure the modulo feedback divider the same as a value of $0001. Reset initializes the
registers to $0040 for a default multiply value of 64.
NOTE
The multiplier select bits have built-in protection such that they cannot be
written when the PLL is on (PLLON = 1).
6.5.4 PLL VCO Range Select Register
The PLL VCO range select register (PMRS) contains the programming information required for the
hardware configuration of the VCO.
Address:$003A
Bit 7654321Bit 0
Read:
Write:
Reset:01000000
VRS[7:0] — VCO Range Select Bits
These read/write bits control the hardware center-of-range linear multiplier L which, in conjunction with
E (See 6.3.3 PLL Circuits, 6.3.6 Programming the PLL, and 6.5.1 PLL Control Register.), controls the
hardware center-of-range frequency, f
PCTL is set. (See 6.3.7 Special Programming Exceptions.) A value of $00 in the VCO range select
VRS7VRS6VRS5VRS4VRS3VRS2VRS1VRS0
Figure 6-8. PLL VCO Range Select Register (PMRS)
. VRS[7:0] cannot be written when the PLLON bit in the
VRS
MC68HC908AP Family Data Sheet, Rev. 3
92Freescale Semiconductor
Interrupts
register disables the PLL and clears the BCS bit in the PLL control register (PCTL). (See 6.3.8 Base
Clock Selector Circuit and 6.3.7 Special Programming Exceptions.). Reset initializes the register to $40
for a default range multiply value of 64.
NOTE
The VCO range select bits have built-in protection such that they cannot be
written when the PLL is on (PLLON = 1) and such that the VCO clock
cannot be selected as the source of the base clock (BCS = 1) if the VCO
range select bits are all clear.
The PLL VCO range select register must be programmed correctly.
Incorrect programming can result in failure of the PLL to achieve lock.
6.5.5 PLL Reference Divider Select Register
The PLL reference divider select register (PMDS) contains the programming information for the modulo
reference divider.
These read/write bits control the modulo reference divider that selects the reference division factor, R.
(See 6.3.3 PLL Circuits and 6.3.6 Programming the PLL.) RDS[3:0] cannot be written when the PLLON
bit in the PCTL is set. A value of $00 in the reference divider select register configures the reference
divider the same as a value of $01. (See 6.3.7 Special Programming Exceptions.) Reset initializes the
register to $01 for a default divide value of 1.
NOTE
The reference divider select bits have built-in protection such that they
cannot be written when the PLL is on (PLLON = 1).
NOTE
The default divide value of 1 is recommended for all applications.
6.6 Interrupts
When the AUTO bit is set in the PLL bandwidth control register (PBWC), the PLL can generate a CPU
interrupt request every time the LOCK bit changes state. The PLLIE bit in the PLL control register (PCTL)
enables CPU interrupts from the PLL. PLLF, the interrupt flag in the PCTL, becomes set whether
interrupts are enabled or not. When the AUTO bit is clear, CPU interrupts from the PLL are disabled and
PLLF reads as logic 0.
Software should read the LOCK bit after a PLL interrupt request to see if the request was due to an entry
into lock or an exit from lock. When the PLL enters lock, the divided VCO clock, CGMPCLK, divided by
two can be selected as the CGMOUT source by setting BCS in the PCTL. When the PLL exits lock, the
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor93
Clock Generator Module (CGM)
VCO clock frequency is corrupt, and appropriate precautions should be taken. If the application is not
frequency sensitive, interrupts should be disabled to prevent PLL interrupt service routines from impeding
software performance or from exceeding stack limitations.
NOTE
Software can select the CGMPCLK divided by two as the CGMOUT source
even if the PLL is not locked (LOCK = 0). Therefore, software should make
sure the PLL is locked before setting the BCS bit.
6.7 Special Modes
The WAIT instruction puts the MCU in low power-consumption standby modes.
6.7.1 Wait Mode
The WAIT instruction does not affect the CGM. Before entering wait mode, software can disengage and
turn off the PLL by clearing the BCS and PLLON bits in the PLL control register (PCTL) to save power.
Less power-sensitive applications can disengage the PLL without turning it off, so that the PLL clock is
immediately available at WAIT exit. This would be the case also when the PLL is to wake the MCU from
wait mode, such as when the PLL is first enabled and waiting for LOCK or LOCK is lost.
6.7.2 Stop Mode
The STOP instruction disables the PLL analog circuits and no clock will be driven out of the VCO.
When entering stop mode with the VCO clock (CGMPCLK) selected, before executing the STOP
instruction:
1.Set the oscillator stop mode enable bit (STOP_XCLKEN in CONFIG2) if continuos clock is required
in stop mode.
2.Clear the BCS bit to select CGMXCLK as CGMOUT.
On exit from stop mode:
1.Set the PLLON bit if cleared before entering stop mode.
2.Wait for PLL to lock by checking the LOCK bit.
3.Set BCS bit to select CGMPCLK as CGMOUT.
6.7.3 CGM During Break Interrupts
The system integration module (SIM) controls whether status bits in other modules can be cleared during
the break state. The BCFE bit in the SIM break flag control register (SBFCR) enables software to clear
status bits during the break state. (See 7.7.3 SIM Break Flag Control Register.)
To allow software to clear status bits during a break interrupt, write a logic 1 to the BCFE bit. If a status
bit is cleared during the break state, it remains cleared when the MCU exits the break state.
To protect the PLLF bit during the break state, write a logic 0 to the BCFE bit. With BCFE at logic 0 (its
default state), software can read and write the PLL control register during the break state without affecting
the PLLF bit.
MC68HC908AP Family Data Sheet, Rev. 3
94Freescale Semiconductor
Acquisition/Lock Time Specifications
6.8 Acquisition/Lock Time Specifications
The acquisition and lock times of the PLL are, in many applications, the most critical PLL design
parameters. Proper design and use of the PLL ensures the highest stability and lowest acquisition/lock
times.
6.8.1 Acquisition/Lock Time Definitions
Typical control systems refer to the acquisition time or lock time as the reaction time, within specified
tolerances, of the system to a step input. In a PLL, the step input occurs when the PLL is turned on or
when it suffers a noise hit. The tolerance is usually specified as a percent of the step input or when the
output settles to the desired value plus or minus a percent of the frequency change. Therefore, the
reaction time is constant in this definition, regardless of the size of the step input. For example, consider
a system with a 5 percent acquisition time tolerance. If a command instructs the system to change from
0Hz to 1MHz, the acquisition time is the time taken for the frequency to reach 1MHz ±50 kHz. 50 kHz =
5% of the 1MHz step input. If the system is operating at 1MHz and suffers a –100kHz noise hit, the
acquisition time is the time taken to return from 900kHz to 1MHz ±5kHz. 5kHz = 5% of the 100kHz step
input.
Other systems refer to acquisition and lock times as the time the system takes to reduce the error between
the actual output and the desired output to within specified tolerances. Therefore, the acquisition or lock
time varies according to the original error in the output. Minor errors may not even be registered. Typical
PLL applications prefer to use this definition because the system requires the output frequency to be
within a certain tolerance of the desired frequency regardless of the size of the initial error.
6.8.2 Parametric Influences on Reaction Time
Acquisition and lock times are designed to be as short as possible while still providing the highest possible
stability. These reaction times are not constant, however. Many factors directly and indirectly affect the
acquisition time.
The most critical parameter which affects the reaction times of the PLL is the reference frequency, f
This frequency is the input to the phase detector and controls how often the PLL makes corrections. For
stability, the corrections must be small compared to the desired frequency, so several corrections are
required to reduce the frequency error. Therefore, the slower the reference the longer it takes to make
these corrections. This parameter is under user control via the choice of crystal frequency f
XCLK
R value programmed in the reference divider. (See 6.3.3 PLL Circuits, 6.3.6 Programming the PLL, and
6.5.5 PLL Reference Divider Select Register.)
Another critical parameter is the external filter network. The PLL modifies the voltage on the VCO by
adding or subtracting charge from capacitors in this network. Therefore, the rate at which the voltage
changes for a given frequency error (thus change in charge) is proportional to the capacitance. The size
of the capacitor also is related to the stability of the PLL. If the capacitor is too small, the PLL cannot make
small enough adjustments to the voltage and the system cannot lock. If the capacitor is too large, the PLL
may not be able to adjust the voltage in a reasonable time. (See 6.8.3 Choosing a Filter.)
Also important is the operating voltage potential applied to V
. The power supply potential alters the
DDA
characteristics of the PLL. A fixed value is best. Variable supplies, such as batteries, are acceptable if
they vary within a known range at very slow speeds. Noise on the power supply is not acceptable,
because it causes small frequency errors which continually change the acquisition time of the PLL.
RDV
and the
.
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor95
Clock Generator Module (CGM)
Temperature and processing also can affect acquisition time because the electrical characteristics of the
PLL change. The part operates as specified as long as these influences stay within the specified limits.
External factors, however, can cause drastic changes in the operation of the PLL. These factors include
noise injected into the PLL through the filter capacitor, filter capacitor leakage, stray impedances on the
circuit board, and even humidity or circuit board contamination.
6.8.3 Choosing a Filter
As described in 6.8.2 Parametric Influences on Reaction Time, the external filter network is critical to the
stability and reaction time of the PLL. The PLL is also dependent on reference frequency and supply
voltage.
Either of the filter networks in Figure 6-10 is recommended when using a 32.768kHz reference clock
(CGMRCLK). Figure 6-10 (a) is used for applications requiring better stability. Figure 6-10 (b) is used in
low-cost applications where stability is not critical.
1 kΩ
0.22 µF
CGMXFC
10 nF
V
SSA
(a)(b)
Figure 6-10. PLL Filter
CGMXFC
V
SSA
0.22 µF
MC68HC908AP Family Data Sheet, Rev. 3
96Freescale Semiconductor
Chapter 7
System Integration Module (SIM)
7.1 Introduction
This section describes the system integration module (SIM). Together with the CPU, the SIM controls all
MCU activities. A block diagram of the SIM is shown in Figure 7-1. Figure 7-2 is a summary of the SIM
input/output (I/O) registers. The SIM is a system state controller that coordinates CPU and exception
timing. The SIM is responsible for:
•Bus clock generation and control for CPU and peripherals:
–Stop/wait/reset/break entry and recovery
–Internal clock control
•Master reset control, including power-on reset (POR) and COP timeout
•Interrupt control:
–Acknowledge timing
–Arbitration control timing
–Vector address generation
•CPU enable/disable timing
•Modular architecture expandable to 128 interrupt sources
Table 7-1 shows the internal signal names used in this section.
Table 7-1. Signal Name Conventions
Signal NameDescription
ICLKInternal oscillator clock
CGMXCLKSelected oscillator clock from oscillator module
CGMVCLK, CGMPCLKPLL output and the divided PLL output
CGMOUT
IABInternal address bus
IDBInternal data bus
PORRSTSignal from the power-on reset module to the SIM
IRSTInternal reset signal
R/W
CGMPCLK-based or oscillator-based clock output from CGM module
(Bus clock = CGMOUT ÷ 2)
The bus clock generator provides system clock signals for the CPU and peripherals on the MCU. The
system clocks are generated from an incoming clock, CGMOUT, as shown in Figure 7-3. This clock can
come from either an external oscillator or from the on-chip PLL. (See Chapter 6 Clock Generator Module
(CGM).)
OSC2
OSC1
STOP MODE CLOCK
ENABLE SIGNALS
FROM CONFIG2
7.2.1 Bus Timing
OSCILLATOR (OSC) MODULE
CGMRCLK
PHASE-LOCKED LOOP (PLL)
Figure 7-3. CGM Clock Signals
OSCCLK
CGMXCLK
ICLK
CGMOUT
SIMDIV2
CGMVCLK
TO TBM
TO TIM, ADC
SIM COUNTER
SYSTEM INTEGRATION MODULE
÷ 2
TO PWM
BUS CLOCK
GENERATORS
MONITOR MODE
USER MODE
SIMOSCEN
IT12
TO REST
OF MCU
IT23
TO REST
OF MCU
PTB0
In user mode, the internal bus frequency is either the oscillator output (CGMXCLK) divided by four or the
divided PLL output (CGMPCLK) divided by four.
MC68HC908AP Family Data Sheet, Rev. 3
Freescale Semiconductor99
System Integration Module (SIM)
7.2.2 Clock Start-up from POR or LVI Reset
When the power-on reset module or the low-voltage inhibit module generates a reset, the clocks to the
CPU and peripherals are inactive and held in an inactive phase until after the 4096 ICLK cycle POR
timeout has completed. The RST
pin is driven low by the SIM during this entire period. The IBUS clocks
start upon completion of the timeout.
7.2.3 Clocks in Stop Mode and Wait Mode
Upon exit from stop mode by an interrupt, break, or reset, the SIM allows ICLK to clock the SIM counter.
The CPU and peripheral clocks do not become active until after the stop delay timeout. This timeout is
selectable as 4096 or 32 ICLK cycles. (See 7.6.2 Stop Mode.)
In wait mode, the CPU clocks are inactive. The SIM also produces two sets of clocks for other modules.
Refer to the wait mode subsection of each module to see if the module is active or inactive in wait mode.
Some modules can be programmed to be active in wait mode.
7.3 Reset and System Initialization
The MCU has these reset sources:
•Power-on reset module (POR)
•External reset pin (RST
•Computer operating properly module (COP)
•Low-voltage inhibit module (LVI)
•Illegal opcode
•Illegal address
)
All of these resets produce the vector $FFFE:$FFFF ($FEFE:$FEFF in monitor mode) and assert the
internal reset signal (IRST). IRST causes all registers to be returned to their default values and all
modules to be returned to their reset states.
An internal reset clears the SIM counter (see 7.4 SIM Counter), but an external reset does not. Each of
the resets sets a corresponding bit in the SIM reset status register (SRSR). (See 7.7 SIM Registers.)
7.3.1 External Pin Reset
The RST pin circuit includes an internal pull-up device. Pulling the asynchronous RST pin low halts all
processing. The PIN bit of the SIM reset status register (SRSR) is set as long as RST
minimum of 67 ICLK cycles, assuming that neither the POR nor the LVI was the source of the reset. See
Table 7-2 for details. Figure 7-4 shows the relative timing.
Table 7-2. PIN Bit Set Timing
Reset TypeNumber of Cycles Required to Set PIN
POR/LVI4163 (4096 + 64 + 3)
All others67 (64 + 3)
is held low for a
MC68HC908AP Family Data Sheet, Rev. 3
100Freescale Semiconductor
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.