To provide the most up-to-date information, the revision of our documents on the World Wide Web will be
the most current. Your printed copy may be an earlier revision. To verify you have the latest information
available, refer to:
http://freescale.com/
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
This product incorporates SuperFlash® technology licensed from SST.
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
September,
2005
Revision
Level
1
Description
Reformatted to meet new publications guidelines.
Modules updated with additional data
1.4.16 BDLC Receive Pin (BDRxD) — Corrected name of BDLC receive pin
to BDRxD.
Removed Keyboard Interface ModuleN/A
Removed Timer Interface Module B
Removed all references to TIMB and TBCLK
The MC68HC908AS32A is a member of the low-cost, high-performance M68HC08 Family of 8-bit
microcontroller units (MCUs). All MCUs in the family use the enhanced M68HC08 central processor unit
(CPU08) and are available with a variety of modules, memory sizes and types, and package types.
1.2 Features
Features include:
•High-performance M68HC08 architecture
•Fully upward-compatible object code with M6805, M146805, and M68HC05 Families
•8.4 MHz internal bus frequency
•32,256 bytes of FLASH electrically erasable read-only memory (FLASH)
•FLASH data security
•512 bytes of on-chip electrically erasable programmable read-only memory with security option
(EEPROM)
•System protection features
–Computer operating properly (COP) with optional reset
–Low-voltage detection with optional reset
–Illegal opcode detection with optional reset
–Illegal address detection with optional reset
•Low-power design (fully static with stop and wait modes)
•Master reset pin and power-on reset
•SAE J1850 byte data link controller digital module
1. No security feature is absolutely secure. However, Freescale’s strategy is to make reading or copying the FLASH and EEPROM difficult for unauthorized users.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor19
General Description
Features of the CPU08 include:
•Enhanced HC05 programming model
•Extensive loop control functions
•16 addressing modes (eight more than the HC05)
•16-bit index register and stack pointer
•Memory-to-memory data transfers
•Fast 8 × 8 multiply instruction
•Fast 16/8 divide instruction
•Binary-coded decimal (BCD) instructions
•Optimization for controller applications
•C language support
1.3 MCU Block Diagram
Figure 1-1 shows the structure of the MC68HC908AS32A.
MC68HC908AS32A Data Sheet, Rev. 1
20Freescale Semiconductor
M68HC08 CPU
CPU
REGISTERS
ARITHMETIC/LOGIC
UNIT (ALU)
CONTROL AND STATUS REGISTERS
USER FLASH — 32, 256 BYTES
USER RAM — 1024 BYTES
USER EEPROM — 512 BYTES
MONITOR ROM — 256 BYTES
USER FLASH VECTOR SPACE — 52 BYTES
OSC1
OSC2
CGMXFC
RST
IRQ
CLOCK GENERATOR
MODULE
SYSTEM INTEGRATION
MODULE
IRQ MODULE
V
REFH
ANALOG-TO-DIGITAL
MODULE
BREAK MODULE
LOW-VOLTAGE INHIBIT
MODULE
COMPUTER OPERATING
PROPERLY MODULE
6-CHANNEL TIMER
INTERFACE MODULE
PROGRAMMABLE INTERRUPT
TIMER MODULE
SERIAL COMMUNICATIONS
INTERFACE MODULE
SERIAL PERIPHERAL
INTERFACE MODULE
BYTE DATA LINK CONTROLLER
MCU Block Diagram
PTB
PTC
PTF
PTA7–PTA0
PTB7/ATD7–
PTB0/ATD0
PTC4
PTC3
PTC2/MCLK
PTC1–PTC0
PTD6/ATD14/TCLK
PTD5/ATD13
PTA4/ATD12
PTD3/ATD11–
PTD0/ATD8
PTE7/SPSCK
PTE6/MOSI
PTE5/MISO
PTE4/SS
PTE3/TCH1
PTE2/TCH0
PTE1/RxD
PTE0/TxD
PTF3/TCH5–
PTF0/TCH2
DDRA
DDRB
DDRC
DDRD
DDRE
DDRF
PTA
PTD
PTE
POWER-ON RESET
MODULE
V
SS
V
DD
V
DDA
V
SSA
POWER
BDRxDBDTxD
AVSS/V
REFK
V
DDAREF
Figure 1-1. MCU Block Diagram for the MC68HC908AS32A
The following pin descriptions are just a quick reference. For a more
detailed representation, see Chapter 13 Input/Output Ports.
1.4.1 Power Supply Pins (VDD and VSS)
VDD and VSS are the power supply and ground pins. The MCU operates from a single power supply.
Fast signal transitions on MCU pins place high, short-duration current demands on the power supply. To
prevent noise problems, take special care to provide power supply bypassing at the MCU as shown in
Figure 1-3. Place the C1 bypass capacitor as close to the MCU as possible. Use a high-frequency
MC68HC908AS32A Data Sheet, Rev. 1
22Freescale Semiconductor
Pin Assignments
response ceramic capacitor for C1. C2 is an optional bulk current bypass capacitor for use in applications
that require the port pins to source high current levels.
is also the ground for the port output buffers and the ground return for the serial clock in the SPI. See
SS
Chapter 16 Serial Peripheral Interface (SPI) for more information.
NOTE
V
must be grounded for proper MCU operation.
SS
1.4.2 Oscillator Pins (OSC1 and OSC2)
The OSC1 and OSC2 pins are the connections for the on-chip oscillator circuit. See Chapter 5 Clock
Generator Module (CGM) for more information.
1.4.3 External Reset Pin (RST)
A 0 on the RST pin forces the MCU to a known startup state. RST is bidirectional, allowing a reset of the
entire system. It is driven low when any internal reset source is asserted. See Chapter 15 System
Integration Module (SIM) for more information.
1.4.4 External Interrupt Pin (IRQ)
IRQ is an asynchronous external interrupt pin. See Chapter 10 External Interrupt Module (IRQ) for more
information.
1.4.5 External Filter Capacitor Pin (CGMXFC)
CGMXFC is an external filter capacitor connection for the clock generator module (CGM). See Chapter 5
Clock Generator Module (CGM) for more information.
1.4.6 Analog Power Supply Pin (V
V
DDA/VDDAREF
is the power supply pin for the analog portion of the ADC and the CGM. See Chapter 3
DDA/VDDAREF
Analog-to-Digital Converter (ADC) and Chapter 5 Clock Generator Module (CGM) for more information.
MC68HC908AS32A Data Sheet, Rev. 1
)
Freescale Semiconductor23
General Description
1.4.7 Analog Ground Pin (V
The V
SSA/VREFL
pin provides both the analog ground connection and the reference low voltage for the
SSA/VREFL
)
ADC as well as the ground connection for the CGM. See Chapter 3 Analog-to-Digital Converter (ADC)
and Chapter 5 Clock Generator Module (CGM) for more information.
1.4.8 ADC Reference High Voltage Pin (V
V
provides the reference high voltage for the ADC. See Chapter 3 Analog-to-Digital Converter (ADC)
REFH
REFH
)
for more information.
1.4.9 Port A Input/Output (I/O) Pins (PTA7–PTA0)
PTA7–PTA0 are general-purpose bidirectional input/output (I/O) port pins. See Chapter 13 Input/Output
Ports for more information.
1.4.10 Port B I/O Pins (PTB7/ATD7–PTB0/ATD0)
Port B is an 8-bit special function port that shares all eight pins with the ADC. See Chapter 3
Analog-to-Digital Converter (ADC) and Chapter 13 Input/Output Ports for more information.
1.4.11 Port C I/O Pins (PTC4–PTC0)
PTC4–PTC3 and PTC1–PTC0 are general-purpose bidirectional I/O port pins. PTC2/MCLK is a special
function port that shares its pin with the system clock which has a frequency equivalent to the system
clock. See Chapter 13 Input/Output Ports for more information.
1.4.12 Port D I/O Pins (PTD6–PTD0/ATD8)
Port D is an 7-bit special-function port that shares seven of its pins with the ADC and one of its pins with
the TIM. See Chapter 17 Timer Interface Module (TIM), Chapter 3 Analog-to-Digital Converter (ADC), and
Chapter 13 Input/Output Ports for more information.
1.4.13 Port E I/O Pins (PTE7/SPSCK–PTE0/TxD)
Port E is an 8-bit special function port that shares two of its pins with the TIM, four of its pins with the SPI,
and two of its pins with the SCI. See Chapter 14 Serial Communications Interface (SCI), Chapter 16 Serial
PTF3/TCH5 General-purpose I/O TIM channel 5Dual stateYesInput Hi-Z
PTF2/TCH4General-purpose I/O TIM channel 4Dual stateYesInput Hi-Z
PTF1/TCH3General-purpose I/O TIM channel 3Dual stateYesInput Hi-Z
PTF0/TCH2General-purpose I/O TIM channel 2Dual stateYesInput Hi-Z
V
DD
V
SS
V
DDA/VDDAREF
V
SSA/VREFL
V
REFH
Chip power supplyN/AN/AN/A
Chip groundN/AN/AN/A
ADC analog power supply
CGM analog power supply
ADC ground/ADC reference
low voltage CGM analog ground
N/AN/AN/A
N/AN/AN/A
A/D reference high voltageN/AN/AN/A
OSC1External clock inN/AN/AInput Hi-Z
OSC2External clock outN/AN/AOutput
CGMXFCPLL loop filter capN/AN/AN/A
IRQExternal interrupt requestN/AN/AInput Hi-Z
RST
ResetN/AN/AOutput low
BDRxDBDLC serial inputN/AYesInput Hi-Z
BDTxDBDLC serial outputOutputNoOutput
1. Hysteresis is not 100% tested but is typically a minimum of 300 mV.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor25
General Description
Table 1-2. Clock Signal Naming Conventions
Clock Signal NameDescription
CGMXCLKBuffered version of OSC1 from CGM
CGMOUTPLL-based or OSC1-based clock output from CGM
Bus clockCGMOUT divided by two
SPSCKSPI serial clock
TCLKExternal clock input for TIM
Table 1-3. Clock Source Summary
ModuleClock Source
ADCCGMXCLK or bus clock
CANCGMXCLK or CGMOUT
COPCGMXCLK
CPUBus clock
FLASHBus clock
EEPROMCGMXCLK or bus clock
RAMBus clock
SPIBus clock/SPSCK
SCICGMXCLK
TIMBus clock or PTD6/ATD14/TCLK
PITBus clock
SIMCGMOUT and CGMXCLK
IRQBus clock
BRKBus clock
LVIBus clock
CGMOSC1 and OSC2
MC68HC908AS32A Data Sheet, Rev. 1
26Freescale Semiconductor
Chapter 2
Memory
2.1 Introduction
The CPU08 can address 64 Kbytes of memory space. The memory map, shown in Figure 2-1, includes:
•32,256 bytes of FLASH EEPROM
•1024 bytes of RAM
•512 bytes of EEPROM with protect option
•52 bytes of user-defined vectors
•256 bytes of monitor ROM
2.2 Unimplemented Memory Locations
Accessing an unimplemented location can have unpredictable effects on MCU operation. In Figure 2-1
and in register figures in this document, unimplemented locations are shaded.
2.3 Reserved Memory Locations
Accessing a reserved location can have unpredictable effects on MCU operation. In Figure 2-1 and in
register figures in this document, reserved locations are marked with the word Reserved or with the
letter R.
2.4 Input/Output (I/O) Section
Addresses $0000–$004F, shown in Figure 2-2, contain the I/O data, status, and control registers.
2.5 Additional Status and Control Registers
Selected addresses in the range $FE00–$FF88 contain additional status and control registers as shown
in Figure 2-3. A noted exception is the computer operating properly (COP) control register (COPCTL) at
address $FFFF.
2.6 Vector Addresses and Priority
Addresses in the range $FFDA–$FFFF contain the user-specified vector locations. The vector addresses
are shown in Table 2-1. It is recommended that all vector addresses are defined.
Figure 2-2. I/O Data, Status and Control Registers (Sheet 1 of 6)
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor29
Memory
Addr.Register NameBit 7654321Bit 0
Data Direction Register B
$0005
Data Direction Register C
$0006
Data Direction Register D
$0007
Port E Data Register
$0008
Port F Data Register
$0009
$000AReservedRRRRRRRR
(DDRB)
See page 151.
(DDRC)
See page 153.
(DDRD)
See page 156.
See page 157.
See page 159.
Read:
Write:
Reset:00000000
Read:
Write:
Reset:00000000
Read:0
Write:
Reset:00000000
Read:
Write:
(PTE)
Reset:Unaffected by reset
Read:0000
(PTF)
Write:
Reset:Unaffected by reset
DDRB7DDRB6DDRB5DDRB4DDRB3DDRB2DDRB1DDRB0
MCLKEN
PTE7PTE6PTE5PTE4PTE3PTE2PTE1PTE0
00
DDRC4DDRC3DDRC2DDRC1DDRC0
DDRD6DDRD5DDRD4DDRD3DDR2DDRD1DDRD0
PTF3PTF2PTF1PTF0
$000BReservedRRRRRRRR
Data Direction Register E
$000C
Data Direction Register F
$000D
$000EReservedRRRRRRRR
$000FReservedRRRRRRRR
SPI Control Register
$0010
SPI Status and Control
$0011
$0012
Register (SPSCR)
SPI Data Register
(DDRE)
See page 158.
(DDRF)
See page 160.
(SPCR)
See page 219.
See page 221.
(SPDR)
See page 223.
Read:
Write:
Reset:00000000
Read:0000
Write:
Reset:00000000
Read:
Write:
Reset:00101000
Read:SPRF0OVRFMODFSPTE0
Write:
Reset:00001000
Read:R7R6R5R4R3R2R1R0
Write:T7T6T5T4T3T2T1T0
Reset:Indeterminate after reset
DDRE7DDRE6DDRE5DDRE4DDRE3DDRE2DDRE1DDRE0
DDRF3DDRF2DDRF1DDRF0
SPRIERSPMSTRCPOLCPHASPWOMSPESPTIE
SPR1SPR0
= Unimplemented
= ReservedU = Unaffected
R
Figure 2-2. I/O Data, Status and Control Registers (Sheet 2 of 6)
MC68HC908AS32A Data Sheet, Rev. 1
30Freescale Semiconductor
Vector Addresses and Priority
Addr.Register NameBit 7654321Bit 0
SCI Control Register 1
$0013
SCI Control Register 2
$0014
SCI Control Register 3
$0015
SCI Status Register 1
$0016
SCI Status Register 2
$0017
SCI Data Register
$0018
SCI Baud Rate Register
$0019
IRQ Status/Control Register
$001A
$001BReservedRRRRRRRR
(SCC1)
See page 176.
(SCC2)
See page 178.
(SCC3)
See page 180.
(SCS1)
See page 181.
(SCS2)
See page 183.
(SCDR)
See page 184.
(SCBR)
See page 184.
(ISCR)
See page 137.
Read:
Write:
Reset:00000000
Read:
Write:
Reset:00000000
Read:R8
Write:
Reset:UU000000
Read:SCTETCSCRFIDLEORNFFEPE
Write:
Reset:11000000
Read:000000BKFRPF
Write:
Reset:00000000
Read:R7R6R5R4R3R2R1R0
Write:T7T6T5T4T3T2T1T0
Reset:Unaffected by reset
Read:00
Write:
Reset:00000000
Read:0000IRQF0
Write:
Reset:00000000
LOOPSENSCITXINVMWAKEILTYPENPTY
SCTIETCIESCRIEILIETERERWUSBK
T8RRORIENEIEFEIEPEIE
SCP1SCP0
0
SCR2SCR1SCR0
ACK
IMASKMODE
$001C
$001D
$001E
$001F
PLL Control Register
(PCTL)
See page 104.
PLL Bandwidth Control
Register (PBWC)
See page 105.
PLL Programming Register
(PPG)
See page 106.
Configuration Write-Once
Register (CONFIG1)
See page 113.
Read:
Write:
Reset:00101111
Read:
Write:
Reset:00000000
Read:
Write:
Reset:01100110
Read:
Write:
Reset:01110000
PLLIE
AUTO
MUL7MUL6MUL5MUL4VRS7VRS6VRS5VRS4
LVISTOPRLVIRSTLVIPWRSSRECCOPLSTOPCOPD
PLLF
LOCK
= Unimplemented
PLLONBCS
ACQ
XLD
R
1111
0000
= ReservedU = Unaffected
Figure 2-2. I/O Data, Status and Control Registers (Sheet 3 of 6)
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor31
Memory
Addr.Register NameBit 7654321Bit 0
TIM Status and Control
$0020
$0021ReservedRRRRRRRR
Register (TSC)
See page 235.
Read:TOF
Write:0TRST
Reset:00100000
TOIETSTOP
00
PS2PS1PS0
$0022
$0023
$0024
$0025
$0026
$0027
$0028
$0029
$002A
$002B
$002C
TIM Counter Register High
(TCNTH)
See page 236.
TIM Counter Register Low
(TCNTL)
See page 236.
TIM Modulo Register High
(TMODH)
See page 237.
TIM Modulo Register Low
(TMODL)
See page 237.
TIM Channel 0 Status and
Control Register (TSC0)
See page 238.
TIM Channel 0 Register High
(TCH0H)
See page 241.
TIM Channel 0 Register Low
(TCH0L)
See page 241.
TIM Channel 1 Status and
Control Register (TSC1)
See page 238.
TIM Channel 1 Register High
(TCH1H)
See page 241.
TIM Channel 1 Register Low
(TCH1L)
See page 241.
TIM Channel 2 Status and
Control Register (TSC2)
See page 238.
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:
Read:CH1F
Write:0
Reset:00000000
Read:
Write:
Reset:Indeterminate after reset
Read:
Write:
Reset:Indeterminate after reset
Read:CH2F
Write:0
Reset:00000000
Bit 1514131211109Bit 8
Bit 7654321Bit 0
CH0IEMS0BMS0AELS0BELS0ATOV0CH0MAX
Bit 1514131211109Bit 8
Bit 7654321Bit 0
CH1IE
Bit 1514131211109Bit 8
Bit 7654321Bit 0
CH2IEMS2BMS2AELS2BELS2ATOV2CH2MAX
= Unimplemented
0
MS1AELS1BELS1ATOV1CH1MAX
= ReservedU = Unaffected
R
Figure 2-2. I/O Data, Status and Control Registers (Sheet 4 of 6)
MC68HC908AS32A Data Sheet, Rev. 1
32Freescale Semiconductor
Vector Addresses and Priority
Addr.Register NameBit 7654321Bit 0
Read:
Write:
Reset:Indeterminate after reset
Read:
Write:
Reset:Indeterminate after reset
Read:CH3F
Write:0
Reset:00000000
Read:
Write:
Reset:Indeterminate after reset
Read:
Write:
Reset:Indeterminate after reset
Read:CH4F
Write:0
Reset:00000000
Read:
Write:
Reset:Indeterminate after reset
Read:
Write:
Reset:Indeterminate after reset
Read:CH5F
Write:0
Reset:00000000
Read:
Write:
Reset:Indeterminate after reset
Read:
Write:
Reset:Indeterminate after reset
Read:COCO
Write:R
Reset:00000000
Read:AD7AD6AD5AD4AD3AD2AD1AD0
(ADR)
Write:RRRRRRRR
Reset:Indeterminate after reset
Bit 1514131211109Bit 8
Bit 7654321Bit 0
CH3IE
Bit 1514131211109Bit 8
Bit 7654321Bit 0
CH4IEMS4BMS4AELS4BELS4ATOV4CH4MAX
Bit 1514131211109Bit 8
Bit 7654321Bit 0
CH5IE
Bit 1514131211109Bit 8
Bit 7654321Bit 0
AIENADCOADCH4ADCH3ADCH2ADCH1ADCH0
= Unimplemented
0
0
MS3AELS3BELS3ATOV3CH3MAX
MS5AELS5BELS5ATOV5CH5MAX
= ReservedU = Unaffected
R
$002D
$002E
$002F
$0030
$0031
$0032
$0033
$0034
$0035
$0036
$0037
$0038
$0039
TIM Channel 2 Register High
(TCH2H)
See page 241.
TIM Channel 2 Register Low
(TCH2L)
See page 241.
TIM Channel 3 Status and
Control Register (TSC3)
See page 238.
TIM Channel 3 Register High
(TCH3H)
See page 241.
TIM Channel 3 Register Low
(TCH3L)
See page 241.
TIM Channel 4 Status and
Control Register (TSC4)
See page 238.
TIM Channel 4 Register High
(TCH4H)
See page 241.
TIM Channel 4 Register Low
(TCH4L)
See page 241.
TIM Channel 5 Status and
Control Register (TSC5)
See page 238.
TIM Channel 5 Register High
(TCH5H)
See page 241.
TIM Channel 5 Register Low
(TCH5L)
See page 241.
ADC Status and Control
Register (ADSCR)
See page 61.
ADC Data Register
See page 63.
Figure 2-2. I/O Data, Status and Control Registers (Sheet 5 of 6)
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor33
Memory
Addr.Register NameBit 7654321Bit 0
$003A
$003B
$003C
$003D
$003E
$003F
$0040
↓
$004A
ADC Input Clock Register
(ADICLK)
See page 63.
BDLC Analog and Roundtrip
Delay Register (BARD)
See page 83.
BDLC Control Register 1
(BCR1)
See page 84.
BDLC Control Register 2
(BCR2)
See page 86.
BDLC State Vector Register
(BSVR)
See page 90.
BDLC Data Register
(BDR)
See page 92.
ReservedRRRRRRRR
Read:
Write:
Reset:00000000
Read:
Write:RR
Reset:11000111
Read:
Write:RR
Reset:11100000
Read:
Write:
Reset:11000000
Read:0 0 I3I2I1I0 0 0
Write:RRRRRRRR
Reset:00000000
Read:
Write:
Reset:Unaffected by reset
ADIV2ADIV1ADIV0ADICLK
ATERXPOL
IMSGCLKSR1R0
ALOOPDLOOPRX4XENBFSTEODTSIFRTMIFR1TMIFR0
BD7BD6BD5BD4BD3BD2BD1BD0
00
0000
BO3BO2BO1BO0
00
IEWCM
$004B
$004C
$004D
$004E
$004F
PIT Status and Control
Register (PSC)
See page 145.
PIT Counter Register High
(PCNTH)
See page 146.
PIT Counter Register Low
(PCNTL)
See page 146.
PIT Counter Modulo Register
High (PMODH)
See page 147.
PIT Counter Modulo Register
Low (PMODL)
See page 147.
Figure 2-2. I/O Data, Status and Control Registers (Sheet 6 of 6)
Read:POF
Write:0PRST
Reset:00100000
Read:Bit 1514131211109Bit 8
Write:
Reset:00000000
Read:Bit 7654321Bit 0
Write:
Reset:00000000
Read:
Write:
Reset:11111111
Read:
Write:
Reset:11111111
Bit 1514131211109Bit 8
Bit 7654321Bit 0
POIEPSTOP
= Unimplemented
00
= ReservedU = Unaffected
R
PPS2PPS1PPS0
MC68HC908AS32A Data Sheet, Rev. 1
34Freescale Semiconductor
Vector Addresses and Priority
Addr.Register NameBit 7654321Bit 0
SIM Break Status Register
$FE00
SIM Reset Status Register
$FE01
$FE02ReservedRRRRRRRR
(SBSR)
See page 200.
(SRSR)
See page 200.
Read:
Write:See note
Reset:0
Read:PORPINCOPILOPILAD0LVI0
Write:
Reset:10000000
RRRRRR
Note: Writing a 0 clears BW
BW
R
$FE03
$FE09
$FE0C
$FE0D
$FE0E
$FE0F
$FE10
$FE11
$FE1A
$FE1B
SIM Break Flag Control Register
(SBFCR)
See page 201.
Configuration Write-Once
Register (CONFIG2)
See page 115.
Break Address Register High
(BRKH)
See page 246.
Break Address Register Low
(BRKL)
See page 246.
Break Status and Control
Register (BRKSCR)
See page 246.
LVI Status Register
(LVISR)
See page 140.
EEDIV High Nonvolatile
Register (EEDIVHNVR)
See page 46.
EEDIV Low Nonvolatile
Register (EEDIVLNVR)
See page 46.
EEDIV Timebase Divider High
Register (EEDIVH)
See page 46.
EEDIV Timebase Divider Low
Register (EEDIVL)
See page 47.
Read:
Write:
Reset:
Read:
Write:
Reset:00011000
Read:
Write:
Reset:00000000
Read:
Write:
Reset:00000000
Read:
Write:
Reset:00000000
Read:LVIOUT0000000
Write:
Reset:00000000
Read:
Write:
Reset:Unaffected by reset; $FF when blank
Read:
Write:
Reset:Unaffected by reset; $FF when blank
Read:
Write:
Reset:Contents of EEDIVHNVR ($FE10), Bits [6:3] = 0
Read:
Write:
Reset:Contents of EEDIVLNVR ($FE11)
BCFERRRRRRR
0
EEDIVCLKRRRAS32ARRR
Bit 1514131211109Bit 8
Bit 7654321Bit 0
BRKEBRKA
EEDIV
SECD
EEDIV7EEDIV6EEDIV5EEDIV4EEDIV3EEDIV2EEDIV1EEDIV0
EEDIV
SECD
EEDIV7EEDIV6EEDIV5EEDIV4EEDIV3EEDIV2EEDIV1EEDIV0
= Unimplemented
000000
EEDIV10EEDIV9EEDIV8
EEDIV10EEDIV9EEDIV8
= Reserved
R
Figure 2-3. Additional Status and Control Registers (Sheet 1 of 2)
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor35
Memory
Addr.Register NameBit 7654321Bit 0
Read:
Write:
Reset: Programmed value or 1 in the erased state
Read:
Write:
Reset:00000000
Read:
Write:
Reset:Contents of EENVR ($FE1C)
Read:
Write:
Reset:Unaffected by reset
Read:0000
Write:
Reset:00000000
BPR7BPR6BPR5BPR4BPR3BPR2BPR1BPR0
0
EEOFFEERAS1EERAS0EELATAUTOEEPGM
EEPRTCTEEBP3EEBP2EEBP1EEBP0
EEPRTCTEEBP3EEBP2EEBP1EEBP0
HVENVERFERASEPGM
$FE1C
$FE1D
$FE1F
$FF80
$FF88
EEPROM Nonvolatile Register
(EENVR)
See page 46.
EEPROM Control Register
(EECR)
See page 43.
EEPROM Array Configuration
Register (EEACR)
See page 44.
FLASH Block Protect Register
(FLBPR)
See page 50.
FLASH Control Register
(FLCR)
See page 49.
$FFFF
COP Control Register
(COPCTL)
See page 119.
Read:LOW BYTE OF RESET VECTOR
Write:WRITING TO $FFFF CLEARS COP COUNTER
Reset:Unaffected by reset
= Unimplemented
R
= Reserved
Figure 2-3. Additional Status and Control Registers (Sheet 2 of 2)
MC68HC908AS32A Data Sheet, Rev. 1
36Freescale Semiconductor
Table 2-1. Vector Addresses
Vector PriorityAddressVector
Lowest$FFDAPIT Vector (High)
$FFDBPIT Vector (Low)
$FFDCBDLC Vector (High)
$FFDDBDLC Vector (Low)
$FFDEADC Vector (High)
$FFDFADC Vector (Low)
$FFE0SCI Transmit Vector (High)
$FFE1SCI Transmit Vector (Low)
$FFE2SCI Receive Vector (High)
$FFE3SCI Receive Vector (Low)
$FFE4SCI Error Vector (High)
$FFE5SCI Error Vector (Low)
$FFE6SPI Transmit Vector (High)
$FFE7SPI Transmit Vector (Low)
$FFE8SPI Receive Vector (High)
$FFE9SPI Receive Vector (Low)
$FFEATIM Overflow Vector (High)
$FFEBTIM Overflow Vector (Low)
$FFECTIM Channel 5 Vector (High)
$FFEDTIM Channel 5 Vector (Low)
$FFEETIM Channel 4 Vector (High)
$FFEFTIM Channel 4 Vector (Low)
$FFF0TIM Channel 3 Vector (High)
$FFF1TIM Channel 3 Vector (Low)
$FFF2TIM Channel 2 Vector (High)
$FFF3TIM Channel 2 Vector (Low)
$FFF4TIM Channel 1 Vector (High)
$FFF5TIM Channel 1 Vector (Low)
$FFF6TIM Channel 0 Vector (High)
$FFF7TIM Channel 0 Vector (Low)
$FFF8PLL Vector (High)
$FFF9PLL Vector (Low)
$FFFAIRQ1 Vector (High)
$FFFBIRQ1 Vector (Low)
$FFFCSWI Vector (High)
$FFFDSWI Vector (Low)
$FFFEReset Vector (High)
Highest$FFFFReset Vector ( L ow)
Vector Addresses and Priority
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor37
Memory
2.7 Random-Access Memory (RAM)
The 1024 bytes of random-access memory (RAM) are located at address $0050–$044F is the RAM
location. The 16-bit stack pointer allows the stack RAM to be anywhere in the 64 Kbyte memory space.
NOTE
For correct operation, the stack pointer must point only to RAM locations.
Within page zero are 176 bytes of RAM. Because the location of the stack RAM is programmable, all page
zero RAM locations can be used for I/O control and user data or code. When the stack pointer is moved
from its reset location at $00FF, direct addressing mode instructions can access all page zero RAM
locations efficiently. Therefore, page zero RAM provides ideal locations for frequently accessed global
variables.
Before processing an interrupt, the CPU uses five bytes of the stack to save the contents of the CPU
registers.
NOTE
For M68HC05, M6805, and M146805 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 could overwrite data
in the RAM during a subroutine or during the interrupt stacking operation.
This subsection describes the 512 bytes of electrically erasable programmable read-only memory
(EEPROM) residing at address range $0800–$09FF.
Features include:
•512 bytes nonvolatile memory
•Byte, block, or bulk erasable
•Nonvolatile EEPROM configuration and block protection options
•On-chip charge pump for programming/erasing
•Security option
•AUTO bit driven programming/erasing time feature
2.8.1 Functional Description
The 512 bytes of EEPROM are located at $0800–$09FF and can be programmed or erased without an
additional external high voltage supply. The program and erase operations are enabled through the use
of an internal charge pump. For each byte of EEPROM, the write/erase endurance is 10,000 cycles.
1. No security feature is absolutely secure. However, Freescale’s strategy is to make reading or copying the EEPROM difficult
for unauthorized users.
The 8-bit EEPROM nonvolatile register (EENVR) and the 16-bit EEPROM timebase divider nonvolatile
register (EEDIVNVR) contain the default settings for the following EEPROM configurations:
•EEPROM timebase reference
•EEPROM security option
•EEPROM block protection
EENVR and EEDIVNVR are nonvolatile EEPROM registers that are programmed and erased in the same
way as EEPROM bytes. The contents of these registers are loaded into their respective volatile registers
during a MCU reset. The values in these read/write volatile registers define the EEPROM configurations.
•For EENVR, the corresponding volatile register is the EEPROM array configuration register
(EEACR).
•For the EEDIVNCR (two 8-bit registers: EEDIVHNVR and EEDIVLNVR), the corresponding volatile
register is the EEPROM divider register (EEDIV: EEDIVH and EEDIVL).
2.8.1.2 EEPROM Timebase Requirements
A 35 µs timebase is required by the EEPROM control circuit for program and erase of EEPROM content.
This timebase is derived from dividing the CGMXCLK or bus clock (selected by EEDIVCLK bit in
CONFIG2 register) using a timebase divider circuit controlled by the 16-bit EEPROM timebase divider
EEDIV register (EEDIVH and EEDIVL).
As the CGMXCLK or bus clock is user selected, the EEPROM timebase divider register must be
configured with the appropriate value to obtain the 35 µs. The timebase divider value is calculated by
using the following formula:
EEDIV= INT[Reference Frequency(Hz) x 35 x10
–6
+0.5]
This value is written to the EEPROM timebase divider register (EEDIVH and EEDIVL) or programmed into
the EEPROM timebase divider nonvolatile register prior to any EEPROM program or erase operations
(see 2.8.1.1 EEPROM Configuration and 2.8.1.2 EEPROM Timebase Requirements).
2.8.1.3 EEPROM Program/Erase Protection
The EEPROM has a special feature that designates the 16 bytes of addresses from $08F0–$08FF to be
permanently secured. This program/erase protect option is enabled by programming the EEPRTCT bit in
the EEPROM nonvolatile register to a 0.
Once the EEPRTCT bit is programmed to 0 for the first time:
•Programming and erasing of secured locations $08F0–$08FF is permanently disabled.
•Secured locations $08F0–$08FF can be read as normal.
•Programming and erasing of EENVR is permanently disabled.
•Bulk and block erase operations are disabled for the unprotected locations $0800–$08EF and
$0900–$09FF.
•Single byte program and erase operations are still available for locations $0800–$08EF and
$0900–$09FF for all bytes that are not protected by the EEPROM block protect EEBPx bits (see
2.8.1.4 EEPROM Block Protection and 2.8.2.2 EEPROM Array Configuration Register)
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor39
Memory
NOTE
Once armed, the protect option is permanently enabled. As a consequence,
all functions in the EENVR will remain in the state they were in immediately
before the security was enabled.
2.8.1.4 EEPROM Block Protection
The 512 bytes of EEPROM are divided into four 128-byte blocks. Each of these blocks can be protected
from erase/program operations by setting the EEBPx bit in the EENVR. Table 2-2 shows the address
ranges for the blocks.
Table 2-2. EEPROM Array Address Blocks
Block Number (EEBPx)Address Range
EEBP0$0800–$087F
EEBP1$0880–$08FF
EEBP2$0900–$097F
EEBP3$0980–$09FF
These bits are effective after a reset or a upon read of the EENVR register. The block protect configuration
can be modified by erasing/programming the corresponding bits in the EENVR register and then reading
the EENVR register. See 2.8.2.2 EEPROM Array Configuration Register for more information.
NOTE
Once EEDIVSECD in the EEDIVHNVR is programmed to 0 and after a
system reset, the EEDIV security feature is permanently enabled because
the EEDIVSECD bit in the EEDIVH is always loaded with 0s thereafter.
Once this security feature is armed, erase and program mode are disabled
for EEDIVHNVR and EEDIVLNVR. Modifications to the EEDIVH and
EEDIVL registers are also disabled. Therefore, be cautious on
programming a value into the EEDIVHNVR.
2.8.1.5 EEPROM Programming and Erasing
The unprogrammed or erase state of an EEPROM bit is a 1. The factory default for all bytes within the
EEPROM array is $FF.
The programming operation changes an EEPROM bit from 1 to 0 (programming cannot change a bit from
0 to a 1). In a single programming operation, the minimum EEPROM programming size is one bit; the
maximum is eight bits (one byte).
The erase operation changes an EEPROM bit from 0 to 1. In a single erase operation, the minimum
EEPROM erase size is one byte; the maximum is the entire EEPROM array.
The EEPROM can be programmed such that one or multiple bits are programmed (written to a 0) at a
time. However, the user may never program the same bit location more than once before erasing the
entire byte. In other words, the user is not allowed to program a 0 to a bit that is already programmed (bit
state is already 0).
For some applications it might be advantageous to track more than 10K events with a single byte of
EEPROM by programming one bit at a time. For that purpose, a special selective bit programming
technique is available. An example of this technique is illustrated in Table 2-3.
Table 2-3. Example Selective Bit Programming Description
Description
Original state of byte (erased)N/A1111:1111
First event is recorded by programming bit position 01111:11101111:1110
Second event is recorded by programming bit position 11111:11011111:1100
Third event is recorded by programming bit position 21111:10111111:1000
Fourth event is recorded by programming bit position 31111:01111111:0000
Events five through eight are recorded in a similar fashion
Program Data
in Binary
Result
in Binary
NOTE
None of the bit locations are actually programmed more than once although
the byte was programmed eight times.
When this technique is utilized, a program/erase cycle is defined as multiple program sequences (up to
eight) to a unique location followed by a single erase operation.
2.8.1.6 Program/Erase Using AUTO Bit
An additional feature available for EEPROM program and erase operations is the AUTO mode. When
enabled, AUTO mode will activate an internal timer that will automatically terminate the program/erase
cycle and clear the EEPGM bit. See 2.8.1.7 EEPROM Programming, 2.8.1.8 EEPROM Erasing, and
2.8.2.1 EEPROM Control Register for more information.
2.8.1.7 EEPROM Programming
The unprogrammed or erase state of an EEPROM bit is a 1. Programming changes the state to a 0. Only
EEPROM bytes in the non-protected blocks and the EENVR register can be programmed.
Use the following procedure to program a byte of EEPROM:
1.Clear EERAS1 and EERAS0 and set EELAT in the EECR.
(A)
NOTE
If using the AUTO mode, also set the AUTO bit during step 1.
2.Write the desired data to the desired EEPROM address.
EEPGM
(C)
Go to step 7 if AUTO is set.
, to program the byte.
3.Set the EEPGM bit.
4.Wait for time, t
(B)
5.Clear EEPGM bit.
6.Wait for time, t
7.Poll the EEPGM bit until it is cleared by the internal timer.
8.Clear EELAT bits.
, for the programming voltage to fall. Go to step 8.
EEFPV
(E)
(D)
NOTE
A. EERAS1 and EERAS0 must be cleared for programming. Setting the
EELAT bit configures the address and data buses to latch data for
programming the array. Only data with a valid EEPROM address will be
latched. If EELAT is set, other writes to the EECR will be allowed after a
valid EEPROM write.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor41
Memory
B. If more than one valid EEPROM write occurs, the last address and data
will be latched overriding the previous address and data. Once data is
written to the desired address, do not read EEPROM locations other than
the written location. (Reading an EEPROM location returns the latched data
and causes the read address to be latched).
C. The EEPGM bit cannot be set if the EELAT bit is cleared or a non-valid
EEPROM address is latched. This is to ensure proper programming
sequence. Once EEPGM is set, do not read any EEPROM locations;
otherwise, the current program cycle will be unsuccessful. When EEPGM
is set, the on-board programming sequence will be activated.
D. The delay time for the EEPGM bit to be cleared in AUTO mode is less
than t
EEPGM
For forward compatibility, software should not make any dependency on
this delay time.
E. Any attempt to clear both EEPGM and EELAT bits with a single
instruction will only clear EEPGM. This is to allow time for removal of high
voltage from the EEPROM array.
2.8.1.8 EEPROM Erasing
. However, on other MCUs, this delay time may be different.
The programmed state of an EEPROM bit is a 0. Erasing changes the state to a 1. Only EEPROM bytes
in the non-protected blocks and the EENVR register can be erased.
Use the following procedure to erase a byte, block, or the entire EEPROM array:
1.Configure EERAS1 and EERAS0 for byte, block, or bulk erase; set EELAT in EECR.
(A)
NOTE
If using the AUTO mode, also set the AUTO bit in step 1.
2.Byte erase — write any data to the desired address.
Block erase — write any data to an address within the desired block.
Bulk erase — write any data to an address within the array.
3.Set the EEPGM bit.
4.Wait for a time: t
(C)
Go to Step 7 if AUTO is set.
EEBYTE
for byte erase; t
EEBLOCK
(B)
(B)
for block erase; t
(B)
EEBULK.
for bulk erase.
5.Clear EEPGM bit.
6.Wait for a time, t
7.Poll the EEPGM bit until it is cleared by the internal timer.
8.Clear EELAT bits.
, for the erasing voltage to fall. Go to Step 8.
EEFPV
(E)
(D)
NOTE
A. Setting the EELAT bit configures the address and data buses to latch
data for erasing the array. Only valid EEPROM addresses will be latched.
If EELAT is set, other writes to the EECR will be allowed after a valid
EEPROM write.
B. If more than one valid EEPROM write occurs, the last address and data
will be latched overriding the previous address and data. Once data is
written to the desired address, do not read EEPROM locations other than
the written location. (Reading an EEPROM location returns the latched data
and causes the read address to be latched).
C. The EEPGM bit cannot be set if the EELAT bit is cleared or a non-valid
EEPROM address is latched. This is to ensure proper programming
sequence. Once EEPGM is set, do not read any EEPROM locations;
otherwise, the current program cycle will be unsuccessful. When EEPGM
is set, the on-board programming sequence will be activated.
D. The delay time for the EEPGM bit to be cleared in AUTO mode is less
than t
EEBYTE /tEEBLOCK/tEEBULK
. However, on other MCUs, this delay time
may be different. For forward compatibility, software should not make any
dependency on this delay time.
E. Any attempt to clear both EEPGM and EELAT bits with a single
instruction will only clear EEPGM. This is to allow time for removal of high
voltage from the EEPROM array.
2.8.2 EEPROM Register Descriptions
Four I/O registers and three nonvolatile registers control program, erase, and options of the EEPROM
array.
2.8.2.1 EEPROM Control Register
This read/write register controls programming/erasing of the array.
Address:$FE1D
Bit 7654321Bit 0
Read:
UNUSED
Write:
Reset:00000000
0
= Unimplemented
EEOFFEERAS1EERAS0EELATAUTOEEPGM
Figure 2-4. EEPROM Control Register (EECR)
Bit 7— Unused Bit
This read/write bit is software programmable but has no functionality.
EEOFF — EEPROM Power Down
This read/write bit disables the EEPROM module for lower power consumption. Any attempts to
access the array will give unpredictable results. Reset clears this bit.
1 = Disable EEPROM array
0 = Enable EEPROM array
EERAS1 and EERAS0 — Erase/Program Mode Select Bits
These read/write bits set the erase modes. Reset clears these bits.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor43
Memory
Table 2-4. EEPROM Program/Erase Mode Select
EEBPxEERAS1EERAS0Mode
000Byte program
001Byte erase
010Block erase
011Bulk erase
1XXNo erase/program
X = don’t care
EELAT — EEPROM Latch Control
This read/write bit latches the address and data buses for programming the EEPROM array. EELAT
cannot be cleared if EEPGM is still set. Reset clears this bit.
1 = Buses configured for EEPROM programming or erase operation
0 = Buses configured for normal operation
AUTO — Automatic Termination of Program/Erase Cycle
When AUTO is set, EEPGM is cleared automatically after the program/erase cycle is terminated by
the internal timer. See note D for 2.8.1.7 EEPROM Programming, 2.8.1.8 EEPROM Erasing, and
19.11.2 EEPROM Memory Characteristics.
1 = Automatic clear of EEPGM is enabled
0 = Automatic clear of EEPGM is disabled
EEPGM — EEPROM Program/Erase Enable
This read/write bit enables the internal charge pump and applies the programming/erasing voltage to
the EEPROM array if the EELAT bit is set and a write to a valid EEPROM location has occurred. Reset
clears the EEPGM bit.
1 = EEPROM programming/erasing power switched on
0 = EEPROM programming/erasing power switched off
NOTE
Writing 0s to both the EELAT and EEPGM bits with a single instruction will
clear EEPGM only to allow time for the removal of high voltage.
2.8.2.2 EEPROM Array Configuration Register
The EEPROM array configuration register configures EEPROM security and EEPROM block protection.
This read-only register is loaded with the contents of the EEPROM nonvolatile register (EENVR) after a
reset.
This feature is a write-once feature. Once the protection is enabled it may
not be disabled.
EEBP[3:0] — EEPROM Block Protection Bits
These bits prevent blocks of EEPROM array from being programmed or erased.
1 = EEPROM array block is protected
0 = EEPROM array block is unprotected
Block Number (EEBPx)Address Range
EEBP0$0800–$087F
EEBP1$0880–$08FF
EEBP2$0900–$097F
EEBP3$0980–$09FF
Table 2-5. EEPROM Block Protect and Security Summary
Address RangeEEBPxEEPRTCT = 1EEPRTCT = 0
$0800–$087F
$0880–$08EF
$08F0–$08FF
$0900– $097F
$0980–$09FF
Byte programming available
EEBP0 = 0
EEBP0 = 1ProtectedProtected
EEBP1 = 0
EEBP1 = 1ProtectedProtected
EEBP1 = 0
EEBP1 = 1Protected
EEBP2 = 0
EEBP2 = 1ProtectedProtected
EEBP3 = 0
bulk, block, and byte
erasing available
Byte programming available
bulk, block, and byte
erasing available
Byte programming available
bulk, block, and byte
erasing available
Byte programming available
bulk, block, and byte
erasing available
Byte programming available
bulk, block, and byte
erasing available
Byte programming available
only byte erasing available
Byte programming available
only byte erasing available
Secured
(no programming
or erasing)
Byte programming available
only byte erasing available
Byte programming available
only byte erasing available
EEBP3 = 1ProtectedProtected
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor45
Memory
2.8.2.3 EEPROM Nonvolatile Register
The contents of this register is loaded into the EEPROM array configuration register (EEACR) after a
reset. This register is erased and programmed in the same way as an EEPROM byte. (See 2.8.2.1
EEPROM Control Register for individual bit descriptions).
Address:$FE1C
Bit 7654321Bit 0
Read:
UNUSEDUNUSEDUNUSEDEEPRTCTEEBP3EEBP2EEBP1EEBP0
Write:
Reset:PV
PV = Programmed value or 1 in the erased state.
Figure 2-6. EEPROM Nonvolatile Register (EENVR)
NOTE
The EENVR will leave the factory programmed with $F0 such that the full
array is available and unprotected.
2.8.2.4 EEPROM Timebase Divider Register
The 16-bit EEPROM timebase divider register consists of two 8-bit registers: EEDIVH and EEDIVL. The
11-bit value in this register is used to configure the timebase divider circuit to obtain the 35 µs timebase
for EEPROM control. These two read/write registers are respectively loaded with the contents of the
EEPROM timebase divider nonvolatile registers (EEDIVHNVR and EEDIVLNVR) after a reset.
Address:$FE1A
Bit 7654321Bit 0
Read:
Write:
Reset:Contents of EEDIVHNVR ($FE10), Bits [6:3] = 0
EEDIV
SECD
0000
EEDIV10EEDIV9EEDIV8
= Unimplemented
Figure 2-7. EEDIV Divider High Register (EEDIVH)
Address:$FE1B
Bit 7654321Bit 0
Read:
Write:
Reset:Contents of EEDIVLNVR ($FE11)
EEDIV7EEDIV6EEDIV5EEDIV4EEDIV3EEDIV2EEDIV1EEDIV0
Figure 2-8. EEDIV Divider Low Register (EEDIVL)
EEDIVSECD — EEPROM Divider Security Disable
This bit enables/disables the security feature of the EEDIV registers. When EEDIV security feature is
enabled, the state of the registers EEDIVH and EEDIVL are locked (including EEDIVSECD bit). The
EEDIVHNVR and EEDIVLNVR nonvolatile memory registers are also protected from being
erased/programmed.
These prescaler bits store the value of EEDIV which is used as the divisor to derive a timebase of 35
µs from the selected reference clock source (CGMXCLK or bus block in the CONFIG2 register) for the
EEPROM related internal timer and circuits. EEDIV[10:0] bits are readable at any time. They are
writable when EELAT = 0 and EEDIVSECD = 1.
The EEDIV value is calculated by the following formula:
–6
EEDIV= INT[Reference Frequency(Hz) x 35 x10
+0.5]
Where the result inside the bracket is rounded down to the nearest integer value
For example, if the reference frequency is 4.9152 MHz, the EEDIV value is 172
NOTE
Programming/erasing the EEPROM with an improper EEDIV value may
result in data lost and reduce endurance of the EEPROM device.
The 16-bit EEPROM timebase divider nonvolatile register consists of two 8-bit registers: EEDIVHNVR
and EEDIVLNVR. The contents of these two registers are respectively loaded into the EEPROM timebase
divider registers, EEDIVH and EEDIVL, after a reset. These two registers are erased and programmed in
the same way as an EEPROM byte.
Address:$FE10
Bit 7654321Bit 0
Read:
Write:
Reset:Unaffected by reset; $FF when blank
EEDIVS-
ECD
R=Reserved
RRRREEDIV10EEDIV9EEDIV8
Figure 2-9. EEPROM Divider Nonvolatile Register High (EEDIVHNVR))
These two registers are protected from erase and program operations if EEDIVSECD is set to 1 in
EEDIVH (see 2.8.2.4 EEPROM Timebase Divider Register) or programmed to a 1 in the EEDIVHNVR.
NOTE
Once EEDIVSECD in the EEDIVHNVR is programmed to 0 and after a
system reset, the EEDIV security feature is permanently enabled because
the EEDIVSECD bit in the EEDIVH is always loaded with 0s thereafter.
Once this security feature is armed, erase and program mode are disabled
for EEDIVHNVR and EEDIVLNVR. Modifications to the EEDIVH and
EEDIVL registers are also disabled. Therefore, care should be taken before
programming a value into the EEDIVHNVR.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor47
Memory
2.8.3 Low-Power Modes
The WAIT and STOP instructions can put the MCU in low power-consumption standby modes.
2.8.3.1 Wait Mode
The WAIT instruction does not affect the EEPROM. It is possible to start the program or erase sequence
on the EEPROM and put the MCU in wait mode.
2.8.3.2 Stop Mode
The STOP instruction reduces the EEPROM power consumption to a minimum. The STOP instruction
should not be executed while a programming or erasing sequence is in progress.
If stop mode is entered while EELAT and EEPGM are set, the programming sequence will be stopped
and the programming voltage to the EEPROM array removed. The programming sequence will be
restarted after leaving stop mode; access to the EEPROM is only possible after the programming
sequence has completed.
If stop mode is entered while EELAT and EEPGM is cleared, the programming sequence will be
terminated abruptly.
In either case, the data integrity of the EEPROM is not guaranteed.
2.9 FLASH Memory (FLASH)
This subsection describes the operation of the embedded FLASH memory. This memory can be read,
programmed, and erased from a single external supply. The program and erase operations are enabled
through the use of an internal charge pump.
The FLASH memory is an array of 32,256 bytes with one byte of block protection and an additional 38
bytes of user vectors. An erased bit reads as a 1 and a programmed bit reads as a 0.
Memory in the FLASH array is organized into rows within pages. There are two rows of memory per page
with 64 bytes per row. The minimum erase block size is a single page,128 bytes. Programming is
performed on a per-row basis, 64 bytes at a time. Program and erase operations are facilitated through
control bits in the FLASH control register (FLCR). Details for these operations appear later. The FLASH
memory map consists of:
•$8000–$FDFF — user memory (32,256 bytes)
•$FF80 — FLASH block protect register (FLBPR)
•$FF88 — FLASH control register (FLCR)
•$FFCC–$FFFF — these locations are reserved for user-defined interrupt and reset vectors
Programming tools are available from Freescale. Contact your local Freescale representative for more
information.
NOTE
A security feature prevents viewing of the FLASH contents.
(1)
1. No security feature is absolutely secure. However, Freescale’s strategy is to make reading or copying the FLASH difficult for
unauthorized users.
MC68HC908AS32A Data Sheet, Rev. 1
48Freescale Semiconductor
FLASH Memory (FLASH)
2.9.1 FLASH Control and Block Protect Registers
The FLASH array has two registers that control its operation, the FLASH control register (FLCR) and the
FLASH bock protect register (FLBPR).
2.9.1.1 FLASH Control Register
The FLASH control register (FLCR) controls FLASH program and erase operations.
Address: $FF88
Bit 7654321Bit 0
Read:0000
Write:
Reset:00000000
= Unimplemented
HVENMASSERASEPGM
Figure 2-11. 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 FLASH array for mass or page 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 set 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
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor49
Memory
2.9.1.2 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 FLASH programming sequence. The value in this register
determines the starting location of the protected range within the FLASH memory.
Address:$FF80
Bit 7654321Bit 0
Read:
Write:
Reset:UUUUUUUU
U = Unaffected by reset. Initial value from factory is 1.
Write to this register is by a programming sequence to the FLASH memory.
BPR7BPR6BPR5BPR4BPR3BPR2BPR1BPR0
Figure 2-12. FLASH Block Protect Register (FLBPR)
FLBPR[7:0] — Block Protect Register Bits [7:0]
These eight bits represent bits [14:7] of a 16-bit memory address. Bit 15 is 1 and bits [6:0] are 0s.
The resultant 16-bit address is used for specifying the start address of the FLASH memory for block
protection. 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 and $XX80 (128 byte page boundaries) within
the FLASH array.
START ADDRESS OF
FLASH BLOCK PROTECT
FLBPR VALUE
0
00011
0
0
Figure 2-13. FLASH Block Protect Start Address
Decreasing the value in FLBPR by one increases the protected range by one page (128 bytes). However,
programming the block protect register with $FE protects a range twice that size, 256 bytes, in the
corresponding array. $FE means that locations $FF00–$FFFF are protected in FLASH. See Table 2-6.
The FLASH memory does not exist at some locations. The block protection range configuration is
unaffected if FLASH memory does not exist in that range. Refer to the memory map (Figure 2-1) and
make sure that the desired locations are protected.
MC68HC908AS32A Data Sheet, Rev. 1
50Freescale Semiconductor
Table 2-6. FLASH Protected Ranges
FLBPR[7:0]Protected Range
$FFNo Protection
$FE$FF00 – $FFFF
$FD$FE80 – $FFFF
$0B$8580 – $FFFF
$0A$8500 – $FFFF
$09$8480 – $FFFF
$08$8400 – $FFFF
$04$8200 – $FFFF
$03$8180 – $FFFF
$02$8100 – $FFFF
$01$8080 – $FFFF
$00$8000 – $FFFF
FLASH Memory (FLASH)
2.9.2 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 blocks of memory from unintentional erase or program
operations due to system malfunction. This protection is done by using the FLASH block protection
register (FLBPR). 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 can not be set in either ERASE or
PROGRAM operations.
NOTE
In performing a program or erase operation, FLBPR must be read after
setting the PGM or ERASE bit and before asserting the HVEN bit.
When the FLBPR is programmed with all 0s, the entire memory is protected from being programmed and
erased. When all the bits are erased (all 1s), the entire memory is accessible for program and erase.
When bits within FLBPR are programmed (0s), they lock a block of memory address ranges as shown in
2.9.1.2 FLASH Block Protect Register. If FLBPR is programmed with any value other than $FF, the
protected block of FLASH memory can not be erased or programmed.
NOTE
The vector locations and the FLBPR are located in the same page. FLBPR
is not protected with special hardware or software; therefore, if this page is
not protected by FLBPR and the vector locations are erased by either a
page or a mass erase operation, FLBPR will also be erased.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor51
Memory
2.9.3 FLASH Page Erase Operation
Use this step-by-step procedure to erase a page (128 bytes) of FLASH memory to read as a 1:
1.Set the ERASE bit and clear the MASS bit in the FLASH control register.
2.Read the FLASH block protect register.
3.Write any data to any FLASH location within the address range of the block to be erased.
4.Wait for a time, t
5.Set the HVEN bit.
6.Wait for a time, t
7.Clear the ERASE bit.
8.Wait for a time, t
9.Clear the HVEN bit.
10.After time, t
RCV
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.
A page erase of the vector page will erase the internal oscillator trim value at $FFC0.
(minimum10 µs).
NVS
(minimum 1 ms or 4 ms).
Erase
(minimum5 µs).
NVH
(typical1 µs), the memory can be accessed in read mode again.
NOTE
CAUTION
In applications that require more than 1000 program/erase cycles, use the 4 ms page erase specification
to get improved long-term reliability. Any application can use this 4 ms page erase specification. However,
in applications where a FLASH location will be erased and reprogrammed less than 1000 times, and
speed is important, use the 1 ms page erase specification to get a shorter cycle time.
MC68HC908AS32A Data Sheet, Rev. 1
52Freescale Semiconductor
2.9.4 FLASH Mass Erase Operation
Use this step-by-step procedure to erase the entire FLASH memory to read as a 1:
1.Set both the ERASE bit and the MASS bit in the FLASH control register.
2.Read the FLASH block protect register.
3.Write any data to any FLASH address
4.Wait for a time, t
(minimum10 µs).
NVS
5.Set the HVEN bit.
6.Wait for a time, t
(minimum4 ms).
MErase
7.Clear the ERASE and MASS bits.
Mass erase is disabled whenever any block is protected (FLBPR does not
equal $FF).
(1)
within the FLASH memory address range.
NOTE
FLASH Memory (FLASH)
8.Wait for a time, t
(minimum100 µs).
NVHL
9.Clear the HVEN bit.
10.After time, t
(typical1 µs), the memory can be accessed in read mode again.
RCV
NOTE
A. Programming and erasing of FLASH locations can not be performed by
code being executed from the same FLASH array.
B. While these operations must be performed in the order shown, other
unrelated operations may occur between the steps. However, care must be
taken to ensure that these operations do not access any address within the
FLASH array memory space such as the COP control register at $FFFF.
C. It is highly recommended that interrupts be disabled during
program/erase operations.
2.9.5 FLASH Program Operation
Programming of the FLASH memory is done on a row basis. A row consists of 64 consecutive bytes with
address ranges as follows:
•$XX00 to $XX3F
•$XX40 to $XX7F
•$XX80 to $XXBF
•$XXC0 to $XXFF
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.
NOTE
1. When in monitor mode, with security sequence failed (see 18.3.2 Security), write to the FLASH block protect register instead of any FLASH address.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor53
Memory
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 the FLASH block protect register.
3.Write any data to any FLASH location within the address range desired.
4.Wait for a time, t
(minimum10 µs).
NVS
5.Set the HVEN bit.
6.Wait for a time, t
7.Write data to the FLASH address being programmed
8.Wait for time, t
(minimum5 µs).
PGS
(minimum30 µs).
PROG
(1)
.
9.Repeat step 7 and 8 until all desired bytes within the row are programmed.
10.Clear the PGM bit
11.Wait for time, t
(1)
.
(minimum5 µs).
NVH
12.Clear the HVEN bit.
13.After time, t
(typical1 µs), the memory can be accessed in read mode again.
RCV
The FLASH programming algorithm flowchart is shown in Figure 2-14.
NOTE
A. Programming and erasing of FLASH locations can not be performed by
code being executed from the same FLASH array.
B. While these operations must be performed in the order shown, other
unrelated operations may occur between the steps. However, care must be
taken to ensure that these operations do not access any address within the
FLASH array memory space such as the COP control register at $FFFF.
C. It is highly recommended that interrupts be disabled during
program/erase operations.
D. Do not exceed t
PROG
maximum or t
maximum. t
HV
is defined as the
HV
cumulative high voltage programming time to the same row before next
erase. t
must satisfy this condition: t
HV
NVS
+ t
NVH
+ t
PGS
+ (t
PROG
X 64) ≤ t
HV
max. Please also see 19.11.3 FLASH Memory Characteristics.
E. The time between each FLASH address change (step 7 to step 7), or the
time between the last FLASH address programmed to clearing the PGM bit
(step 7 to step 10) must not exceed t
PROG
maximum.
F. 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 $FFDA–$FFFF (38 bytes)
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
MC68HC908AS32A Data Sheet, Rev. 1
54Freescale Semiconductor
PROG
maximum.
Algorithm for Programming
a Row (64 Bytes) of FLASH Memory
FLASH Memory (FLASH)
1
SET PGM BIT
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
WAIT FOR A TIME, t
SET HVEN BIT
WAIT FOR A TIME, t
WRITE DATA TO THE FLASH ADDRESS
TO BE PROGRAMMED
8
WAIT FOR A TIME, t
NVS
PGS
PROG
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
PROG
maximum.
time, t
This row program algorithm assumes the row/s
to be programmed are initially erased.
The WAIT and STOP instructions will place the MCU in low power-consumption standby modes.
2.9.6.1 Wait Mode
Putting the MCU into wait mode while the FLASH is in read mode does not affect the operation of the
FLASH memory directly; however, no memory activity will take place since the CPU is inactive.
The WAIT instruction should not be executed while performing a program or erase operation on the
FLASH. Wait mode will suspend any FLASH program/erase operations and leave the memory in a
standby mode.
2.9.6.2 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; however, no memory activity will take place since the CPU is inactive.
The STOP instruction should not be executed while performing a program or erase operation on the
FLASH. Stop mode will suspend any FLASH program/erase operations and leave the memory in a
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 minimum.
MC68HC908AS32A Data Sheet, Rev. 1
56Freescale Semiconductor
Chapter 3
Analog-to-Digital Converter (ADC)
3.1 Introduction
This section describes the analog-to-digital converter (ADC). The ADC is an 8-bit analog-to-digital
converter.
For further information regarding analog-to-digital converters on Freescale microcontrollers, please
consult the HC08 ADC Reference Manual, Freescale document order number ADCRM/AD.
3.2 Features
Features include:
•15 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
Fifteen ADC channels are available for sampling external sources at pins
PTD6/ATD14/TACLK
single ADC converter to select one of 15 ADC channels as ADC voltage in (ADCVIN). ADCVIN is
converted by the successive approximation register-based counters. When the conversion is completed,
ADC places the result in the ADC data register and sets a flag or generates an interrupt. See Figure 3-2.
3.3.1 ADC Port I/O Pins
PTD6/ATD14/TACLK–PTD0/ATD8 and PTB7/ATD7–PTB0/ATD0 are general- purpose I/O pins that
share with the ADC channels.
The channel select bits define which ADC channel/port pin will be used as the input signal. The ADC
overrides the port I/O logic by forcing that pin as input to the ADC. The remaining ADC channels/port pins
are controlled by the port I/O logic and can be used as general-purpose I/O. Writes to the port register or
DDR will not have any affect on the port pin that is selected by the ADC. Read of a port pin which is in
use by the ADC will return a 0 if the corresponding DDR bit is at 0. If the DDR bit is at 1, the value in the
port data latch is read.
Do not use ADC channels ATD14 or ATD12 when using the
PTD6/ATD14/TACLK or PTD4/ATD12/TBCLK
the 16-bit timers.
–PTD0/ATD8 and PTB7/ATD7–PTB0/ATD0. An analog multiplexer allows the
NOTE
pins as the clock inputs for
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor57
Analog-to-Digital Converter (ADC)
M68HC08 CPU
CPU
REGISTERS
CONTROL AND STATUS REGISTERS
USER FLASH — 32, 256 BYTES
USER RAM — 1024 BYTES
USER EEPROM — 512 BYTES
MONITOR ROM — 256 BYTES
USER FLASH VECTOR SPACE — 52 BYTES
OSC1
OSC2
CGMXFC
RST
IRQ
ARITHMETIC/LOGIC
UNIT (ALU)
CLOCK GENERATOR
MODULE
SYSTEM INTEGRATION
MODULE
IRQ MODULE
V
REFH
ANALOG-TO-DIGITAL
MODULE
BREAK MODULE
LOW-VOLTAGE INHIBIT
MODULE
COMPUTER OPERATING
PROPERLY MODULE
6-CHANNEL TIMER
INTERFACE MODULE
PROGRAMMABLE INTERRUPT
TIMER MODULE
SERIAL COMMUNICATIONS
INTERFACE MODULE
SERIAL PERIPHERAL
INTERFACE MODULE
BYTE DATA LINK CONTROLLER
DDRA
DDRB
DDRC
DDRD
DDRE
DDRF
PTA
PTB
PTC
PTD
PTE
PTF
PTA7–PTA0
PTB7/ATD7–
PTB0/ATD0
PTC4
PTC3
PTC2/MCLK
PTC1–PTC0
PTD6/ATD14/TCLK
PTD5/ATD13
PTA4/ATD12
PTD3/ATD11–
PTD0/ATD8
PTE7/SPSCK
PTE6/MOSI
PTE5/MISO
PTE4/SS
PTE3/TCH1
PTE2/TCH0
PTE1/RxD
PTE0/TxD
PTF3/TCH5–
PTF0/TCH2
POWER-ON RESET
MODULE
V
SS
V
DD
V
DDA
V
SSA
POWER
BDRxDBDTxD
AVSS/V
REFK
V
DDAREF
Figure 3-1. Block Diagram Highlighting ADC Block and Pins
3.3.2 Voltage Conversion
When the input voltage to the ADC equals V
Characteristics), the ADC converts the signal to $FF (full scale). If the input voltage equals V
converts it to $00. Input voltages between V
Conversion accuracy of all other input voltages is not guaranteed. Avoid current injection on unused ADC
inputs to prevent potential conversion error.
Input voltage should not exceed the analog supply voltages.
(see 19.7 Analog-to-Digital Converter (ADC)
REFH
REFH
and V
are a straight-line linear conversion.
SSA
NOTE
SSA,
the ADC
MC68HC908AS32A Data Sheet, Rev. 1
58Freescale Semiconductor
INTERNAL DATA BUS
READ DDRB/DDRB
Functional Description
WRITE DDRB/DDRD
WRITE PTB/PTD
READ PTB/PTD
INTERRUPT
LOGIC
AIENCOCO
BUS CLOCK
CONVERSION
COMPLETE
CGMXCLK
RESET
DDRBx/DDRDx
PTBx/PTDx
ADC DATA REGISTER
ADC
ADC CLOCK
CLOCK
GENERATOR
ADC VOLTAGE IN
(ADCVIN)
DISABLE
DISABLE
ADC CHANNEL x
CHANNEL
SELECT
PTBx/PTDx
ADCH[4:0]
ADIV[2:0]ADICLK
Figure 3-2. ADC Block Diagram
3.3.3 Conversion Time
Conversion starts after a write to the ADSCR (ADC status control register, $0038), and requires between
16 and 17 ADC clock cycles to complete. Conversion time in terms of the number of bus cycles is a
function of ADICLK select, CGMXCLK frequency, bus frequency, and ADIV prescaler bits. For example,
with a CGMXCLK frequency of 4 MHz, bus frequency of 8 MHz, and fixed ADC clock frequency of 1 MHz,
one conversion will take between 16 and 17 µs and there will be between 128 bus cycles between each
conversion. Sample rate is approximately 60 kHz.
Refer to 19.7 Analog-to-Digital Converter (ADC) Characteristics.
Conversion Time = ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
16 to 17 ADC Clock Cycles
ADC Clock Frequency
Number of Bus Cycles = Conversion Time x Bus Frequency
3.3.4 Continuous Conversion
In the 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.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor59
Analog-to-Digital Converter (ADC)
Conversions will continue until the ADCO bit (ADC status control register, $0038) is cleared. The COCO
bit is set after the first conversion and will stay set for the next several conversions until the next write of
the ADC status and control register or the next read of the ADC data register.
3.3.5 Accuracy and Precision
The conversion process is monotonic and has no missing codes. See 19.7 Analog-to-Digital Converter
(ADC) Characteristics for accuracy information.
3.4 Interrupts
When the AIEN bit is set, the ADC module is capable of generating a CPU interrupt after each ADC
conversion. If the COCO bit is set, an interrupt is generated. The COCO bit is not used as a conversion
complete flag when interrupts are enabled.
3.5 Low-Power Modes
The following subsections describe the low-power modes.
3.5.1 Wait Mode
The ADC continues normal operation during wait mode. Any enabled CPU interrupt request from the ADC
can bring the MCU out of wait mode. If the ADC is not required to bring the MCU out of wait mode, power
down the ADC by setting the ADCH[4:0] bits in the ADC status and control register before executing the
WAIT instruction.
3.5.2 Stop Mode
The ADC module is inactive after the execution of a STOP instruction. Any pending conversion is aborted.
ADC conversions resume when the MCU exits stop mode. Allow one conversion cycle to stabilize the
analog circuitry before attempting a new ADC conversion after exiting stop mode.
3.6 I/O Signals
The ADC module has 15 channels that are shared with I/O ports B and D. Refer to 19.7 Analog-to-Digital
Converter (ADC) Characteristics for voltages referenced below.
3.6.1 ADC Analog Power Pin (V
The ADC analog portion uses V
voltage potential as V
V
is the high reference voltage for all analog-to-digital conversions.
REFH
Route V
. External filtering may be necessary to ensure clean V
DD
DDAREF
capacitors as close as possible to the package. V
for operation of the ADC.
DDAREF
carefully for maximum noise immunity and place bypass
DDAREF
)/ADC Voltage Reference Pin (V
as its power pin. Connect the V
NOTE
DDAREF
REFH
DDA/VDDAREF
pin to the same
DDAREF
must be present
)
for good results.
MC68HC908AS32A Data Sheet, Rev. 1
60Freescale Semiconductor
I/O Registers
3.6.2 ADC Analog Ground Pin (V
The ADC analog portion uses V
as V
SS
. V
is the lower reference supply for the ADC.
REFL
as its ground pin. Connect the V
SSA
)/ADC Voltage Reference Low Pin (V
SSA
pin to the same voltage potential
SSA
REFL
3.6.3 ADC Voltage In (ADCVIN)
ADCVIN is the input voltage signal from one of the 15 ADC channels to the ADC module.
3.7 I/O Registers
These I/O registers control and monitor ADC operation:
•ADC status and control register (ADSCR)
•ADC data register (ADR)
•ADC clock register (ADICLK)
3.7.1 ADC Status and Control Register
The following paragraphs describe the function of the ADC status and control register.
Address:$0038
Bit 7654321Bit 0
Read:COCO
Write:R
Reset:00011111
R= Reserved
AIENADCOCH4CH3CH2CH1CH0
)
Figure 3-3. ADC Status and Control Register (ADSCR)
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.
This bit is cleared whenever the ADC status and control register is written or whenever the ADC data
register is read.
If the AIEN bit is a 1, the COCO is a read/write bit which selects the CPU to service the ADC interrupt
request. Reset clears this bit.
When this bit is set, an interrupt is generated at the end of an ADC conversion. The interrupt signal is
cleared when the data register is read or the status/control register is written. Reset clears the AIEN bit.
When set, the ADC will convert samples continuously and update the ADR register at the end of each
conversion. Only one conversion is allowed when this bit is cleared. Reset clears the ADCO bit.
1 = Continuous ADC conversion
0 = One ADC conversion
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor61
Analog-to-Digital Converter (ADC)
ADCH[4:0] — ADC Channel Select Bits
ADCH4, ADCH3, ADCH2, ADCH1, and ADCH0 form a 5-bit field which is used to select one of 15 ADC
channels. Channel selection is detailed in the following table. Care should be taken when using a port
pin as both an analog and a 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 used. Reset sets these bits.
NOTE
Recovery from the disabled state requires one conversion cycle to stabilize.
Table 3-1. Mux Channel Select
ADCH4ADCH3ADCH2ADCH1ADCH0Input Select
00000PTB0/ATD0
00001PTB1/ATD1
00010PTB2/ATD2
00011PTB3/ATD3
00100PTB4/ATD4
00101PTB5/ATD5
00110PTB6/ATD6
00111PTB7/ATD7
01000 PTD0/ATD8/ATD8
01001 PTD1/ATD9/ATD9
01010PTD2/ATD10/ATD10
01011PTD3/ATD11/ATD11
01100PTD4/ATD12/TBCLK/ATD12
01101PTD5/ATD13/ATD13
01110PTD6/ATD14/TACLK/ATD14
V
REFH
(1)
(1)
(2)
(2)
Range 01111 ($0F) to 11010 ($1A)
11011Reserved
11100
11101
11110
11111 [ADC power off]
1. If any unused channels are selected, the resulting ADC conversion will be unknown.
2. The voltage levels supplied from internal reference nodes as specified in the table are used to
verify the operation of the ADC converter both in production test and for user applications.
Unused
Unused
V
SSA/VREFL
MC68HC908AS32A Data Sheet, Rev. 1
62Freescale Semiconductor
I/O Registers
3.7.2 ADC Data Register
One 8-bit result register is provided. This register is updated each time an ADC conversion completes.
Address:$0039
Bit 7654321Bit 0
Read:AD7AD6AD5AD4AD3AD2AD1AD0
Write:
Reset:Indeterminate after reset
= Unimplemented
Figure 3-4. ADC Data Register (ADR)
3.7.3 ADC Input Clock Register
This register selects the clock frequency for the ADC.
Address:$003A
Bit 7654321Bit 0
Read:
Write:
Reset:00000000
ADIV2ADIV1ADIV0ADICLK
= Unimplemented
0000
Figure 3-5. ADC Input Clock Register (ADICLK)
ADIV2–ADIV0 — ADC Clock Prescaler Bits
ADIV2, ADIV1, and 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
1XXADC input clock ÷ 16
X = don’t care
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor63
Analog-to-Digital Converter (ADC)
ADICLK — ADC Input Clock Register Bit
ADICLK selects either bus clock or CGMXCLK as the input clock source to generate the internal ADC
clock. Reset selects CGMXCLK as the ADC clock source.
If the external clock (CGMXCLK) is equal to or greater than 1 MHz, CGMXCLK can be used as the
clock source for the ADC. If CGMXCLK is less than 1 MHz, use the PLL-generated bus clock as the
clock source. As long as the internal ADC clock is at approximately 1 MHz, correct operation can be
guaranteed. See 19.7 Analog-to-Digital Converter (ADC) Characteristics.
1 = Internal bus clock
0 = External clock (CGMXCLK)
f
or Bus Frequency
1 MHz = ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
XCLK
ADIV[2:0]
NOTE
During the conversion process, changing the ADC clock will result in an
incorrect conversion.
MC68HC908AS32A Data Sheet, Rev. 1
64Freescale Semiconductor
Chapter 4
Byte Data Link Controller (BDLC)
4.1 Introduction
The byte data link controller (BDLC) provides access to an external serial communication multiplex bus,
operating according to the Society of Automotive Engineers (SAE) J1850 protocol.
4.2 Features
Features include:
•SAE J1850 class B data communications network interface compatible and ISO compatible for low
speed (<
•10.4 kbps variable pulse width (VPW) bit format
•Digital noise filter
•Collision detection
•Hardware cyclical redundancy check (CRC) generation and checking
•Two power-saving modes with automatic wakeup on network activity
•Polling and CPU interrupts available
125 kbps) serial data communications in automotive applications
•Block mode receive and transmit supported
•Supports 4X receive mode, 41.6 kbps
•Digital loopback mode
•Analog loopback mode
•In-frame response (IFR) types 0, 1, 2, and 3 supported
4.3 Functional Description
Figure 4-2 shows the organization of the BDLC module. The CPU interface contains the software
addressable registers and provides the link between the CPU and the buffers. The buffers provide storage
for data received and data to be transmitted onto the J1850 bus. The protocol handler is responsible for
the encoding and decoding of data bits and special message symbols during transmission and reception.
The MUX interface provides the link between the BDLC digital section and the analog physical interface.
The wave shaping, driving, and digitizing of data is performed by the physical interface.
Use of the BDLC module in message networking fully implements the SAE Standard J1850 Class B Data Communication Network Interface specification.
NOTE
It is recommended that the reader be familiar with the SAE J1850 document
and ISO Serial Communication document prior to proceeding with this
section.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor65
Byte Data Link Controller (BDLC)
M68HC08 CPU
CPU
REGISTERS
CONTROL AND STATUS REGISTERS
USER FLASH — 32, 256 BYTES
USER RAM — 1024 BYTES
USER EEPROM — 512 BYTES
MONITOR ROM — 256 BYTES
USER FLASH VECTOR SPACE — 52 BYTES
OSC1
OSC2
CGMXFC
RST
IRQ
ARITHMETIC/LOGIC
UNIT (ALU)
CLOCK GENERATOR
MODULE
SYSTEM INTEGRATION
MODULE
IRQ MODULE
V
REFH
ANALOG-TO-DIGITAL
MODULE
BREAK MODULE
LOW-VOLTAGE INHIBIT
MODULE
COMPUTER OPERATING
PROPERLY MODULE
6-CHANNEL TIMER
INTERFACE MODULE
PROGRAMMABLE INTERRUPT
TIMER MODULE
SERIAL COMMUNICATIONS
INTERFACE MODULE
SERIAL PERIPHERAL
INTERFACE MODULE
BYTE DATA LINK CONTROLLER
DDRA
DDRB
DDRC
DDRD
DDRE
DDRF
PTA
PTB
PTC
PTD
PTE
PTF
PTA7–PTA0
PTB7/ATD7–
PTB0/ATD0
PTC4
PTC3
PTC2/MCLK
PTC1–PTC0
PTD6/ATD14/TCLK
PTD5/ATD13
PTA4/ATD12
PTD3/ATD11–
PTD0/ATD8
PTE7/SPSCK
PTE6/MOSI
PTE5/MISO
PTE4/SS
PTE3/TCH1
PTE2/TCH0
PTE1/RxD
PTE0/TxD
PTF3/TCH5–
PTF0/TCH2
POWER-ON RESET
MODULE
V
SS
V
DD
V
DDA
V
SSA
POWER
BDRxDBDTxD
AVSS/V
REFK
V
DDAREF
Figure 4-1. Block Diagram Highlighting BDLC Block and Pins
MC68HC908AS32A Data Sheet, Rev. 1
66Freescale Semiconductor
Functional Description
TO CPU
CPU INTERFACE
PROTOCOL HANDLER
MUX INTERFACE
PHYSICAL INTERFACE
BDLC
TO J1850 BUS
Figure 4-2. BDLC Block Diagram
4.3.1 BDLC Operating Modes
The BDLC has five main modes of operation which interact with the power supplies, pins, and the
remainder of the MCU as shown in Figure 4-3.
NETWORK ACTIVITY OR
OTHER MCU WAKEUP
BDLC STOP
POWER OFF
VDD ≤ V
(MINIMUM)
DD
RESET
ANY MCU RESET SOURCE ASSERTED
(FROM ANY MODE)
COP, ILLADDR, PU, RESET, LVR, POR
STOP INSTRUCTION OR
WAIT INSTRUCTION AND WCM = 1
RUN
VDD > VDD (MINIMUM) AND
ANY MCU RESET SOURCE ASSERTED
NO MCU RESET SOURCE ASSERTED
NETWORK ACTIVITY OR
OTHER MCU WAKEUP
BDLC WAIT
WAIT INSTRUCTION AND WCM = 0
Figure 4-3. BDLC Operating Modes State Diagram
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor67
Byte Data Link Controller (BDLC)
4.3.1.1 Power Off Mode
This mode is entered from reset mode whenever the BDLC supply voltage, V
, drops below its minimum
DD
specified value for the BDLC to guarantee operation. The BDLC will be placed in reset mode by
low-voltage reset (LVR) before being powered down. In this mode, the pin input and output specifications
are not guaranteed.
4.3.1.2 Reset Mode
This mode is entered from the power off mode whenever the BDLC supply voltage, V
minimum specified value (V
–10%) and some MCU reset source is asserted. The internal MCU reset
DD
rises above its
DD,
must be asserted while powering up the BDLC or an unknown state will be entered and correct operation
cannot be guaranteed. Reset mode is also entered from any other mode as soon as one of the MCU’s
possible reset sources (such as LVR, POR, COP watchdog, and reset pin, etc.) is asserted.
In reset mode, the internal BDLC voltage references are operative; V
is supplied to the internal circuits
DD
which are held in their reset state; and the internal BDLC system clock is running. Registers will assume
their reset condition. Outputs are held in their programmed reset state. Therefore, inputs and network
activity are ignored.
4.3.1.3 Run Mode
This mode is entered from the reset mode after all MCU reset sources are no longer asserted. Run mode
is entered from the BDLC wait mode whenever activity is sensed on the J1850 bus.
Run mode is entered from the BDLC stop mode whenever network activity is sensed, although messages
will not be received properly until the clocks have stabilized and the CPU is in run mode also.
In this mode, normal network operation takes place. The user should ensure that all BDLC transmissions
have ceased before exiting this mode.
4.3.1.4 BDLC Wait Mode
This power-conserving mode is entered automatically from run mode whenever the CPU executes a
WAIT instruction and if the WCM bit in the BCR1 register is cleared previously.
In this mode, the BDLC internal clocks continue to run. The first passive-to-active transition of the bus
generates a CPU interrupt request from the BDLC which wakes up the BDLC and the CPU. In addition,
if the BDLC receives a valid EOF symbol while operating in wait mode, then the BDLC also will generate
a CPU interrupt request which wakes up the BDLC and the CPU. See 4.7.1 Wait Mode.
4.3.1.5 BDLC Stop Mode
This power-conserving mode is entered automatically from run mode whenever the CPU executes a
STOP instruction or if the CPU executes a WAIT instruction and the WCM bit in the BCR1 register is set
previously.
In this mode, the BDLC internal clocks are stopped but the physical interface circuitry is placed in a
low-power mode and awaits network activity. If network activity is sensed, then a CPU interrupt request
will be generated, restarting the BDLC internal clocks. See 4.7.2 Stop Mode.
MC68HC908AS32A Data Sheet, Rev. 1
68Freescale Semiconductor
BDLC MUX Interface
4.3.1.6 Digital Loopback Mode
When a bus fault has been detected, the digital loopback mode is used to determine if the fault condition
is caused by failure in the node’s internal circuits or elsewhere in the network, including the node’s analog
physical interface. In this mode, the transmit digital output pin (BDTxD) and the receive digital input pin
(BDRxD) of the digital interface are disconnected from the analog physical interface and tied together to
allow the digital portion of the BDLC to transmit and receive its own messages without driving the J1850
bus.
4.3.1.7 Analog Loopback Mode
Analog loopback is used to determine if a bus fault has been caused by a failure in the node’s off-chip
analog transceiver or elsewhere in the network. The BCLD analog loopback mode does not modify the
digital transmit or receive functions of the BDLC. It does, however, ensure that once analog loopback
mode is exited, the BDLC will wait for an idle bus condition before participation in network communication
resumes. If the off-chip analog transceiver has a loopback mode, it usually causes the input to the output
drive stage to be looped back into the receiver, allowing the node to receive messages it has transmitted
without driving the J1850 bus. In this mode, the output to the J1850 bus is typically high impedance. This
allows the communication path through the analog transceiver to be tested without interfering with
network activity. Using the BDLC analog loopback mode in conjunction with the analog transceiver’s
loopback mode ensures that, once the off-chip analog transceiver has exited loopback mode, the BCLD
will not begin communicating before a known condition exists on the J1850 bus.
4.4 BDLC MUX Interface
The MUX interface is responsible for bit encoding/decoding and digital noise filtering between the protocol
handler and the physical interface.
TO CPU
CPU INTERFACE
PROTOCOL HANDLER
MUX INTERFACE
PHYSICAL INTERFACE
BDLC
TO J1850 BUS
Figure 4-4. BDLC Block Diagram
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor69
Byte Data Link Controller (BDLC)
4.4.1 Rx Digital Filter
The receiver section of the BDLC includes a digital low-pass filter to remove narrow noise pulses from the
incoming message. An outline of the digital filter is shown in Figure 4-5.
DATA
LATCHSYNC
FILTERED
RX DATA OUT
RX DATA
FROM
PHYSICAL
INTERFACE
(BDRXD)
MUX
INTERFACE
CLOCK
INPUT
DQ
4-BIT UP/DOWN COUTER
UP/DOWN
OUTDQ
Figure 4-5. BDLC Rx Digital Filter Block Diagram
4.4.1.1 Operation
The clock for the digital filter is provided by the MUX interface clock (see f
parameter in Table 4-3).
BDLC
At each positive edge of the clock signal, the current state of the receiver physical interface (BDRxD)
signal is sampled. The BDRxD signal state is used to determine whether the counter should increment or
decrement at the next negative edge of the clock signal.
The counter will increment if the input data sample is high but decrement if the input sample is low.
Therefore, the counter will thus progress either up toward 15 if, on average, the BDRxD signal remains
high or progress down toward 0 if, on average, the BDRxD signal remains low.
When the counter eventually reaches the value 15, the digital filter decides that the condition of the
BDRxD signal is at a stable logic level 1 and the data latch is set, causing the filtered Rx data signal to
become a logic level 1. Furthermore, the counter is prevented from overflowing and can only be
decremented from this state.
Alternatively, should the counter eventually reach the value 0, the digital filter decides that the condition
of the BDRxD signal is at a stable logic level 0 and the data latch is reset, causing the filtered Rx data
signal to become a logic level 0. Furthermore, the counter is prevented from underflowing and can only
be incremented from this state.
The data latch will retain its value until the counter next reaches the opposite end point, signifying a
definite transition of the signal.
4.4.1.2 Performance
The performance of the digital filter is best described in the time domain rather than the frequency domain.
If the signal on the BDRxD signal transitions, then there will be a delay before that transition appears at
the filtered Rx data output signal. This delay will be between 15 and 16 clock periods, depending on where
the transition occurs with respect to the sampling points. This filter delay must be taken into account when
performing message arbitration.
MC68HC908AS32A Data Sheet, Rev. 1
70Freescale Semiconductor
BDLC MUX Interface
For example, if the frequency of the MUX interface clock (f
) is 1.0486 MHz, then the period (t
BDLC
BDLC
is 954 ns and the maximum filter delay in the absence of noise will be 15.259 µs.
The effect of random noise on the BDRxD signal depends on the characteristics of the noise itself. Narrow
noise pulses on the BDRxD signal will be ignored completely if they are shorter than the filter delay. This
provides a degree of low-pass filtering.
If noise occurs during a symbol transition, the detection of that transition can be delayed by an amount
equal to the length of the noise burst. This is just a reflection of the uncertainty of where the transition is
truly occurring within the noise.
Noise pulses that are wider than the filter delay, but narrower than the shortest allowable symbol length,
will be detected by the next stage of the BDLC’s receiver as an invalid symbol.
Noise pulses that are longer than the shortest allowable symbol length will be detected normally as an
invalid symbol or as invalid data when the frame’s CRC is checked.
4.4.2 J1850 Frame Format
All messages transmitted on the J1850 bus are structured using the format shown in Figure 4-6. J1850
states that each message has a maximum length of 101 PWM bit times or 12 VPW bytes, excluding SOF,
EOD, NB, and EOF, with each byte transmitted MSB first.
All VPW symbol lengths in the following descriptions are typical values at a 10.4 kbps bit rate.
IDLESOF
PRIORITY
(DATA0)
DATA
MESSAGE ID
(DATA1)
DATA
E
CRC
N
O
D
N
B
OPTIONAL
IFREOFIDLE
I
F
S
)
Figure 4-6. J1850 Bus Message Format (VPW)
SOF — Start-of-Frame Symbol
All messages transmitted onto the J1850 bus must begin with a long-active 200-µs period SOF symbol.
This indicates the start of a new message transmission. The SOF symbol is not used in the CRC
calculation.
Data — In-Message Data Bytes
The data bytes contained in the message include the message priority/type, message ID byte (typically
the physical address of the responder), and any actual data being transmitted to the receiving node.
The message format used by the BDLC is similar to the 3-byte consolidated header message format
outlined by the SAE J1850 document. See SAE J1850 — Class B Data Communications Network Interface for more information about 1- and 3-byte headers.
Messages transmitted by the BDLC onto the J1850 bus must contain at least one data byte and,
therefore, can be as short as one data byte and one CRC byte. Each data byte in the message is eight
bits in length and is transmitted MSB to LSB.
CRC — Cyclical Redundancy Check Byte
This byte is used by the receiver(s) of each message to determine if any errors have occurred during
the transmission of the message. The BDLC calculates the CRC byte and appends it onto any
messages transmitted onto the J1850 bus. It also performs CRC detection on any messages it
receives from the J1850 bus.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor71
Byte Data Link Controller (BDLC)
CRC generation uses the divisor polynomial X8 + X4 + X3 + X2 + 1. The remainder polynomial initially
is set to all ones. Each byte in the message after the start of frame (SOF) symbol is processed serially
through the CRC generation circuitry. The one’s complement of the remainder then becomes the 8-bit
CRC byte, which is appended to the message after the data bytes in MSB-to-LSB order.
When receiving a message, the BDLC uses the same divisor polynomial. All data bytes, excluding the
SOF and end of data symbols (EOD) but including the CRC byte, are used to check the CRC. If the
message is error free, the remainder polynomial will equal X
7
+ X6 + X2 = $C4, regardless of the data
contained in the message. If the calculated CRC does not equal $C4, the BDLC will recognize this as
a CRC error and set the CRC error flag in the BSVR.
EOD — End-of-Data Symbol
The EOD symbol is a long 200-µs passive period on the J1850 bus used to signify to any recipients of
a message that the transmission by the originator has completed. No flag is set upon reception of the
EOD symbol.
IFR — In-Frame Response Bytes
The IFR section of the J1850 message format is optional. Users desiring further definition of in-frame
response should review the SAE J1850 — Class B Data Communications Network Interface
specification.
EOF — End-of-Frame Symbol
This symbol is a long 280-µs passive period on the J1850 bus and is longer than an end-of-data (EOD)
symbol, which signifies the end of a message. Since an EOF symbol is longer than a 200-µs EOD
symbol, if no response is transmitted after an EOD symbol, it becomes an EOF, and the message is
assumed to be completed. The EOF flag is set upon receiving the EOF symbol.
IFS — Inter-Frame Separation Symbol
The IFS symbol is a 20-µs passive period on the J1850 bus which allows proper synchronization
between nodes during continuous message transmission. The IFS symbol is transmitted by a node
after the completion of the end-of-frame (EOF) period and, therefore, is seen as a 300-µs passive
period.
When the last byte of a message has been transmitted onto the J1850 bus and the EOF symbol time
has expired, all nodes then must wait for the IFS symbol time to expire before transmitting a
start-of-frame (SOF) symbol, marking the beginning of another message.
However, if the BDLC is waiting for the IFS period to expire before beginning a transmission and a
rising edge is detected before the IFS time has expired, it will synchronize internally to that edge. If a
write to the BDR register (for instance, to initiate transmission) occurred on or before 104 • t
BDLC
the received rising edge, then the BDLC will transmit and arbitrate for the bus. If a CPU write to the
BDR register occurred after 104 • t
from the detection of the rising edge, then the BDLC will not
BDLC
transmit, but will wait for the next IFS period to expire before attempting to transmit the byte.
A rising edge may occur during the IFS period because of varying clock tolerances and loading of the
J1850 bus, causing different nodes to observe the completion of the IFS period at different times. To
allow for individual clock tolerances, receivers must synchronize to any SOF occurring during an IFS
period.
NOTE
If two messages are received with a 300 µs (
± 1 µ
s) interframe separation
(IFS) as measured at the RX pin, the start-of-frame (SOF) symbol of the
second message will generate an invalid symbol interrupt. This interrupt
results in the second message being lost and will therefore be unavailable
from
MC68HC908AS32A Data Sheet, Rev. 1
72Freescale Semiconductor
BDLC MUX Interface
to the application software. Implementations of this BDLC design on silicon
µ
have not been exposed to interframe separation rates faster than 320
s in
practical application and have therefore previously not exhibited this
behavior. Ensuring that no nodes on the J1850 network transmit messages
at 300
µ
s (
± 1 µ
s) IFS will avoid this missed message frame. In addition,
developing application software to robustly handle lost messages will
minimize application impact.
BREAK — Break
The BDLC cannot transmit a BREAK symbol.
If the BDLC is transmitting at the time a BREAK is detected, it treats the BREAK as if a transmission
error had occurred and halts transmission.
If the BDLC detects a BREAK symbol while receiving a message, it treats the BREAK as a reception
error and sets the invalid symbol flag in the BSVR, also ignoring the frame it was receiving. If while
receiving a message in 4X mode, the BDLC detects a BREAK symbol, it treats the BREAK as a
reception error, sets the invalid symbol flag, and exits 4X mode (for example, the RX4XE bit in BCR2
is cleared automatically). If bus control is required after the BREAK symbol is received and the IFS
time has elapsed, the programmer must resend the transmission byte using highest priority.
NOTE
The J1850 protocol BREAK symbol is not related to the HC08 break
module. Refer to 18.2 Break Module (BRK).
IDLE — Idle Bus
An idle condition exists on the bus during any passive period after expiration of the IFS period (for
instance, ≥ 300 µs). Any node sensing an idle bus condition can begin transmission immediately.
4.4.3 J1850 VPW Symbols
Huntsinger’s variable pulse width modulation (VPW) is an encoding technique in which each bit is defined
by the time between successive transitions and by the level of the bus between transitions (for instance,
active or passive). Active and passive bits are used alternately. This encoding technique is used to reduce
the number of bus transitions for a given bit rate.
Each logic 1 or logic 0 contains a single transition and can be at either the active or passive level and one
of two lengths, either 64 µs or 128 µs (t
previous bit. The start-of-frame (SOF), end-of-data (EOD), end-of-frame (EOF), and inter-frame
separation (IFS) symbols always will be encoded at an assigned level and length. See Figure 4-7.
Each message will begin with an SOF symbol an active symbol and, therefore, each data byte (including
the CRC byte) will begin with a passive bit, regardless of whether it is a 1 or a 0.
All VPW bit lengths stated in the following descriptions are typical values at a 10.4 kbps bit rate.
Logic 0
A logic 0 is defined as either:
–An active-to-passive transition followed by a passive period 64 µs in length, or
–A passive-to-active transition followed by an active period 128 µs in length
See Figure 4-7(a).
at 10.4 kbps baud rate), depending upon the encoding of the
NOM
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor73
Byte Data Link Controller (BDLC)
ACTIVE
PASSIVE
ACTIVE
PASSIVE
ACTIVE
≥ 240 µs
PASSIVE
(C) BREAK
ACTIVE
280 µs
PASSIVE
128 µs
128 µs
20 µs
(A) LOGIC 0
(B) LOGIC 1
(D) START OF FRAME
300 µs
200 µs
OR
OR
64 µs
64 µs
200 µs
(E) END OF DATA
IDLE > 300 µs
(F) END OF FRAME
(G) INTER-FRAME
SEPARATION
(H) IDLE
Figure 4-7. J1850 VPW Symbols with Nominal Symbol Times
Logic 1
A logic 1 is defined as either:
a.An active-to-passive transition followed by a passive period 128 µs in length, or
b.A passive-to-active transition followed by an active period 64 µs in length
See Figure 4-7(b).
Normalization Bit (NB)
The NB symbol has the same property as a logic 1 or a logic 0. It is only used in IFR message
responses.
Break Signal (BREAK)
The BREAK signal is defined as a passive-to-active transition followed by an active period of at least
240 µs. See Figure 4-7(c).
Start-of-Frame Symbol (SOF)
The SOF symbol is defined as passive-to-active transition followed by an active period 200 µs in length
(see Figure 4-7(d)). This allows the data bytes which follow the SOF symbol to begin with a passive
bit, regardless of whether it is a logic 1 or a logic 0.
End-of-Data Symbol (EOD)
The EOD symbol is defined as an active-to-passive transition followed by a passive period 200 µs in
length (see Figure 4-7(e)).
MC68HC908AS32A Data Sheet, Rev. 1
74Freescale Semiconductor
BDLC MUX Interface
End-of-Frame Symbol (EOF)
The EOF symbol is defined as an active-to-passive transition followed by a passive period 280 µs in
length (see Figure 4-7(f)). If no IFR byte is transmitted after an EOD symbol is transmitted, after
another 80 µs the EOD becomes an EOF, indicating completion of the message.
Inter-Frame Separation Symbol (IFS)
The IFS symbol is defined as a passive period 300 µs in length. The 20-µs IFS symbol contains no
transition, since when used it always appends to an EOF symbol (see Figure 4-7(g)).
Idle
An idle is defined as a passive period greater than 300 µs in length.
4.4.4 J1850 VPW Valid/Invalid Bits and Symbols
The timing tolerances for receiving data bits and symbols from the J1850 bus have been defined to allow
for variations in oscillator frequencies. In many cases the maximum time allowed to define a data bit or
symbol is equal to the minimum time allowed to define another data bit or symbol.
Since the minimum resolution of the BDLC for determining what symbol is being received is equal to a
single period of the MUX interface clock (t
time concurrences equal to one cycle of t
This one clock resolution allows the BDLC to differentiate properly between the different bits and symbols.
This is done without reducing the valid window for receiving bits and symbols from transmitters onto the
J1850 bus which have varying oscillator frequencies.
), an apparent separation in these maximum time/minimum
BDLC
occurs.
BDLC
In Huntsinger’s’ variable pulse width (VPW) modulation bit encoding, the tolerances for both the passive
and active data bits received and the symbols received are defined with no gaps between definitions. For
example, the maximum length of a passive logic 0 is equal to the minimum length of a passive logic 1,
and the maximum length of an active logic 0 is equal to the minimum length of a valid SOF symbol. See
Figure 4-8.
200 µs
128 µs
64 µs
ACTIVE
PASSIVE
a
ACTIVE
PASSIVE
ba
ACTIVE
PASSIVE
bc
ACTIVE
(1) INVALID PASSIVE BIT
(2) VALID PASSIVE LOGIC 0
(3) VALID PASSIVE LOGIC 1
(4) VALID EOD SYMBOL
PASSIVE
cd
Figure 4-8. J1850 VPW Received Passive Symbol Times
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor75
Byte Data Link Controller (BDLC)
Invalid Passive Bit
See Figure 4-8(1). If the passive-to-active received transition beginning the next data bit or symbol
occurs between the active-to-passive transition beginning the current data bit (or symbol) and a, the
current bit would be invalid.
Valid Passive Logic 0
See Figure 4-8(2). If the passive-to-active received transition beginning the next data bit (or symbol)
occurs between a and b, the current bit would be considered a logic 0.
Valid Passive Logic 1
See Figure 4-8(3). If the passive-to-active received transition beginning the next data bit (or symbol)
occurs between b and c, the current bit would be considered a logic 1.
Valid EOD Symbol
See Figure 4-8(4). If the passive-to-active received transition beginning the next data bit (or symbol)
occurs between c and d, the current symbol would be considered a valid end-of-data symbol (EOD).
Valid EOF and IFS Symbol
See Figure 4-9.
300 µs
280 µs
ACTIVE
PASSIVE
ACTIVE
PASSIVE
a
b
cd
(1) VALID EOF SYMBOL
(2) VALID EOF+
IFS SYMBOL
Figure 4-9. J1850 VPW Received Passive EOF and IFS Symbol Times
In Figure 4-9(1), if the passive-to-active received transition beginning the SOF symbol of the next
message occurs between a and b, the current symbol will be considered a valid end-of-frame (EOF)
symbol.
See Figure 4-9(2). If the passive-to-active received transition beginning the SOF symbol of the next
message occurs between c and d, the current symbol will be considered a valid EOF symbol followed
by a valid inter-frame separation symbol (IFS). All nodes must wait until a valid IFS symbol time has
expired before beginning transmission. However, due to variations in clock frequencies and bus
loading, some nodes may recognize a valid IFS symbol before others and immediately begin
transmitting. Therefore, any time a node waiting to transmit detects a passive-to-active transition once
a valid EOF has been detected, it should immediately begin transmission, initiating the arbitration
process.
Idle Bus
In Figure 4-9(2), if the passive-to-active received transition beginning the start-of-frame (SOF) symbol
of the next message does not occur before d, the bus is considered to be idle, and any node wishing
to transmit a message may do so immediately.
MC68HC908AS32A Data Sheet, Rev. 1
76Freescale Semiconductor
64 µs
BDLC MUX Interface
200 µs
128 µs
ACTIVE
PASSIVE
a
ACTIVE
PASSIVE
ba
ACTIVE
PASSIVE
bc
ACTIVE
PASSIVE
cd
(1) INVALID ACTIVE BIT
(2) VALID ACTIVE LOGIC 1
(3) VALID ACTIVE LOGIC 0
(4) VALID SOF SYMBOL
Figure 4-10. J1850 VPW Received Active Symbol Times
Invalid Active Bit
In Figure 4-10(1), if the active-to-passive received transition beginning the next data bit (or symbol)
occurs between the passive-to-active transition beginning the current data bit (or symbol) and a, the
current bit would be invalid.
Valid Active Logic 1
In Figure 4-10(2), if the active-to-passive received transition beginning the next data bit (or symbol)
occurs between a and b, the current bit would be considered a logic 1.
Valid Active Logic 0
In Figure 4-10(3), if the active-to-passive received transition beginning the next data bit (or symbol)
occurs between b and c, the current bit would be considered a logic 0.
Valid SOF Symbol
In Figure 4-10(4), if the active-to-passive received transition beginning the next data bit (or symbol)
occurs between c and d, the current symbol would be considered a valid SOF symbol.
Valid BREAK Symbol
In Figure 4-11, if the next active-to-passive received transition does not occur until after e, the current
symbol will be considered a valid BREAK symbol. A BREAK symbol should be followed by a
start-of-frame (SOF) symbol beginning the next message to be transmitted onto the J1850 bus. See
4.4.2 J1850 Frame Format for BDLC response to BREAK symbols.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor77
Byte Data Link Controller (BDLC)
240 µs
ACTIVE
PASSIVE
e
(2) VALID BREAK SYMBOL
Figure 4-11. J1850 VPW Received BREAK Symbol Times
4.4.5 Message Arbitration
Message arbitration on the J1850 bus is accomplished in a non-destructive manner, allowing the
message with the highest priority to be transmitted, while any transmitters which lose arbitration simply
stop transmitting and wait for an idle bus to begin transmitting again.
If the BDLC wants to transmit onto the J1850 bus, but detects that another message is in progress, it waits
until the bus is idle. However, if multiple nodes begin to transmit in the same synchronization window,
message arbitration will occur beginning with the first bit after the SOF symbol and will continue with each
bit thereafter.
The variable pulse width modulation (VPW) symbols and J1850 bus electrical characteristics are chosen
carefully so that a logic 0 (active or passive type) will always dominate over a logic 1 (active or passive
type) that is simultaneously transmitted. Hence, logic 0s are said to be dominant and logic 1s are said to
be recessive.
Whenever a node detects a dominant bit on BDRxD when it transmitted a recessive bit, the node loses
arbitration and immediately stops transmitting. This is known as bitwise arbitration.
Since a logic 0 dominates a logic 1, the message with the lowest value will have the highest priority and
will always win arbitration. For instance, a message with priority 000 will win arbitration over a message
with priority 011.
This method of arbitration will work no matter how many bits of priority encoding are contained in the
message.
During arbitration, or even throughout the transmitting message, when an opposite bit is detected,
transmission is stopped immediately unless it occurs on the 8th bit of a byte. In this case, the BDLC
automatically will append up to two extra logic 1 bits and then stop transmitting. These two extra bits will
be arbitrated normally and thus will not interfere with another message. The second logic 1 bit will not be
sent if the first loses arbitration. If the BDLC has lost arbitration to another valid message, then the two
extra logic 1s will not corrupt the current message. However, if the BDLC has lost arbitration due to noise
on the bus, then the two extra logic 1s will ensure that the current message will be detected and ignored
as a noise-corrupted message.
MC68HC908AS32A Data Sheet, Rev. 1
78Freescale Semiconductor
BDLC Protocol Handler
TRANSMITTER A DETECTS
AN ACTIVE STATE ON
THE BUS AND STOPS
0
0
0
0
DATA
BIT 5
TRANSMITTING
TRANSMITTER B WINS
ARBITRATION AND
CONTINUES
TRANSMITTING
ACTIVE
TRANSMITTER A
PASSIVE
ACTIVE
TRANSMITTER B
PASSIVE
ACTIVE
J1850 BUS
PASSIVE
SOF
0
0
0
DATA
BIT 1
1
1
1
DATA
BIT 2
1
1
1
DATA
BIT 3
1
DATA
BIT 4
Figure 4-12. J1850 VPW Bitwise Arbitrations
4.5 BDLC Protocol Handler
The protocol handler is responsible for framing, arbitration, CRC generation/checking, and error
detection. The protocol handler conforms to SAE J1850 — Class B Data Communications Network Interface.
NOTE
Freescale assumes that the reader is familiar with the J1850 specification
before this protocol handler description is read.
TO CPU
CPU INTERFACE
PROTOCOL HANDLER
MUX INTERFACE
PHYSICAL INTERFACE
BDLC
TO J1850 BUS
Figure 4-13. BDLC Block Diagram
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor79
Byte Data Link Controller (BDLC)
4.5.1 Protocol Architecture
The protocol handler contains the state machine, Rx shadow register, Tx shadow register, Rx shift
register, Tx shift register, and loopback multiplexer as shown in Figure 4-14.
TO PHYSICAL INTERFACE
BDRxDBDTxD
DLOOP FROM BCR2
LOOPBACK CONTROL
Figure 4-14. BDLC Protocol Handler Outline
4.5.2 Rx and Tx Shift Registers
LOOPBACK
MULTIPLEXER
RxD
Rx SHIFT REGISTER
Rx SHADOW REGISTER
8
Rx DATA
TO CPU INTERFACE AND Rx/Tx BUFFERS
BDTxD
STATE MACHINE
CONTROL
CONTROL
Tx SHIFT REGISTER
Tx SHADOW REGISTER
ALOOP
8
Tx DATA
The Rx shift register gathers received serial data bits from the J1850 bus and makes them available in
parallel form to the Rx shadow register. The Tx shift register takes data, in parallel form, from the Tx
shadow register and presents it serially to the state machine so that it can be transmitted onto the J1850
bus.
4.5.3 Rx and Tx Shadow Registers
Immediately after the Rx shift register has completed shifting in a byte of data, this data is transferred to
the Rx shadow register and RDRF or RXIFR is set (see 4.6.4 BDLC State Vector Register) and an
interrupt is generated if the interrupt enable bit (IE) in BCR1 is set. After the transfer takes place, this new
data byte in the Rx shadow register is available to the CPU interface, and the Rx shift register is ready to
shift in the next byte of data. Data in the Rx shadow register must be retrieved by the CPU before it is
overwritten by new data from the Rx shift register.
Once the Tx shift register has completed its shifting operation for the current byte, the data byte in the Tx
shadow register is loaded into the Tx shift register. After this transfer takes place, the Tx shadow register
is ready to accept new data from the CPU when TDRE flag in BSVR is set.
MC68HC908AS32A Data Sheet, Rev. 1
80Freescale Semiconductor
BDLC Protocol Handler
4.5.4 Digital Loopback Multiplexer
The digital loopback multiplexer connects RxD to either BDTxD or BDRxD, depending on the state of the
DLOOP bit in the BCR2 register (see 4.6.3 BDLC Control Register 2).
4.5.5 State Machine
All of the functions associated with performing the protocol are executed or controlled by the state
machine. The state machine is responsible for framing, collision detection, arbitration, CRC
generation/checking, and error detection. The following subsections describe the BDLC’s actions in a
variety of situations.
4.5.5.1 4X Mode
The BDLC can exist on the same J1850 bus as modules which use a special 4X (41.6 kbps) mode of
J1850 variable pulse width modulation (VPW) operation. The BDLC cannot transmit in 4X mode, but can
receive messages in 4X mode, if the RX4X bit is set in BCR2 register. If the RX4X bit is not set in the
BCR2 register, any 4X message on the J1850 bus is treated as noise by the BDLC and is ignored.
4.5.5.2 Receiving a Message in Block Mode
Although not a part of the SAE J1850 protocol, the BDLC does allow for a special block mode of operation
of the receiver. As far as the BDLC is concerned, a block mode message is simply a long J1850 frame
that contains an indefinite number of data bytes. All of the other features of the frame remain the same,
including the SOF, CRC, and EOD symbols.
Another node wishing to send a block mode transmission must first inform all other nodes on the network
that this is about to happen. This is usually accomplished by sending a special predefined message.
4.5.5.3 Transmitting a Message in Block Mode
A block mode message is transmitted inherently by simply loading the bytes one by one into the BDR
register until the message is complete. The programmer should wait until the TDRE flag (see 4.6.4 BDLC
State Vector Register) is set prior to writing a new byte of data into the BDR register. The BDLC does not
contain any predefined maximum J1850 message length requirement.
4.5.5.4 J1850 Bus Errors
The BDLC detects several types of transmit and receive errors which can occur during the transmission
of a message onto the J1850 bus.
Transmission Error
If the message transmitted by the BDLC contains invalid bits or framing symbols on non-byte
boundaries, this constitutes a transmission error. When a transmission error is detected, the BDLC
immediately will cease transmitting. The error condition ($1C) is reflected in the BSVR register (see
Table 4-5). If the interrupt enable bit (IE in BCR1) is set, a CPU interrupt request from the BDLC is
generated.
CRC Error
A cyclical redundancy check (CRC) error is detected when the data bytes and CRC byte of a received
message are processed and the CRC calculation result is not equal to $C4. The CRC code will detect
any single and 2-bit errors, as well as all 8-bit burst errors and almost all other types of errors. The
CRC error flag ($18 in BSVR) is set when a CRC error is detected. See 4.6.4 BDLC State Vector
Register.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor81
Byte Data Link Controller (BDLC)
Symbol Error
A symbol error is detected when an abnormal (invalid) symbol is detected in a message being received
from the J1850 bus. However, if the BDLC is transmitting when this happens, it will be treated as a loss
of arbitration ($14 in BSVR) rather than a transmitter error. The ($1C) symbol invalid or the
out-of-range flag is set when a symbol error is detected. Therefore, ($1C) symbol invalid flag is stacked
behind the ($14) LOA flag during a transmission error process. See 4.6.4 BDLC State Vector Register.
Framing Error
A framing error is detected if an EOD or EOF symbol is detected on a non-byte boundary from the
J1850 bus. A framing error also is detected if the BDLC is transmitting the EOD and instead receives
an active symbol. The ($1C) symbol invalid or the out-of-range flag is set when a framing error is
detected. See 4.6.4 BDLC State Vector Register.
Bus Fault
If a bus fault occurs, the response of the BDLC will depend upon the type of bus fault.
If the bus is shorted to battery, the BDLC will wait for the bus to fall to a passive state before it will
attempt to transmit a message. As long as the short remains, the BDLC will never attempt to transmit
a message onto the J1850 bus.
If the bus is shorted to ground, the BDLC will see an idle bus, begin to transmit the message, and then
detect a transmission error ($1C in BSVR), since the short to ground would not allow the bus to be
driven to the active (dominant) SOF state. The BDLC will abort that transmission and wait for the next
CPU command to transmit.
In any case, if the bus fault is temporary, as soon as the fault is cleared, the BDLC will resume normal
operation. If the bus fault is permanent, it may result in permanent loss of communication on the J1850
bus. See 4.6.4 BDLC State Vector Register.
BREAK — Break
If a BREAK symbol is received while the BDLC is transmitting or receiving, an invalid symbol ($1C in
BSVR) interrupt will be generated. Reading the BSVR register (see 4.6.4 BDLC State Vector Register)
will clear this interrupt condition. The BDLC will wait for the bus to idle, then wait for a start-of-frame
(SOF) symbol.
The BDLC cannot transmit a BREAK symbol. It can only receive a BREAK symbol from the J1850 bus.
Framing errorInvalid symbol interrupt will be generated. The BDLC will wait for start-of-frame (SOF).
Bus short to V
Bus short to GND
BDLC receives BREAK symbol.The BDLC will wait for the next valid SOF. Invalid symbol interrupt will be generated.
DD
For invalid bits or framing symbols on non-byte boundaries, invalid symbol interrupt will
be generated. BDLC stops transmission.
CRC error interrupt will be generated. The BDLC will wait for SOF.
The BDLC will abort transmission immediately. Invalid symbol interrupt will be generated.
The BDLC will not transmit until the bus is idle.
Thermal overload will shut down physical interface. Fault condition is reflected in BSVR
as an invalid symbol.
MC68HC908AS32A Data Sheet, Rev. 1
82Freescale Semiconductor
BDLC CPU Interface
4.6 BDLC CPU Interface
The CPU interface provides the interface between the CPU and the BDLC and consists of five user
registers.
•BDLC analog and roundtrip delay register (BARD)
•BDLC control register 1 (BCR1)
•BDLC control register 2 (BCR2)
•BDLC state vector register (BSVR)
•BDLC data register (BDR)
TO CPU
CPU INTERFACE
PROTOCOL HANDLER
MUX INTERFACE
PHYSICAL INTERFACE
BDLC
TO J1850 BUS
Figure 4-15. BDLC Block Diagram
4.6.1 BDLC Analog and Roundtrip Delay Register
This register programs the BDLC to compensate for various delays of different external transceivers. The
default delay value is16 µs. Timing adjustments from 9 µs to 24 µs in steps of 1 µs are available. The
BARD register can be written only once after each reset, after which they become read-only bits. The
register may be read at any time.
Address:$003B
Bit 7654321Bit 0
Read:
Write:RR
Reset:11000111
ATERXPOL
R= Reserved
Figure 4-16. BDLC Analog and Roundtrip Delay Register (BARD)
00
BO3BO2BO1BO0
ATE — Analog Transceiver Enable Bit
The analog transceiver enable (ATE) bit is used to select either the on-board or an off-chip analog
transceiver.
1 = Select on-board analog transceiver
0 = Select off-chip analog transceiver
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor83
Byte Data Link Controller (BDLC)
NOTE
This device does not contain an on-board transceiver. This bit should be
programmed to a logic 0 for proper operation.
RXPOL — Receive Pin Polarity Bit
The receive pin polarity (RXPOL) bit is used to select the polarity of an incoming signal on the receive
pin. Some external analog transceivers invert the receive signal from the J1850 bus before feeding it
back to the digital receive pin.
1 = Select normal/true polarity; true non-inverted signal from the J1850 bus; for example, the
external transceiver does not invert the receive signal
0 = Select inverted polarity, where an external transceiver inverts the receive signal from the J1850
bus
B03–B00 — BARD Offset Bits
Table 4-2 shows the expected transceiver delay with respect to BARD offset values.
Table 4-2. BDLC Transceiver Delay
BARD Offset Bits
B0[3:0]
4.6.2 BDLC Control Register 1
Corresponding Expected
Transceiver’s Delays (µs)
00009
000110
001011
001112
010013
010114
011015
011116
100017
100118
101019
101120
110021
110122
111023
111124
This register is used to configure and control the BDLC.
Address:$003C
Bit 7654321Bit 0
Read:
Write:RR
Reset:11100000
IMSGCLKSR1R0
R= Reserved
00
IEWCM
Figure 4-17. BDLC Control Register 1 (BCR1)
MC68HC908AS32A Data Sheet, Rev. 1
84Freescale Semiconductor
BDLC CPU Interface
IMSG — Ignore Message Bit
This bit is used to disable the receiver until a new start-of-frame (SOF) is detected.
1 = Disable receiver. When set, all BDLC interrupt requests will be masked and the status bits will
be held in their reset state. If this bit is set while the BDLC is receiving a message, the rest of
the incoming message will be ignored.
0 = Enable receiver. This bit is cleared automatically by the reception of an SOF symbol or a BREAK
symbol. It will then generate interrupt requests and will allow changes of the status register to
occur. However, these interrupts may still be masked by the interrupt enable (IE) bit.
CLKS — Clock Bit
The nominal BDLC operating frequency (f
) must always be 1.048576 MHz or 1 MHz for J1850
BDLC
bus communications to take place. The CLKS register bit allows the user to select the frequency
(1.048576 MHz or 1 MHz) used to adjust symbol timing automatically.
1 = Binary frequency (1.048576 MHz) selected for f
0 = Integer frequency (1 MHz) selected for f
BDLC
BDLC
R1 and R0 — Rate Select Bits
These bits determine the amount by which the frequency of the MCU CGMXCLK signal is divided to
form the MUX interface clock (f
) which defines the basic timing resolution of the MUX interface.
BDLC
They may be written only once after reset, after which they become read-only bits.
The nominal frequency of f
must always be 1.048576 MHz or 1.0 MHz for J1850 bus
BDLC
communications to take place. Hence, the value programmed into these bits is dependent on the
chosen MCU system clock frequency per Table 4-3.
.
Table 4-3. BDLC Rate Selection
f
Frequency
XCLK
1.049 MHz0011.049 MHz
2.097 MHz0121.049 MHz
4.194 MHz1041.049 MHz
8.389 MHz1181.049 MHz
1.000 MHz0011.00 MHz
2.000 MHz0121.00 MHz
4.000 MHz1041.00 MHz
8.000 MHz1181.00 MHz
R1R0Division
f
BDLC
IE— Interrupt Enable Bit
This bit determines whether the BDLC will generate CPU interrupt requests in run mode. It does not
affect CPU interrupt requests when exiting the BDLC stop or BDLC wait modes. Interrupt requests will
be maintained until all of the interrupt request sources are cleared by performing the specified actions
upon the BDLC’s registers. Interrupts that were pending at the time that this bit is cleared may be lost.
1 = Enable interrupt requests from BDLC
0 = Disable interrupt requests from BDLC
If the programmer does not wish to use the interrupt capability of the BDLC, the BDLC state vector
register (BSVR) can be polled periodically by the programmer to determine BDLC states. See 4.6.4
BDLC State Vector Register for a description of the BSVR.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor85
Byte Data Link Controller (BDLC)
WCM — Wait Clock Mode Bit
This bit determines the operation of the BDLC during CPU wait mode. See 4.7.2 Stop Mode and 4.7.1
Wait Mode for more details on its use.
1 = Stop BDLC internal clocks during CPU wait mode
0 = Run BDLC internal clocks during CPU wait mode
4.6.3 BDLC Control Register 2
This register controls transmitter operations of the BDLC. It is recommended that BSET and BCLR
instructions be used to manipulate data in this register to ensure that the register’s content does not
change inadvertently.
Address:$003D
Bit 7654321Bit 0
Read:
Write:
Reset:11000000
ALOOP — Analog Loopback Mode Bit
This bit determines whether the J1850 bus will be driven by the analog physical interface’s final drive
stage. The programmer can use this bit to reset the BDLC state machine to a known state after the
off-chip analog transceiver is placed in loopback mode. When the user clears ALOOP, to indicate that
the off-chip analog transceiver is no longer in loopback mode, the BDLC waits for an EOF symbol
before attempting to transmit.
1 = Input to the analog physical interface’s final drive stage is looped back to the BDLC receiver.
The J1850 bus is not driven.
0 = The J1850 bus will be driven by the BDLC. After the bit is cleared, the BDLC requires the bus
to be idle for a minimum of end-of-frame symbol time (t
minimum of inter-frame symbol time (t
Transmitter VPW Symbol Timings.
ALOOPDLOOPRX4XENBFSTEODTSIFRTMIFR1TMIFR0
Figure 4-18. BDLC Control Register 2 (BCR2)
) before message reception or a
TRV4
) before message transmission. See 19.12.1 BDLC
TRV6
DLOOP — Digital Loopback Mode Bit
This bit determines the source to which the digital receive input (BDRxD) is connected and can be used
to isolate bus fault conditions (see Figure 4-14). If a fault condition has been detected on the bus, this
control bit allows the programmer to connect the digital transmit output to the digital receive input. In
this configuration, data sent from the transmit buffer will be reflected back into the receive buffer. If no
faults exist in the BDLC, the fault is in the physical interface block or elsewhere on the J1850 bus.
1 = When set, BDRxD is connected to BDTxD. The BDLC is now in digital loopback mode.
0 = When cleared, BDTxD is not connected to BDRxD. The BDLC is taken out of digital loopback
mode and can now drive the J1850 bus normally.
RX4XE — Receive 4X Enable Bit
This bit determines if the BDLC operates at normal transmit and receive speed (10.4 kbps) or receive
only at 41.6 kbps. This feature is useful for fast download of data into a J1850 node for diagnostic or
factory programming of the node.
1 = When set, the BDLC is put in 4X receive-only operation.
0 = When cleared, the BDLC transmits and receives at 10.4 kbps.
MC68HC908AS32A Data Sheet, Rev. 1
86Freescale Semiconductor
BDLC CPU Interface
NBFS — Normalization Bit Format Select Bit
This bit controls the format of the normalization bit (NB) (see Figure 4-19). SAE J1850 strongly
encourages using an active long (logic 0) for in-frame responses containing cyclical redundancy check
(CRC) and an active short (logic 1) for in-frame responses without CRC.
1 = NB that is received or transmitted is a 0 when the response part of an in-frame response (IFR)
ends with a CRC byte. NB that is received or transmitted is a 1 when the response part of an
in-frame response (IFR) does not end with a CRC byte.
0 = NB that is received or transmitted is a 1 when the response part of an in-frame response (IFR)
ends with a CRC byte. NB that is received or transmitted is a 0 when the response part of an
in-frame response (IFR) does not end with a CRC byte.
TEOD — Transmit End of Data Bit
This bit is set by the programmer to indicate the end of a message is being sent by the BDLC. It will
append an 8-bit CRC after completing transmission of the current byte. This bit also is used to end an
in-frame response (IFR). If the transmit shadow register is full when TEOD is set, the CRC byte will be
transmitted after the current byte in the Tx shift register and the byte in the Tx shadow register have
been transmitted. (See 4.5.3 Rx and Tx Shadow Registers for a description of the transmit shadow
register.) Once TEOD is set, the transmit data register empty flag (TDRE) in the BDLC state vector
register (BSVR) is cleared to allow lower priority interrupts to occur. See 4.6.4 BDLC State Vector
Register.
1 = Transmit end-of-data (EOD) symbol
0 = The TEOD bit will be cleared automatically at the rising edge of the first CRC bit that is sent or
if an error is detected. When TEOD is used to end an IFR transmission, TEOD is cleared when
the BDLC receives back a valid EOD symbol or an error condition occurs.
TSIFR, TMIFR1, and TMIFR0 — Transmit In-Frame Response Control Bits
These three bits control the type of in-frame response being sent. The programmer should not set
more than one of these control bits to a 1 at any given time. However, if more than one of these three
control bits are set to 1, the priority encoding logic will force these register bits to a known value as
shown in Table 4-4. For example, if 011 is written to TSIFR, TMIFR1, and TMIFR0, then internally they
will be encoded as 010. However, when these bits are read back, they will read 011.
Table 4-4. BDLC Transmit In-Frame Response
Control Bit Priority Encoding
Write/Read
TSIFR
000000
1XX100
01X010
001001
Write/Read
TMIFR1
Write/Read
TMIFR0
Actual
TSIFR
Actual
TMIFR1
Actual
TMIFR0
The BDLC supports the in-frame response (IFR) feature of J1850 by setting these bits correctly. The
four types of J1850 IFR are shown below. The purpose of the in-frame response modes is to allow
multiple nodes to acknowledge receipt of the data by responding with their personal ID or physical
address in a concatenated manner after they have seen the EOD symbol. If transmission arbitration is
lost by a node while sending its response, it continues to transmit its ID/address until observing its
unique byte in the response stream. For VPW modulation, because the first bit of the IFR is always
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor87
Byte Data Link Controller (BDLC)
passive, a normalization bit (active) must be generated by the responder and sent prior to its
ID/address byte. When there are multiple responders on the J1850 bus, only one normalization bit is
sent which assists all other transmitting nodes to sync up their response.
TSIFR — Transmit Single Byte IFR with No CRC (Type 1 or 2) Bit
The TSIFR bit is used to request the BDLC to transmit the byte in the BDLC data register (BDR, $003F)
as a single byte IFR with no CRC. Typically, the byte transmitted is a unique identifier or address of
the transmitting (responding) node. See Figure 4-19.
1 = If this bit is set prior to a valid EOD being received with no CRC error, once the EOD symbol
has been received the BDLC will attempt to transmit the appropriate normalization bit followed
by the byte in the BDR.
0 = The TSIFR bit will be cleared automatically, once the BDLC has successfully transmitted the
byte in the BDR onto the bus, or TEOD is set, or an error is detected on the bus.
EOD
EOD
EOF
EOD
EOF
NB
ID
SOF
HEADERDATA FIELDCRC
TYPE 0 — NO IFR
SOF
HEADERDATA FIELDCRC
TYPE 1 — SINGLE BYTE TRANSMITTED FROM A SINGLE RESPONDER
EOD
SOF
HEADERDATA FIELD
TYPE 2 — SINGLE BYTE TRANSMITTED FROM MULTIPLE RESPONDERS
SOF
HEADER
TYPE 3 — MULTIPLE BYTES TRANSMITTED FROM A SINGLE RESPONDER
NB = Normalization Bit
ID = Identifier (usually the physical address of the responder(s))
HEADER = Specifies one of three frame lengths
DATA FIELDCRC
CRC
EOD
EOD
NB
NB
ID1
IFR DATA FIELD
ID N
EOF
CRC
(OPTIONAL)
EOD
EOF
Figure 4-19. Types of In-Frame Response (IFR)
If the programmer attempts to set the TSIFR bit immediately after the EOD symbol has been received
from the bus, the TSIFR bit will remain in the reset state and no attempt will be made to transmit the IFR
byte.
If a loss of arbitration occurs when the BDLC attempts to transmit and after the IFR byte winning
arbitration completes transmission, the BDLC will again attempt to transmit the BDR (with no
normalization bit). The BDLC will continue transmission attempts until an error is detected on the bus, or
TEOD is set, or the BDLC transmission is successful.
If loss or arbitration occurs in the last two bits of the IFR byte, two additional 1 bits will not be sent out
because the BDLC will attempt to retransmit the byte in the transmit shift register after the IRF byte
winning arbitration completes transmission.
MC68HC908AS32A Data Sheet, Rev. 1
88Freescale Semiconductor
BDLC CPU Interface
TMIFR1 — Transmit Multiple Byte IFR with CRC (Type 3) Bit
The TMIFR1 bit requests the BDLC to transmit the byte in the BDLC data register (BDR) as the first
byte of a multiple byte IFR with CRC or as a single byte IFR with CRC. Response IFR bytes are still
subject to J1850 message length maximums. See 4.4.2 J1850 Frame Format and Figure 4-19.
If this bit is set prior to a valid EOD being received with no CRC error, once the EOD symbol has been
received the BDLC will attempt to transmit the appropriate normalization bit followed by IFR bytes. The
programmer should set TEOD after the last IFR byte has been written into the BDR register. After
TEOD has been set and the last IFR byte has been transmitted, the CRC byte is transmitted.
The TMIFR1 bit will be cleared automatically – once the BDLC has successfully transmitted the CRC
byte and EOD symbol – by the detection of an error on the multiplex bus or by a transmitter underrun
caused when the programmer does not write another byte to the BDR after the TDRE interrupt.
If the TMIFR1 bit is set, the BDLC will attempt to transmit the normalization symbol followed by the byte
in the BDR. After the byte in the BDR has been loaded into the transmit shift register, a TDRE interrupt
(see 4.6.4 BDLC State Vector Register) will occur similar to the main message transmit sequence. The
programmer should then load the next byte of the IFR into the BDR for transmission. When the last
byte of the IFR has been loaded into the BDR, the programmer should set the TEOD bit in the BDLC
control register 2 (BCR2). This will instruct the BDLC to transmit a CRC byte once the byte in the BDR
is transmitted and then transmit an EOD symbol, indicating the end of the IFR portion of the message
frame.
However, if the programmer wishes to transmit a single byte followed by a CRC byte, the programmer
should load the byte into the BDR before the EOD symbol has been received, and then set the TMIFR1
bit. Once the TDRE interrupt occurs, the programmer should then set the TEOD bit in the BCR2. This
will result in the byte in the BDR being the only byte transmitted before the IFR CRC byte, and no TDRE
interrupt will be generated.
If the programmer attempts to set the TMIFR1 bit immediately after the EOD symbol has been received
from the bus, the TMIFR1 bit will remain in the reset state, and no attempt will be made to transmit an
IFR byte.
If a loss of arbitration occurs when the BDLC is transmitting any byte of a multiple byte IFR, the BDLC
will go to the loss of arbitration state, set the appropriate flag, and cease transmission.
If the BDLC loses arbitration during the IFR, the TMIFR1 bit will be cleared and no attempt will be made
to retransmit the byte in the BDR. If loss of arbitration occurs in the last two bits of the IFR byte, two
additional 1 bits will be sent out.
NOTE
The extra logic 1s are an enhancement to the J1850 protocol which forces
a byte boundary condition fault. This is helpful in preventing noise from
going onto the J1850 bus from a corrupted message.
TMIFR0 — Transmit Multiple Byte IFR without CRC (Type 3) Bit
The TMIFR0 bit is used to request the BDLC to transmit the byte in the BDLC data register (BDR) as
the first byte of a multiple byte IFR without CRC. Response IFR bytes are still subject to J1850
message length maximums. See 4.4.2 J1850 Frame Format and Figure 4-19.
1 = If this bit is set prior to a valid EOD being received with no CRC error, once the EOD symbol
has been received the BDLC will attempt to transmit the appropriate normalization bit followed
by IFR bytes. The programmer should set TEOD after the last IFR byte has been written into
the BDR register. After TEOD has been set, the last IFR byte to be transmitted will be the last
byte which was written into the BDR register.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor89
Byte Data Link Controller (BDLC)
0 = The TMIFR0 bit will be cleared automatically; once the BDLC has successfully transmitted the
EOD symbol; by the detection of an error on the multiplex bus; or by a transmitter underrun
caused when the programmer does not write another byte to the BDR after the TDRE interrupt.
If the TMIFR0 bit is set, the BDLC will attempt to transmit the normalization symbol followed by the byte
in the BDR. After the byte in the BDR has been loaded into the transmit shift register, a TDRE interrupt
(see 4.6.4 BDLC State Vector Register) will occur similar to the main message transmit sequence. The
programmer should then load the next byte of the IFR into the BDR for transmission. When the last
byte of the IFR has been loaded into the BDR, the programmer should set the TEOD bit in the BCR2.
This will instruct the BDLC to transmit an EOD symbol once the byte in the BDR is transmitted,
indicating the end of the IFR portion of the message frame. The BDLC will not append a CRC when
the TMIFR0 is set.
If the programmer attempts to set the TMIFR0 bit after the EOD symbol has been received from the
bus, the TMIFR0 bit will remain in the reset state, and no attempt will be made to transmit an IFR byte.
If a loss of arbitration occurs when the BDLC is transmitting, the TMIFR0 bit will be cleared and no
attempt will be made to retransmit the byte in the BDR. If loss of arbitration occurs in the last two bits
of the IFR byte, two additional 1 bits (active short bits) will be sent out.
NOTE
The extra logic 1s are an enhancement to the J1850 protocol which forces
a byte boundary condition fault. This is helpful in preventing noise from
going onto the J1850 bus from a corrupted message.
4.6.4 BDLC State Vector Register
This register is provided to substantially decrease the CPU overhead associated with servicing interrupts
while under operation of a multiplex protocol. It provides an index offset that is directly related to the
BDLC’s current state, which can be used with a user-supplied jump table to rapidly enter an interrupt
service routine. This eliminates the need for the user to maintain a duplicate state machine in software.
Address:$003E
Bit 7654321Bit 0
Read:0 0 I3I2I1I0 0 0
Write:RRRRRRRR
Reset:00000000
R= Reserved
Figure 4-20. BDLC State Vector Register (BSVR)
I0, I1, I2, and I3 — Interrupt Source Bits
These bits indicate the source of the interrupt request that currently is pending. The encoding of these
bits are listed in Table 4-5.
Bits I0, I1, I2, and I3 are cleared by a read of the BSVR except when the BDLC data register needs
servicing (RDRF, RXIFR, or TDRE conditions). RXIFR and RDRF can be cleared only by a read of the
BSVR followed by a read of the BDLC data register (BDR). TDRE can either be cleared by a read of
the BSVR followed by a write to the BDLC BDR or by setting the TEOD bit in BCR2.
MC68HC908AS32A Data Sheet, Rev. 1
90Freescale Semiconductor
BDLC CPU Interface
Table 4-5. BDLC Interrupt Sources
BSVRI3I2I1I0Interrupt SourcePriority
$00 0000No interrupts pending0 (lowest)
$04 0001Received EOF1
$08 0010Received IFR byte (RXIFR)2
$0C 0011BDLC Rx data register full (RDRF)3
$10 0100 BDLC Tx data register empty (TDRE)4
$14 0101Loss of arbitration5
$18 0110 Cyclical redundancy check (CRC) error6
$1C 0111Symbol invalid or out of range7
$20 1000wakeup8 (highest)
Upon receiving a BDLC interrupt, the user can read the value within the BSVR, transferring it to the CPU’s
index register. The value can then be used to index into a jump table, with entries four bytes apart, to
quickly enter the appropriate service routine. For example:
ServiceLDXBSVRFetch State Vector Number
JMPJMPTAB,XEnter service routine,
*(must end in RTI)
*
JMPTABJMPSERVE0Service condition #0
NOP
JMPSERVE1Service condition #1
NOP
JMPSERVE2Service condition #2
NOP
*
JMPSERVE8Service condition #8
END
NOTE
The NOPs are used only to align the JMPs onto 4-byte boundaries so that
the value in the BSVR can be used intact. Each of the service routines must
end with an RTI instruction to guarantee correct continued operation of the
device. Note also that the first entry can be omitted since it corresponds to
no interrupt occurring.
The service routines should clear all of the sources that are causing the pending interrupts. Note that the
clearing of a high priority interrupt may still leave a lower priority interrupt pending, in which case bits I0,
I1, and I2 of the BSVR will then reflect the source of the remaining interrupt request.
If fewer states are used or if a different software approach is taken, the jump table can be made smaller
or omitted altogether.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor91
Byte Data Link Controller (BDLC)
4.6.5 BDLC Data Register
Address:$003F
Bit 7654321Bit 0
Read:
Write:
Reset:Unaffected by Reset
This register is used to pass the data to be transmitted to the J1850 bus from the CPU to the BDLC. It is
also used to pass data received from the J1850 bus to the CPU. Each data byte (after the first one) should
be written only after a Tx data register empty (TDRE) state is indicated in the BSVR.
Data read from this register will be the last data byte received from the J1850 bus. This received data
should only be read after an Rx data register full (RDRF) interrupt has occurred. See 4.6.4 BDLC State
Vector Register.
The BDR is double buffered via a transmit shadow register and a receive shadow register. After the byte
in the transmit shift register has been transmitted, the byte currently stored in the transmit shadow register
is loaded into the transmit shift register. Once the transmit shift register has shifted the first bit out, the
TDRE flag is set, and the shadow register is ready to accept the next data byte. The receive shadow
register works similarly. Once a complete byte has been received, the receive shift register stores the
newly received byte into the receive shadow register. The RDRF flag is set to indicate that a new byte of
data has been received. The programmer has one BDLC byte reception time to read the shadow register
and clear the RDRF flag before the shadow register is overwritten by the newly received byte.
D7D6D5D4D3D2D1D0
Figure 4-21. BDLC Data Register (BDR)
To abort an in-progress transmission, the programmer should stop loading data into the BDR. This will
cause a transmitter underrun error and the BDLC automatically will disable the transmitter on the next
non-byte boundary. This means that the earliest a transmission can be halted is after at least one byte
plus two extra logic 1s have been transmitted. The receiver will pick this up as an error and relay it in the
state vector register as an invalid symbol error.
NOTE
The extra logic 1s are an enhancement to the J1850 protocol which forces
a byte boundary condition fault. This is helpful in preventing noise from
going onto the J1850 bus from a corrupted message.
4.7 Low-Power Modes
The following information concerns wait mode and stop mode.
4.7.1 Wait Mode
This power-conserving mode is entered automatically from run mode whenever the CPU executes a
WAIT instruction and the WCM bit in BDLC control register 1 (BCR1) is previously clear. In BDLC wait
mode, the BDLC cannot drive any data.
A subsequent successfully received message, including one that is in progress at the time that this mode
is entered, will cause the BDLC to wake up and generate a CPU interrupt request if the interrupt enable
(IE) bit in the BDLC control register 1 (BCR1) is previously set. (See 4.6.2 BDLC Control Register 1 for a
MC68HC908AS32A Data Sheet, Rev. 1
92Freescale Semiconductor
Low-Power Modes
better understanding of IE.) This results in less of a power saving, but the BDLC is guaranteed to receive
correctly the message which woke it up, since the BDLC internal operating clocks are kept running.
NOTE
Ensuring that all transmissions are complete or aborted before putting the
BDLC into wait mode is important.
4.7.2 Stop Mode
This power-conserving mode is entered automatically from run mode whenever the CPU executes a
STOP instruction or if the CPU executes a WAIT instruction and the WCM bit in the BDLC control
register 1 (BCR1) is previously set. This is the lowest power mode that the BDLC can enter.
A subsequent passive-to-active transition on the J1850 bus will cause the BDLC to wake up and generate
a non-maskable CPU interrupt request. When a STOP instruction is used to put the BDLC in stop mode,
the BDLC is not guaranteed to correctly receive the message which woke it up, since it may take some
time for the BDLC internal operating clocks to restart and stabilize. If a WAIT instruction is used to put the
BDLC in stop mode, the BDLC is guaranteed to correctly receive the byte which woke it up, if and only if
an end-of-frame (EOF) has been detected prior to issuing the WAIT instruction by the CPU. Otherwise,
the BDLC will not correctly receive the byte that woke it up.
If this mode is entered while the BDLC is receiving a message, the first subsequent received edge will
cause the BDLC to wake up immediately, generate a CPU interrupt request, and wait for the BDLC
internal operating clocks to restart and stabilize before normal communications can resume. Therefore,
the BDLC is not guaranteed to receive that message correctly.
NOTE
It is important to ensure all transmissions are complete or aborted prior to
putting the BDLC into stop mode.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor93
Byte Data Link Controller (BDLC)
MC68HC908AS32A Data Sheet, Rev. 1
94Freescale Semiconductor
Chapter 5
Clock Generator Module (CGM)
5.1 Introduction
The CGM generates the crystal clock signal, CGMXCLK, which operates at the frequency of the crystal.
The CGM also generates the base clock signal, CGMOUT, from which the system clocks are derived.
CGMOUT is based on either the crystal clock divided by two or the phase-locked loop (PLL) clock,
CGMVCLK, divided by two. The PLL is a frequency generator designed for use with 1-MHz to 8-MHz
crystals or ceramic resonators. The PLL can generate an 8-MHz bus frequency without using high
frequency crystals.
5.2 Features
Features include:
•Phase-locked loop with output frequency in integer multiples of the crystal reference
•Programmable hardware voltage-controlled oscillator (VCO) for low-jitter operation
•Automatic bandwidth control mode for low-jitter operation
•Automatic frequency lock detector
•CPU interrupt on entry or exit from locked condition
5.3 Functional Description
The CGM consists of three major submodules:
•Crystal oscillator circuit — The crystal oscillator circuit generates the constant crystal frequency
clock, CGMXCLK.
•Phase-locked loop (PLL) — The PLL generates the programmable VCO frequency clock
CGMVCLK.
•Base clock selector circuit — This software-controlled circuit selects either CGMXCLK divided by
two or the VCO clock, CGMVCLK, divided by two as the base clock, CGMOUT. The system clocks
are derived from CGMOUT.
Figure 5-2 shows the structure of the CGM.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor95
Clock Generator Module (CGM)
M68HC08 CPU
CPU
REGISTERS
CONTROL AND STATUS REGISTERS
USER FLASH — 32, 256 BYTES
USER RAM — 1024 BYTES
USER EEPROM — 512 BYTES
MONITOR ROM — 256 BYTES
USER FLASH VECTOR SPACE — 52 BYTES
OSC1
OSC2
CGMXFC
RST
IRQ
ARITHMETIC/LOGIC
UNIT (ALU)
CLOCK GENERATOR
MODULE
SYSTEM INTEGRATION
MODULE
IRQ MODULE
V
REFH
ANALOG-TO-DIGITAL
MODULE
BREAK MODULE
LOW-VOLTAGE INHIBIT
MODULE
COMPUTER OPERATING
PROPERLY MODULE
6-CHANNEL TIMER
INTERFACE MODULE
PROGRAMMABLE INTERRUPT
TIMER MODULE
SERIAL COMMUNICATIONS
INTERFACE MODULE
SERIAL PERIPHERAL
INTERFACE MODULE
BYTE DATA LINK CONTROLLER
DDRA
DDRB
DDRC
DDRD
DDRE
DDRF
PTA
PTB
PTC
PTD
PTE
PTF
PTA7–PTA0
PTB7/ATD7–
PTB0/ATD0
PTC4
PTC3
PTC2/MCLK
PTC1–PTC0
PTD6/ATD14/TCLK
PTD5/ATD13
PTA4/ATD12
PTD3/ATD11–
PTD0/ATD8
PTE7/SPSCK
PTE6/MOSI
PTE5/MISO
PTE4/SS
PTE3/TCH1
PTE2/TCH0
PTE1/RxD
PTE0/TxD
PTF3/TCH5–
PTF0/TCH2
POWER-ON RESET
MODULE
V
SS
V
DD
V
DDA
V
SSA
POWER
BDRxDBDTxD
AVSS/V
REFK
V
DDAREF
Figure 5-1. Block Diagram Highlighting CGM Block and Pins
MC68HC908AS32A Data Sheet, Rev. 1
96Freescale Semiconductor
Functional Description
OSC1
CGMRDV
PHASE
DETECTOR
LOCK
DETECTOR
LOCKAUTOACQ
V
DDA
CGMRCLK
CGMXFCV
LOOP
FILTER
BANDWIDTH
CONTROL
SS
PLL ANALOG
CLOCK
SELECT
CIRCUIT
BCS
VRS7–VRS4
VOLTAGE
CONTROLLED
OSCILLATOR
INTERRUPT
CONTROL
PLLIEPLLF
÷ 2
A
B
S*
CGMINT
*When S = 1,
CGMOUT = B
CGMXCLK
CGMOUT
PTC3
MONITOR MODE
USER MODE
MUL7–MUL4
CGMVDVCGMVCLK
FREQUENCY
DIVIDER
Figure 5-2. CGM Block Diagram
5.3.1 Crystal Oscillator Circuit
The crystal oscillator circuit consists of an inverting amplifier and an external crystal. The OSC1 pin is the
input to the amplifier and the OSC2 pin is the output. The SIMOSCEN signal enables the crystal oscillator
circuit.
The CGMXCLK signal is the output of the crystal oscillator circuit and runs at a rate equal to the crystal
frequency. CGMXCLK is then buffered to produce CGMRCLK, the PLL reference clock.
CGMXCLK can be used by other modules which require precise timing for operation. The duty cycle of
CGMXCLK is not guaranteed to be 50% and depends on external factors, including the crystal and related
external components.
An externally generated clock also can feed the OSC1 pin of the crystal oscillator circuit. Connect the
external clock to the OSC1 pin and let the OSC2 pin float.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor97
Clock Generator Module (CGM)
5.3.2 Phase-Locked Loop Circuit (PLL)
The PLL is a frequency generator that can operate in either acquisition mode or tracking mode, depending
on the accuracy of the output frequency. The PLL can change between acquisition and tracking modes
either automatically or manually.
5.3.2.1 Circuits
The PLL consists of these circuits:
•Voltage-controlled oscillator (VCO)
•Modulo VCO frequency divider
•Phase detector
•Loop filter
•Lock detector
The operating range of the VCO is programmable for a wide range of frequencies and for maximum
immunity to external noise, including supply and CGMXFC noise. The VCO frequency is bound to a range
from roughly one-half to twice the center-of-range frequency, f
CGMVRS
CGMXFC pin changes the frequency within this range. By design, f
center-of-range frequency, f
, (4.9152 MHz) times a linear factor L or (L)f
NOM
CGMRCLK is the PLL reference clock, a buffered version of CGMXCLK. CGMRCLK runs at a frequency,
f
CGMRCLK
running at a frequency f
The VCO’s output clock, CGMVCLK, running at a frequency f
, and is fed to the PLL through a buffer. The buffer output is the final reference clock, CGMRDV,
CGMRDV=fCGMRCLK
.
CGMVCLK
programmable modulo divider. The modulo divider reduces the VCO clock by a factor, N. The divider’s
output is the VCO feedback clock, CGMVDV, running at a frequency f
Programming the PLL for more information.
. Modulating the voltage on the
CGMVRS
is equal to the nominal
.
NOM
, is fed back through a
CGMVDV=fCGMVCLK
/N. See 5.3.2.4
The phase detector then compares the VCO feedback clock, CGMVDV, with the final reference clock,
CGMRDV. A correction pulse is generated based on the phase difference between the two signals. The
loop filter then slightly alters the dc voltage on the external capacitor connected to CGMXFC based on
the width and direction of the correction pulse. The filter can make fast or slow corrections depending on
its mode, as described in 5.3.2.2 Acquisition and Tracking Modes. The value of the external capacitor and
the reference frequency determines the speed of the corrections and the stability of the PLL.
The lock detector compares the frequencies of the VCO feedback clock, CGMVDV, and the final
reference clock, CGMRDV. Therefore, the speed of the lock detector is directly proportional to the final
reference frequency, f
CGMRDV
. The circuit determines the mode of the PLL and the lock condition based
on this comparison.
5.3.2.2 Acquisition and Tracking Modes
The PLL filter is manually or automatically configurable into one of two operating modes:
•Acquisition mode — In acquisition mode, the filter can make large frequency corrections to the
VCO. This mode is used at PLL startup or when the PLL has suffered a severe noise hit and the
VCO frequency is far off the desired frequency. When in acquisition mode, the ACQ
bit is clear in
the PLL bandwidth control register. See 5.5.2 PLL Bandwidth Control Register for more
information.
MC68HC908AS32A Data Sheet, Rev. 1
98Freescale Semiconductor
Functional Description
•Tracking mode — In tracking mode, the filter makes only small corrections to the frequency of the
VCO. PLL jitter is much lower in tracking mode, but the response to noise is also slower. The PLL
enters tracking mode when the VCO frequency is nearly correct, such as when the PLL is selected
as the base clock source. See 5.3.3 Base Clock Selector Circuit for more information. The PLL is
automatically in tracking mode when it’s not in acquisition mode or when the ACQ
bit is set.
5.3.2.3 Manual and Automatic PLL Bandwidth Modes
The PLL can change the bandwidth or operational mode of the loop filter manually or automatically.
In automatic bandwidth control mode (AUTO = 1), the lock detector automatically switches between
acquisition and tracking modes. Automatic bandwidth control mode also is used to determine when the
VCO clock, CGMVCLK, is safe to use as the source for the base clock, CGMOUT. See 5.5.2 PLL
Bandwidth Control Register for more information. If PLL CPU interrupt requests are enabled, the software
can wait for a PLL CPU interrupt request and then check the LOCK bit. If CPU interrupts are disabled,
software can poll the LOCK bit continuously (during PLL startup, usually) or at periodic intervals. In either
case, when the LOCK bit is set, the VCO clock is safe to use as the source for the base clock. See 5.3.3
Base Clock Selector Circuit for more information. If the VCO is selected as the source for the base clock
and the LOCK bit is clear, the PLL has suffered a severe noise hit and the software must take appropriate
action, depending on the application. See 5.6 Interrupts for more information.
These conditions apply when the PLL is in automatic bandwidth control mode:
•The ACQ
bit (see 5.5.2 PLL Bandwidth Control Register) is a read-only indicator of the mode of the
filter. See 5.3.2.2 Acquisition and Tracking Modes for more information.
•The ACQ
the VCO frequency is out of a certain tolerance, ∆
bit is set when the VCO frequency is within a certain tolerance, ∆
. See Chapter 19 Electrical Specifications for
unt
, and is cleared when
trk
more information.
•The LOCK bit is a read-only indicator of the locked state of the PLL.
•The LOCK bit is set when the VCO frequency is within a certain tolerance, ∆
when the VCO frequency is out of a certain tolerance, ∆
. See Chapter 19 Electrical
UNL
, and is cleared
Lock
Specifications for more information.
•CPU interrupts can occur if enabled (PLLIE = 1) when the PLL’s lock condition changes, toggling
the LOCK bit. See 5.5.1 PLL Control Register for more information.
The PLL also can operate in manual mode (AUTO = 0). Manual mode is used by systems that do not
require an indicator of the lock condition for proper operation. Such systems typically operate well below
f
BUSMAX
and require fast startup. The following conditions apply when in manual mode:
•ACQ
•Before entering tracking mode (ACQ
is a writable control bit that controls the mode of the filter. Before turning on the PLL in manual
mode, the ACQ
bit must be clear.
= 1), software must wait a given time, t
(see Chapter 19
ACQ
Electrical Specifications for more information), after turning on the PLL by setting PLLON in the PLL
control register (PCTL).
•Software must wait a given time, t
, after entering tracking mode before selecting the PLL as the
AL
clock source to CGMOUT (BCS = 1).
•The LOCK bit is disabled.
•CPU interrupts from the CGM are disabled.
MC68HC908AS32A Data Sheet, Rev. 1
Freescale Semiconductor99
Clock Generator Module (CGM)
5.3.2.4 Programming the PLL
Use this 9-step procedure to program the PLL. Table 5-1 lists the variables used and their meaning.
Please also reference Figure 5-2
Table 5-1. Variable Definitions
.
VariableDefinition
f
BUSDES
f
VCLKDES
f
CGMRCLK
f
CGMVCLK
f
BUS
f
NOM
f
CGMVRS
Desired bus clock frequency
Desired VCO clock frequency
Chosen reference crystal frequency
Calculated VCO clock frequency
Calculated bus clock frequency
Nominal VCO center frequency
Shifted VCO center frequency
1.Choose the desired bus frequency, f
Example: f
BUSDES
= 8 MHz
2.Calculate the desired VCO frequency, f
Example: f
VCLKDES
= 4 × 8 MHz = 32 MHz
3.Using a reference frequency, f
BUSDES
VCLKDES
, equal to the crystal frequency, calculate the VCO frequency
RCLK
multiplier, N. Round the result to the nearest integer.
N
------------------------- ---=
f
4.Calculate the VCO frequency, f
Example: f
5.Calculate the bus frequency, f
Example:
Example:
CGMVCLK
f
CGMVCLK
CGMVCLK
, and compare f
BUS
f
Bus
f
Bus
N
.
.
. f
VCLKDES
f
VCLKDES
CGMRCLK
32 MHz
--------------------=8=
4 MHz
Nf
×=
CGMRCLK
= 4 × f
= 8 × 4 MHz = 32 MHz
with f
BUS
f
CGMVCLK
------------------------- ------=
4
32 MHz
--------------------=8 MHz=
4
BUSDES
BUSDES
.
6.If the calculated f
another f
100Freescale Semiconductor
RCLK
.
is not within the tolerance limits of your application, select another f
Bus
MC68HC908AS32A Data Sheet, Rev. 1
BUSDES
or
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.