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.
Revision History
Date
1/20050First releaseN/A
8/20051Section 4.7 Application Information added.
Revision
Level
Description
Minor changes to the second and third paragraphs in the note in Section
The MC68HC908LB8 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, memory types, and package types.
The MC68HC908LB8 has peripherals dedicated to high resolution PWM and power factor correction
(PFC).
1.2 Features
For convenience, features have been organized to reflect:
•Standard features of the MC68HC908LB8
•Features of the CPU08
1.2.1 Standard Features of the MC68HC908LB8
Features of the MC68HC908LB8 include:
•8-MHz internal bus frequency
•Trimmable internal oscillator:
–4.0 MHz internal bus operation
–8-bit trim capability
–25% untrimmed
–5% trimmed
•8 Kbytes of 10 K write/erase cycle typical on-chip in application programmable FLASH memory
with security option
•128 bytes of on-chip random-access memory (RAM)
•Dual channel high resolution PWM with dead time insertion and shutdown input. The outputs use
frequency dithering to achieve a 4 ns output resolution.
•Dual channel pulse-width modulator (PWM) module to provide power factor correction capability
•Op amp/comparator for power factor correction capability or general purpose use
•7-bit keyboard interrupt
•One 16-bit, 2-channel timer interface module with one output available on port pin (PTA6) for input
capture and PWM
•17 general-purpose input/output (I/O) pins and one input only pin
–Three shared with high resolution PWM (HRP)
–Three shared with PWM module
(1)
1. No security feature is absolutely secure. However, Freescale Semiconductor’s strategy is to make reading or copying the
FLASH difficult for unauthorized users.
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor17
General Description
–Three shared with op amp/comparator
–Seven shared with ADC module (AD[0:6])
–One shared with timer channel 0
–Two shared with OSC1 and OSC2
–One shared with reset
–Seven shared with keyboard interrupt
–One input-only pin shared with external interrupt (IRQ)
2. Fault function switchable between pins PTB2 and PTB7.
Figure 1-1. MCU Block Diagram
1.4 Pin Assignments
Figure 1-2 illustrates the pin assignments for the 20-pin SOIC package.
MC68HC908LB8 Data Sheet, Rev. 1
20Freescale Semiconductor
Pin Functions
V
1
DD
2
V
SS
PTC0/OSC1
PTC1/OSC2
PTC2/SHTDWN/IRQ
PTB0/TOP
PTB1/BOT
PTB2/FAULT
PTB3/PWM0
PTB4/PWM1
3
4
5
6
7
8
9
10
Figure 1-2. 20-Pin SOIC and PDIP Pin Assignments
1.5 Pin Functions
Table 1-1 provides a description of the pin functions.
Table 1-1. Pin Functions
Pin
Name
V
DD
V
SS
PTA0
PTA1
PTA2
PTA3
PTA4
PTA5
Power supply Power
Power supply ground Power
PTA0 — General purpose I/O port Input/Output
KBI0 — Keyboard interrupt input 0Input
ADC0 — A/D channel 0 inputInput
PTA1 — General purpose I/O port Input/Output
KBI1 — Keyboard interrupt input 1Input
ADC1 — A/D channel 1 inputInput
PTA2 — General purpose I/O port Input/Output
KBI2 — Keyboard interrupt input 2Input
ADC2 — A/D channel 2 inputInput
PTA3 — General purpose I/O port Input/Output
KBI3 — Keyboard interrupt input 3Input
ADC3 — A/D channel 3 inputInput
PTA4 — General purpose I/O port Input/Output
KBI4 — Keyboard interrupt input 4Input
ADC4 — A/D channel 4 inputInput
PTA5 — General purpose I/O port Input/Output
RST
— Reset input, active low with internal pullup and Schmitt triggerInput
KBI5 — Keyboard interrupt input 5 Input
DescriptionInput/Output
20
PTA6/ADC5/TCH0/KBI6
19
PTA5/RST
18
PTA4/ADC4/KBI4
17
PTA3/ADC3/KBI3
PTA2/ADC2/KBI2
16
PTA1/ADC1/KBI1
15
PTA0/ADC0/KBI0
14
PTB7/V
13
12
11
OUT
PTB6/V–
PTB5/V+
/KBI5
/ADC6/FAULT
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor21
General Description
Table 1-1. Pin Functions (Continued)
Pin
Name
PTA6
PTB0
PTB1
PTB2
PTB3
PTB4
PTB5
PTB6
PTB7
PTC0
PTC1
PTC2
DescriptionInput/Output
PTA6 — General purpose I/O port Input/Output
KBI6 — Keyboard interrupt input 6Input
TCH0 — Timer Channel 0 I/O Input/Output
ADC5 — A/D channel 5 inputInput
PTB0 — General purpose I/O portInput/Output
TOP — High resolution PWM outputOutput
PTB1 — General purpose I/O portInput/Output
BOT — High resolution PWM outputOutput
PTB2 — General purpose I/O portInput/Output
FAULT — High resolution PWM fault input (switchable between PTB2 and PTB7)Input
PTB3 — General purpose I/O portInput/Output
PWM0 — Pulse-width modulator output 0Output
PTB4 — General purpose I/O portInput/Output
PWM1 — Pulse-width modulator output 1Output
PTB5 — General purpose I/O portInput/Output
V+ — Op amp/comparator inputInput
PTB6 — General purpose I/O portInput/Output
V– — Op amp/comparator inputInput
PTB7 — General purpose I/O portInput/Output
V
— Op amp/comparator output
OUT
ADC6 — A/D channel 6 inputInput
FAULT — High resolution PWM fault input (switchable between PTB2 and PTB7)Input
PTC0 — General purpose I/O portInput/Output
OSC1 — XTAL, RC, or external oscillator inputInput
PTC1 — General purpose I/O portInput/Output
OSC2 — XTAL oscillator output (XTAL option only)
RC or internal oscillator output (OSC2EN = 1 in PTAPUE register)
PTC2 — General purpose input portInput
SHTDWN — High resolution PWM inputInput
IRQ
— External interrupt with programmable pullup and Schmitt triggerInput
Output
Output
Output
1.6 Pin Function Priority
Table 1-2 is meant to resolve the priority if multiple functions are enabled on a single pin.
NOTE
Upon reset all pins come up as input ports regardless of the priority table.
MC68HC908LB8 Data Sheet, Rev. 1
22Freescale Semiconductor
Table 1-2. Function Priority in Shared Pins
Pin NameHighest-to-Lowest Priority Sequence
PTA0ADC0 → KBI0 → PTA0
PTA1ADC1 → KBI1 → PTA1
PTA2ADC2 → KBI2 → PTA2
PTA3ADC3 → KBI3 → PTA3
PTA4ADC4 → KBI4 → PTA4
PTA5RST
PTA6ADC5 → TCH0 → KBI6 → PTA6
PTB0TOP → PTB0
PTB1BOT → PTB1
PTB2
PTB3PWM0 → PTB3
PTB4PWM1 → PTB4
PTB5V+ → PTB5
→ KBI5 → PTA5
(1)
FAULT
→ PTB2
Pin Function Priority
PTB6V– → PTB6
PTB7
PTC0OSC1 → PTC0
PTC1OSC2 → PTC1
PTC2SHTDWN → IRQ
V
/ ADC6 / FAULT
OUT
(1)(2)
→ PTC2
→ PTB7
NOTES:
1. Fault function is switchable between pins PTB2 and PTB7.
2. V
, ADC6, and FAULT functions all share equal priority. All of these functions can be used
OUT
simultaneously on this pin.
NOTE
Any unused inputs and I/O ports should be tied to an appropriate logic level
(either V
or VSS). Although the I/O ports of the MC68HC908LB8 do not
DD
require termination, termination is recommended to reduce the possibility
of static damage.
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor23
General Description
1.7 System Clock Distribution
V
DD
R
EXT
XRC
IRC
OSC
MUX
BUSCLKX4
SIM
÷2
÷4
BUSCLKX4
BUSCLKX2
BUSCLK
CPUFLASHRAMMON ROM
Figure 1-3. System Clock Distribution Diagram
Some of the modules inside the MCU use different clock sources. Figure 1-3 shows a simplified clock
connection diagram. The OSC supplies the clock sources:
•BUSCLKX4 is the basic reference clock of the device. It is either:
–The external crystal oscillator
–An external clock source
–An external RC oscillator
–The internal oscillator
PWM
HRPCOPTIMADCKBI
FLASH
PROGRAMMING
ROM
MC68HC908LB8 Data Sheet, Rev. 1
24Freescale Semiconductor
Chapter 2
Memory
2.1 Introduction
The CPU08 can address 64 Kbytes of memory space. The memory map, shown in Figure 2-1, includes:
•System registers
•8192 bytes of user FLASH memory
•128 bytes of random-access memory (RAM)
•674 bytes of FLASH programming routines read-only memory (ROM)
•34 bytes of user-defined vectors
2.2 Unimplemented Memory Locations
Accessing an unimplemented location can cause an illegal address reset. In the memory map
(Figure 2-1) and in register figures in this document, unimplemented locations are shaded.
2.3 Reserved Memory Locations
Accessing a reserved location can have unpredictable effects on microcontroller (MCU) operation. In the
Figure 2-1 and in register figures in this document, reserved locations are marked with the word Reserved
or with the letter R.
2.4 Register Section
Most of the control, status, and data registers are in the zero page area of $0000–$0058. Additional I/O
registers have these addresses:
•$FE00; break status register, BSR
•$FE01; SIM reset status register, SRSR
•$FE02; break auxiliary register, BRKAR
•$FE03; break flag control register, BFCR
•$FE04; interrupt status register 1, INT1
•$FE05; interrupt status register 2, INT2
•$FE06; reserved
•$FE07; reserved
•$FE08; FLASH control register, FLCR
•$FE09; break address register high, BRKH
•$FE0A; break address register low, BRKL
•$FE0B; break status and control register, BRKSCR
•$FE0C; LVI status register, LVISR
•$FF7E; FLASH block protect register, FLBPR
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor25
Memory
Data registers are shown in Figure 2-2. Table 2-1 is a list of vector locations.
$0000
I/O REGISTERS↓
$0058
$0059
↓
$007F
$0080
↓
$00FF
$0100
↓
$037D
UNIMPLEMENTED
RANDOM-ACCESS MEMORY
128 BYTES
UNIMPLEMENTED
(1)
(1)
$037E
↓
FLASH PROGRAMMING ROUTINES ROM
674 BYTES
$061F
$0620
↓
UNIMPLEMENTED
(1)
$DEFF
$DE00
↓
FLASH MEMORY
8192 BYTES
$FDFF
$FE00BREAK STATUS REGISTER (BSR)
$FE01SIM RESET STATUS REGISTER (SRSR)
$FE02BREAK AUXILIARY REGISTER (BRKAR)
$FE03BREAK FLAG CONTROL REGISTER (BFCR)
$FE04INTERRUPT STATUS REGISTER 1 (INT1)
$FE05INTERRUPT STATUS REGISTER 2 (INT2)
$FE06RESERVED
$FE07RESERVED
$FE08FLASH CONTROL REGISTER (FLCR)
$FE09BREAK ADDRESS REGISTER HIGH (BRKH)
$FE0ABREAK ADDRESS REGISTER LOW (BRKL)
$FE0BBREAK STATUS AND CONTROL REGISTER (BRKSCR)
$FE0CLVI STATUS REGISTER (LVISR)
$FE0D
↓
UNIMPLEMENTED
$FE1F
Figure 2-1. Memory Map
MC68HC908LB8 Data Sheet, Rev. 1
26Freescale Semiconductor
Register Section
$FE20
↓
$FF7D
$FF7EFLASH BLOCK PROTECT REGISTER (FLBPR)
$FF7F
↓
$FFBF
$FFC0INTERNAL OSCILLATOR TRIM VALUE
$FFC1
↓
$FFDD
$FFDE
↓
(2)
$FFFF
1. Attempts to execute code from addresses in these ranges will
generate an illegal address reset.
2. $FFF6–$FFFD used for eight security bytes
MONITOR ROM
350 BYTES
UNIMPLEMENTED
UNIMPLEMENTED
FLASH VECTORS
34 BYTES
Figure 2-1. Memory Map (Continued)
Addr.Register NameBit 7654321Bit 0
Port A Data Register
$0000
See page 134.
Port B Data Register
$0001
See page 136.
Port C Data Register
$0002
See page 138.
$0003ReservedReserved
Read:
(PTA)
Write:
Reset:Unaffected by reset
Read:
Write:
(PTB)
Reset:Unaffected by reset
Read:00000PTC2
Write:
(PTC)
Reset:00000000
PTB7PTB6PTB5PTB4PTB3PTB2PTB1PTB0
PTA6PTA5PTA4PTA3PTA2PTA1PTA0
PTC1PTC0
Read:0
Write:
Reset:00000000
Read:
Write:
Reset:00000000
DDRB7DDRB6DDRB5DDRB4DDRB3DDRB2DDRB1DDRB0
Bold= BufferedU = Unaffected
DDRA6DDRA5DDRA4DDRA3DDRA2DDRA1DDRA0
= UnimplementedR= Reserved
$0004
$0005
Data Direction Register A
(DDRA)
See page 135.
Data Direction Register B
(DDRB)
See page 137.
Figure 2-2. Control, Status, and Data Registers (Sheet 1 of 8)
2. RSTEN reset to 0 by a power-on reset (POR) only.
$001F
Configuration Register 1
(CONFIG1)
See page 61.
Read:
(1)
Write:
COPRSLVISTOPLVIRSTDLVIPWRD
Reset:00000000
0
SSRECSTOPCOPD
1. One-time writable register after reach reset.
= UnimplementedR= Reserved
Bold= BufferedU = Unaffected
Figure 2-2. Control, Status, and Data Registers (Sheet 2 of 8)
MC68HC908LB8 Data Sheet, Rev. 1
28Freescale Semiconductor
Register Section
Addr.Register NameBit 7654321Bit 0
$0020
$0021
$0022
$0023
$0024
$0025
$0026
$0027
$0028
$0029
$002A
$002B
↓
$0029
Timer Status and Control
Register (TSC)
See page 195.
Timer Counter
Register High (TCNTH)
See page 196.
Timer Counter
Register Low (TCNTL)
See page 196.
Timer Counter Modulo
Register High (TMODH)
See page 197.
Timer Counter Modulo
Register Low (TMODL)
See page 197.
Timer Channel 0 Status
and Control Register (TSC0)
See page 198.
Timer Channel 0
Register High (TCH0H)
See page 201.
Timer Channel 0
Register Low (TCH0L)
See page 201.
Timer Channel 1 Status
and Control Register (TSC1)
See page 198.
Timer Channel 1
Register High (TCH1H)
See page 201.
Timer Channel 1
Register Low (TCH1L)
See page 201.
Unimplemented
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
Read:CH1F
Write:0
Reset:00000000
Read:
Write:
Reset:Indeterminate after reset
Read:
Write:
Reset:Indeterminate after reset
Bit 1514131211109Bit 8
Bit 7654321Bit 0
Bit 1514131211109Bit 8
Bit 7654321Bit 0
Bit 1514131211109Bit 8
Bit 7654321Bit 0
TOIETSTOP
CH0IEMS0BMS0AELS0BELS0ATOV0CH0MAX
CH1IE
0
00
MS1AELS1BELS1ATOV1CH1MAX
PS2PS1PS0
= UnimplementedR= Reserved
Bold= BufferedU = Unaffected
Figure 2-2. Control, Status, and Data Registers (Sheet 3 of 8)
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor29
Memory
Addr.Register NameBit 7654321Bit 0
$0030
↓
$0033
$0034
↓
$0035
ReservedReserved
Unimplemented
Oscillator Status Register
$0036
$0037Unimplemented
Oscillator Trim Register
$0038
Op Amp/Comparator Control
$0039
$003A
↓
$003B
ADC Status and Control
$003C
$003DUnimplemented
(OSCSTAT)
See page 130.
(OSCTRIM)
See page 131.
Register (OACCR)
See page 55.
Unimplemented
Register (ADSCR)
See page 48.
Read:
Write:
Reset:00000000
Read:
Write:
Reset:10000000
Read:
Write:
Reset:0UUUUUU 0
Read:
Write:
Reset:00011111
RRRRRRECGON
TRIM7TRIM6TRIM5TRIM4TRIM3TRIM2TRIM1TRIM0
OACM
COCOAIENADCOADCH4ADCH3ADCH2ADCH1ADCH0
EGGST
OACE
Read:AD7AD6AD5AD4A3AD2AD1AD0
(ADR)
Write:
Reset:Unaffected by reset
Read:
Write:
Reset:00000000
ADIV2ADIV1ADIV0
= UnimplementedR= Reserved
Bold= BufferedU = Unaffected
00000
$003E
$003F
ADC Data Register
See page 50.
ADC Clock Register
(ADCLK)
See page 50.
Figure 2-2. Control, Status, and Data Registers (Sheet 4 of 8)
MC68HC908LB8 Data Sheet, Rev. 1
30Freescale Semiconductor
Register Section
Addr.Register NameBit 7654321Bit 0
$0040
$0041
$0042
$0043
$0044
$0045
$0046
$0047
$0048
$0049
$004A
$004B
PWM Control Register 1
(PCTL1)
See page 155.
PWM Control Register 2
(PCTL2)
See page 157.
Fault Control Register
(FCR)
See page 159.
Fault Status Register
(FSR)
See page 159.
Fault Control Register 2
(FCR2)
See page 160.
PWM Counter Register High
(PCNTH)
See page 153.
PWM Counter Register Low
(PCNTL)
See page 153.
PWM Counter Modulo
Register High (PMODH)
See page 154.
PWM Counter Modulo
Register Low (PMODL)
See page 154.
PWM 0 Value Register High
(PVAL0H)
See page 154.
PWM 0 Value Register Low
(PVAL0L)
See page 155.
PWM 1 Value Register High
(PVAL1H)
See page 154.
Read:0
Write:
Reset:00000000
Read:
Write:
Reset:00001100
Read:000000
Write:
Reset:00000000
Read:000000FPINFFLAG
Write:
Reset:U0U0U0U0
Read:00000000
Write:
Reset:00000000
Read:0000Bit 11Bit 10Bit 9Bit 8
Write:
Reset:00000000
Read:Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
Write:
Reset:00000000
Read:0000
Write:
Reset:0000Indeterminate after reset
Read:
Write:
Reset:Indeterminate after reset
Read:
Write:
Reset:00000000
Read:
Write:
Reset:00000000
Read:
Write:
Reset:00000000
LDFQ1LDFQ0DIS1DIS0POL1POL0PRSC1PRSC0
Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
Bit 15Bit 14Bit 13Bit 12Bit 11Bit 10Bit 9Bit 8
Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
Bit 15Bit 14Bit 13Bit 12Bit 11Bit 10Bit 9Bit 8
FPOSPWMINTPWMF
00
Bit 11Bit 10Bit 9Bit 8
LDOKPWMEN
FINTFMODE
FTACK
= UnimplementedR= Reserved
Bold= BufferedU = Unaffected
Figure 2-2. Control, Status, and Data Registers (Sheet 5 of 8)
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor31
Memory
Addr.Register NameBit 7654321Bit 0
PWM 1 Value Register Low
$004C
PWM Disable Mapping Write
$004D
$004E
↓
$004F
$0050ReservedReserved
Once Register (DISMAP)
(PVAL1L)
See page 155.
See page 158.
Unimplemented
Read:
Write:
Reset:00000000
Read:000000
Write:
Reset:00000011
Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
MAP1MAP0
HRP Control Register
$0051
HRP Duty Cycle Register
$0052
HRP Duty Cycle Register
$0053
HRP Period Register High
$0054
HRP Period Register Low
$0055
HRP Dead Time Register
$0056
HRP Timebase Register High
$0057
(HRPCTRL)
See page 105.
High (HRPDCH)
See page 107.
Low (HRPDCL)
See page 107.
(HRPPERH)
See page 107.
(HRPPERL)
See page 107.
(HRP_DT)
See page 108.
(HRPTBH)
See page 108.
Read:
Write:
Reset0000000
1. When HRPMODE bit = 0, STEP[4:0] are mapped into the HRPPERL register —
when HRPMODE = 1, STEP[4:0] are mapped into the HRPDCL register.
Read:
Write:
Reset00000000
Read:
Write:
Reset00000000
Read:
Write:
Reset00000000
Read:
Write:
Reset00000000
Read:
Write:
Reset00001000
Read:
Write:
Reset00000000
DC10DC9DC8DC7DC6DC5DC4DC3
DC2DC1DC0STEP4STEP3STEP3STEP1STEP0
P10P9P8P7P6P5P4P3
P2P1P0STEP4STEP3STEP2STEP1STEP0
DT7DT6DT5DT4DT3DT2DT1DT0
TB15TB14TB13TB12TB11TB10TB9TB8
SHTLVLHRPOESHTIFSHTIESHTEN
HRP-
MODE
HRPEN
(1)
= UnimplementedR= Reserved
Bold= BufferedU = Unaffected
Figure 2-2. Control, Status, and Data Registers (Sheet 6 of 8)
MC68HC908LB8 Data Sheet, Rev. 1
32Freescale Semiconductor
Register Section
Addr.Register NameBit 7654321Bit 0
HRP Timebase Register Low
$0058
Frequency Dithering Control
$0059
$005A
↓
$005F
(HRPTBL)
See page 108.
Register (HRPDCR)
See page 109.
ReservedReserved
Read:
Write:
Reset00000000
Read:
Write:
Reset0000
TB7TB6TB5TB4TB3TB2TB1TB0
CLKSRCSEL2SEL1SEL0
Break Status Register
$FE00
SIM Reset Status Register
$FE01
Break Auxiliary Register
$FE02
Break Flag Control Register
$FE03
$FE04
↓
$FE07
FLASH Control Register
$FE08
Break Address Register High
$FE09
Break Address Register Low
$FE0A
Read:
(BSR)
Write:(Note)
See page 183.
(SRSR)
See page 184.
(BRKAR)
See page 206.
(BFCR)
See page 185.
ReservedReserved
(FLCR)
See page 37.
(BRKH)
See page 206.
(BRKL)
See page 206.
Reset:00000000
Read:PORPINCOPILOPILADMODRSTLVI0
Write:
POR:10000000
Read:
Write:
Reset:00000000
Read:
Write:
Reset:00000000
Read:0000
Write:
Reset:00000000
Read:
Write:
Reset:00000000
Read:
Write:
Reset:00000000
RRRRRR
Note: Writing a 0 clears SBSW.
Bit 76 5 4321Bit 0
BCFERRRRRRR
Bit 1514131211109Bit 8
Bit 7654321Bit 0
SBSW
HVENMASSERASEPGM
R
= UnimplementedR= Reserved
Bold= BufferedU = Unaffected
Figure 2-2. Control, Status, and Data Registers (Sheet 7 of 8)
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor33
Memory
Addr.Register NameBit 7654321Bit 0
Break Status and Control
$FE0B
$FE0C
$FFC0 Internal Oscillator Trim ValueTRIM7TRIM6TRIM5TRIM4TRIM3TRIM2TRIM1TRIM0
$FFC1ReservedReserved
Register (BRKSCR)
See page 205.
LVI Status Register
(LVISR)
See page 121.
Read:
Write:
Reset:00000000
Read:LVIOUT0000000
Write:
Reset:00000000
BRKEBRKA
000000
Factory programmed FLASH byte
FLASH Block Protect
$FF7E
1. Non-volatile FLASH register
$FFFF
Register (FLBPR)
See page 42.
COP Control Register
(COPCTL)
See page 65.
Figure 2-2. Control, Status, and Data Registers (Sheet 8 of 8)
Read:
(1)
Write:
Reset:Unaffected by reset
Read:Low byte of reset vector
Write:Writing clears COP counter (any value)
Reset:Unaffected by reset
BPR7BPR6BPR5BPR4BPR3BPR2BPR1BPR0
= UnimplementedR= Reserved
Bold= BufferedU = Unaffected
MC68HC908LB8 Data Sheet, Rev. 1
34Freescale Semiconductor
Random-Access Memory (RAM)
Table 2-1. Vector Addresses
Vector PriorityAddressVector
Highest
$FFFFReset vector (low)
$FFFEReset vector (high)
$FFFDSWI vector (low)
$FFFCSWI vector (high)
$FFFBIRQ vector (low)
$FFFAIRQ
$FFF9
↓
$FFF8
$FFF7TIM Channel 0 vector (low)
$FFF6TIM Channel 0 vector (high)
$FFF5TIM Channel 1 vector (low)
$FFF4TIM Channel 1 vector (high)
$FFF3TIM overflow vector (low)
.
vector (high)
Not used
$FFF2TIM overflow vector (high)
$FFF1FAULT (PWM vector) (low)
$FFF0FAULT (PWM vector) (high)
$FFEFPWMINT (PWM vector) (low)
$FFEEPWMINT (PWM vector) (high)
$FFEDSHTDWN (HRP vector) (low)
$FFECSHTDWN (HRP vector) (high)
$FFEB
Lowest
↓
$FFE2
$FFE1Keyboard vector (low)
$FFE0Keyboard vector (high)
$FFDFADC conversion complete vector (low)
$FFDEADC conversion complete vector (high)
Not used
2.5 Random-Access Memory (RAM)
Addresses $0080 through $00FF are RAM locations. The location of the stack RAM is programmable.
The 16-bit stack pointer allows the stack to be anywhere in the 64-Kbyte memory space.
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor35
Memory
NOTE
For correct operation, the stack pointer must point only to RAM locations.
Before processing an interrupt, the CPU uses five bytes of the stack to save the contents of the CPU
registers.
NOTE
For M6805 compatibility, the H register is not stacked.
During a subroutine call, the CPU uses two bytes of the stack to store the return address. The stack
pointer decrements during pushes and increments during pulls.
NOTE
Be careful when using nested subroutines. The CPU may overwrite data in
the RAM during a subroutine or during the interrupt stacking operation.
2.6 FLASH Memory (FLASH)
This section describes the operation of the embedded FLASH memory. This memory can be read,
programmed, and erased from a single external supply. The program, erase, and read operations are
enabled through the use of an internal charge pump. It is recommended that the user utilize the FLASH
programming routines provided in the on-chip ROM, which are described more fully in a separate
Freescale Semiconductor application note.
The FLASH memory is an array of 8 Kbytes with an additional 34 bytes of user vectors and one byte of
block protection. An erased bit reads as 1 and a programmed bit reads as a 0. Memory in the FLASH
array is organized into two rows per page basis. For the 8-K word by 8-bit embedded FLASH memory,
the page size is 64 bytes per page and the row size is 32 bytes per row. Hence the minimum erase page
size is 64 bytes and the minimum program row size is 32 bytes. Program and erase operations are
facilitated through control bits in FLASH control register (FLCR). Details for these operations appear later
in this section.
The address ranges for the user memory and vectors are:
•$DE00–$FDFF; user memory
•$FE08
; FLASH control register
•$FF7E; FLASH block protect register
•$FFDE–$FFFF; these locations are reserved for user-defined interrupt and reset vectors
MC68HC908LB8 Data Sheet, Rev. 1
36Freescale Semiconductor
FLASH Memory (FLASH)
Programming tools are available from Freescale Semiconductor. Contact your local Freescale
Semiconductor representative for more information.
NOTE
A security feature prevents viewing of the FLASH contents.
(1)
2.6.1 FLASH Control Register
The FLASH control register (FLCR) controls FLASH program and erase operations.
Address:$FE08
Bit 7654321Bit 0
Read:0000
Write:
Reset:00000000
= Unimplemented
Figure 2-3. FLASH Control Register (FLCR)
HVEN — High-Voltage Enable Bit
This read/write bit enables the charge pump to drive high voltages for program and erase operations
in the array. HVEN can only be set if either PGM = 1 or ERASE = 1 and the proper sequence for
program or erase is followed.
1 = High voltage enabled to array and charge pump on
0 = High voltage disabled to array and charge pump off
MASS — Mass Erase Control Bit
Setting this read/write bit configures the 8-Kbyte FLASH array for mass erase operation.
This read/write bit configures the memory for erase operation. ERASE is interlocked with the PGM bit
such that both bits cannot be equal to 1 or set to 1 at the same time.
This read/write bit configures the memory for program operation. PGM is interlocked with the ERASE
bit such that both bits cannot be equal to 1 or set to 1 at the same time.
1 = Program operation selected
0 = Program operation unselected
2.6.2 FLASH Page Erase Operation
Use this step-by-step procedure to erase a page (64 bytes) of FLASH memory to read as logic 1. A page
consists of 64 consecutive bytes starting from addresses $XX00, $XX40, $XX80, or $XXC0. The 34-byte
user interrupt vectors area also forms a page. Any FLASH memory page can be erased alone, except for
the 34-byte interrupt vectors page, which must be mass erased.
1. No security feature is absolutely secure. However, Freescale Semiconductor’s strategy is to make reading or copying the
FLASH difficult for unauthorized users.
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor37
Memory
1.Set the ERASE bit, and clear the MASS bit in the FLASH control register.
2.Read the FLASH block protect register.
3.Write any data to any FLASH location within the address range of the block to be erased.
4.Wait for a time, t
(minimum 10 µs)
NVS
5.Set the HVEN bit.
6.Wait for a time, t
(minimum 1 ms or 4 ms)
Erase
7.Clear the ERASE bit.
8.Wait for a time, t
(minimum 5 µs)
NVH
9.Clear the HVEN bit.
10.After a time, t
(typical 1 µs), the memory can be accessed again in read mode.
RCV
NOTE
Programming and erasing of FLASH locations cannot be performed by
code being executed from FLASH memory. While these operations must be
performed in the order shown, other unrelated operations may occur
between the steps.
CAUTION
Be aware that erasing the vector page will erase the internal oscillator trim
value at $FFC0.
It is highly recommended that interrupts be disabled during program/ erase
operations.
In applications that need more than 1000 program/erase cycles, use the 4-ms page erase specification
to get improved long-term reliability. Any application can use this 4-ms page erase specification.
However, in applications where a FLASH location will be erased and reprogrammed less than 1000 times,
and speed is important, use the 1-ms page erase specification to get a shorter cycle time.
2.6.3 FLASH Mass Erase Operation
Use this step-by-step procedure to erase entire FLASH memory to read as logic 1:
1.Set both the ERASE bit and the MASS bit in the FLASH control register.
2.Read from the FLASH block protect register.
3.Write any data to any FLASH address
4.Wait for a time, t
(minimum 10 µs)
NVS
5.Set the HVEN bit.
6.Wait for a time, t
MErase
(minimum 4 ms)
7.Clear the ERASE and MASS bits.
Mass erase is disabled whenever any block is protected (FLBPR does not
equal $FF).
8.Wait for a time, t
1. When in monitor mode, with security sequence failed (see 19.3.2 Security), write to the FLASH block protect register instead
of any FLASH address.
38Freescale Semiconductor
(minimum 100 µs)
NVHL
MC68HC908LB8 Data Sheet, Rev. 1
(1)
within the FLASH memory address range.
NOTE
FLASH Memory (FLASH)
9.Clear the HVEN bit.
10.After time, t
(typical1 µs), the memory can be accessed in read mode again.
RCV
NOTE
Programming and erasing of FLASH locations cannot be performed by
code being executed from the FLASH memory. While these operations
must be performed in the order as shown, but other unrelated operations
may occur between the steps.
CAUTION
A mass erase will erase the internal oscillator trim value at $FFC0.
2.6.4 FLASH Program/Read Operation
Programming of the FLASH memory is done on a row basis. A row consists of 32 consecutive bytes
starting from addresses $XX00, $XX20, $XX40, $XX60, $XX80, $XXA0, $XXC0, and $XXE0.
During the programming cycle, make sure that all addresses being written to fit within one of the ranges
specified above. Attempts to program addresses in different row ranges in one programming cycle will
fail. Use this step-by-step procedure to program a row of FLASH memory (Figure 2-4 is a flowchart
representation).
NOTE
In order to avoid program disturbs, the row must be erased before any byte
on that row is programmed.
1.Set the PGM bit. This configures the memory for program operation and enables the latching of
address and data for programming.
2.Read from the FLASH block protect register.
3.Write any data to any FLASH address within the row address range desired.
4.Wait for a time, t
(minimum 10 µs).
NVS
5.Set the HVEN bit.
6.Wait for a time, t
(minimum 5 µs).
PGS
7.Write data to the FLASH address to be programmed.
8.Wait for a time, t
(minimum 30 µs).
PROG
9.Repeat step 7 and 8 until all the bytes within the row are programmed.
10.Clear the PGM bit.
11.Wait for a time, t
(1)
(minimum 5 µs).
NVH
12.Clear the HVEN bit.
13.After time, t
(minimum 1 µs), the memory can be accessed in read mode again.
RCV
NOTE
The COP register at location $FFFF should not be written between steps
5-12, when the HVEN bit is set. Since this register is located at a valid
FLASH address, unpredictable behavior may occur if this location is written
while HVEN is set.
This program sequence is repeated throughout the memory until all data is programmed.
1. The time between each FLASH address change, or the time between the last FLASH address programmed to clearing PGM
bit, must not exceed the maximum programming time, t
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor39
PROG
maximum.
Memory
NOTE
Programming and erasing of FLASH locations cannot be performed by
code being executed from the FLASH memory. While these operations
must be performed in the order shown, other unrelated operations may
occur between the steps. Do not exceed t
maximum, see 20.12
PROG
Memory Characteristics.
It is highly recommended that interrupts be disabled during program/erase operations.
Do not exceed t
programming time to the same row before next erase. t
maximum or tHV maximum. tHV is defined as the cumulative high voltage
PROG
must satisfy this condition:
HV
t
NVX
= t
NVH
+ t
PGS
+ (t
x 32) <= tHV maximum
PROG
Refer to 20.12 Memory Characteristics.
The time between programming the FLASH address change (step 7 to step 7), or the time between the
last FLASH programmed to clearing the PGM bit (step 7 to step 10) must not exceed the maximum
programming time, t
PROG
maximum.
CAUTION
Be cautious when programming the FLASH array to ensure that
non-FLASH locations are not used as the address that is written to when
selecting either the desired row address range in step 3 of the algorithm or
the byte to be programmed in step 7 of the algorithm. This applies
particularly to $FFD4–$FFDF.
2.6.5 FLASH Block Protection
Due to the ability of the on-board charge pump to erase and program the FLASH memory in the target
application, provision is made for protecting a block of memory from unintentional erase or program
operations due to system malfunction. This protection is done by using of a FLASH block protect register
(FLBPR). The FLBPR determines the range of the FLASH memory which is to be protected. The range
of the protected area starts from a location defined by FLBPR and ends at the bottom of the FLASH
memory ($FFFF). When the memory is protected, the HVEN bit cannot be set in either ERASE or
PROGRAM operations.
NOTE
In performing a program or erase operation, the FLASH block protect
register must be read after setting the PGM or ERASE bit and before
asserting the HVEN bit
When the FLBPR is program with all 0’s, the entire memory is protected from being programmed and
erased. When all the bits are erased (all 1’s), the entire memory is accessible for program and erase.
When bits within the FLBPR are programmed, they lock a block of memory, address ranges as shown in
2.6.6 FLASH Block Protect Register. Once the FLBPR is programmed with a value other than $FF, any
erase or program of the FLBPR or the protected block of FLASH memory is prohibited. The presence of
a V
on the IRQ pin will bypass the block protection so that all of the memory included in the block
TST
protect register is open for program and erase operations.
NOTE
The FLASH block protect register is not protected with special hardware or
software. Therefore, if this page is not protected by FLBPR the register is
erased by either a page or mass erase operation.
MC68HC908LB8 Data Sheet, Rev. 1
40Freescale Semiconductor
FLASH Memory (FLASH)
Algorithm for Programming
a Row (32 Bytes) of FLASH Memory
1
2
READ THE FLASH BLOCK PROTECT REGISTER
3
WRITE ANY DATA TO ANY FLASH ADDRESS
WITHIN THE ROW ADDRESS RANGE DESIRED
4
5
6
7
WRITE DATA TO THE FLASH ADDRESS
8
SET PGM BIT
WAIT FOR A TIME, t
SET HVEN BIT
WAIT FOR A TIME, t
TO BE PROGRAMMED
WAIT FOR A TIME, t
NVS
PGS
PROG
9
NOTES:
The time between each FLASH address change (step 7 to step 7),
or the time between the last FLASH address programmed
to clearing PGM bit (step 7 to step 10)
must not exceed the maximum programming
time, t
PROG
max.
This row program algorithm assumes the row/s
to be programmed are initially erased.
Figure 2-4. FLASH Programming Flowchart
COMPLETED
PROGRAMMING
THIS ROW?
N
Y
10
11
12
13
CLEAR PGM BIT
WAIT FOR A TIME, t
CLEAR HVEN BIT
WAIT FOR A TIME, t
END OF PROGRAMMING
NVH
RCV
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor41
Memory
2.6.6 FLASH Block Protect Register
The FLASH block protect register (FLBPR) is implemented as a byte within the FLASH memory, and
therefore can only be written during a programming sequence of the FLASH memory. The value in this
register determines the starting location of the protected range within the FLASH memory.
Address:$FF7E
Bit 7654321Bit 0
Read:
Write:
Reset:UUUUUUUU
BPR[7:0] — FLASH Block Protect Bits
These eight bits represent bits [13:6] of a 16-bit memory address. Bit 15 and 14 are 1s and bits [5:0]
are 0s.
The resultant 16-bit address is used for specifying the start address of the FLASH memory for block
protection. The FLASH is protected from this start address to the end of FLASH memory, at $FFFF.
With this mechanism, the protect start address can be $XX00, $XX40, $XX80, and $XXC0 (64 bytes
page boundaries) within the FLASH memory.
BPR7BPR6BPR5BPR4BPR3BPR2BPR1BPR0
U = Unaffected by reset. Initial value from factory is 1.
Write to this register is by a programming sequence to the FLASH memory.
Putting the MCU into wait mode while the FLASH is in read mode does not affect the operation of the
FLASH memory directly, but there will not be any memory activity since the CPU is inactive.
The WAIT instruction should not be executed while performing a program or erase operation on the
FLASH, otherwise the operation will discontinue, and the FLASH will be on standby mode.
2.6.8 Stop Mode
Putting the MCU into stop mode while the FLASH is in read mode does not affect the operation of the
FLASH memory directly, but there will not be any memory activity since the CPU is inactive.
The STOP instruction should not be executed while performing a program or erase operation on the
FLASH, otherwise the operation will discontinue, and the FLASH will be on standby mode
NOTE
Standby mode is the power saving mode of the FLASH module in which all
internal control signals to the FLASH are inactive and the current
consumption of the FLASH is at a minimum.
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor43
Memory
MC68HC908LB8 Data Sheet, Rev. 1
44Freescale Semiconductor
Chapter 3
Analog-to-Digital Converter (ADC)
3.1 Introduction
This section describes the 8-bit analog-to-digital converter (ADC).
2. Fault function switchable between pins PTB2 and PTB7.
POWER
OP AMP/COMPARATOR
MODULE
Figure 3-1. Block Diagram Highlighting ADC Block and Pins
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor45
Analog-to-Digital Converter (ADC)
3.2 Features
Features of the ADC module include:
•7 channels with multiplexed input
•Linear successive approximation
•8-bit resolution
•Single or continuous conversion
•Conversion complete flag or conversion complete interrupt
•Selectable ADC clock
3.3 Functional Description
Seven ADC channels are available for sampling external sources at pins PTB7/ADC6, PTA6/ADC5,
PTA4/ADC4–PTA0/ADC0. An analog multiplexer allows a single ADC converter to select one of seven
ADC channels as ADC voltage in (ADCVIN). ADCVIN is converted by the successive approximation
register based counters. When the conversion is complete, ADC places the result in the ADC data register
and sets a flag or generates an interrupt.
See Figure 3-2.
INTERNAL DATA BUS
READ DDRAx/DDRBx
WRITE DDRAx/DDRBx
WRITE PTAx/PTBx
READ PTAx/PTBx
INTERRUPT
LOGIC
AIENCOCO
RESET
CONVERSION
COMPLETE
BUS CLOCK
DDRAx/DDRAx
PTAx/PTBx
ADC DATA REGISTER
ADC
ADC CLOCK
CLOCK
GENERATOR
ADIV[2:0]
Figure 3-2. ADC Block Diagram
DISABLE
ADC
VOLTAGE IN
)
(V
ADIN
DISABLE
CHANNEL
SELECT
PTAx/PTBx
ADC CHANNEL x
ADCH[4:0]
3.3.1 ADC Port I/O Pins
PTB7/ADC6, PTA6/ADC5, PTA4/ADC4–PTA0/ADC0 are general-purpose I/O (input/output) pins that
share with the ADC channels. The channel select bits define which ADC channel/port pin will be used as
MC68HC908LB8 Data Sheet, Rev. 1
46Freescale Semiconductor
Monotonicity
the input signal. The ADC overrides the port I/O logic by forcing that pin as input to the ADC. The
remaining ADC channels/port pins are controlled by the port I/O logic and can be used as
general-purpose I/O. Writes to the port register or data direction register (DDR) will not have any effect
on the port pin that is selected by the ADC. Read of a port pin in use by the ADC will return a logic 0. If
the DDR bit is at 1, the value in the port data latch is read.
3.3.2 Voltage Conversion
When the input voltage to the ADC equals V
input voltage equals V
, the ADC converts it to $00. Input voltages between V
REFL
, the ADC converts the signal to $FF (full scale). If the
REFH
and V
REFH
REFL
are a
straight-line linear conversion.
V
REFH
and V
are internally connected to VDD and VSS respectively.
REFL
3.3.3 Conversion Time
Conversion starts after a write to the ADC status and control register (ADSCR). One conversion will take
between 16 and 17 ADC clock cycles. The ADIVx bit should be set to provide a 1-MHz ADC clock
frequency.
Conversion time =
16 to 17 ADC cycles
ADC frequency
Number of bus cycles = conversion time × bus frequency
3.3.4 Conversion
In continuous conversion mode, the ADC data register will be filled with new data after each conversion.
Data from the previous conversion will be overwritten whether that data has been read or not.
Conversions will continue until the ADCO bit is cleared. The COCO bit is set after the first conversion and
will stay set until the next write of the ADC status and control register or the next read of the ADC data
register.
In single conversion mode, conversion begins with a write to the ADSCR. Only one conversion occurs
between writes to the ADSCR.
3.3.5 Accuracy and Precision
The conversion process is monotonic and has no missing codes.
3.4 Monotonicity
The conversion process is monotonic and has no missing codes.
3.5 Interrupts
When the AIEN bit is set, the ADC module is capable of generating CPU interrupts after each ADC
conversion. A CPU interrupt is generated if the COCO bit is at 0. The COCO bit is not used as a
conversion complete flag when interrupts are enabled.
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor47
Analog-to-Digital Converter (ADC)
3.6 Low-Power Modes
The WAIT and STOP instruction can put the MCU in low power consumption standby modes.
3.6.1 Wait Mode
The ADC continues normal operation during wait mode. Any enabled CPU interrupt request from the ADC
can bring the MCU out of wait mode. If the ADC is not required to bring the MCU out of wait mode, power
down the ADC by setting ADCH4–ADCH0 bits in the ADC status and control register before executing the
WAIT instruction.
3.6.2 Stop Mode
The ADC module is inactive after the execution of a STOP instruction. Any pending conversion is aborted.
ADC functionality resume when the MCU exits stop mode after an external interrupt. Allow one conversion
cycle to stabilize the analog circuitry.
3.7 I/O Signals
The ADC module has seven pins shared with ports A and B: PTB7/ADC6, PTA6/ADC5,
PTA4/ADC4–PTA0/ADC0.
V
is the input voltage signal from one of the seven ADC channels to the ADC module.
ADIN
3.8 I/O Registers
These I/O registers control and monitor ADC operation:
•ADC status and control register (ADSCR)
•ADC data register (ADR)
•ADC clock register (ADCLK)
3.8.1 ADC Status and Control Register
Function of the ADC status and control register (ADSCR) is described here.
Address:$003C
Bit 7654321Bit 0
Read:
Write:
Reset:00011111
COCO — Conversions Complete Bit
When the AIEN bit is a 0, the COCO is a read-only bit which is set each time a conversion is completed
except in the continuous conversion mode where it is set after the first conversion. This bit is cleared
whenever the ADSCR is written or whenever the ADR is read.
If the AIEN bit is a 1, the COCO becomes a read/write bit, which should be cleared to 0 for CPU to
service the ADC interrupt request. Reset clears this bit.
COCOAIENADCOADCH4ADCH3ADCH2ADCH1ADCH0
Figure 3-3. ADC Status and Control Register (ADSCR)
When this bit is set, an interrupt is generated at the end of an ADC conversion. The interrupt signal is
cleared when the data register is read or the status/control register is written. Reset clears the AIEN bit.
When set, the ADC will convert samples continuously and update the ADR register at the end of each
conversion. Only one conversion is completed between writes to the ADSCR when this bit is cleared.
Reset clears the ADCO bit.
1 = Continuous ADC conversion
0 = One ADC conversion
ADCH4–ADCH0 — ADC Channel Select Bits
ADCH4–ADCH0 form a 5-bit field which is used to select one of 7 ADC channels. Only seven channels,
AD6–AD0, are available on this MCU. The channels are detailed in Table 3-1. Care should be taken
when using a port pin as both an analog and digital input simultaneously to prevent switching noise
from corrupting the analog signal. See Table 3-1.
The ADC subsystem is turned off when the channel select bits are all set to 1. This feature allows for
reduced power consumption for the MCU when the ADC is not being used.
NOTE
Recovery from the disabled state requires one conversion cycle to stabilize.
The voltage levels supplied from internal reference nodes, as specified in
Table 3-1, are used to verify the operation of the ADC converter both in production test and for user
applications.
Table 3-1. Mux Channel Select
ADCH4ADCH3ADCH2ADCH1ADCH0Input Select
00000 PTA0/AD0
00001 PTA1/AD1
00010 PTA2/AD2
00011 PTA3/AD3
00100 PTA4/AD4
00101 PTA6/AD5
00110 PTB7/AD6
01000
11100
11101
11110
11111ADC power off
(1)
Unused↓↓↓↓↓
V
V
REFH
REFL
(2)
(2)
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor49
Analog-to-Digital Converter (ADC)
NOTES:
1. If any unused channels are selected, the resulting ADC conversion will be unknown or reserved.
2. V
REFH
and V
are internally connected to VDD and VSS respectively.
REFL
3.8.2 ADC Data Register
One 8-bit result register is provided. This register is updated each time an ADC conversion completes.
Address:$003E
Read:AD7AD6AD5AD4AD3AD2AD1AD0
Write:
Reset:Unaffected by reset
= Unimplemented
Figure 3-4. ADC Data Register (ADR)
3.8.3 ADC Clock Register
The ADC clock register (ADCLK) selects the clock frequency for the ADC.
Address:$003F
Bit 7654321Bit 0
Read:
ADIV2ADIV1ADIV0
Write:
Reset:00000000
= Unimplemented
00000
Figure 3-5. ADC Clock Register (ADCLK)
ADIV2–ADIV0 — ADC Clock Prescaler Bits
ADIV2–ADIV0 form a 3-bit field which selects the divide ratio used by the ADC to generate the internal
ADC clock. Table 3-2 shows the available clock configurations. The ADC clock should be set to
approximately 1 MHz.
Table 3-2. ADC Clock Divide Ratio
ADIV2ADIV1ADIV0ADC Clock Rate
000ADC input clock ÷ 1
001ADC input clock ÷ 2
010ADC input clock ÷ 4
011ADC input clock ÷ 8
1
NOTES:
1. X = Don’t care
(1)
X
(1)
X
ADC input clock ÷ 16
MC68HC908LB8 Data Sheet, Rev. 1
50Freescale Semiconductor
I/O Registers
The ADC requires a clock rate of approximately 1 MHz for correct operation. If the selected clock source
is not fast enough, the ADC will generate incorrect conversions. See 20.8 5.0-Volt ADC Characteristics.
f
ADIC
Bus frequency
=
ADIV[2:0]
≅ 1 MHz
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor51
Analog-to-Digital Converter (ADC)
MC68HC908LB8 Data Sheet, Rev. 1
52Freescale Semiconductor
Chapter 4
Op Amp/Comparator Module
4.1 Introduction
This section describes the functionality of the op amp/comparator.
4.2 Features
Features of the op amp/comparator include:
•Software enable/disable
•Op amp and comparator modes for optimized performance
•Shared output pin with ADC input pin and PWM fault pin to allow a op amp/comparator circuit to
be inputs to these modules
4.3 Pin Name Conventions
The op amp/comparator shares two input pins and an output pin with the port B input/output (I/O). The full
names of the op amp/comparator pins are listed in
Table 4-1. Note that the generic pin names appear in the text that follows.
Table 4-1. Pin Name Conventions
Generic Pin NameFull Pin Name
V
OUT
V–PTB6/V–
V+PTB5/V+
PTB7/V
ADC6/FAULT
OUT/
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor53
Op Amp/Comparator Module
M68HC08 CPU
INTERNAL BUS
CPU
REGISTERS
CONTROL AND STATUS
REGISTERS — 64 BYTES
USER FLASH — 8 KBYTES
USER RAM — 128 BYTES
MONITOR ROM — 350 BYTES
FLASH PROGRAMMING
ROUTINES ROM — 674 BYTES
USER FLASH VECTOR SPACE — 34 BYTES
ARITHMETIC/LOGIC
UNIT (ALU)
OSCILLATOR
MODULE
SYSTEM INTEGRATION
MODULE
DUAL CHANNEL PWM
MODULE
HIGH RESOLUTION PWM
MODULE
LOW-VOLTAGE INHIBIT
MODULE
COMPUTER OPERATING
PROPERLY MODULE
2-CHANNEL TIMER
MODULE
8-BIT ANALOG-TO-DIGITAL
CONVERTER MODULE
KEYBOARD INTERRUPT
MODULE
DDRA
DDRB
DDRC
PORTA
PORTB
PORTC
(1)
/AD5/TCH0/KBI6
PTA6
(1)
/RST/KBI5
PTA5
(1)
/AD4/KBI4
PTA4
(1)
/AD3/KBI3
PTA3
(1)
/AD2/KBI2
PTA2
(1)
/AD1/KBI1
PTA1
(1)
/AD0/KBI0
PTA0
PTB7/V
OUT
PTB6/V–
PTB5/V+
PTB4/PWM1
PTB3/PWM0
PTB2/FAULT
PTB1/BOT
PTB0/TOP
(1)
PTC2
/SHTDWN/IRQ
(1)
PTC1
/OSC2
(1)
/OSC1
PTC0
/AD6/FAULT
(2)
(2)
V
DD
V
SS
Notes:
1. Pin contains integrated pullup device.
2. Fault function switchable between pins PTB2 and PTB7.
POWER
OP AMP/COMPARATOR
MODULE
Figure 4-1. Block Diagram Highlighting Op Amp/Comparator Block and Pins
4.4 Functional Description
The op amp/comparator module has two modes of operation — op amp mode and comparator mode. Op
amp mode optimizes the module for accurate signal amplification with low input offset voltage.
Comparator mode optimizes the module for use as a comparator with fast output response.
The output of the op amp/comparator shares its pin with an analog-to-digital converter (ADC6) channel.
The fault function of the PWM can also be switched to share this pin. The ADC channel function and the
op amp output can be enabled simultaneously so that the output of the op amp could be sampled directly
by the associated ADC channels. See Figure 4-2.
NOTE
Setting an op amp/comparator enable control bit (OACE) and an op
amp/comparator module selected control bit (OACM) forces V+ and V– to
be inputs and V
to be an output, overriding the data direction register.
OUT
MC68HC908LB8 Data Sheet, Rev. 1
54Freescale Semiconductor
Low Power Modes
In order to read the digital states of the pins configured as inputs, the data
direction register bit must be a 0; to read the states of the pins configured
as outputs the data direction register bit must be a 1.
OACE
V+
GROUND
V–
GROUND
OACE
OACE
+
-
OACE
V
OUT
FLOATING
Figure 4-2. Op Amp/Comparator Block Diagram
4.5 Low Power Modes
4.5.1 Wait Mode
The WAIT instruction places the MCU in a low power consumption mode. While in WAIT the op
amp/comparator cannot be enabled or disabled. If the op amp/comparator module is not needed during
wait mode, reduce power consumption by disabling the op amp/comparator before executing the WAIT
command.
4.5.2 Stop Mode
The op amp/comparator is inactive after execution of the STOP command. The
op amp/comparator will be in a low-power state and will not drive its output pin. When the MCU exits stop
mode after and external interrupt, the op amp/comparator continues operation.
4.6 Op Amp/Comparator Control Register
There is a single operational control register (OACCR) that contains the enable bit for the op
amp/comparator.
Address:
OACM — Op Amp/Comparator Mode Select Bit
This bit selects between 2 modes of operation, op amp mode and comparator mode.
1 = Op amp mode selected
Freescale Semiconductor55
$0039
Bit 7654321Bit 0
Read:
Write:
Reset:0UUUUUU 0
OACM
= Unimplemented
U = Unaffected
OACE
Figure 4-3. Op Amp/Comparator Control Register (OACCR)
MC68HC908LB8 Data Sheet, Rev. 1
Op Amp/Comparator Module
0 = Comparator mode selected
OACE — Op Amp/Comparator Enable Bit
Setting of the corresponding bit in the register enables the associated op amp/comparator and
connects it to the op amp/comparator pins.
1 = Op amp/comparator is connected to pins and powered on
0 = Op amp/comparator is disconnected from pins and powered off
NOTE
Enabling the op amp/comparator prevents PTB[5:7] from being used as
standard I/O. However, the PTB7 pin can be shared with AD6 and FAULT
if the ADC and PWM modules are also enabled.
4.7 Application Information
We make the following assumptions during the design of the operational amplifier.
1.The signal amplified by the operational amplifier is sampled by the internal ADC.
2.Noise resulting from the operation of other circuitry within the MCU will appear at the output of the
circuit due to the amplification set by user.
We recommend the following.
1.An external 500pF capacitor should be added between the output of the operational amplifier
(PTB7) and VSS. This capacitor will act as a filter to internal bus noise caused by the operation of
other digital circuitry in the MCU.
2.Care should be taken to ensure proper filtering at or around the operation bus speed in the
amplification circuit, to prevent noise from being amplified along with the desired signal.
3.The maximum frequency of the signal to be amplified should be limited to 200kHz. This will ensure
that the filtering element will not affect the gain of the desired signal.
4.Do not set the gain of the amplifier to less than 5 (except in the unity gain buffer).
5.Use the circuit component values suggested for the common amplfier configurations shown in the
following figures (Figure 4-4, Figure 4-5, and Figure 4-6).
VDD
Unity Gain Buffer
Vin
+
–
CL
500pF
RL
>20kΩ
Vout
Figure 4-4. Suggested Application Circuit for Unity Gain Buffer
MC68HC908LB8 Data Sheet, Rev. 1
56Freescale Semiconductor
C1
1µF
R2
100k
Application Information
VDD
R1
100k
Inverting Amplifier
+
Vout
–
CLRL
500pF>20k
Vin
R3
10k
R4
>50k
Figure 4-5. Suggested Application Circuit for Inverting Amplifier
VDD
C2
1µF
R6
100k
R3
10k
R5
100k
Non-inverting Amplifier
+
–
CLRL
500pF>20k
R4
>40k
VDD
C1
1µF
Vin
R1
100k
R2
100k
Vout
Figure 4-6. Suggested Application Circuit for Non-inverting Amplifier
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor57
Op Amp/Comparator Module
MC68HC908LB8 Data Sheet, Rev. 1
58Freescale Semiconductor
Chapter 5
Configuration Register (CONFIG)
5.1 Introduction
This section describes the configuration registers, CONFIG1 and CONFIG2. The configuration registers
enable or disable these options:
•COP timeout period (2
•STOP instruction
•Stop mode recovery (32 x BUSCLKX4 cycles or
4096 x BUSCLKX4 cycles)
•Computer operating properly module (COP)
•Low-voltage inhibit (LVI) module control
•IRQ
•RST
•OSC option selection
pin
pin
5.2 Functional Description
The configuration registers are used in the initialization of various options. 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 microcontroller unit (MCU), it is recommended that these
registers be written immediately after reset. The configuration registers are located at $001E and $001F
and may be read at anytime.
18
– 24 or 213 – 24 BUSCLKX4 cycles)
NOTE
On a FLASH device, the options are one-time writable by the user after
each reset. 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 5-1 and Figure 5-2.
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor59
Configuration Register (CONFIG)
Address:$001E
Bit 7654321Bit 0
Read:
IRQPUDIRQENROSCOPT1 OSCOPT0
Write:
Reset:0000000U
POR:00000000
= UnimplementedR= ReservedU = Unaffected
Figure 5-1. Configuration Register 2 (CONFIG2)
IRQPUD — IRQ Pin Pullup Control Bit
1 = Internal pullup is disconnected
0 = Internal pullup is connected between pin IRQ
and V
DD
IRQEN — IRQ Pin Function Selection Bit
1 = Interrupt request function active in pin
0 = Interrupt request function inactive in pin
OSCOPT1 and OSCPOT0 — Selection Bits for Oscillator Option
OSCOPT[1:0]Oscillator Selection
00Internal oscillator
01External oscillator
10External RC oscillator
11External XTAL oscillator
00
RSTEN
RSTEN — RST
Pin Function Selection
1 = Reset function active in pin
0 = Reset function inactive in pin
The RSTEN bit is cleared by a power-on reset (POR) only. Other resets will
leave this bit unaffected.
NOTE
MC68HC908LB8 Data Sheet, Rev. 1
60Freescale Semiconductor
Address:$001F
Bit 7654321Bit 0
Functional Description
Read:
COPRSLVISTOPLVIRSTDLVIPWRD
Write:
Reset:00000000
= Unimplemented
0
SSRECSTOPCOPD
Figure 5-2. Configuration Register 1 (CONFIG1)
COPRS — COP Rate Select Bit
COPD selects the COP timeout period. Reset clears COPRS. See Chapter 6 Computer Operating
Properly (COP) Module
1 = COP timeout period = 2
0 = COP timeout period = 2
13
– 24 BUSCLKX4 cycles
18
– 24 BUSCLKX4 cycles
LVISTOP — LVI Enable in Stop Mode Bit
When the LVIPWRD bit is clear, setting the LVISTOP bit enables the LVI to operate during stop mode.
Reset clears LVISTOP.
1 = LVI enabled during stop mode
0 = LVI disabled during stop mode
LVIRSTD — LVI Reset Disable Bit
LVIRSTD disables the reset signal from the LVI module. See Chapter 12 Low-Voltage Inhibit (LVI).
LVIPWRD disables the LVI module. See Chapter 12 Low-Voltage Inhibit (LVI).
1 = LVI module power disabled
0 = LVI module power enabled
SSREC — Short Stop Recovery Bit
SSREC enables the CPU to exit stop mode with a delay of 32 BUSCLKX4 cycles instead of a
4096-BUSCLKX4 cycle delay.
1 = Stop mode recovery after 32 BUSCLKX4 cycles
0 = Stop mode recovery after 4096 BUSCLKX4 cycles
NOTE
Exiting stop mode by an LVI reset will result in the long stop recovery.
If running with external crystal, it is advisable to set the short stop recovery bit to 0. The short stop
recovery does not provide enough time for oscillator stabilization and for this reason the SSREC bit
should not be set.
When using the LVI during normal operation but disabling during stop mode, the LVI will have an
enable time of t
. The system stabilization time for power-on reset and long stop recovery (both 4096
EN
BUSCLKX4 cycles) gives a delay longer than the LVI enable time for these startup scenarios. There
is no period where the MCU is not protected from a low-power condition. However, when using the
short stop recovery configuration option, the 32-BUSCLKX4 delay must be greater than the LVI’s turn
on time to avoid a period in startup where the LVI is not protecting the MCU.
The computer operating properly (COP) module contains a free-running counter that generates a reset if
allowed to overflow. The COP module helps software recover from runaway code. Prevent a COP reset
by clearing the COP counter periodically. The COP module can be disabled through the COPD bit in the
configuration 1 (CONFIG1) register.
6.2 Functional Description
SIM MODULE
BUSCLKX4
INTERNAL RESET SOURCES
RESET VECTOR FETCH
COPCTL WRITE
COPEN (FROM SIM)
COPD (FROM CONFIG1)
RESET
COPCTL WRITE
COP RATE SELECT
(COPRS FROM CONFIG1)
12-BIT SIM COUNTER
(1)
CLEAR ALL STAGES
COP CLOCK
CLEAR STAGES 5–12
COP TIMEOUT
COP MODULE
6-BIT COP COUNTER
CLEAR
COP COUNTER
SIM RESET CIRCUIT
RESET STATUS REGISTER
1. See Chapter 17 System Integration Module (SIM) for more details.
Figure 6-1. COP Block Diagram
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor63
Computer Operating Properly (COP) Module
The COP counter is a free-running 6-bit counter preceded by the 12-bit system integration module (SIM)
counter. If not cleared by software, the COP counter overflows and generates an asynchronous reset after
18–24
2
configuration register 1. With a 2
or 213–24 BUSCLKX4 cycles; depending on the state of the COP rate select bit, COPRS, in
18–24
BUSCLKX4 cycle overflow option, using the internal clock to
produce bus speed of 4 MHz gives a COP timeout period of 16.383 ms. Writing any value to location
$FFFF before an overflow occurs prevents a COP reset by clearing the COP counter and stages 12–5 of
the SIM counter.
NOTE
Service the COP immediately after reset and before entering or after exiting
stop mode to guarantee the maximum time before the first COP counter
overflow.
A COP reset pulls the RST
pin low for 32 × BUSCLKX4 cycles and sets the COP bit in the reset status
register (RSR). See 17.7.2 SIM Reset Status Register.
NOTE
Place COP clearing instructions in the main program and not in an interrupt
subroutine. Such an interrupt subroutine could keep the COP from
generating a reset even while the main program is not working properly.
6.3 I/O Signals
The following paragraphs describe the signals shown in Figure 6-1.
6.3.1 BUSCLKX4
BUSCLKX4 is the oscillator output signal. BUSCLKX4 frequency is equal to the crystal frequency, the
internal oscillator frequency, or the RC oscillator frequency.
6.3.2 COPCTL Write
Writing any value to the COP control register (COPCTL) (see 6.4 COP Control Register) clears the COP
counter and clears bits 12–5 of the SIM counter. Reading the COP control register returns the low byte of
the reset vector.
6.3.3 Power-On Reset
The power-on reset (POR) circuit in the SIM clears the SIM counter 4096 × BUSCLKX4 cycles after power
up.
6.3.4 Internal Reset
An internal reset clears the SIM counter and the COP counter.
6.3.5 Reset Vector Fetch
A reset vector fetch occurs when the vector address appears on the data bus. A reset vector fetch clears
the SIM counter.
MC68HC908LB8 Data Sheet, Rev. 1
64Freescale Semiconductor
COP Control Register
6.3.6 COPD (COP Disable)
The COPD signal reflects the state of the COP disable bit (COPD) in the configuration register 1
(CONFIG1). See Chapter 5 Configuration Register (CONFIG).
6.3.7 COPRS (COP Rate Select)
The COPRS signal reflects the state of the COP rate select bit (COPRS) in the configuration register 1
(CONFIG1). See Chapter 5 Configuration Register (CONFIG).
6.4 COP Control Register
The COP control register (COPCTL) is located at address $FFFF and overlaps the reset vector. Writing
any value to $FFFF clears the COP counter and starts a new timeout period. Reading location $FFFF
returns the low byte of the reset vector.
Address: $FFFF
Bit 7654321Bit 0
Read:LOW BYTE OF RESET VECTOR
Write:CLEAR COP COUNTER
Reset:Unaffected by reset
Figure 6-2. COP Control Register (COPCTL)
6.5 Interrupts
The COP does not generate CPU interrupt requests.
6.6 Monitor Mode
The COP is disabled in monitor mode when V
is present on the IRQ pin.
TST
6.7 Low-Power Modes
The WAIT and STOP instructions put the microcontroller unit (MCU) in low power-consumption standby
modes.
6.7.1 Wait Mode
The COP remains active during wait mode. If COP is enabled, a reset will occur at COP timeout.
6.7.2 Stop Mode
Stop mode turns off the BUSCLKX4 input to the COP and clears the SIM counter. Service the COP
immediately before entering or after exiting stop mode to ensure a full COP timeout period after entering
or exiting stop mode.
To prevent inadvertently turning off the COP with a STOP instruction, a configuration option is available
that disables the STOP instruction. When the STOP bit in the configuration register has the STOP
instruction disabled, execution of a STOP instruction results in an illegal opcode reset.
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor65
Computer Operating Properly (COP) Module
MC68HC908LB8 Data Sheet, Rev. 1
66Freescale Semiconductor
Chapter 7
Central Processor Unit (CPU)
7.1 Introduction
The M68HC08 CPU (central processor unit) is an enhanced and fully object-code-compatible version of
the M68HC05 CPU. The CPU08 Reference Manual (Freescale Semiconductor document order number
CPU08RM/AD) contains a description of the CPU instruction set, addressing modes, and architecture.
7.2 Features
Features of the CPU include:
•Object code fully upward-compatible with M68HC05 Family
•16-bit stack pointer with stack manipulation instructions
•16-bit index register with x-register manipulation instructions
•8-MHz CPU internal bus frequency
•64-Kbyte program/data memory space
•16 addressing modes
•Memory-to-memory data moves without using accumulator
•Fast 8-bit by 8-bit multiply and 16-bit by 8-bit divide instructions
•Enhanced binary-coded decimal (BCD) data handling
•Modular architecture with expandable internal bus definition for extension of addressing range
beyond 64 Kbytes
•Low-power stop and wait modes
7.3 CPU Registers
Figure 7-1 shows the five CPU registers. CPU registers are not part of the memory map.
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor67
Central Processor Unit (CPU)
7
15
HX
15
15
70
V11HINZC
0
ACCUMULATOR (A)
0
INDEX REGISTER (H:X)
0
STACK POINTER (SP)
0
PROGRAM COUNTER (PC)
CONDITION CODE REGISTER (CCR)
CARRY/BORROW FLAG
ZERO FLAG
NEGATIVE FLAG
INTERRUPT MASK
HALF-CARRY FLAG
TWO’S COMPLEMENT OVERFLOW FLAG
Figure 7-1. CPU Registers
7.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 7-2. Accumulator (A)
7.3.2 Index Register
The 16-bit index register allows indexed addressing of a 64-Kbyte memory space. H is the upper byte of
the index register, and X is the lower byte. H:X is the concatenated 16-bit index register.
In the indexed addressing modes, the CPU uses the contents of the index register to determine the
conditional address of the operand.
The index register can serve also as a temporary data storage location.
Bit
151413121110987654321
Read:
Write:
Reset:00000000XXXXXXXX
X = Indeterminate
Bit
0
Figure 7-3. Index Register (H:X)
MC68HC908LB8 Data Sheet, Rev. 1
68Freescale Semiconductor
CPU Registers
7.3.3 Stack Pointer
The stack pointer is a 16-bit register that contains the address of the next location on the stack. During a
reset, the stack pointer is preset to $00FF. The reset stack pointer (RSP) instruction sets the least
significant byte to $FF and does not affect the most significant byte. The stack pointer decrements as data
is pushed onto the stack and increments as data is pulled from the stack.
In the stack pointer 8-bit offset and 16-bit offset addressing modes, the stack pointer can function as an
index register to access data on the stack. The CPU uses the contents of the stack pointer to determine
the conditional address of the operand.
Bit
151413121110987654321
Read:
Write:
Reset:0000000011111111
Bit
0
Figure 7-4. Stack Pointer (SP)
NOTE
The location of the stack is arbitrary and may be relocated anywhere in
random-access memory (RAM). Moving the SP out of page 0 ($0000 to
$00FF) frees direct address (page 0) space. For correct operation, the
stack pointer must point only to RAM locations.
7.3.4 Program Counter
The program counter is a 16-bit register that contains the address of the next instruction or operand to be
fetched.
Normally, the program counter automatically increments to the next sequential memory location every
time an instruction or operand is fetched. Jump, branch, and interrupt operations load the program
counter with an address other than that of the next sequential location.
During reset, the program counter is loaded with the reset vector address located at $FFFE and $FFFF.
The vector address is the address of the first instruction to be executed after exiting the reset state.
Bit
151413121110987654321
Read:
Write:
Reset:Loaded with vector from $FFFE and $FFFF
Bit
0
Figure 7-5. Program Counter (PC)
7.3.5 Condition Code Register
The 8-bit condition code register contains the interrupt mask and five flags that indicate the results of the
instruction just executed. Bits 6 and 5 are set permanently to 1. The following paragraphs describe the
functions of the condition code register.
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor69
Central Processor Unit (CPU)
Bit 7654321Bit 0
Read:
Write:
Reset:X11X1XXX
V11HINZC
X = Indeterminate
Figure 7-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.
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
MC68HC908LB8 Data Sheet, Rev. 1
70Freescale Semiconductor
Arithmetic/Logic Unit (ALU)
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
7.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 Semiconductor document order number
CPU08RM/AD) for a description of the instructions and addressing modes and more detail about the
architecture of the CPU.
7.5 Low-Power Modes
The WAIT and STOP instructions put the MCU in low power-consumption standby modes.
7.5.1 Wait Mode
The 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
7.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.
7.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.
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor71
Central Processor Unit (CPU)
7.7 Instruction Set Summary
Table 7-1 provides a summary of the M68HC08 instruction set.
AAccumulatornAny bit
CCarry/borrow bitopr Operand (one or two bytes)
CCRCondition code registerPCProgram counter
ddDirect address of operandPCH Program counter high byte
dd rrDirect address of operand and relative offset of branch instructionPCL Program counter low byte
DDDirect to direct addressing modeREL Relative addressing mode
DIRDirect addressing moderelRelative program counter offset byte
DIX+Direct to indexed with post increment addressing moderrRelative program counter offset byte
ee ffHigh and low bytes of offset in indexed, 16-bit offset addressingSP1 Stack pointer, 8-bit offset addressing mode
EXTExtended addressing modeSP2 Stack pointer 16-bit offset addressing mode
ffOffset byte in indexed, 8-bit offset addressingSPStack pointer
HHalf-carry bitUUndefined
HIndex register high byteVOverflow bit
hh llHigh and low bytes of operand address in extended addressingXIndex register low byte
IInterrupt maskZZero bit
iiImmediate operand byte&Logical AND
IMDImmediate source to direct destination addressing mode|Logical OR
IMMImmediate addressing mode
INHInherent addressing mode( )Contents of
IXIndexed, no offset addressing mode–( ) Negation (two’s complement)
IX+Indexed, no offset, post increment addressing mode#Immediate value
IX+DIndexed with post increment to direct addressing mode
IX1Indexed, 8-bit offset addressing mode←Loaded with
IX1+Indexed, 8-bit offset, post increment addressing mode?If
IX2Indexed, 16-bit offset addressing mode:Concatenated with
MMemory locationSet or cleared
NNegative bit—Not affected
The IRQ (external interrupt) module provides a maskable interrupt input.
8.2 Features
Features of the IRQ module include:
•A multiplexed external interrupt pin (IRQ
•IRQ interrupt control bits
•Hysteresis buffer
•Programmable edge-only or edge and level interrupt sensitivity
•Automatic interrupt acknowledge
•Selectable internal pullup resistor
8.3 Functional Description
IRQ pin functionality is enabled by setting configuration register 2 (CONFIG2) IRQEN bit accordingly. A
zero disables the IRQ function and IRQ
IRQ function.
will assume the other shared functionalities. A one enables the
)
A logic 0 applied to the external interrupt pin can latch a central processor unit (CPU) interrupt request.
Figure 8-1 shows the structure of the IRQ module.
Interrupt signals on the IRQ
the following actions occurs:
•Vector fetch — A vector fetch automatically generates an interrupt acknowledge signal that clears
the latch that caused the vector fetch.
•Software clear — Software can clear an interrupt latch by writing to the appropriate acknowledge
bit in the interrupt status and control register (INTSCR). Writing a 1 to the ACK bit clears the IRQ
latch.
•Reset — A reset automatically clears the interrupt latch.
The external interrupt pin is falling-edge triggered and is software-configurable to be either falling-edge
or falling-edge and low-level triggered. The MODE bit in the INTSCR controls the triggering sensitivity of
the IRQ
When an interrupt pin is edge-triggered only, the interrupt remains set until a vector fetch, software clear,
or reset occurs.
pin.
pin are latched into the IRQ latch. An interrupt latch remains set until one of
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor81
External Interrupt (IRQ)
ACK
RESET
VECTOR
FETCH
DECODER
V
DD
IRQPUD
INTERNAL ADDRESS BUS
IRQ
INTERNAL
PULLUP
DEVICE
V
DD
CLR
DQ
CK
IRQ
FF
MODE
IMASK
SYNCHRO-
NIZER
HIGH
VOLTAGE
DETECT
Figure 8-1. IRQ Module Block Diagram
IRQF
TO CPU FOR
BIL/BIH
INSTRUCTIONS
IRQ
INTERRUPT
REQUEST
TO MODE
SELECT
LOGIC
When an interrupt pin is both falling-edge and low-level triggered, the interrupt remains set until both of
these events occur:
•Vector fetch or software clear
•Return of the interrupt pin to logic 1
The vector fetch or software clear may occur before or after the interrupt pin returns to logic 1. As long as
the pin is low, the interrupt request remains pending. A reset will clear the latch and the MODE control bit,
thereby clearing the interrupt even if the pin stays low.
When set, the IMASK bit in the INTSCR masks all external interrupt requests. A latched interrupt request
is not presented to the interrupt priority logic unless the IMASK bit is clear.
NOTE
The interrupt mask (I) in the condition code register (CCR) masks all
interrupt requests, including external interrupt requests.
Addr.Register NameBit 7654321Bit 0
Read:0000IRQF0
Write:ACK
IMASKMODE
Reset:00000000
$001D
IRQ Status and Control
Register (INTSCR)
See page 84.
= Unimplemented
Figure 8-2. IRQ I/O Register Summary
8.4 IRQ Pin
A logic 0 on the IRQ pin can latch an interrupt request into the IRQ latch. A vector fetch, software clear,
or reset clears the IRQ latch.
MC68HC908LB8 Data Sheet, Rev. 1
82Freescale Semiconductor
IRQ Module During Break Interrupts
If the MODE bit is set, the IRQ pin is both falling-edge-sensitive and low-level-sensitive. With MODE set,
both of the following actions must occur to clear IRQ:
•Vector fetch or software clear — A vector fetch generates an interrupt acknowledge signal to clear
the latch. Software may generate the interrupt acknowledge signal by writing a 1 to the ACK bit in
the interrupt status and control register (INTSCR). The ACK bit is useful in applications that poll the
IRQ
pin and require software to clear the IRQ latch. Writing to the ACK bit prior to leaving an
interrupt service routine can also prevent spurious interrupts due to noise. Setting ACK does not
affect subsequent transitions on the IRQ
pin. A falling edge that occurs after writing to the ACK bit
latches another interrupt request. If the IRQ mask bit, IMASK, is clear, the CPU loads the program
counter with the vector address at locations $FFFA and $FFFB.
•Return of the IRQ
pin to logic 1 — As long as the IRQ pin is at logic 0, IRQ remains active.
The vector fetch or software clear and the return of the IRQ
interrupt request remains pending as long as the IRQ
pin is at logic 0. A reset will clear the latch and the
pin to logic 1 may occur in any order. The
MODE control bit, thereby clearing the interrupt even if the pin stays low.
If the MODE bit is clear, the IRQ
pin is falling-edge-sensitive only. With MODE clear, a vector fetch or
software clear immediately clears the IRQ latch.
The IRQF bit in the INTSCR register can be used to check for pending interrupts. The IRQF bit is not
affected by the IMASK bit, which makes it useful in applications where polling is preferred.
Use the BIH or BIL instruction to read the logic level on the IRQ
pin.
NOTE
If the IRQ function is not enabled for pin PTC2/SHTDWN/IRQ, BIL and BIH
instructions will always read a logic 1 value.
When using the level-sensitive interrupt trigger, avoid false interrupts by
masking interrupt requests in the interrupt routine.
An internal pullup resistor to V
is connected to the IRQ pin; this can be
DD
disabled by setting the IRQPUD bit in the CONFIG2 register ($001E).
8.5 IRQ Module During Break Interrupts
The BCFE bit in the SIM break flag control register (SBFCR) enables software to clear the latch during
the break state. See 19.2 Break Module (BRK).
To allow software to clear the IRQ latch during a break interrupt, write a 1 to the BCFE bit. If a latch is
cleared during the break state, it remains cleared when the MCU exits the break state.
To protect CPU interrupt flags during the break state, write a 0 to the BCFE bit. With BCFE at 0 (its default
state), writing to the ACK bit in the IRQ status and control register during the break state has no effect on
the IRQ interrupt flags.
8.6 IRQ Status and Control Register
The IRQ status and control register (INTSCR) controls and monitors operation of the IRQ module. The
INTSCR:
•Shows the state of the IRQ flag
•Clears the IRQ latch
•Masks IRQ interrupt request
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor83
External Interrupt (IRQ)
•Controls triggering sensitivity of the IRQ interrupt pin
Address:$001D
Bit 7654321Bit 0
Read:
Write:
Reset:00000000
= Unimplemented
IRQF0
ACK
IMASKMODE
Figure 8-3. IRQ Status and Control Register (INTSCR)
IRQF — IRQ Flag Bit
This read-only status bit is high when the IRQ interrupt is pending.
1 = IRQ
0 = IRQ
interrupt pending
interrupt not pending
ACK — IRQ Interrupt Request Acknowledge Bit
Writing a 1 to this write-only bit clears the IRQ latch. ACK always reads as 0. Reset clears ACK.
IMASK — IRQ Interrupt Mask Bit
Writing a 1 to this read/write bit disables IRQ interrupt requests. Reset clears IMASK.
This read/write bit controls the triggering sensitivity of the IRQ
1 = IRQ
0 = IRQ
interrupt requests on falling edges and low levels
interrupt requests on falling edges only
pin. Reset clears MODE.
MC68HC908LB8 Data Sheet, Rev. 1
84Freescale Semiconductor
Chapter 9
Keyboard Interrupt Module (KBI)
9.1 Introduction
The keyboard interrupt module (KBI) provides seven independently maskable external interrupts which
are accessible via PTA0–PTA6. When a port pin is enabled for keyboard interrupt function, an internal
pullup device is also enabled on the pin.
2. Fault function switchable between pins PTB2 and PTB7.
POWER
OP AMP/COMPARATOR
MODULE
Figure 9-1. Block Diagram Highlighting KBI Block and Pins
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor85
Keyboard Interrupt Module (KBI)
9.2 Features
Features include:
•Seven keyboard interrupt pins with separate keyboard interrupt enable bits and one keyboard
interrupt mask
•Hysteresis buffers
•Programmable edge-only or edge- and level- interrupt sensitivity
•Exit from low-power modes
•I/O (input/output) port bit(s) software configurable with pullup device(s) if configured as input port
bit(s)
INTERNAL BUS
VECTOR FETCH
DECODER
KBI0
TO PULLUP ENABLE
KBIE0
KBI6
ACKK
RESET
V
DD
.
.
.
CLR
DQ
CK
SYNCHRONIZER
IMASKK
KEYF
KEYBOARD
INTERRUPT
REQUEST
TO PULLUP ENABLE
KBIE6
MODEK
Figure 9-2. Keyboard Module Block Diagram
Addr.Register NameBit 7654321Bit 0
Keyboard Status and Control
$001A
Register (INTKBSCR)
Keyboard Interrupt Enable
$001B
Register (INTKBIER)
See page 89.
See page 90.
Read:0000KEYF0
Write:ACKK
IMASKKMODEK
Reset:00000000
Read:
Write:
KBIE6KBIE5KBIE4KBIE3KBIE2KBIE1KBIE0
Reset:00000000
= Unimplemented
Figure 9-3. I/O Register Summary
MC68HC908LB8 Data Sheet, Rev. 1
86Freescale Semiconductor
Functional Description
9.3 Functional Description
Writing to the KBIE6–KBIE0 bits in the keyboard interrupt enable register independently enables or
disables each port A pin as a keyboard interrupt pin. Enabling a keyboard interrupt pin also enables its
internal pullup device. A logic 0 applied to an enabled keyboard interrupt pin latches a keyboard interrupt
request. A keyboard interrupt is latched when one or more keyboard pins goes low after all were high.
The MODEK bit in the keyboard status and control register controls the triggering mode of the keyboard
interrupt.
•If the keyboard interrupt is edge-sensitive only, a falling edge on a keyboard pin does not latch an
interrupt request if another keyboard pin is already low. To prevent losing an interrupt request on
one pin because another pin is still low, software can disable the latter pin while it is low.
•If the keyboard interrupt is falling edge- and low-level sensitive, an interrupt request is present as
long as any keyboard interrupt pin is low and the pin is keyboard interrupt enabled.
If the MODEK bit is set, the keyboard interrupt pins are both falling edge- and low-level sensitive, and both
of the following actions must occur to clear a keyboard interrupt request:
•Vector fetch or software clear — A vector fetch generates an interrupt acknowledge signal to clear
the interrupt request. Software may generate the interrupt acknowledge signal by writing a 1 to the
ACKK bit in the keyboard status and control register (INTKBSCR). The ACKK bit is useful in
applications that poll the keyboard interrupt pins and require software to clear the keyboard
interrupt request. Writing to the ACKK bit prior to leaving an interrupt service routine can also
prevent spurious interrupts due to noise. Setting ACKK does not affect subsequent transitions on
the keyboard interrupt pins. A falling edge that occurs after writing to the ACKK bit latches another
interrupt request. If the keyboard interrupt mask bit, IMASKK, is clear, the CPU loads the program
counter with the vector address at locations $FFE0 and $FFE1.
•Return of all enabled keyboard interrupt pins to logic 1 — As long as any enabled keyboard
interrupt pin is at logic 0, the keyboard interrupt remains set.
The vector fetch or software clear and the return of all enabled keyboard interrupt pins to logic 1 may occur
in any order.
If the MODEK bit is clear, the keyboard interrupt pin is falling-edge-sensitive only. With MODEK clear, a
vector fetch or software clear immediately clears the keyboard interrupt request.
Reset clears the keyboard interrupt request and the MODEK bit, clearing the interrupt request even if a
keyboard interrupt pin stays at logic 0.
The keyboard flag bit (KEYF) in the keyboard status and control register can be used to see if a pending
interrupt exists. The KEYF bit is not affected by the keyboard interrupt mask bit (IMASKK) which makes
it useful in applications where polling is preferred.
To determine the logic level on a keyboard interrupt pin, use the data direction register to configure the
pin as an input and read the data register.
NOTE
Setting a keyboard interrupt enable bit (KBIEx) forces the corresponding
keyboard interrupt pin to be an input, overriding the data direction register.
However, the data direction register bit must be a 0 for software to read the
pin.
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor87
Keyboard Interrupt Module (KBI)
9.4 Keyboard Initialization
When a keyboard interrupt pin is enabled, it takes time for the internal pullup to reach a logic 1. Therefore,
a false interrupt can occur as soon as the pin is enabled.
To prevent a false interrupt on keyboard initialization:
1.Mask keyboard interrupts by setting the IMASKK bit in the keyboard status and control register.
2.Enable the KBI pins by setting the appropriate KBIEx bits in the keyboard interrupt enable register.
3.Write to the ACKK bit in the keyboard status and control register to clear any false interrupts.
4.Clear the IMASKK bit.
An interrupt signal on an edge-triggered pin can be acknowledged immediately after enabling the pin. An
interrupt signal on an edge- and level-triggered interrupt pin must be acknowledged after a delay that
depends on the external load.
Another way to avoid a false interrupt:
1.Configure the keyboard pins as outputs by setting the appropriate DDRA bits in data direction
register A.
2.Write 1s to the appropriate port A data register bits.
3.Enable the KBI pins by setting the appropriate KBIEx bits in the keyboard interrupt enable register.
9.5 Low-Power Modes
The WAIT and STOP instructions put the microcontroller unit (MCU) in low power-consumption standby
modes.
9.5.1 Wait Mode
The keyboard module remains active in wait mode. Clearing the IMASKK bit in the keyboard status and
control register enables keyboard interrupt requests to bring the MCU out of wait mode.
9.5.2 Stop Mode
The keyboard module remains active in stop mode. Clearing the IMASKK bit in the keyboard status and
control register enables keyboard interrupt requests to bring the MCU out of stop mode.
9.6 Keyboard Module During Break Interrupts
The system integration module (SIM) controls whether the keyboard interrupt latch 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.
To allow software to clear the keyboard interrupt latch during a break interrupt, write a 1 to the BCFE bit.
If a latch is cleared during the break state, it remains cleared when the MCU exits the break state.
To protect the latch during the break state, write a 0 to the BCFE bit. With BCFE at 0 (its default state),
writing to the keyboard acknowledge bit (ACKK) in the keyboard status and control register during the
break state has no effect. See 9.7.1 Keyboard Status and Control Register.
MC68HC908LB8 Data Sheet, Rev. 1
88Freescale Semiconductor
9.7 I/O Registers
These registers control and monitor operation of the keyboard module:
Each of these read/write bits enables the corresponding keyboard interrupt pin to latch interrupt
requests. Reset clears the keyboard interrupt enable register.
1 = PTAx pin enabled as keyboard interrupt pin
0 = PTAx pin not enabled as keyboard interrupt pin
MC68HC908LB8 Data Sheet, Rev. 1
90Freescale Semiconductor
Chapter 10
High Resolution PWM (HRP)
10.1 Introduction
The High Resolution PWM (HRP) provides two complementary outputs that can be used to control
half-bridge systems in, for example, light ballast applications. It uses a dithering control method to provide
a high step resolution (3.906 ns from an 8 MHz input clock). It also provides a shutdown input that can be
used to disable the outputs when a fault condition is detected in the application.
The pins supporting the HRP can be seen in Figure 10-1, and a block diagram of the HRP module is
shown in Figure 10-3.
10.2 Features
Features of the HRP include:
•One complementary output pair for driving a half bridge
•Dithering between two frequencies or duty cycles, for increased output resolution
•Automatic calculation of second frequency or duty cycle for output dithering
•Variable frequency mode with automatic 50% duty cycle calculation
•Variable duty cycle mode
•Programmable deadtime insertion
•Shutdown input for fast disabling of outputs
10.3 Pin Name Conventions
The HRP shares two output pins with two port B input/output (I/O) pins and one input pin with one port C
input pin.
Table 10-1. Pin Naming Conventions
HRP Generic Pin NameFull HRP Pin Name
TOPPTB0/TOP
BOTPTB1/BOT
SHTDWNPTC2/SHTDWN/IRQ
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor91
High Resolution PWM (HRP)
M68HC08 CPU
INTERNAL BUS
CPU
REGISTERS
CONTROL AND STATUS
REGISTERS — 64 BYTES
USER FLASH — 8 KBYTES
USER RAM — 128 BYTES
MONITOR ROM — 350 BYTES
FLASH PROGRAMMING
ROUTINES ROM — 674 BYTES
USER FLASH VECTOR SPACE — 34 BYTES
ARITHMETIC/LOGIC
UNIT (ALU)
OSCILLATOR
MODULE
SYSTEM INTEGRATION
MODULE
DUAL CHANNEL PWM
MODULE
HIGH RESOLUTION PWM
MODULE
LOW-VOLTAGE INHIBIT
MODULE
COMPUTER OPERATING
PROPERLY MODULE
2-CHANNEL TIMER
MODULE
8-BIT ANALOG-TO-DIGITAL
CONVERTER MODULE
KEYBOARD INTERRUPT
MODULE
DDRA
DDRB
DDRC
PORTA
PORTB
PORTC
(1)
/AD5/TCH0/KBI6
PTA6
(1)
/RST/KBI5
PTA5
(1)
/AD4/KBI4
PTA4
(1)
/AD3/KBI3
PTA3
(1)
/AD2/KBI2
PTA2
(1)
/AD1/KBI1
PTA1
(1)
/AD0/KBI0
PTA0
PTB7/V
OUT
PTB6/V–
PTB5/V+
PTB4/PWM1
PTB3/PWM0
PTB2/FAULT
PTB1/BOT
PTB0/TOP
(1)
PTC2
/SHTDWN/IRQ
(1)
PTC1
/OSC2
(1)
/OSC1
PTC0
/AD6/FAULT
(2)
(2)
V
DD
V
Notes:
SS
1. Pin contains integrated pullup device.
2. Fault function switchable between pins PTB2 and PTB7.
POWER
Figure 10-1. Block Diagram Highlighting HRP Block and Pins
Setting the HRPOE bit in the HRPCTRL register forces the corresponding
HRP output pins to be outputs, overriding the data direction register. In
order to read the states of the pins, the data direction register bit must be
a0.
Setting the SHTEN bit in the HRPCTRL register forces the SHTDWN pin to
be an input, overriding the data direction register. In order to read the state
of the pin, the data direction register bit must be a 0.
OP AMP/COMPARATOR
MODULE
NOTE
MC68HC908LB8 Data Sheet, Rev. 1
92Freescale Semiconductor
Functional Description
Addr.Register NameBit 7654321Bit 0
HRP Control Register
$0051
HRP Duty Cycle Register
$0052
HRP Duty Cycle Register
$0053
HRP Period Register High
$0054
HRP Period Register Low
$0055
HRP Deadtime Register
$0056
HRP Timebase Register High
$0057
HRP Timebase Register Low
$0058
Frequency Dithering Control
$0059
Register (HRPDCR)
(HRPCTRL)
See page 105.
High (HRPDCH)
See page 107.
Low (HRPDCL)
See page 107.
(HRPPERH)
See page 107.
(HRPPERL)
See page 107.
(HRPDT)
See page 108.
(HRPTBH)
See page 108.
(HRPTBL)
See page 108.
See page 109.
Read:
Write:
Reset0000000
Read:
Write:
Reset00000000
Read:
Write:
Reset00000000
Read:
Write:
Reset00000000
Read:
Write:
Reset00000000
Read:
Write:
Reset00001000
Read:
Write:
Reset00000000
Read:
Write:
Reset00000000
Read:
Write:
Reset0000
DC10DC9DC8DC7DC6DC5DC4DC3
DC2DC1DC0STEP4STEP3STEP3STEP1STEP0
P10P9P8P7P6P5P4P3
P2P1P0STEP4STEP3STEP2STEP1STEP0
DT7DT6DT5DT4DT3DT2DT1DT0
TB15TB14TB13TB12TB11TB10TB9TB8
TB7TB6TB5TB4TB3TB2TB1TB0
SHTLVLHRPOESHTIFSHTIESHTENHRPMODEHRPEN
CLKSRCSEL2SEL1SEL0
= Unimplemented
Figure 10-2. HRP I/O Register Summary
NOTE
When HRPMODE = 0, STEP[4:0] are mapped into the five least significant
bits of the HRPPERL register.
When HRPMODE = 1, STEP[4:0] are mapped into the five least significant
bits of the HRPDCL register.
10.4 Functional Description
Figure 10-3 provides a block diagram of the module.
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor93
High Resolution PWM (HRP)
BUSCLK
HRPCLK
INTERNAL BUS
CONTROL
REGISTERS
DUAL
FREQUENCY
GENERATOR
DITHERING
CONTROLLER
DEADTIME GENERATOR
DEADTIME GENERATOR
COMPLEMENTARY OUTPUTS
WITH PROGRAMMABLE DEADTIME
SHUTDOWN DETECT INPUT
FOR FAST DISABLING
OF OUTPUTS
TOP
BOT
SHTDWN
Figure 10-3. Block Diagram of High Resolution PWM (HRP)
The HRP comprises four blocks, as follows
1.A dual frequency generator, which generates a pair of complementary PWM output signals. It
allows dithering between two adjacent frequencies or duty cycles to increase the resolution of the
output signal. After deadtime insertion, these signals are routed to the TOP and BOT output pins
2.A dithering controller, or timebase, which sets the dithering cycle time and the percentage of time
spent on each of the dithering frequencies or duty cycles.
3.Two deadtime generators, for inserting deadtime into the output signals.
4.A set of control registers
The HRP can operate in two modes.
1.Variable Frequency Mode: for variation of the output frequency at a fixed 50% duty cycle
2.Variable Duty Cycle Mode: for variation of the duty cycle at a fixed frequency.
10.4.1 The Principle of Frequency Dithering
Frequency dithering is an averaging technique, which can increase the resolution of an output signal by
switching between two frequencies. By varying the time spent on each frequency, the average output
frequency will be a value between the two frequencies. For example, in Figure 10-4 a signal switches
between 10 kHz and 20 kHz over a fixed cycle time. 30% of each cycle is spent at 20 kHz, 70% at 10 kHz.
The equivalent average frequency over time is 13 kHz.
MC68HC908LB8 Data Sheet, Rev. 1
94Freescale Semiconductor
1 CYCLE
10 kHz20 kHz
1006050403020708090100
20 kHz10 kHz
Functional Description
% CYCLE
t
13 kHz
AVERAGE
SIGNAL
Figure 10-4. Dithering Waveforms
10.4.2 Frequency Dithering on the HRP
The HRP provides frequency dithering between two signals whose periods differ by one HRPCLK cycle.
When the HRP is supplied with an 8 MHz clock, the difference between the period values is 125 ns.
The HRP provides a programmable number of dithering steps, up to a maximum of 32 steps. This results
in a maximum frequency resolution of 125/32 = 3.906 ns when using an 8 MHz clock.
Figure 10-5 shows the relationship between the two dithering frequencies and the output frequency when
32 dithering steps are chosen. In this example, the Period signal is output for 25% of the time, i.e. 8 of the
32 steps, and the Period+1 signal is output for 75% of the time, i.e. 24 of the 32 steps.
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor95
High Resolution PWM (HRP)
PERIOD +1 = $81
FREQUENCY = 1/ ($81 * 125 ns) = 62.015 kHz
PERIOD = $80PERIOD +1 = $81
081624
AVERAGE FREQUENCY = 62.015 + ((62.500 – 62.015)/32 * 8) = 62.136 kHz
0
PERIOD = $80
FREQUENCY = 1/ ($80 * 125 ns) = 62.500 kHz
STEPS
16
80
24
t
Figure 10-5. High Resolution PWM Dithering
10.4.3 Duty Cycle Dithering
As an alternative to frequency dithering, duty cycle dithering, where dithering occurs between two signals
having the same frequency, but with duty cycles differing by one clock period. The HRP can perform duty
cycle dithering with the same step resolution as the frequency dithering option (125/32 = 3.906 ns, with
an 8 MHz clock).
10.4.4 Frequency Generation
The dual frequency generator block contains a 16-bit up counter, which generates an output signal, based
on the values in the period register HRPPERH:HRPPERL and the duty cycle register HRPDCH:HRPDCL.
The output signal and its inverse are later fed into the deadtime generators for deadtime insertion.
Multiplexors on the inputs of the period register and the duty cycle register select between two period
(PERIOD1 and PERIOD2) and two duty cycle (DUTY1 and DUTY2) values. The values of PERIOD1,
PERIOD2, DUTY1, and DUTY2 are determined by the HRPMODE bit in the HRPCTRL register and the
contents of the HRPPERH:HRPPERL and HRPDCH:HRPDCL registers.
PERIOD1 and DUTY1 define the frequency output by the dual-frequency generator; PERIOD2 and
DUTY2 define a second output frequency, which is automatically calculated by the HRP module.
The module switches between PERIOD1/DUTY1 and PERIOD2/DUTY2.
MC68HC908LB8 Data Sheet, Rev. 1
96Freescale Semiconductor
Functional Description
The rate of switching is controlled by the dithering controller, and is dependent on the values of the
CLKSRC bit and the SEL[2:0] bits in the HRPDCR register, the contents of the HRPTBH:HRPTBL
registers, and, depending on the value of the HRPMODE bit, the five least significant bits in the HRPPERL
or HRPDCL registers.
Table 10-2. HRPMODE Bit Options
HRPMODEModePERIOD1PERIOD2DUTY1DUTY2
0
1
Var iable
Frequency
Variable Duty
Cycle
P[10:0]P[10:0] +1PERIOD1/2PERIOD2/2
P[10:0]P[10:0]DC[10:0]DC[10:0] +1
For more detailed information, see 10.4.7 Dithering Controller.
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor97
HRPMODE
10
TO DEADTIME
GENERATORS
/2
01
STEP[4:0]
+1
DC[10:0]
HRPTBH HRPTBL
DIVIDER
DUTY 1DUTY 2
01
COMPARE
1
INCREMENT
COMPARE
/2
16-BIT COUNTER
5-BIT
SELECT
FREQUENCY
RESET
0
COUNTER
10
Q
S
+1
10
UP COUNTER
PERIOD REGISTER
DUTY CYCLE REGISTER
R
CLK
SRC
PERIOD 1PERIOD 2
DITHERING TIMEBASE
P[10:0]
DUAL FREQUENCY GENERATOR
Figure 10-6. Dithering Controller and Dual Frequency Generator Block
COMPARE
MODULUS
SEL[2:0]
CLKSEL = 0, clock from dual frequency generator
CLKSEL = 1, clock from 16-bit timebase counter
HRPCLK
Functional Description
1
-
10.4.5 Variable Frequency Mode (HRPMODE = 0)
Variable frequency mode is selected when HRPMODE = 0. In this mode the period of the output signal
can be varied, while keeping the duty cycle fixed at 50%.
PERIOD1, PERIOD2, DUTY1, and DUTY2 are calculated from bits P[10:0] in registers
HRPPERH:HRPPERL to produce two frequencies having periods differing by one clock cycle but both
with 50% duty cycles. Table 10-2 lists the period and duty cycle values based on the HRPMODE bit.
The scaled value in STEP[4:0] (the five least significant bits of HRPPERH:HRPPERL) specifies how
many of the selected number of steps are spent on the longer period (PERIOD2). For more detailed
information, see 10.4.7 Dithering Controller.
The formula for calculating the average output period in variable frequency mode (including dithering) is:
where the function INT() represents the integer part of the operand, and 2
factor.
In Variable Frequency Mode, the individual periods and duty cycles are given by:
SEL[2:0]
⎝⎠
2
32
SEL[2:0]
(EQ 10-1)
is the STEP[4:0] scaling
DUTY1
DUTY2
PERIOD1
PERIOD1
--------------------------50% duty cycle==
2
9PERIOD2
PERIOD2
--------------------------50% duty cycle==
2
P[10:0]
------------------------=
HRPCLK
P[10:0]
=
-------------------------HRPCLK
+
(EQ 10-2)
(EQ 10-3)
(EQ 10-4)
(EQ 10-5)
10.4.6 Variable Duty Cycle Mode (HRPMODE = 1)
Variable duty cycle mode is selected when HRPMODE = 1. This mode allows dithering to be achieved by
varying the duty cycle of the output waveform while keeping the period fixed.
In this mode, the period of both PERIOD1 and PERIOD2 are identical. DUTY2 is automatically set to
DUTY1 + 1. This provides two signals with the same frequency but with duty cycles differing by one bus
clock cycle. Dithering between these two signals can increase the resolution of the output by a factor of
up to 32.
The scaled value in STEP[4:0] (the five least significant bits of HRPDCH:HRPDCL) specifies how many
of the selected number of steps are spent on the longer duty cycle, DUTY2.
For more detailed information, see 10.4.7 Dithering Controller.
MC68HC908LB8 Data Sheet, Rev. 1
Freescale Semiconductor99
High Resolution PWM (HRP)
The formula for calculating the output duty cycle in variable duty cycle mode is:
In Variable Duty Cycle Mode, the individual periods and duty cycles are given by:
(EQ 10-6)
PERIOD1
DUTY1DC[10:0]=
PERIOD2PERIOD1
DUTY2DUTY11+DC[10:0]1+==
P[10:0]
------------------------=
HRPCLK
------------------------==
HRPCLK
P[10:0]
(EQ 10-7)
(EQ 10-8)
(EQ 10-9)
(EQ 10-10)
10.4.7 Dithering Controller
The dithering controller consists of a 5-bit counter with programmable modulus. The counter contents are
compared with a scaled version of the STEP[4:0] bits.
The modulus value (i.e., the total number of steps) and the STEP[4:0] scaling factor are set by the SEL
bits in the HRP configuration register. Table 10-3 lists the available options. Note that the scaling of the
STEP[4:0] bits is linked to the modulus value. For example, if a modulus of 32 is chosen, STEP[4:0] is not
scaled (32 steps of dithering are available). If a modulus of 16 is chosen, STEP[4:0] is divided by 2, so
that only 16 steps of dithering are available.
Table 10-3. Number of Steps and Step Scaling
SELNumber of StepsDivide STEP[4:0] by...
0321
1162
284
348
4216
5032
6ReservedReserved
7ReservedReserved
For example, if you decide to have 16 steps (SEL = 1) instead of the maximum of 32, and you set
STEP[4:0] equal to 23, then the scaled value of STEP will be 11 (i.e., the integer part of 23 divided by 2).
If you decide to have 4 steps instead of 32, the scaled value of 23 would be 2 (the integer part of 23 divided
by 8).
MC68HC908LB8 Data Sheet, Rev. 1
100Freescale Semiconductor
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.