To provide the most up-to-date information, the revision of our documents on the World Wide Web will be
the most current. Your printed copy may be an earlier revision. To verify you have the latest information
available, refer to:
http://freescale.com/
The following revision history table summarizes changes contained in this document.
Revision History
Date
October 10, 200501.07New Data Sheet
Revision
Level
Description
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
This product incorporates SuperFlash® technology licensed from SST.
The MC9S12E128 is a 112/80/64 pin low cost general purpose MCU comprised of standard on-chip
peripherals including a 16-bit central processing unit (HCS12 CPU), up to 128K bytes of Flash EEPROM,
up to 8K bytes of RAM, three asynchronous serial communications interface modules (SCI), a serial
peripheral interface (SPI), an Inter-IC Bus (IIC), three 4-channel 16-bit timer modules (TIM), a 6-channel
15-bit Pulse Modulator with Fault protection module (PMF), a 6-channel 8-bit Pulse Width Modulator
(PWM), a 16-channel 10-bit analog-to-digital converter (ADC), and two 1-channel 8-bit digital-to-analog
converters (DAC). The MC9S12E128 has full 16-bit data paths throughout. The inclusion of a PLL circuit
allows power consumption and performance to be adjusted to suit operational requirements. In addition to
the I/O ports available on each module, 16 dedicated I/O port bits are available with Wake-Up capability
from STOP or WAIT mode. Furthermore, an on chip bandgap based voltage regulator (VREG) generates
the internal digital supply voltage of 2.5V (VDD) from a 3.135V to 5.5V external supply range.
1.1.1Features
•16-bit HCS12 CORE
— HCS12 CPU
– i. Upward compatible with M68HC11 instruction set
– ii. Interrupt stacking and programmer’s model identical to M68HC11
– iii. Instruction queue
– iv. Enhanced indexed addressing
— Module Mapping Control (MMC)
— Interrupt control (INT)
— Background Debug Module (BDM)
— Debugger (DBG12) including breakpoints and change-of-flow trace buffer
— Multiplexed External Bus Interface (MEBI)
•Wake-Up interrupt inputs
— Up to 16 port bits available for wake up interrupt function with digital filtering
•Memory Options
— 32K, 64K or 128K Byte Flash EEPROM
•6 PWM channels (PWM)
— Programmable period and duty cycle
— 8-bit 6-channel or 16-bit 3-channel
— Separate control for each pulse width and duty cycle
— Center-aligned or left-aligned outputs
— Programmable clock select logic with a wide range of frequencies
— Fast emergency shutdown input
•6-channel Pulse width Modulator with Fault protection (PMF)
— Three independent 15-bit counters with synchronous mode
— Complementary channel operation
— Edge and center aligned PWM signals
— Programmable dead time insertion
— Integral reload rates from 1 to 16
— Four fault protection shut down input pins
— Three current sense input pins
•Serial interfaces
— Three asynchronous serial communication interfaces (SCI)
— Synchronous serial peripheral interface (SPI)
— Inter-IC Bus (IIC)
•Clock and Reset Generator (CRG)
— Windowed COP watchdog
— Real Time interrupt
— Clock Monitor
— Pierce or low current Colpitts oscillator
— Phase-locked loop clock frequency multiplier
— Self Clock mode in absence of external clock
— Low power 0.5 to 16Mhz crystal oscillator reference clock
MC9S12E128 Data Sheet, Rev. 1.07
22Freescale Semiconductor
•Operating frequency
— 50MHz equivalent to 25MHz Bus Speed
•Internal 2.5V Regulator
— Input voltage range from 3.135V to 5.5V
— Low power mode capability
— Includes low voltage reset (LVR) circuitry
— Includes low voltage interrupt (LVI) circuitry
•112-Pin LQFP or 80-Pin QFP or 64-Pin QFN package
— Up to 90 I/O lines with 5V input and drive capability (112 pin package)
— Up to two dedicated 5V input only lines (IRQ and XIRQ)
— Sixteen 3.3V/5V A/D converter inputs
Table 1-1 shows the device register map of the MC9S12E128 after reset. Figure 1-2, Figure 1-3 and
Figure 1-4 illustrate the device memory map with Flash and RAM.
Table 1-1. Device Register Map Overview
AddressModuleSize
0x0000–0x0017CORE (Ports A, B, E, Modes, Inits, Test)24
0x0020–0x002FCORE (DBG)16
0x0030–0x0033CORE (PPAGE, Port K)4
0x0034–0x003FClock and Reset Generator (PLL, RTI, COP)12
0x0040–0x006FStandard Timer 16-bit 4 channels (TIM0)48
0x0070–0x007FReserved16
0x0080–0x00AF Analog to Digital Converter 10-bit 16 channels (ATD)48
0x00B0–0x00C7 Reserved24
0x00C8–0x00CF Serial Communications Interface 0 (SCI0)8
0x00D0–0x00D7 Serial Communications Interface 1 (SCI1)8
0x00D8–0x00DF Serial Peripheral Interface (SPI)8
0x00E0–0x00E7 Inter IC Bus8
0x00E8–0x00EF Serial Communications Interface 2 (SCI2)8
0x00F0–0x00F3Digital to Analog Converter 8-bit 1-channel (DAC0)4
0x00F4–0x00F7Digital to Analog Converter 8-bit 1-channel (DAC1)4
0x00F8–0x00FF Reserved8
The part ID is located in two 8-bit registers PARTIDH and PARTIDL (addresses 0x001A and 0x001B after
reset. The read-only value is a unique part ID for each revision of the chip. Table 1-2 shows the assigned
part ID numbers.
Table 1-2. Assigned Part ID Numbers
DeviceMask Set NumberPart ID
MC9S12E1282L15P0x5102
1
The coding is as follows:
Bit 15–12: Major family identifier
Bit 11–8: Minor family identifier
Bit 7–4: Major mask set revision number including FAB transfers
Bit 3–0: Minor — non full — mask set revision
1
The device memory sizes are located in two 8-bit registers MEMSIZ0 and MEMSIZ1 (addresses 0x001C
and 0x001D after reset). Table 1-3 shows the read-only values of these registers. Refer to HCS12 Module
Mapping Control (MMC) block description chapter for further details.
The Port E output buffer enable signal control at reset is determined by the PEAR register and is mode dependent. For
example, in special test mode RDWE = LSTRE = 1 which enables the PE[3:2] output buffers and disables the pull-ups. Refer
to the S12 MEBI block description chapter for PEAR register details.
Pin Name
Function 2
IS[6:4]—VDDXPERQ/
Pin Name
Function 3
Power
Domain
Internal Pull Resistor
CTRLReset State
DisabledPort M I/O Pin, DAC0 output
PPSM
DisabledPort P I/O Pins, PWM output
PPSP
DisabledPort Q I/O Pins, IS[6:4] input
PPSQ
DisabledPort Q I/O Pins, Fault[3:0] input
PPSQ
UpPort S I/O Pin, SPI SS signal
PPSS
UpPort S I/O Pin, SPI SCK signal
PPSS
UpPort S I/O Pin, SPI MOSI signal
PPSS
UpPort S I/O Pin, SPI MISO signal
PPSS
UpPort S I/O Pin, SCI1 transmit signal
PPSS
UpPort S I/O Pin, SCI1 receive signal
PPSS
UpPort S I/O Pin, SCI0 transmit signal
PPSS
UpPort S I/O Pin, SCI0 receive signal
PPSS
DisabledPort T I/O Pins, timer (TIM1)
PPST
DisabledPort T I/O Pins, timer (TIM0)
PPST
DisabledPort U I/O Pins
PPSU
DisabledPort U I/O Pins, PWM outputs
PPSU
DisabledPort U I/O Pins, timer (TIM2), PWM
PPSU
Description
outputs
NOTE
Signals shown in bold are not available in the 112-pin package.
Signals shown in italic are not available in the 80-pin package.
If the port pins are not bonded out in the chosen package the user should initialize the registers to be inputs
with enabled pull resistance to avoid excess current consumption. This applies to the following pins:
(80QFP): Port A[7:0], Port B[7:0], Port E[6,5,3,2], Port K[7:0], Port U[7:4]
(64QFN): Port U[3:0], Port Q[6:4], Port M[3], Port AD[14,11,10,9,7,5,3,1]
EXTAL and XTAL are the external clock and crystal driver pins. On reset all the device clocks are derived
from the EXTAL input frequency. XTAL is the crystal output.
1.4.2RESET — External Reset Pin
RESET is an active low bidirectional control signal that acts as an input to initialize the MCU to a known
start-up state. It also acts as an open-drain output to indicate that an internal failure has been detected in
either the clock monitor or COP watchdog circuit. External circuitry connected to the RESET pin should
not include a large capacitance that would interfere with the ability of this signal to rise to a valid logic one
within 32 ECLK cycles after the low drive is released. Upon detection of any reset, an internal circuit
drives the RESET pin low and a clocked reset sequence controls when the MCU can begin normal
processing.
1.4.3TEST — Test Pin
The TEST pin is reserved for test and must be tied to VSS in all applications.
1.4.4XFC — PLL Loop Filter Pin
Dedicated pin used to create the PLL loop filter. See the CRG block description chapter for more detailed
information.
1.4.5BKGD / TAGHI / MODC — Background Debug, Tag High & Mode Pin
The BKGD / TAGHI / MODC pin is used as a pseudo-open-drain pin for the background debug
communication. It is used as a MCU operating mode select pin during reset. The state of this pin is latched
to the MODC bit at the rising edge of RESET. In MCU expanded modes of operation, when instruction
tagging is on, an input low on this pin during the falling edge of E-clock tags the high half of the instruction
word being read into the instruction queue. This pin always has an internal pull up.
1.4.6PA[7:0] / ADDR[15:8] / DATA[15:8] — Port A I/O Pins
PA[7:0] are general purpose input or output pins. In MCU expanded modes of operation, these pins are
used for the multiplexed external address and data bus. PA[7:0] pins are not available in the 80 pin package
version.
1.4.7PB[7:0] / ADDR[7:0] / DATA[7:0] — Port B I/O Pins
PB[7:0] are general purpose input or output pins. In MCU expanded modes of operation, these pins are
used for the multiplexed external address and data bus. PB[7:0] pins are not available in the 80 pin package
version.
PE7 is a general purpose input or output pin. During MCU expanded modes of operation, the NOACC
signal, when enabled, is used to indicate that the current bus cycle is an unused or “free cycle”. This signal
will assert when the CPU is not using the bus. The
crystal in combination with the internal Colpitts (low power) oscillator is used or whether Pierce
oscillator/external clock circuitry is used. The state of this pin is latched at the rising edge of
the input is a logic low the EXTAL pin is configured for an external clock drive or a Pierce Oscillator. If
the input is a logic high a Colpitts oscillator circuit is configured on EXTAL and XTAL. Since this pin is
an input with a pull-up device during reset, if the pin is left floating, the default configuration is a Colpitts
oscillator circuit on EXTAL and XTAL.
EXTAL
1
CDC
MCU
XTAL
XCLKS is an input signal which controls whether a
RESET. If
C1
C2
Crystal or
ceramic resonator
VSSPLL
1. Due to the nature of a translated ground Colpitts oscillator a DC voltage bias is
applied to the crystal. Please contact the crystal manufacturer for crystal DC
PE6 is a general purpose input or output pin. It is used as a MCU operating mode select pin during reset.
The state of this pin is latched to the MODB bit at the rising edge of RESET. This pin is shared with the
instruction queue tracking signal IPIPE1. This pin is an input with a pull-down device which is only active
when RESET is low. PE6 is not available in the 80 pin package version.
PE5 is a general purpose input or output pin. It is used as a MCU operating mode select pin during reset.
The state of this pin is latched to the MODA bit at the rising edge of RESET. This pin is shared with the
instruction queue tracking signal IPIPE0. This pin is an input with a pull-down device which is only active
when RESET is low. PE5 is not available in the 80-pin package version.
1.4.11PE4 / ECLK— Port E I/O Pin 4 / E-Clock Output
PE4 is a general purpose input or output pin. In Normal Single Chip mode PE4 is configured with an active
pull-up while in reset and immediately out of reset. The pullup can be turned off by clearing PUPEE in the
PUCR register. In all modes except Normal Single Chip Mode, the PE4 pin is initially configured as the
output connection for the internal bus clock (ECLK). ECLK is used as a timing reference and to
demultiplex the address and data in expanded modes. The ECLK frequency is equal to 1/2 the crystal
frequency out of reset. The ECLK output function depends upon the settings of the NECLK bit in the
PEAR register, the IVIS bit in the MODE register and the ESTR bit in the EBICTL register. All clocks,
including the ECLK, are halted when the MCU is in STOP mode. It is possible to configure the MCU to
interface to slow external memory. ECLK can be stretched for such accesses. The PE4 pin is initially
configured as ECLK output with stretch in all expanded modes. Reference the MISC register (EXSTR[1:0]
bits) for more information. In normal expanded narrow mode, the ECLK is available for use in external
select decode logic or as a constant speed clock for use in the external application system.
1.4.12PE3 / LSTRB / TAGLO — Port E I/O Pin 3 / Low-Byte Strobe (LSTRB)
PE3 can be used as a general-purpose I/O in all modes and is an input with an active pull-up out of reset.
The pullup can be turned off by clearing PUPEE in the PUCR register. PE3 can also be configured as a
Low-Byte Strobe (
not be possible until this function is enabled.
register. In Expanded Wide and Emulation Narrow modes, and when BDM tagging is enabled, the
function is multiplexed with the
falling edge of ECLK will tag the low byte of an instruction word being read into the instruction queue.
PE3 is not available in the 80 pin package version.
LSTRB). The LSTRB signal is used in write operations, so external low byte writes will
LSTRB can be enabled by setting the LSTRE bit in the PEAR
LSTRB
TAGLO function. When enabled a logic zero on the TAGLO pin at the
1.4.13PE2 / R/W — Port E I/O Pin 2 / Read/Write
PE2 can be used as a general-purpose I/O in all modes and is configured an input with an active pull-up
out of reset. The pullup can be turned off by clearing PUPEE in the PUCR register. If the read/
function is required it should be enabled by setting the RDWE bit in the PEAR register. External writes
will not be possible until the read/
package version.
write function is enabled. The PE2 pin is not available in the 80 pin
write
1.4.14PE1 / IRQ — Port E input Pin 1 / Maskable Interrupt Pin
PE1 is always an input and can always be read. The PE1 pin is also the IRQ input used for requesting an
asynchronous interrupt to the MCU. During reset, the I bit in the condition code register (CCR) is set and
IRQ interrupt is masked until software enables it by clearing the I bit. The IRQ is software
programmable to either falling edge-sensitive triggering or level-sensitive triggering based on the setting
of the IRQE bit in the IRQCR register. The
triggering out of reset. It can be disabled by clearing IRQEN bit in the IRQCR register. There is an active
pull-up on this pin while in reset and immediately out of reset. The pullup can be turned off by clearing
PUPEE in the PUCR register.
IRQ is always enabled and configured to level-sensitive
1.4.15PE0 / XIRQ — Port E input Pin 0 / Non Maskable Interrupt Pin
PE0 is always an input and can always be read. The PE0 pin is also the XIRQ input for requesting a
nonmaskable asynchronous interrupt to the MCU. During reset, the X bit in the condition code register
(CCR) is set and any
Because the
network. There is an active pull-up on this pin while in reset and immediately out of reset. The pullup can
be turned off by clearing PUPEE in the PUCR register.
XIRQ input is level sensitive triggered, it can be connected to a multiple-source wired-OR
XIRQ interrupt is masked until MCU software enables it by clearing the X bit.
1.4.16PK7 / ECS / ROMCTL — Port K I/O Pin 7
PK7 is a general purpose input or output pin. During MCU expanded modes of operation, when the EMK
bit in the MODE register is set to 1, this pin is used as the emulation chip select output (
modes the PK7 pin can be used to determine the reset state of the ROMON bit in the MISC register. At the
rising edge of
this pin while in reset and immediately out of reset. The pullup can be turned off by clearing PUPKE in
the PUCR register. Refer to the HCS12 MEBI block description chapter for further details. PK7 is not
available in the 80 pin package version.
RESET, the state of the PK7 pin is latched to the ROMON bit. There is an active pull-up on
ECS). In expanded
1.4.17PK6 / XCS — Port K I/O Pin 6
PK6 is a general purpose input or output pin. During MCU expanded modes of operation, when the EMK
bit in the MODE register is set to 1, this pin is used as an external chip select signal for most external
accesses that are not selected by ECS. There is an active pull-up on this pin while in reset and immediately
out of reset. The pullup can be turned off by clearing PUPKE in the PUCR register. Refer to the HCS12
MEBI block description chapter for further details. PK6 is not available in the 80 pin package version.
1.4.18PK[5:0] / XADDR[19:14] — Port K I/O Pins [5:0]
PK[5:0] are general purpose input or output pins. In MCU expanded modes of operation, when the EMK
bit in the MODE register is set to 1, PK[5:0] provide the expanded address XADDR[19:14] for the external
bus. There are active pull-ups on PK[5:0] pins while in reset and immediately out of reset. The pullup can
be turned off by clearing PUPKE in the PUCR register. Refer to the HCS12 MEBI block description
chapter for further details. PK[5:0] are not available in the 80 pin package version.
1.4.19PAD[15:0] / AN[15:0] / KWAD[15:0] — Port AD I/O Pins [15:0]
PAD[15:0] are the analog inputs for the analog to digital converter (ADC). They can also be configured as
general purpose digital input or output pin. When enabled as digital inputs or outputs, the PAD[15:0] can
also be configured as Keypad Wake-up pins (KWU) and generate interrupts causing the MCU to exit STOP
or WAIT mode. Consult the Port Integration Module (PIM) PIM_9E128 block description chapter and the
ATD_10B16C block description chapter for information about pin configurations.
1.4.20PM7 / SCL — Port M I/O Pin 7
PM7 is a general purpose input or output pin. When the IIC module is enabled it becomes the serial clock
line (SCL) for the IIC module (IIC). While in reset and immediately out of reset the PM7 pin is configured
as a high impedance input pin. Consult the Port Integration Module (PIM) PIM_9E128 block description
chapter and the IIC block description chapter for information about pin configurations.
1.4.21PM6 / SDA — Port M I/O Pin 6
PM6 is a general purpose input or output pin. When the IIC module is enabled it becomes the Serial Data
Line (SDL) for the IIC module (IIC). While in reset and immediately out of reset the PM6 pin is configured
as a high impedance input pin. Consult the Port Integration Module (PIM) PIM_9E128 block description
chapter and the IIC block description chapter for information about pin configurations.
1.4.22PM5 / TXD2 — Port M I/O Pin 5
PM5 is a general purpose input or output. When the Serial Communications Interface 2 (SCI2) transmitter
is enabled the PM5 pin is configured as the transmit pin TXD2 of SCI2. While in reset and immediately
out of reset the PM5 pin is configured as a high impedance input pin. Consult the Port Integration Module
(PIM) PIM_9E128 block description chapter and the SCI block description chapter for information about
pin configurations.
1.4.23PM4 / RXD2 — Port M I/O Pin 4
PM4 is a general purpose input or output. When the Serial Communications Interface 2 (SCI2) receiver is
enabled the PM4 pin is configured as the receive pin RXD2 of SCI2. While in reset and immediately out
of reset the PM4 pin is configured as a high impedance input pin. Consult the Port Integration Module
(PIM) PIM_9E128 block description chapter and the SCI block description chapter for information about
pin configurations.
1.4.24PM3 — Port M I/O Pin 3
PM3 is a general purpose input or output pin. While in reset and immediately out of reset the PM3 pin is
configured as a high impedance input pin. Consult the Port Integration Module (PIM) PIM_9E128 block
description chapter for information about pin configurations.
1.4.25PM1 / DAO1 — Port M I/O Pin 1
PM1 is a general purpose input or output pin. When the Digital to Analog module 1 (DAC1) is enabled the
PM1 pin is configured as the analog output DA01 of DAC1. While in reset and immediately out of reset
the PM1 pin is configured as a high impedance input pin. Consult the Port Integration Module (PIM)
PIM_9E128 block description chapter and the DAC_8B1C block description chapter for information about
pin configurations.
1.4.26PM0 / DAO2 — Port M I/O Pin 0
PM0 is a general purpose input or output pin. When the Digital to Analog module 2 (DAC2) is enabled the
PM0 pin is configured as the analog output DA02 of DAC2. While in reset and immediately out of reset
the PM0 pin is configured as a high impedance input pin. Consult the Port Integration Module (PIM)
PIM_9E128 block description chapter and the DAC_8B1C block description chapter for information about
pin configurations.
1.4.27PP[5:0] / PW0[5:0] — Port P I/O Pins [5:0]
PP[5:0] are general purpose input or output pins. When the Pulse width Modulator with Fault protection
(PMF) is enabled the PP[5:0] output pins, as a whole or as pairs, can be configured as PW0[5:0] outputs.
While in reset and immediately out of reset the PP[5:0] pins are configured as a high impedance input pins.
Consult the Port Integration Module (PIM) PIM_9E128 block description chapter and the PMF_15B6C
block description chapter for information about pin configurations.
1.4.28PQ[6:4] / IS[2:0] — Port Q I/O Pins [6:4]
PQ[6:4] are general purpose input or output pins. When enabled in the Pulse width Modulator with Fault
protection module (PMF), the PQ[6:4] pins become the current status input pins,
pulse width correction. While in reset and immediately out of reset PP[5:0] pins are configured as a high
impedance input pins. Consult the Port Integration Module (PIM) PIM_9E128 block description chapter
and the PMF_15B6C block description chapter for information about pin configurations.
IS[2:0], for top/bottom
1.4.29PQ[3:0] / FAULT[3:0] — Port Q I/O Pins [3:0]
PQ[3:0] are general purpose input or output pins. When enabled in the Pulse width Modulator with Fault
protection module (PMF), the PQ[3:0] pins become the Fault protection inputs pins, FAULT[3:0], of the
PMF. While in reset and immediately out of reset the PQ[3:0] pins are configured as a high impedance
input pins. Consult the Port Integration Module (PIM) PIM_9E128 block description chapter and the
PMF_15B6C block description chapter for information about pin configurations.
1.4.30PS7 / SS — Port S I/O Pin 7
PS7 is a general purpose input or output. When the Serial Peripheral Interface (SPI) is enabled PS7
becomes the slave select pin
a high impedance input pin. Consult the Port Integration Module (PIM) PIM_9E128 block description
chapter and the SPI block description chapter for information about pin configurations.
SS. While in reset and immediately out of reset the PS7 pin is configured as
PS6 is a general purpose input or output pin. When the Serial Peripheral Interface (SPI) is enabled PS6
becomes the serial clock pin, SCK. While in reset and immediately out of reset the PS6 pin is configured
as a high impedance input pin. Consult the Port Integration Module (PIM) PIM_9E128 block description
chapter and the SPI block description chapter for information about pin configurations.
1.4.32PS5 / MOSI — Port S I/O Pin 5
PS5 is a general purpose input or output pin. When the Serial Peripheral Interface (SPI) is enabled PS5 is
the master output (during master mode) or slave input (during slave mode) pin. While in reset and
immediately out of reset the PS5 pin is configured as a high impedance input pin Consult the Port
Integration Module (PIM) PIM_9E128 block description chapter and the SPI block description chapter for
information about pin configurations.
1.4.33PS4 / MISO — Port S I/O Pin 4
PS4 is a general purpose input or output pin. When the Serial Peripheral Interface (SPI) is enabled PS4 is
the master input (during master mode) or slave output (during slave mode) pin. While in reset and
immediately out of reset the PS4 pin is configured as a high impedance input pin. Consult the Port
Integration Module (PIM) PIM_9E128 block description chapter and the SPI block description chapter for
information about pin configurations.
1.4.34PS3 / TXD1 — Port S I/O Pin 3
PS3 is a general purpose input or output. When the Serial Communications Interface 1 (SCI1) transmitter
is enabled the PS3 pin is configured as the transmit pin, TXD1, of SCI1. While in reset and immediately
out of reset the PS3 pin is configured as a high impedance input pin. Consult the Port Integration Module
(PIM) PIM_9E128 block description chapter and the SCI block description chapter for information about
pin configurations.
1.4.35PS2 / RXD1 — Port S I/O Pin 2
PS2 is a general purpose input or output. When the Serial Communications Interface 1 (SCI1) receiver is
enabled the PS2 pin is configured as the receive pin RXD1 of SCI1. While in reset and immediately out of
reset the PS2 pin is configured as a high impedance input pin. Consult the Port Integration Module (PIM)
PIM_9E128 block description chapter and the SCI block description chapter for information about pin
configurations.
1.4.36PS1 / TXD0 — Port S I/O Pin 1
PS1 is a general purpose input or output. When the Serial Communications Interface 0 (SCI0) transmitter
is enabled the PS1 pin is configured as the transmit pin, TXD0, of SCI0. While in reset and immediately
out of reset the PS1 pin is configured as a high impedance input pin. Consult the Port Integration Module
(PIM) PIM_9E128 block description chapter and the SCI block description chapter for information about
pin configurations.
PS0 is a general purpose input or output. When the Serial Communications Interface 0 (SCI0) receiver is
enabled the PS0 pin is configured as the receive pin RXD0 of SCI0. While in reset and immediately out of
reset the PS0 pin is configured as a high impedance input pin. Consult the Port Integration Module (PIM)
PIM_9E128 block description chapter and the SCI block description chapter for information about pin
configurations.
1.4.38PT[7:4] / IOC1[7:4]— Port T I/O Pins [7:4]
PT[7:4] are general purpose input or output pins. When the Timer system 1 (TIM1) is enabled they can
also be configured as the TIM1 input capture or output compare pins IOC1[7-4]. While in reset and
immediately out of reset the PT[7:4] pins are configured as a high impedance input pins. Consult the Port
Integration Module (PIM) PIM_9E128 block description chapter and the TIM_16B4C block description
chapter for information about pin configurations.
1.4.39PT[3:0] / IOC0[7:4]— Port T I/O Pins [3:0]
PT[3:0] are general purpose input or output pins. When the Timer system 0 (TIM0) is enabled they can
also be configured as the TIM0 input capture or output compare pins IOC0[7-4]. While in reset and
immediately out of reset the PT[3:0] pins are configured as a high impedance input pins. Consult the Port
Integration Module (PIM) PIM_9E128 block description chapter and the TIM_16B4C block description
chapter for information about pin configurations.
1.4.40PU[7:6] — Port U I/O Pins [7:6]
PU[7:6] are general purpose input or output pins. While in reset and immediately out of reset the PU[7:6]
pins are configured as a high impedance input pins. Consult the Port Integration Module (PIM)
PIM_9E128 for information about pin configurations. PU[7:6] are not available in the 80 pin package
version.
1.4.41PU[5:4] / PW1[5:4] — Port U I/O Pins [5:4]
PU[5:4] are general purpose input or output pins. When the Pulse Width Modulator (PWM) is enabled the
PU[5:4] output pins, individually or as a pair, can be configured as PW1[5:4] outputs. While in reset and
immediately out of reset the PU[5:4] pins are configured as a high impedance input pins. Consult the Port
Integration Module (PIM) PIM_9E128 block description chapter and the PWM_8B6C block description
chapter for information about pin configurations. PU[5:4] are not available in the 80 pin package version.
1.4.42PU[3:0] / IOC2[7:4]/PW1[3:0] — Port U I/O Pins [3:0]
PU[3:0] are general purpose input or output pins. When the Timer system 2 (TIM2) is enabled they can
also be configured as the TIM2 input capture or output compare pins IOC2[7-4]. When the Pulse Width
Modulator (PWM) is enabled the PU[3:0] output pins, individually or as a pair, can be configured as
PW1[3:0] outputs. The MODRR register in the Port Integration Module determines if the TIM2 or PWM
function is selected. While in reset and immediately out of reset the PU[3:0] pins are configured as a high
impedance input pins. Consult the Port Integration Module (PIM) PIM_9E128 block description chapter,
TIM_16B4C block description chapter, and the PWM_8B6C block description chapter for information
about pin configurations.
1.4.43VDDX,VSSX — Power & Ground Pins for I/O Drivers
External power and ground for I/O drivers. Bypass requirements depend on how heavily the MCU pins are
loaded.
1.4.44VDDR, VSSR — Power Supply Pins for I/O Drivers & for Internal
Voltage Regulator
External power and ground for I/O drivers and input to the internal voltage regulator. Bypass requirements
depend on how heavily the MCU pins are loaded.
1.4.45VDD1, VDD2, VSS1, VSS2 — Power Supply Pins for Internal Logic
Power is supplied to the MCU through VDD and VSS. This 2.5V supply is derived from the internal
voltage regulator. There is no static load on those pins allowed. The internal voltage regulator is turned off,
if VDDR is tied to ground.
1.4.46VDDA, VSSA — Power Supply Pins for ATD and VREG
VDDA, VSSA are the power supply and ground input pins for the voltage regulator and the analog to
digital converter.
1.4.47VRH, VRL — ATD Reference Voltage Input Pins
VRH and VRL are the reference voltage input pins for the analog to digital converter.
1.4.48VDDPLL, VSSPLL — Power Supply Pins for PLL
Provides operating voltage and ground for the Oscillator and the Phased-Locked Loop. This allows the
supply voltage to the Oscillator and PLL to be bypassed independently. This 2.5V voltage is generated by
the internal voltage regulator.
Table 1-5. MC9S12E128 Power and Ground Connection Summary
Mnemonic
VDD1, VDD22.5 VInternal power and ground generated by internal regulator. These also allow an external
VSS1, VSS20V
VDDR3.3/5.0 VExternal power and ground, supply to internal voltage regulator.
VSSR0 V
VDDX3.3/5.0 VExternal power and ground, supply to pin drivers.
VSSX0 V
VDDA3.3/5.0 VOperating voltage and ground for the analog-to-digital converter, the reference for the
VSSA0 V
VRH3.3/5.0 VReference voltage high for the ATD converter, and DAC.
VRL0 VReference voltage low for the ATD converter.
VDDPLL2.5 VProvides operating voltage and ground for the Phased-Locked Loop. This allows the
VSSPLL0 V
Nominal
Voltage
Description
source to supply the core VDD/VSS voltages and bypass the internal voltage regulator.
To disable voltage regulator attach V
internal voltage regulator and the digital-to-analog converters, allowsthe supply voltageto
the A/D to be bypassed independently.
supply voltage to the PLL to be bypassed independently. Internal power and ground
generated by internal regulator.
DDR
to V
SSR
.
NOTE
All VSS pins must be connected together in the application. Because fast
signal transitions place high, short-duration current demands on the power
supply, use bypass capacitors with high-frequency characteristics and place
them as close to the MCU as possible. Bypass requirements depend on
MCU pin load.
Eight possible modes determine the operating configuration of the MC9S12E128. Each mode has an
associated default memory map and external bus configuration controlled by a further pin.
Three low power modes exist for the device.
1.6.2Chip Configuration Summary
The operating mode out of reset is determined by the states of the MODC, MODB, and MODA pins during
reset. The MODC, MODB, and MODA bits in the MODE register show the current operating mode and
provide limited mode switching during operation. The states of the MODC, MODB, and MODA pins are
latched into these bits on the rising edge of the reset signal. The ROMCTL signal allows the setting of the
ROMON bit in the MISC register thus controlling whether the internal Flash is visible in the memory map.
ROMON = 1 mean the Flash is visible in the memory map. The state of the ROMCTL pin is latched into
the ROMON bit in the MISC register on the rising edge of the reset signal.
Table 1-7. Mode Selection
BKGD =
MODC
000X1Special Single Chip, BDM allowed and ACTIVE. BDM is
The device will make available a security feature preventing the unauthorized read and write of the
memory contents. This feature allows:
•Protection of the contents of FLASH,
•Operation in single-chip mode,
•Operation from external memory with internal FLASH disabled.
The user must be reminded that part of the security must lie with the user’s code. An extreme example
would be user’s code that dumps the contents of the internal program. This code would defeat the purpose
of security. At the same time the user may also wish to put a back door in the user’s program. An example
of this is the user downloads a key through the SCI which allows access to a programming routine that
updates parameters.
1.7.1Securing the Microcontroller
Once the user has programmed the FLASH, the part can be secured by programming the security bits
located in the FLASH module. These non-volatile bits will keep the part secured through resetting the part
and through powering down the part.
The security byte resides in a portion of the Flash array.
Check the Flash block description chapter for more details on the security configuration.
1.7.2Operation of the Secured Microcontroller
1.7.2.1Normal Single Chip Mode
This will be the most common usage of the secured part. Everything will appear the same as if the part was
not secured with the exception of BDM operation. The BDM operation will be blocked.
1.7.2.2Executing from External Memory
The user may wish to execute from external space with a secured microcontroller. This is accomplished
by resetting directly into expanded mode. The internal FLASH will be disabled. BDM operations will be
blocked.
1.7.3Unsecuring the Microcontroller
In order to unsecure the microcontroller, the internal FLASH must be erased. This can be done through an
external program in expanded mode.
Once the user has erased the FLASH, the part can be reset into special single chip mode. This invokes a
program that verifies the erasure of the internal FLASH. Once this program completes, the user can erase
and program the FLASH security bits to the unsecured state. This is generally done through the BDM, but
the user could also change to expanded mode (by writing the mode bits through the BDM) and jumping to
an external program (again through BDM commands). Note that if the part goes through a reset before the
security bits are reprogrammed to the unsecure state, the part will be secured again.
1.8Low Power Modes
The microcontroller features three main low power modes. Consult the respective block description
chapter for information on the module behavior in Stop, Pseudo Stop, and Wait Mode. An important source
of information about the clock system is the Clock and Reset Generator (CRG) block description chapter.
1.8.1Stop
Executing the CPU STOP instruction stops all clocks and the oscillator thus putting the chip in fully static
mode. Wake up from this mode can be done via reset or external interrupts.
1.8.2Pseudo Stop
This mode is entered by executing the CPU STOP instruction. In this mode the oscillator is still running
and the Real Time Interrupt (RTI) or Watchdog (COP) sub module can stay active. Other peripherals are
turned off. This mode consumes more current than the full STOP mode, but the wake up time from this
mode is significantly shorter.
1.8.3Wait
This mode is entered by executing the CPU WAI instruction. In this mode the CPU will not execute
instructions. The internal CPU signals (address and data bus) will be fully static. All peripherals stay
active. For further power consumption the peripherals can individually turn off their local clocks.
1.8.4Run
Although this is not a low power mode, unused peripheral modules should not be enabled in order to save
power.
1.9Resets and Interrupts
Consult the Exception Processing section of the CPU12 Reference Manual for information on resets and
interrupts. System resets can be generated through external control of the
and reset generator module CRG or through the low voltage reset (LVR) generator of the voltage regulator
module. Refer to the CRG and VREG block description chapters for detailed information on reset
generation.
1.9.1Vectors
Table 1-9 lists interrupt sources and vectors in default order of priority.
When a reset occurs, MCU registers and control bits are changed to known start-up states. Refer to the
respective module block description chapters for register reset states. Refer to the HCS12 MEBI block
description chapter for mode dependent pin configuration of port A, B and E out of reset.
Refer to the PIM block description chapter for reset configurations of all peripheral module ports.
Refer to Table 1-1 for locations of the memories depending on the operating mode after reset.
The RAM array is not automatically initialized out of reset.
The Printed Circuit Board (PCB) must be carefully laid out to ensure proper operation of the voltage
regulator as well as the MCU itself. The following rules must be observed:
•Every supply pair must be decoupled by a ceramic capacitor connected as near as possible to the
corresponding pins (C1–C6).
•Central point of the ground star should be the VSSR pin.
•Use low ohmic low inductance connections between VSS1, VSS2 and VSSR.
•VSSPLL must be directly connected to VSSR.
•Keep traces of VSSPLL, EXTAL and XTAL as short as possible and occupied board area for C7,
C8, C11 and Q1 as small as possible.
•Do not place other signals or supplies underneath area occupied by C7, C8, C10 and Q1 and the
connection area to the MCU.
•Central power input should be fed in at the VDDA/VSSA pins.
The FTS128K1 module implements a 128 Kbyte Flash (nonvolatile) memory. The Flash memory contains
one array of 128 Kbytes organized as 1024 rows of 128 bytes with an erase sector size of eight rows (1024
bytes). The Flash array may be read as either bytes, aligned words, or misaligned words. Read access time
is one bus cycle for byte and aligned word, and two bus cycles for misaligned words.
The Flash array is ideal for program and data storage for single-supply applications allowing for field
reprogramming without requiring external voltage sources for program or erase. Program and erase
functions are controlled by a command driven interface. The Flash module supports both mass erase and
sector erase. An erased bit reads 1 and a programmed bit reads 0. The high voltage required to program
and erase is generated internally. It is not possible to read from a Flash array while it is being erased or
programmed.
CAUTION
A Flash word must be in the erased state before being programmed.
Cumulative programming of bits within a Flash word is not allowed.
2.1.1Glossary
Command Write Sequence — A three-step MCU instruction sequence to program, erase, or erase verify
the Flash array memory.
2.1.2Features
•128 Kbytes of Flash memory comprised of one 128 Kbyte array divided into 128 sectors of 1024
bytes
•Automated program and erase algorithm
•Interrupts on Flash command completion and command buffer empty
•Fast sector erase and word program operation
•2-stage command pipeline for faster multi-word program times
•Flexible protection scheme to prevent accidental program or erase
•Single power supply for Flash program and erase operations
•Security feature to prevent unauthorized access to the Flash array memory
MC9S12E128 Data Sheet, Rev. 1.07
Freescale Semiconductor85
Chapter 2 128 Kbyte Flash Module (FTS128K1V1)
2.1.3Modes of Operation
See Section 2.4.2, “Operating Modes” for a description of the Flash module operating modes. For program
and erase operations, refer to Section 2.4.1, “Flash Command Operations”.
2.1.4Block Diagram
Figure 2-1 shows a block diagram of the FTS128K1 module.
FTS128K1
Flash
Command
Complete
Interrupt
Command
Buffer Empty
Interrupt
Interface
Command Pipeline
cmd2
addr2
data2
Registers
cmd1
addr1
data1
Flash Array
64K * 16 Bits
sector 0
sector 1
Protection
Security
Oscillator
Clock
Clock
Divider
Figure 2-1. FTS128K1 Block Diagram
FCLK
2.2External Signal Description
The FTS128K1 module contains no signals that connect off-chip.
MC9S12E128 Data Sheet, Rev. 1.07
sector 127
86Freescale Semiconductor
Chapter 2 128 Kbyte Flash Module (FTS128K1V1)
2.3Memory Map and Registers
This section describes the FTS128K1 memory map and registers.
2.3.1Module Memory Map
The FTS128K1 memory map is shown in Figure 2-2. The HCS12 architecture places the Flash array
addresses between 0x4000 and 0xFFFF, which corresponds to three 16 Kbyte pages. The content of the
HCS12 Core PPAGE register is used to map the logical middle page ranging from address 0x8000 to
0xBFFF to any physical 16K byte page in the Flash array memory.
2.3.2.5) can be set to globally protect the entire Flash array. Three separate areas, one starting from the
Flash array starting address (called lower) towards higher addresses, one growing downward from the
Flash array end address (called higher), and the remaining addresses, can be activated for protection. The
Flash array addresses covered by these protectable regions are shown in Figure 2-2. The higher address
area is mainly targeted to hold the boot loader code since it covers the vector space. The lower address area
can be used for EEPROM emulation in an MCU without an EEPROM module since it can be left
unprotected while the remaining addresses are protected from program or erase. Default protection
settings as well as security information that allows the MCU to restrict access to the Flash module are
stored in the Flash configuration field described in Table 2-1.
The Flash module contains a set of 16 control and status registers located between module base + 0x0000
and 0x000F. A summary of the Flash module registers is given in Figure 2-3. Detailed descriptions of each
register bit are provided.
Register
Name
0x0000
FCLKDIV
0x0001
FSEC
0x0002
RESERVED1
0x0003
FCNFG
0x0004
FPROT
0x0005
FSTAT
0x0006
FCMD
0x0007
RESERVED2
0x0008
FADDRHI
0x0009
FADDRLO
0x000A
FDATAHI
1
0x000B
FDATALO
0x000C
RESERVED3
0x000D
RESERVED4
0x000E
RESERVED5
0x000F
RESERVED6
Bit 7654321Bit 0
RFDIVLD
W
PRDIV8FDIV5FDIV4FDIV3FDIV2FDIV1FDIV0
RKEYEN1KEYEN0NV5NV4NV3NV2SEC1SEC0
W
R00000000
1
W
R
CBEIECCIEKEYACC
W
R
FPOPENNV6FPHDISFPHS1FPHS0FPLDISFPLS1FPLS0
W
R
CBEIF
W
R0
W
CCIF
PVIOLACCERR
CMDB6CMDB5
00000
0BLANK
00
CMDB2
FAIL
0
DONE
CMDB0
R00000000
1
W
R
1
W
R
1
W
R
W
R
1
W
FABHI
FABLO
FDHI
FDLO
R00000000
1
W
R00000000
1
W
R00000000
1
W
R00000000
1
W
= Unimplemented or Reserved
Figure 2-3. Flash Register Summary
1
Intended for factory test purposes only.
MC9S12E128 Data Sheet, Rev. 1.07
90Freescale Semiconductor
Chapter 2 128 Kbyte Flash Module (FTS128K1V1)
2.3.2.1Flash Clock Divider Register (FCLKDIV)
The FCLKDIV register is used to control timed events in program and erase algorithms.
Module Base + 0x0000
76543210
RFDIVLD
W
Reset00000000
All bits in the FCLKDIV register are readable, bits 6–0 are write once and bit 7 is not writable.
0 FCLKDIV register has not been written
1 FCLKDIV register has been written to since the last reset
Enable Prescalar by 8
0 The oscillator clock is directly fed into the Flash clock divider
1 The oscillator clock is divided by 8 before feeding into the Flash clock divider
Clock Divider Bits — The combination of PRDIV8 and FDIV[5:0] must divide the oscillator clock down to a
frequency of 150 kHz – 200 kHz. The maximum divide ratio is 512. Refer to Section 2.4.1.1, “Writing the
FCLKDIV Register” for more information.
2.3.2.2Flash Security Register (FSEC)
The FSEC register holds all bits associated with the security of the MCU and Flash module.
Module Base + 0x0001
76543210
RKEYEN1KEYEN0NV5NV4NV3NV2SEC1SEC0
W
ResetFFFFFFFF
= Unimplemented or Reserved
Figure 2-5. Flash Security Register (FSEC)
All bits in the FSEC register are readable but not writable.
The FSEC register is loaded from the Flash configuration field at 0xFF0F during the reset sequence,
indicated by F in Figure 2-5.
MC9S12E128 Data Sheet, Rev. 1.07
Freescale Semiconductor91
Chapter 2 128 Kbyte Flash Module (FTS128K1V1)
Table 2-4. FSEC Field Descriptions
FieldDescription
7–6
KEYEN[1:0]
5–2
NV[5:2]
1–0
SEC[1:0]
Backdoor Key Security Enable Bits — The KEYEN[1:0] bits define the enabling of the backdoor key access
to the Flash module as shown in Table 2-5.
Nonvolatile Flag Bits — The NV[5:2] bits are available to the user as nonvolatile flags.
Flash Security Bits —The SEC[1:0] bitsdefine the securitystate of the MCUas shown in Table 2-6. Ifthe Flash
module is unsecured using backdoor key access, the SEC[1:0] bits are forced to 1:0.
Table 2-5. Flash KEYEN States
KEYEN[1:0]Status of Backdoor Key Access
00DISABLED
1
01
10ENABLED
11DISABLED
1
Preferred KEYEN state to disable Backdoor Key Access.
DISABLED
Table 2-6. Flash Security States
SEC[1:0]Status of Security
00Secured
1
01
10Unsecured
11Secured
1
Preferred SEC state to set MCU to secured state.
Secured
The security function in the Flash module is described in Section 2.4.3, “Flash Module Security”.
2.3.2.3RESERVED1
This register is reserved for factory testing and is not accessible to the user.
Module Base + 0x0002
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure 2-6. RESERVED1
All bits read 0 and are not writable.
MC9S12E128 Data Sheet, Rev. 1.07
92Freescale Semiconductor
Chapter 2 128 Kbyte Flash Module (FTS128K1V1)
2.3.2.4Flash Configuration Register (FCNFG)
The FCNFG register enables the Flash interrupts and gates the security backdoor key writes.
Module Base + 0x0003
76543210
R
CBEIECCIEKEYACC
W
Reset00000000
= Unimplemented or Reserved
Figure 2-7. Flash Configuration Register (FCNFG)
CBEIE, CCIE, and KEYACC are readable and writable while remaining bits read 0 and are not writable.
KEYACC is only writable if the KEYEN bit in the FSEC register is set to the enabled state (see Section
2.3.2.2).
Table 2-7. FCNFG Field Descriptions
FieldDescription
00000
7
CBEIE
6
CCIE
5
KEYACC
Command Buffer Empty Interrupt Enable — The CBEIE bit enables the interrupts in case of an empty
command buffer in the Flash module.
0 Command Buffer Empty interrupts disabled
1 An interrupt will be requested whenever the CBEIF flag is set (see Section 2.3.2.6)
Command Complete Interrupt Enable — The CCIE bit enables the interrupts in case of all commands being
completed in the Flash module.
0 Command Complete interrupts disabled
1 An interrupt will be requested whenever the CCIF flag is set (see Section 2.3.2.6)
Enable Security Key Writing.
0 Flash writes are interpreted as the start of a command write sequence
1 Writes to the Flash array are interpreted as a backdoor key while reads of the Flash array return invalid data
2.3.2.5Flash Protection Register (FPROT)
The FPROT register defines which Flash sectors are protected against program or erase.
Module Base + 0x0004
76543210
R
FPOPENNV6FPHDISFPHS1FPHS0FPLDISFPLS1FPLS0
W
ResetFFFFFFFF
Figure 2-8. Flash Protection Register (FPROT)
The FPROT register is readable in normal and special modes. FPOPEN can only be written from a 1 to a 0.
FPLS[1:0] can be written anytime until FPLDIS is cleared. FPHS[1:0] can be written anytime until
MC9S12E128 Data Sheet, Rev. 1.07
Freescale Semiconductor93
Chapter 2 128 Kbyte Flash Module (FTS128K1V1)
FPHDIS is cleared. The FPROT register is loaded from Flash address 0xFF0D during the reset sequence,
indicated by F in Figure 2-8.
To change the Flash protection that will be loaded on reset, the upper sector of the Flash array must be
unprotected, then the Flash protection byte located at Flash address 0xFF0D must be written to.
A protected Flash sector is disabled by FPHDIS and FPLDIS while the size of the protected sector is
defined by FPHS[1:0] and FPLS[1:0] in the FPROT register.
Trying to alter any of the protected areas will result in a protect violation error and the PVIOL flag will be
set in the FSTAT register (see Section 2.3.2.6). A mass erase of the whole Flash array is only possible when
protection is fully disabled by setting the FPOPEN, FPLDIS, and FPHDIS bits. An attempt to mass erase
a Flash array while protection is enabled will set the PVIOL flag in the FSTAT register.
Table 2-8. FPROT Field Descriptions
FieldDescription
7
FPOPEN
6
NV6
5
FPHDIS
4–3
FPHS[1:0]
2
FPLDIS
1–0
FPLS[1:0]
Protection Function for Program or Erase — It is possible using the FPOPEN bit to either select address
ranges to be protected using FPHDIS, FPLDIS, FPHS[1:0] and FPLS[1:0] or to select the same ranges to be
unprotected. When FPOPEN is set, FPxDIS enables the ranges to be protected, whereby clearing FPxDIS
enables protection for the range specified by the corresponding FPxS[1:0] bits. When FPOPEN is cleared,
FPxDIS defines unprotected ranges as specified by the corresponding FPxS[1:0] bits. In this case, setting
FPxDIS enables protection. Thus the effective polarity of the FPxDIS bits is swapped by the FPOPEN bit as
shown in Table 2-9. This function allows the main part of the Flash arrayto be protected while a small range can
remain unprotected for EEPROM emulation.
0 The FPHDIS and FPLDIS bits define Flash address ranges to be unprotected
1 The FPHDIS and FPLDIS bits define Flash address ranges to be protected
Nonvolatile Flag Bit — The NV6 bit should remain in the erased state for future enhancements.
Flash Protection Higher Address Range Disable — The FPHDIS bit determines whether there is a
protected/unprotected area in the higher space of the Flash address map.
0 Protection/unprotection enabled
1 Protection/unprotection disabled
Flash Protection Higher Address Size — The FPHS[1:0] bits determine the size of the protected/unprotected
sector as shown in Table 2-10. The FPHS[1:0] bits can only be written to while the FPHDIS bit is set.
Flash Protection Lower Address Range Disable — The FPLDIS bit determines whether there is a
protected/unprotected sector in the lower space of the Flash address map.
0 Protection/unprotection enabled
1 Protection/unprotection disabled
Flash Protection Lower Address Size — The FPLS[1:0] bits determine the size of the protected/unprotected
sector as shown in Table 2-11. The FPLS[1:0] bits can only be written to while the FPLDIS bit is set.
11xx1xxNo protection
11xx0xxProtect low range
10xx1xxProtect high range
10xx0xxProtect high and low ranges
01xx1xxFull Flash array protected
00xx1xxUnprotected high range
01xx0xxUnprotected low range
00xx0xxUnprotected high and low ranges
1
For range sizes refer to Table 2-10 and Table 2-11 or .
Figure 2-9 illustrates all possible protection scenarios. Although the protection scheme is loaded from the
Flash array after reset, it is allowed to change in normal modes. This protection scheme can be used by
applications requiring re-programming in single chip mode while providing as much protection as possible
if no re-programming is required.
MC9S12E128 Data Sheet, Rev. 1.07
Freescale Semiconductor95
Chapter 2 128 Kbyte Flash Module (FTS128K1V1)
Scenario
0xFFFF
Scenario
0xFFFF
FPHDIS = 1
FPLDIS = 1
7654
FPOPEN = 1
3210
FPOPEN = 0
FPHDIS = 1
FPLDIS = 0
FPHDIS = 0
FPLDIS = 1
FPHDIS = 0
FPLDIS = 0
FPLS[1:0]
FPHS[1:0]
FPLS[1:0]
FPHS[1:0]
Protected Flash
Figure 2-9. Flash Protection Scenarios
2.3.2.5.1Flash Protection Restrictions
The general guideline is that protection can only be added, not removed. All valid transitions between
Flash protection scenarios are specified in Table 2-12. Any attempt to write an invalid scenario to the
FPROT register will be ignored and the FPROT register will remain unchanged. The contents of the
FPROT register reflect the active protection scenario.
Table 2-12. Flash Protection Scenario Transitions
From
Protection
Scenario
0XXXX
1XX
2XX
3X
4XX
5XXXX
01234567
To Protection Scenario
1
MC9S12E128 Data Sheet, Rev. 1.07
96Freescale Semiconductor
Chapter 2 128 Kbyte Flash Module (FTS128K1V1)
Table 2-12. Flash Protection Scenario Transitions
From
Protection
Scenario
6XXXX
7XXXXXXXX
1
Allowed transitions marked with X.
01234567
To Protection Scenario
1
2.3.2.6Flash Status Register (FSTAT)
The FSTAT register defines the status of the Flash command controller and the results of command
execution.
Module Base + 0x0005
76543210
R
CBEIF
W
Reset11000001
CCIF
PVIOLACCERR
= Unimplemented or Reserved
Figure 2-10. Flash Status Register (FSTAT)
0BLANK
FAIL
DONE
In normal modes, bits CBEIF, PVIOL, and ACCERR are readable and writable, bits CCIF and BLANK
are readable and not writable, remaining bits, including FAIL and DONE, read 0 and are not writable. In
special modes, FAIL is readable and writable while DONE is readable but not writable. FAIL must be clear
in special modes when starting a command write sequence.
Table 2-13. FSTAT Field Descriptions
FieldDescription
7
CBEIF
6
CCIF
Command Buffer Empty Interrupt Flag — The CBEIF flag indicates that the address, data and command
buffers are empty so that a new command write sequence can be started. The CBEIF flag is cleared by writing
a 1 to CBEIF. Writing a 0 to the CBEIF flag has no effect on CBEIF. Writing a 0 to CBEIF after writing an aligned
word to the Flash address space but before CBEIF is cleared will abort a command write sequence and cause
the ACCERR flag in the FSTAT register to be set. Writing a 0 to CBEIF outside of a command write sequence
will not set the ACCERR flag. The CBEIF flag is used together with the CBEIE bit in the FCNFG register to
generate an interrupt request (see Figure 2-26).
0 Buffers are full
1 Buffers are ready to accept a new command
Command Complete Interrupt Flag — TheCCIF flag indicates that thereare no more commands pending.The
CCIF flag is cleared when CBEIF is clear and sets automatically upon completion of all active and pending
commands. The CCIF flag does not set when an active commands completes and a pending command is
fetchedfrom the command buffer. Writing to the CCIF flag has no effect. The CCIF flag is used together with the
CCIE bit in the FCNFG register to generate an interrupt request (see Figure 2-26).
0 Command in progress
1 All commands are completed
MC9S12E128 Data Sheet, Rev. 1.07
Freescale Semiconductor97
Chapter 2 128 Kbyte Flash Module (FTS128K1V1)
Table 2-13. FSTAT Field Descriptions
FieldDescription
5
PVIOL
4
ACCERR
2
BLANK
1
FAIL
0
DONE
Protection Violation — The PVIOL flag indicates an attempt was made to program or erase an address in a
protected Flash array memory area. The PVIOL flag is cleared by writing a 1 to PVIOL. Writing a 0 to the PVIOL
flag has no effect on PVIOL. While PVIOL is set, it is not possible to launch another command.
0 No protection violation detected
1 Protection violation has occurred
Access Error — The ACCERR flag indicates an illegal access to the Flash array caused by either a violation of
the command write sequence, issuing an illegal command (illegal combination of the CMDBx bits in the FCMD
register) or the executionof aCPU STOP instruction whilea command isexecuting(CCIF=0). The ACCERR flag
is cleared by writing a 1 to ACCERR. Writinga 0 to the ACCERR flag has no effecton ACCERR. While ACCERR
is set, it is not possible to launch another command.
0 No access error detected
1 Access error has occurred
Flash Array Has Been Verified as Erased — The BLANK flag indicates that an erase verify command has
checked the Flash array and found it to be erased. The BLANK flag is cleared by hardware when CBEIF is
cleared as part of a new valid command write sequence. Writing to the BLANK flag has no effect on BLANK.
0 If an erase verify command has been requested, and the CCIF flag is set, then a 0 in BLANK indicates the
array is not erased
1 Flash array verifies as erased
Flag Indicating a Failed Flash Operation — In special modes, the FAILflag will set if the eraseverify operation
fails(Flash arrayverified as not erased). Writinga 0tothe FAILflag has no effecton FAIL.TheFAILflag is cleared
by writing a 1 to FAIL. While FAIL is set, it is not possible to launch another command.
0 Flash operation completed without error
1 Flash operation failed
Flag Indicating a Failed Operation is not Active — In special modes, the DONE flag will clear if a program,
erase, or erase verify operation is active.
0 Flash operation is active
1 Flash operation is not active
2.3.2.7Flash Command Register (FCMD)
The FCMD register defines the Flash commands.
Module Base + 0x0006
76543210
R0
CMDB6CMDB5
W
Reset00000000
= Unimplemented or Reserved
Figure 2-11. Flash Command Register (FCMD)
Bits CMDB6, CMDB5, CMDB2, and CMDB0 are readable and writable during a command write
sequence while bits 7, 4, 3, and 1 read 0 and are not writable.
MC9S12E128 Data Sheet, Rev. 1.07
98Freescale Semiconductor
00
CMDB2
0
CMDB0
Table 2-14. FCMD Field Descriptions
FieldDescription
Chapter 2 128 Kbyte Flash Module (FTS128K1V1)
6, 5, 2, 0
CMDB[6:5]
ValidFlash commands are shown in Table 2-15. An attempt to execute any command other than those listed in
Table 2-15 will set the ACCERR bit in the FSTAT register (see Section 2.3.2.6).
CMDB[2]
CMDB[0]
Table 2-15. Valid Flash Command List
CMDBNVM Command
0x05Erase verify
0x20Word program
0x40Sector erase
0x41Mass erase
2.3.2.8RESERVED2
This register is reserved for factory testing and is not accessible to the user.
Module Base + 0x0007
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure 2-12. RESERVED2
All bits read 0 and are not writable.
2.3.2.9Flash Address Register (FADDR)
FADDRHI and FADDRLO are the Flash address registers.
\
Module Base + 0x0008
76543210
R
W
Reset00000000
Figure 2-13. Flash Address High Register (FADDRHI)
\
\
FABHI
MC9S12E128 Data Sheet, Rev. 1.07
Freescale Semiconductor99
Chapter 2 128 Kbyte Flash Module (FTS128K1V1)
Module Base + 0x0009
76543210
R
W
Reset00000000
FABLO
Figure 2-14. Flash Address Low Register (FADDRLO)
In normal modes, all FABHI and FABLO bits read 0 and are not writable. In special modes, the FABHI
and FABLO bits are readable and writable. For sector erase, the MCU address bits [9:0] are ignored. For
mass erase, any address within the Flash array is valid to start the command.
2.3.2.10Flash Data Register (FDATA)
FDATAHI and FDATALO are the Flash data registers.
Module Base + 0x000A
76543210
R
W
FDHI
Reset00000000
Figure 2-15. Flash Data High Register (FDATAHI)
Module Base + 0x000B
76543210
R
W
Reset00000000
FDLO
Figure 2-16. Flash Data Low Register (FDATALO)
In normal modes, all FDATAHI and FDATALO bits read 0 and are not writable. In special modes, all
FDATAHI and FDATALO bits are readable and writable when writing to an address within the Flash
address range.
2.3.2.11RESERVED3
This register is reserved for factory testing and is not accessible to the user.
MC9S12E128 Data Sheet, Rev. 1.07
100Freescale Semiconductor
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.