This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A full list of family members and options is included in the appendices.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor3
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The following revision history table summarizes changes contained in this document.
MC9S12G Family Reference Manual,Rev.1.06
4Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor7
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor9
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
10.7.2Application information for COP and API usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . .374
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor15
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor27
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter1
Device Overview MC9S12G-Family
Revision History
1.1Introduction
The MC9S12G-Family is an optimized, automotive, 16-bit microcontroller product line focused on
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table1-2shows the maximum number of peripherals or peripheral channels per package type. Not all
peripherals are available at the same time. The maximum number of peripherals is also limited by the
device chosen as perTable1-1.
12-Bit ADC
channels————————16—16
Temperature
Sensor————————YES—YES
RVA————————YES—YES
8-Bit DAC————————2—2
ACMP (analog
comparator)11111——————
PLLYesYesYesYesYesYesYesYesYesYesYes
External oscYesYesYesYesYesYesYesYesYesYesYes
Internal 1 MHz
RC oscillatorYesYesYesYesYesYesYesYesYesYesYes
20-pin TSSOPYesYes—————————
32-pin LQFPYesYesYesYesYes——————
48-pin LQFPYesYesYesYesYesYesYesYesYesYesYes
48-pin QFNYesYes—————————
64-pin LQFP——YesYesYesYesYesYesYesYesYes
100-pin LQFP—————YesYesYesYesYesYes
Supply voltage3.13V – 5.5V
Execution speedStatic – 25MHz
1Not all peripherals are available in all package types
Table1-2. Maximum Peripheral Availability per Package
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.2.2Chip-Level Features
On-chip modules available within the family include the following features:
•S12 CPU core
•Up to 240Kbyte on-chip flash with ECC
•Up to 4Kbyte EEPROM with ECC
•Up to 11Kbyte on-chip SRAM
•Phase locked loop (IPLL) frequency multiplier with internal filter
Table1-2. Maximum Peripheral Availability per Package
Peripheral20 TSSOP32 LQFP 48 LQFP,
48 QNFN 64 LQFP100 LQFP
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor31
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.3.1S12 16-Bit Central Processor Unit (CPU)
S12 CPU is a high-speed 16-bit processing unit:
•Full 16-bit data paths supports efficient arithmetic operation and high-speed math execution
•Includes many single-byte instructions. This allows much more efficient use of ROM space.
•Extensive set of indexed addressing capabilities, including:
—Using the stack pointer as an indexing register in all indexed operations
—Using the program counter as an indexing register in all but auto increment/decrement mode
—Accumulator offsets using A, B, or D accumulators
•Single control register to enable/disable pull devices on ports A, B, C, D and E, on per-port basis
and on BKGD pin
•Control registers to enable/disable open-drain (wired-or) mode on ports S and M
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
32Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Interrupt flag register for pin interrupts on ports P, J and AD
•Control register to configureIRQ pin operation
•Routing register to support programmable signal redirection in 20 TSSOP only
•Routing register to support programmable signal redirection in 100 LQFP package only
•Package code register preset by factory related to package in use, writable once after reset. Also
includes bit to reprogram routing of API_EXTCLK in all packages.
•Control register for free-running clock outputs
•
1.3.5Main External Oscillator (XOSCLCP)
•Loop control Pierce oscillator using a 4 MHz to 16 MHz crystal
—Current gain control on amplitude output
—Signal with low harmonic distortion
—Low power
—Good noise immunity
—Eliminates need for external current limiting resistor
—Transconductance sized for optimum start-up margin for typical crystals
—Oscillator pins can be shared w/ GPIO functionality
1.3.6Internal RC Oscillator (IRC)
•Trimmable internal reference clock.
—Frequency: 1 MHz
—Trimmed accuracy over –40˚C to +125˚C ambient temperature range:
±1.0% for temperature option C and V (seeTableA-4)
±1.3% for temperature option M (seeTableA-4)
1.3.7Internal Phase-Locked Loop (IPLL)
•Phase-locked-loop clock frequency multiplier
—No external components required
—Reference divider and multiplier allow large variety of clock rates
—Automatic bandwidth control mode for low-jitter operation
—Automatic frequency lock detector
—Configurable option to spread spectrum for reduced EMC radiation (frequency modulation)
—Reference clock sources:
–External 4–16 MHz resonator/crystal (XOSCLCP)
–Internal 1 MHz RC oscillator (IRC)
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor33
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.3.8System Integrity Support
•Power-on reset (POR)
•System reset generation
•Illegal address detection with reset
•Low-voltage detection with interrupt or reset
•Real time interrupt (RTI)
•Computer operating properly (COP) watchdog
—Configurable as window COP for enhanced failure detection
—Initialized out of reset using option bits located in flash memory
•Clock monitor supervising the correct function of the oscillator
1.3.9Timer (TIM)
•Up to eight x 16-bit channels for input capture or output compare
•16-bit free-running counter with 7-bit precision prescaler
•In case of eight channel timer Version an additional 16-bit pulse accumulator is available
1.3.10Pulse Width Modulation Module (PWM)
•Up to eight channel x 8-bit or up to four channel x 16-bit pulse width modulator
—Programmable period and duty cycle per channel
—Center-aligned or left-aligned outputs
—Programmable clock select logic with a wide range of frequencies
1.3.11Controller Area Network Module (MSCAN)
•1 Mbit per second, CAN 2.0 A, B software compatible
—Standard and extended data frames
—0–8 bytes data length
—Programmable bit rate up to 1 Mbps
•Five receive buffers with FIFO storage scheme
•Three transmit buffers with internal prioritization
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Bus-off recovery by software intervention or automatically
•16-bit time stamp of transmitted/received messages
1.3.12Serial Communication Interface Module (SCI)
•Up to three SCI modules
•Full-duplex or single-wire operation
•Standard mark/space non-return-to-zero (NRZ) format
•Selectable IrDA 1.4 return-to-zero-inverted (RZI) format with programmable pulse widths
•13-bit baud rate selection
•Programmable character length
•Programmable polarity for transmitter and receiver
•Active edge receive wakeup
•Break detect and transmit collision detect supporting LIN 1.3, 2.0, 2.1 and SAE J2602
1.3.13Serial Peripheral Interface Module (SPI)
•Up to three SPI modules
•Configurable 8- or 16-bit data size
•Full-duplex or single-wire bidirectional
•Double-buffered transmit and receive
•Master or slave mode
•MSB-first or LSB-first shifting
•Serial clock phase and polarity options
1.3.14Analog-to-Digital Converter Module (ADC)
Up to 16-channel, 10-bit/12-bit1 analog-to-digital converter
—3 us conversion time
—8-/101-bit resolution
—Left or right justified result data
—Wakeup from low power modes on analog comparison > or <= match
—Continuous conversion mode
—External triggers to initiate conversions via GPIO or peripheral outputs such as PWM or TIM
—Multiple channel scans
—Precision fixed voltage reference for ADC conversions
—
•Pins can also be used as digital I/O including wakeup capability
1.12-bit resolution only available on S12GA192 and S12GA240 devices.
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor35
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.3.15Reference Voltage Attenuator (RVA)
•Attenuation of ADC reference voltage with low long-term drift
—buffered or unbuffered analog output voltage usable
•operational amplifier stand alone usable
1.3.17Analog Comparator (ACMP)
•Low offset, low long-term offset drift
•Selectable interrupt on rising, falling, or rising and falling edges of comparator output
•Option to output comparator signal on an external pin
•Option to trigger timer input capture events
1.3.18On-Chip Voltage Regulator (VREG)
•Linear voltage regulator with bandgap reference
•Low-voltage detect (LVD) with low-voltage interrupt (LVI)
•Power-on reset (POR) circuit
•Low-voltage reset (LVR)
1.3.19Background Debug (BDM)
•Non-intrusive memory access commands
•Supports in-circuit programming of on-chip nonvolatile memory
1.3.20Debugger (DBG)
•Trace buffer with depth of 64 entries
•Three comparators (A, B and C)
—Access address comparisons with optional data comparisons
—Program counter comparisons
—Exact address or address range comparisons
•Two types of comparator matches
—Tagged This matches just before a specific instruction begins execution
—Force This is valid on the first instruction boundary after a match occurs
•Four trace modes
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
36Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Four stage state sequencer
1.4Key Performance Parameters
The key performance parameters of S12G devices feature:
•Continuous Operating voltage of 3.15 V to 5.5 V
•Operating temperature (TA) of –40˚C to 125˚C
•Junction temperature (TJ) of up to 150˚C
•Bus frequency (fBus) of dc to 25 MHz
•Packaging:
—100-pin LQFP, 0.5mm pitch, 14mm x 14mm outline
—64-pin LQFP, 0.5mm pitch, 10mm x 10mm outline
—48-pin LQFP, 0.5mm pitch, 7mm x 7mm outline
—48-pin QFN, 0.5mm pitch, 7mm x 7mm outline
—32-pin LQFP, 0.8mm pitch, 7mm x 7mm outline
—20 TSSOP, 0.65 mm pitch, 4.4mm x 6.5mm outline
1.5Block Diagram
Figure1-1 shows a block diagram of the MC9S12G-Family.
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor37
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure1-1. MC9S12G-Family Block Diagram
1.6Family Memory Map
Table1-3 shows the MC9S12G-Family register memory map.
Table1-3. Device Register Memory Map
AddressModuleSize
(Bytes)
0x0000–0x0009PIM (Port Integration Module)10
1K … 11K bytes RAM
RESET
EXTAL
XTAL
0.5K … 4K bytes EEPROM with ECC
BKGD
VDDR
Real Time Interrupt
Clock Monitor
Single-wire Background
TEST
Debug Module
ADC
Interrupt Module
(WU Int)
SCI0
PS3
PS0
PS1
PS2
PTS
AN[15:0]PAD[15:0]
10-bit 8...16 ch.
16-bit 6 … 8 channel
Timer
TIM
Asynchronous Serial IF
8-bit 6 … 8 channel
Pulse Width Modulator
PWM
PB[7:0]
PTB
PA[7:0]
PTA
16K … 240K bytes Flash with ECC
CPU12-V1
COP Watchdog
PLL with Frequency
Modulation option
Debug Module
3 comparators
64 Byte Trace Buffer
Reset Generation
and Test Entry
RXD
TXD
PJ2
PTJ (Wake-up Int)
CAN
PM3
PM0
PM1
PM2
PTM
msCAN 2.0B
RXCAN
TXCAN
Auton. Periodic Int.
PJ7
PJ6
PT3
PT0
PT1
PT2
PTT
PT7
PT4
PT5
PT6
PP3
PP0
PP1
PP2
PTP (Wake-up Int)
PP7
PP4
PP5
PWM3
PWM0
PWM1
PWM2
PWM4
PWM5
IOC3
IOC0
IOC1
IOC2
IOC7
IOC4
IOC5
IOC6
VDDA
VSSA
VRH
VDDX1/VSSX1
VDDX2/VSSX2
PJ0
PJ1
3-5V IO Supply
VSS
Low Power Pierce
Oscillator
PP6
PWM6
PWM7
SCI1
Asynchronous Serial IF
RXD
TXD
MOSI
SS
SCK
MISO
SPI0
Synchronous Serial IF
PS4
PS5
PS6
PS7
SCI2
Asynchronous Serial IF
RXD
TXD
Voltage Regulator
Input: 3.13V – 5.5V
Block Diagram shows the maximum configuration!
MOSI
SS
SCK
MISO
SPI1
Synchronous Serial IF
MOSI
SS
SCK
MISO
SPI2
Synchronous Serial IF
PJ3
PJ4
PJ5
PD[7:0]
PTD
PC[7:0]
PTC
VDDX3/VSSX3
Not all pins or all peripherals are available on all devices and packages.
Rerouting options are not shown.
PE0
PTE
PE1
PTAD
Analog-Digital
Converter
ACMP
Analog
Comparator
DAC0
Digital-Analog
Converter
AMPM
AMP
DACU
AMPP
DAC1
Digital-Analog
Converter
12-bit 16 ch.or
RVA
Internal RC Oscillator
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
38Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
0x000A–0x000BMMC (Memory Map Control)2
0x000C–0x000DPIM (Port Integration Module)2
0x000E–0x000FReserved2
0x0010–0x0017MMC (Memory Map Control)8
0x0018–0x0019Reserved2
0x001A–0x001BDevice ID register2
0x001C–0x001FPIM (Port Integration Module)4
0x0020–0x002FDBG (Debug Module)16
0x0030–0x0033Reserved4
0x0034–0x003FCPMU (Clock and Power Management)12
0x0040–0x006FTIM (Timer Module <= 8 channels)48
0x0070–0x009FADC (Analog to Digital Converter <= 16 channels)48
0x00C8–0x00CFSCI0 (Serial Communication Interface)8
0x00D0–0x00D7SCI1 (Serial Communication Interface)18
0x00D8–0x00DFSPI0 (Serial Peripheral Interface)8
0x00E0–0x00E7Reserved8
0x00E8–0x00EFSCI2 (Serial Communication Interface)28
0x00F0–0x00F7SPI1 (Serial Peripheral Interface)38
0x00F8–0x00FFSPI2 (Serial Peripheral Interface)48
0x0100–0x0113FTMRG control registers20
0x0114–0x011FReserved12
0x0120INT (Interrupt Module)1
0x0121–0x013FReserved31
0x0140–0x017FCAN564
0x0180–0x023FReserved192
0x0240–0x025FPIM (Port Integration Module)32
0x0260–0x0261ACMP (Analog Comparator)62
0x0262–0x0275PIM (Port Integration Module)20
0x0276RVA (Reference Voltage Attenuator)71
0x0277–0x027FPIM (Port Integration Module)9
0x0280–0x02EFReserved112
0x02F0–0x02FFCPMU (Clock and Power Management)16
0x0300–0x03BFReserved192
0x03C0–0x03C7DAC0 (Digital to Analog Converter)88
AddressModuleSize
(Bytes)
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor39
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1While for memory sizes <64K the whole 256k space could be addressed using the PPAGE, it is more efficient to use
an unpaged memory model
2Page 0xC
Table1-4. MC9S12G-Family Memory Parameters
FeatureS12GN16 S12GN32S12G48
S12GN48S12G64 S12G96S12G128S12G192
S12GA192
S12G240
S12GA240
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor41
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure1-2. MC9S12G Global Memory Map
Paging Window
0x3_FFFF
Local CPU and BDM
Memory MapGlobal Memory Map
0xFFFF
0xC000
0x0_0400
0x0_0000
0x3_C000
0x0000
0x8000
0x0400
0x40000x0_4000
Paging Window
Flash
Space
Flash
Space
RAM
RAM
Unimplemented
Unimplemented
Flash Space
Flash Space
Flash Space
Flash Space
Flash Space
Flash Space
Register Space
Register Space
Internal
NVM
Resources
Internal
NVM
Resources
Flash Space
Flash Space
Flash Space
Flash Space
Flash Space
Flash Space
Flash Space
Flash Space
EEPROM
EEPROMEEPROM
EEPROM
Page 0x1
Page 0x1
Page 0xF
Page 0xF
Page 0xD
Page 0xD
Register Space
Register Space
Page 0xC
Page 0xC
Page 0xE
Page 0xE
Page 0xF
Page 0xF
Page 0xD
Page 0xD
Page 0xC
Page 0xC
NVMRES=0
NVMRES=0NVMRES=1
NVMRES=1
Flash Space
Flash Space
Page 0x2
Page 0x2
0x3_0000
0x3_4000
0x3_8000
0x0_8000
RAM
RAM
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
42Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.6.1Part ID Assignments
The part ID is located in two 8-bit registers PARTIDH and PARTIDL (addresses 0x001A and 0x001B).
This section describes signals that connect off-chip. It includes a pinout diagram, a table of signal
properties, and detailed discussion of signals. It is built from the signal description sections of the
individual IP blocks on the device.
1.7.1Pin Assignment Overview
Table1-6 provides a summary of which ports are available for each package option.
Table1-5. Assigned Part ID Numbers
DeviceMask Set NumberPart ID
MC9S12GA2400N95B0xF080
MC9S12G2400N95B0xF080
MC9S12GA1920N95B0xF080
MC9S12G1920N95B0xF080
MC9S12G1280N51A0xF180
MC9S12G960N51A0xF180
MC9S12G640N75C0xF280
MC9S12G480N75C0xF280
MC9S12GN480N75C0xF280
MC9S12GN320N48A0xF380
1N48A0xF381
MC9S12GN160N48A0xF380
1N48A0xF381
Table1-6. Port Availability by Package Option
Port20 TSSOP32 LQFP48 LQFP
48 QFN64 LQFP100 LQFP
Port AD/ADC Channels68121616
Port A pins00008
Port B pins00008
Port C pins00008
Port D pins00008
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor43
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NOTE
To avoid current drawn from floating inputs, the input buffers of all
at the rising edge ofRESET. The BKGD pin has an internal pull-up device.
Port E pins22222
Port J00488
Port M02244
Port P04688
Port S46888
Port T24688
Sum of Ports1426405486
I/O Power Pairs VDDX/VSSX1/11/11/11/13/3
Table1-6. Port Availability by Package Option
Port20 TSSOP32 LQFP48 LQFP
48 QFN64 LQFP100 LQFP
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
44Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.7.2.4EXTAL, XTAL — Oscillator Signal
EXTAL and XTAL are the crystal driver and external clock signals. On reset all the device clocks are
derived from the internal reference clock. XTAL is the oscillator output.
1.7.2.5PAD[15:0] / KWAD[15:0] — Port AD Input Pins of ADC
PAD[15:0] are general-purpose input or output signals. These signals can have a pull-up or pull-down
device selected and enabled on per signal basis. Out of reset the pull devices are disabled.
1.7.2.6PA[7:0] — Port A I/O Signals
PA[7:0] are general-purpose input or output signals. The signals can have pull-up devices, enabled by a
single control bit for this signal group. Out of reset the pull-up devices are disabled .
1.7.2.7PB[7:0] — Port B I/O Signals
PB[7:0] are general-purpose input or output signals. The signals can have pull-up devices, enabled by a
single control bit for this signal group. Out of reset the pull-up devices are disabled .
1.7.2.8PC[7:0] — Port C I/O Signals
PC[7:0] are general-purpose input or output signals. The signals can have pull-up devices, enabled by a
single control bit for this signal group. Out of reset the pull-up devices are disabled .
1.7.2.9PD[7:0] — Port D I/O Signals
PD[7:0] are general-purpose input or output signals. The signals can have pull-up device, enabled by a
single control bit for this signal group. Out of reset the pull-up devices are disabled.
and enabled on per signal basis. Out of reset the pull devices are disabled. The signals can be configured
on per pin basis to open-drain mode.
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor45
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.7.2.13PP[7:0] / KWP[7:0] — Port P I/O Signals
PP[7:0] are general-purpose input or output signals. The signals can be configured on per signal basis as
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This signal is associated with the receive functionality of the scalable controller area network controller
(MSCAN).
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor47
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.7.3Power Supply Pins
MC9S12G power and ground pins are described below. 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.
NOTE
All ground pins must be connected together in the application.
1.7.3.1VDDX[3:1]/VDDX, VSSX[3:1]/VSSX— Power and Ground Pins for I/O Drivers
Also the VSSA is connected to VSSX and the common pin is named
VSSXA. See sectionSection1.8, “Device Pinouts” for further details.
1.7.3.5VRH — Reference Voltage Input Pin
VRH is the reference voltage input pin for the digital-to-analog converter and the analog-to-digital
converter. Refer toSection1.18, “ADC VRH/VRL Signal Connection” for further details.
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor49
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
the VDDX and VDDR supplies are combined on one pin.
VDDXRA3.15V – 5.0 VExternal power supply for I/O drivers, internal voltage regulator and analog-to-digital
converter. For the 20- and 32-pin package the VDDX, VDDR and VDDA supplies are
combined on one pin.
VSSXA0VReturn ground for I/O driver and VDDA analog supply
VRH3.15V – 5.0 VReference voltage for the analog-to-digital converter.
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
50Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.8Device Pinouts
1.8.1S12GN16 and S12GN32
1.8.1.1Pinout 20-Pin TSSOP
Figure1-3. 20-Pin TSSOP Pinout for S12GN16 and S12GN32
Table1-8. 20-Pin TSSOP Pinout for S12GN16 and S12GN32
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1The regular I/O characteristics (seeSectionA.2, “I/O Characteristics”) apply if the EXTAL/XTAL function is disabled
Table1-8. 20-Pin TSSOP Pinout for S12GN16 and S12GN32
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package
PinPin2nd
Func.
3rd
Func.
4th
Func
5th
Func
6th
Func
7th
Func
8th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
52Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.8.1.2Pinout 32-Pin LQFP
Figure1-4. 32-Pin LQFP OPinout for S12GN16 and S12GN32
Table1-9. 32-Pin LQFP OPinout for S12GN16 and S12GN32
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
1RESET————VDDXPULLUP
2VDDXRAVRH——————
3VSSXA———————
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
24
23
22
21
20
19
18
17
32
31
30
29
28
27
26
25
S12GN16
s12GN32
32-PinLQFP
PAD7/KWAD7/AN7/ACMPM
PAD6/KWAD6/AN6/ACMPP
PAD5/KWAD5/AN5/ACMPO
PAD4/KWAD4/AN4
PAD3/KWAD3/AN3
PAD2/KWAD2/AN2
PAD1/KWAD1/AN1
PAD0/KWAD0/AN0
PWM0/API_EXTCLK/ETRIG0/KWP0/PP0
PWM1/ECLKX2/ETRIG1/KWP1/PP1
PWM2/ETRIG2/KWP2/PP2
PWM3/ETRIG3/KWP3/PP3
IOC3/PT3
IOC2/PT2
IRQ/IOC1/PT1
XIRQ/IOC0/PT0
RESET
VRH/VDDXRA
VSSXA
EXTAL/PE0
VSS
XTAL/PE1
TEST
BKGD
PM1/TXD1/TXCAN
PM0/RXD1/RXCAN
PS7/API_EXTCLK/ECLK/PWM5/SS
0
PS6/IOC5/SCK0
PS5/IOC4/MOSI0
PS4/PWM4/MISO0
PS1/TXD0
PS0/RXD0
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor53
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
4PE01EXTAL————PUCR/PDPEEDown
5VSS———————
6PE11XTAL————PUCR/PDPEEDown
7TEST————N.A.RESET pinDown
8BKGDMODC———VDDXPUCR/BKPUEUp
9PP0KWP0ETRIG0API_EXTCLKPWM0VDDXPERP/PPSPDisabled
10PP1KWP1ETRIG1ECLKX2PWM1VDDXPERP/PPSPDisabled
11PP2KWP2ETRIG2PWM2—VDDXPERP/PPSPDisabled
12PP3KWP3ETRIG3PWM3—VDDXPERP/PPSPDisabled
13PT3IOC3———VDDXPERT/PPSTDisabled
14PT2IOC2———VDDXPERT/PPSTDisabled
15PT1IOC1IRQ——VDDXPERT/PPSTDisabled
16PT0IOC0XIRQ——VDDXPERT/PPSTDisabled
17PAD0KWAD0AN0——VDDAPER1AD/PPS1ADDisabled
18PAD1KWAD1AN1——VDDAPER1AD/PPS1ADDisabled
19PAD2KWAD2AN2——VDDAPER1AD/PPS1ADDisabled
20PAD3KWAD3AN3——VDDAPER1AD/PPS1ADDisabled
21PAD4KWAD4AN4——VDDAPER1AD/PPS1ADDisabled
22PAD5KWAD5AN5ACMPO—VDDAPER1AD/PPS1ADDisabled
23PAD6KWAD6AN6ACMPP—VDDAPER1AD/PPS1ADDisabled
24PAD7KWAD7AN7ACMPM—VDDAPER1AD/PPS1ADDisabled
25PS0RXD0———VDDXPERS/PPSSUp
26PS1TXD0———VDDXPERS/PPSSUp
27PS4PWM4MISO0——VDDXPERS/PPSSUp
28PS5IOC4MOSI0——VDDXPERS/PPSSUp
29PS6IOC5SCK0——VDDXPERS/PPSSUp
30PS7API_EXTCLKECLKPWM5SS0VDDXPERS/PPSSUp
31PM0————VDDXPERM/PPSMDisabled
32PM1————VDDXPERM/PPSMDisabled
Table1-9. 32-Pin LQFP OPinout for S12GN16 and S12GN32
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
54Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.8.1.3Pinout 48-Pin LQFP/QFN
Figure1-5. 48-Pin LQFP/QFN Pinout for S12GN16 and S12GN32
1The regular I/O characteristics (seeSectionA.2, “I/O Characteristics”) apply if the EXTAL/XTAL function is disabled
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
36
35
34
33
32
31
30
29
28
27
26
25
48
47
46
45
44
43
42
41
40
39
38
37
S12GN16
S12GN32
48-PinLQFP/QFN
PAD7/KWAD7/AN7
PAD6/KWAD6/AN6
PAD5/KWAD5/AN5
PAD4/KWAD4/AN4
PAD11/KWAD11/ACMPM
PAD3/KWAD3/AN3
PAD10/KWAD10/ACMPP
PAD2/KWAD2/AN2
PAD9/KWAD9/ACMPO
PAD1/KWAD1/AN1
PAD8/KWAD8
PAD0/KWAD0/AN0
PWM0/API_EXTCLK/ETRIG0/KWP0/PP0
PWM1/ECLKX2/ETRIG1/KWP1/PP1
ETRIG2/KWP2/PP2
ETRIG3/KWP3/PP3
PWM4/KWP4/PP4
PWM5/KWP5/PP5
IOC5/PT5
IOC4/PT4
IOC3/PT3
IOC2/PT2
IRQ/IOC1/PT1
XIRQ/IOC0/PT0
RESET
VDDXR
VSSX
EXTAL/PE0
VSS
XTAL/PE1
TEST
KWJ0/PJ0
KWJ1/PJ1
KWJ2/PJ2
KWJ3/PJ3
BKGD
PM1
PM0
PS7/API_EXTCLK/ECLK/SS0
PS6/SCK0
PS5/MOSI0
PS4/MISO0
PS3
PS2
PS1/TXD0
PS0/RXD0
VSSA
VDDA/VRH
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor55
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table1-10. 48-Pin LQFP/QFN Pinout for S12GN16 and S12GN32
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.8.2S12GN48
1.8.2.1Pinout 32-Pin LQFP
28PAD9KWAD9ACMPO——VDDAPER0AD/PPS0ADDisabled
29PAD2KWAD2AN2——VDDAPER1AD/PPS1ADDisabled
30PAD10KWAD10ACMPPVDDAPER0AD/PPS0ADDisabled
31PAD3KWAD3AN3——VDDAPER1AD/PPS1ADDisabled
32PAD11KWAD11ACMPMVDDAPER0AD/PPS0ADDisabled
33PAD4KWAD4AN4——VDDAPER1AD/PPS1ADDisabled
34PAD5KWAD5AN5——VDDAPER1AD/PPS0ADDisabled
35PAD6KWAD6AN6——VDDAPER1AD/PPS1ADDisabled
36PAD7KWAD7AN7——VDDAPER1AD/PPS1ADDisabled
37VDDAVRH——————
38VSSA———————
39PS0RXD0———VDDXPERS/PPSSUp
40PS1TXD0———VDDXPERS/PPSSUp
41PS2————VDDXPERS/PPSSUp
42PS3————VDDXPERS/PPSSUp
43PS4MISO0———VDDXPERS/PPSSUp
44PS5MOSI0———VDDXPERS/PPSSUp
45PS6SCK0———VDDXPERS/PPSSUp
46PS7API_EXTCLKECLKSS0—VDDXPERS/PPSSUp
47PM0————VDDXPERM/PPSMDisabled
48PM1————VDDXPERM/PPSMDisabled
1The regular I/O characteristics (seeSectionA.2, “I/O Characteristics”) apply if the EXTAL/XTAL function is disabled
Table1-10. 48-Pin LQFP/QFN Pinout for S12GN16 and S12GN32
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor57
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure1-6. 32-Pin LQFP Pinout for S12GN48
Table1-11. 32-Pin LQFP Pinout for S12GN48
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
1RESET————VDDXPULLUP
2VDDXRAVRH——————
3VSSXA———————
4PE01EXTAL————PUCR/PDPEEDown
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
24
23
22
21
20
19
18
17
32
31
30
29
28
27
26
25
S12GN48
32-PinLQFP
PAD7/KWAD7/AN7/ACMPM
PAD6/KWAD6/AN6/ACMPP
PAD5/KWAD5/AN5/ACMPO
PAD4/KWAD4/AN4
PAD3/KWAD3/AN3
PAD2/KWAD2/AN2
PAD1/KWAD1/AN1
PAD0/KWAD0/AN0
PWM0/API_EXTCLK/ETRIG0/KWP0/PP0
PWM1/ECLKX2/ETRIG1/KWP1/PP1
PWM2/ETRIG2/KWP2/PP2
PWM3/ETRIG3/KWP3/PP3
IOC3/PT3
IOC2/PT2
IRQ/IOC1/PT1
XIRQ/IOC0/PT0
RESET
VRH/VDDXRA
VSSXA
EXTAL/PE0
VSS
XTAL/PE1
TEST
BKGD
PM1/TXD1
PM0/RXD1
PS7/API_EXTCLK/ECLK/PWM5/SS0
PS6/IOC5/SCK0
PS5/IOC4/MOSI0
PS4/PWM4/MISO0
PS1/TXD0
PS0/RXD0
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
58Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
5VSS———————
6PE11XTAL————PUCR/PDPEEDown
7TEST————N.A.RESET pinDown
8BKGDMODC———VDDXPUCR/BKPUEUp
9PP0KWP0ETRIG0API_EXTCLKPWM0VDDXPERP/PPSPDisabled
10PP1KWP1ETRIG1ECLKX2PWM1VDDXPERP/PPSPDisabled
11PP2KWP2ETRIG2PWM2—VDDXPERP/PPSPDisabled
12PP3KWP3ETRIG3PWM3—VDDXPERP/PPSPDisabled
13PT3IOC3———VDDXPERT/PPSTDisabled
14PT2IOC2———VDDXPERT/PPSTDisabled
15PT1IOC1IRQ——VDDXPERT/PPSTDisabled
16PT0IOC0XIRQ——VDDXPERT/PPSTDisabled
17PAD0KWAD0AN0——VDDAPER1AD/PPS1ADDisabled
18PAD1KWAD1AN1——VDDAPER1AD/PPS1ADDisabled
19PAD2KWAD2AN2——VDDAPER1AD/PPS1ADDisabled
20PAD3KWAD3AN3——VDDAPER1AD/PPS1ADDisabled
21PAD4KWAD4AN4——VDDAPER1AD/PPS1ADDisabled
22PAD5KWAD5AN5ACMPO—VDDAPER1AD/PPS1ADDisabled
23PAD6KWAD6AN6ACMPP—VDDAPER1AD/PPS1ADDisabled
24PAD7KWAD7AN7ACMPM—VDDAPER1AD/PPS1ADDisabled
25PS0RXD0———VDDXPERS/PPSSUp
26PS1TXD0———VDDXPERS/PPSSUp
27PS4PWM4MISO0——VDDXPERS/PPSSUp
28PS5IOC4MOSI0——VDDXPERS/PPSSUp
29PS6IOC5SCK0——VDDXPERS/PPSSUp
30PS7API_EXTCLKECLKPWM5SS0VDDXPERS/PPSSUp
31PM0RXD1———VDDXPERM/PPSMDisabled
32PM1TXD1———VDDXPERM/PPSMDisabled
1The regular I/O characteristics (seeSectionA.2, “I/O Characteristics”) apply if the EXTAL/XTAL function is disabled
Table1-11. 32-Pin LQFP Pinout for S12GN48
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor59
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.8.2.2Pinout 48-Pin LQFP
Figure1-7. 48-Pin LQFP Pinout for S12GN48
Table1-12. 48-Pin LQFP Pinout for S12GN48
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
1RESET————VDDXPULLUP
2VDDXR———————
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
36
35
34
33
32
31
30
29
28
27
26
25
48
47
46
45
44
43
42
41
40
39
38
37
S12GN48
48-PinLQFP
PAD7/KWAD7/AN7
PAD6/KWAD6/AN6
PAD5/KWAD5/AN5
PAD4/KWAD4/AN4
PAD11/KWAD11/AN11/ACMPM
PAD3/KWAD3/AN3
PAD10/KWAD10/AN10/ACMPP
PAD2/KWAD2/AN2
PAD9/KWAD9/AN9/ACMPO
PAD1/KWAD1/AN1
PAD8/KWAD8/AN8
PAD0/KWAD0/AN0
PWM0/API_EXTCLK/ETRIG0/KWP0/PP0
PWM1/ECLKX2/ETRIG1/KWP1/PP1
PWM2/ETRIG2/KWP2/PP2
PWM3/ETRIG3/KWP3/PP3
PWM4/KWP4/PP4
PWM5/KWP5/PP5
IOC5/PT5
IOC4/PT4
IOC3/PT3
IOC2/PT2
IRQ/IOC1/PT1
XIRQ/IOC0/PT0
RESET
VDDXR
VSSX
EXTAL/PE0
VSS
XTAL/PE1
TEST
MISO1/KWJ0/PJ0
MOSI1/KWJ1/PJ1
SCK1/KWJ2/PJ2
SS1/KWJ3/PJ3
BKGD
PM1
PM0
PS7/API_EXTCLK/ECLK/SS0
PS6/SCK0
PS5/MOSI0
PS4/MISO0
PS3/TXD1
PS2/RXD1
PS1/TXD0
PS0/RXD0
VSSA
VDDA/VRH
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
60Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
32PAD11KWAD11AN11ACMPMVDDAPER0AD/PPS0ADDisabled
33PAD4KWAD4AN4——VDDAPER1AD/PPS1ADDisabled
34PAD5KWAD5AN5——VDDAPER1AD/PPS0ADDisabled
35PAD6KWAD6AN6——VDDAPER1AD/PPS1ADDisabled
36PAD7KWAD7AN7——VDDAPER1AD/PPS1ADDisabled
37VDDAVRH——————
38VSSA———————
39PS0RXD0———VDDXPERS/PPSSUp
40PS1TXD0———VDDXPERS/PPSSUp
41PS2RXD1———VDDXPERS/PPSSUp
42PS3TXD1———VDDXPERS/PPSSUp
43PS4MISO0———VDDXPERS/PPSSUp
44PS5MOSI0———VDDXPERS/PPSSUp
45PS6SCK0———VDDXPERS/PPSSUp
46PS7API_EXTCLKECLKSS0—VDDXPERS/PPSSUp
47PM0————VDDXPERM/PPSMDisabled
48PM1————VDDXPERM/PPSMDisabled
1The regular I/O characteristics (seeSectionA.2, “I/O Characteristics”) apply if the EXTAL/XTAL function is disabled
Table1-12. 48-Pin LQFP Pinout for S12GN48
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
62Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.8.2.3Pinout 64-Pin LQFP
Figure1-8. 64-Pin LQFP Pinout for S12GN48
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
S12GN48
64-Pin LQFP
PWM0/API_EXTCLK/ETRIG0/KWP0/PP0
PWM1/ECLKX2/ETRIG1/KWP1/PP1
PWM2/ETRIG2/KWP2/PP2
PWM3/ETRIG3/KWP3/PP3
PWM4/KWP4/PP4
PWM5/KWP5/PP5
KWP6/PP6
KWP7/PP7
PT7
PT6
IOC5/PT5
IOC4/PT4
IOC3/PT3
IOC2/PT2
IRQ/IOC1/PT1
XIRQ/IOC0/PT0
KWJ6/PJ6
KWJ5/PJ5
KWJ4/PJ4
RESET
VDDX
VDDR
VSSX
EXTAL/PE0
VSS
XTAL/PE1
TEST
MISO1/KWJ0/PJ0
MOSI1/KWJ1/PJ1
SCK1/KWJ2/PJ2
SS1/KWJ3/PJ3
BKGD
PJ7/KWJ7
PM3
PM2
PM1
PM0
PS7/API_EXTCLK/ECLK/SS0
PS6/SCK0
PS5/MOSI0
PS4/MISO0
PS3/TXD1
PS2/RXD1
PS1/TXD0
PS0/RXD0
VSSA
VDDA
VRH
PAD15/KWAD15
PAD7/KWAD7/AN7
PAD14/KWAD14
PAD6/KWAD6/AN6
PAD13/KWAD13
PAD5/KWAD5/AN5
PAD12/KWAD12
PAD4/KWAD4/AN4
PAD11/KWAD11/AN11/ACMPM
PAD3/KWAD3/AN3
PAD10/KWAD10/AN10/ACMPP
PAD2/KWAD2/AN2
PAD9/KWAD9/AN9/ACMPO
PAD1/KWAD1/AN1
PAD8/KWAD8/AN8
PAD0/KWAD0/AN0
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor63
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28PT4IOC4———VDDXPERT/PPSTDisabled
29PT3IOC3———VDDXPERT/PPSTDisabled
30PT2IOC2———VDDXPERT/PPSTDisabled
31PT1IOC1IRQ——VDDXPERT/PPSTDisabled
32PT0IOC0XIRQ——VDDXPERT/PPSTDisabled
33PAD0KWAD0AN0——VDDAPER1AD/PPS1ADDisabled
34PAD8KWAD8AN8——VDDAPER0AD/PPS0ADDisabled
35PAD1KWAD1AN1——VDDAPER1AD/PPS1ADDisabled
36PAD9KWAD9AN9ACMPO—VDDAPER0ADPPS0ADDisabled
37PAD2KWAD2AN2——VDDAPER1AD/PPS1ADDisabled
38PAD10KWAD10AN10ACMPP—VDDAPER0AD/PPS0ADDisabled
39PAD3KWAD3AN3——VDDAPER1AD/PPS1ADDisabled
40PAD11KWAD11AN11ACMPM—VDDAPER0AD/PPS0ADDisabled
41PAD4KWAD4AN4——VDDAPER1AD/PPS1ADDisabled
42PAD12KWAD12———VDDAPER0AD/PPS0ADDisabled
43PAD5KWAD5AN5——VDDAPER1AD/PPS1ADDisabled
44PAD13KWAD13———VDDAPER0AD/PPS0ADDisabled
45PAD6KWAD6AN6——VDDAPER1AD/PPS1ADDisabled
46PAD14KWAD14——VDDAPER0AD/PPS0ADDisabled
47PAD7KWAD7AN7——VDDAPER1AD/PPS1ADDisabled
48PAD15KWAD15——VDDAPER0AD/PPS0ADDisabled
49VRH———————
50VDDA———————
51VSSA———————
52PS0RXD0———VDDXPERS/PPSSUp
53PS1TXD0———VDDXPERS/PPSSUp
54PS2RXD1———VDDXPERS/PPSSUp
55PS3TXD1———VDDXPERS/PPSSUp
56PS4MISO0———VDDXPERS/PPSSUp
Table1-13. 64-Pin LQFP Pinout for S12GN48
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor65
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.8.3S12G48 and S12G64
1.8.3.1Pinout 32-Pin LQFP
57PS5MOSI0———VDDXPERS/PPSSUp
58PS6SCK0———VDDXPERS/PPSSUp
59PS7API_EXTCLKECLKSS0—VDDXPERS/PPSSUp
60PM0————VDDXPERM/PPSMDisabled
61PM1————VDDXPERM/PPSMDisabled
62PM2————VDDXPERM/PPSMDisabled
63PM3————VDDXPERM/PPSMDisabled
64PJ7KWJ7———VDDXPERJ/PPSJUp
1The regular I/O characteristics (seeSectionA.2, “I/O Characteristics”) apply if the EXTAL/XTAL function is disabled
Table1-13. 64-Pin LQFP Pinout for S12GN48
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
66Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure1-9. 32-Pin LQFP Pinout for S12G48 and S12G64
Table1-14. 32-Pin LQFP Pinout for S12G48 and S12G64
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
1RESET————VDDXPULLUP
2VDDXRAVRH——————
3VSSXA———————
4PE01EXTAL————PUCR/PDPEEDown
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
24
23
22
21
20
19
18
17
32
31
30
29
28
27
26
25
S12G48
S12G64
32-PinLQFP
PAD7/KWAD7/AN7/ACMPM
PAD6/KWAD6/AN6/ACMPP
PAD5/KWAD5/AN5/ACMPO
PAD4/KWAD4/AN4
PAD3/KWAD3/AN3
PAD2/KWAD2/AN2
PAD1/KWAD1/AN1
PAD0/KWAD0/AN0
PWM0/API_EXTCLK/ETRIG0/KWP0/PP0
PWM1/ECLKX2/ETRIG1/KWP1/PP1
PWM2/ETRIG2/KWP2/PP2
PWM3/ETRIG3/KWP3/PP3
IOC3/PT3
IOC2/PT2
IRQ/IOC1/PT1
XIRQ/IOC0/PT0
RESET
VRH/VDDXRA
VSSXA
EXTAL/PE0
VSS
XTAL/PE1
TEST
BKGD
PM1/TXD1/TXCAN
PM0/RXD1/RXCAN
PS7/API_EXTCLK/ECLK/PWM5/SS0
PS6/IOC5/SCK0
PS5/IOC4/MOSI0
PS4/PWM4/MISO0
PS1/TXD0
PS0/RXD0
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor67
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
5VSS———————
6PE11XTAL————PUCR/PDPEEDown
7TEST————N.A.RESET pinDown
8BKGDMODC———VDDXPUCR/BKPUEUp
9PP0KWP0ETRIG0API_EXTCLKPWM0VDDXPERP/PPSPDisabled
10PP1KWP1ETRIG1ECLKX2PWM1VDDXPERP/PPSPDisabled
11PP2KWP2ETRIG2PWM2—VDDXPERP/PPSPDisabled
12PP3KWP3ETRIG3PWM3—VDDXPERP/PPSPDisabled
13PT3IOC3———VDDXPERT/PPSTDisabled
14PT2IOC2———VDDXPERT/PPSTDisabled
15PT1IOC1IRQ——VDDXPERT/PPSTDisabled
16PT0IOC0XIRQ——VDDXPERT/PPSTDisabled
17PAD0KWAD0AN0——VDDAPER1AD/PPS1ADDisabled
18PAD1KWAD1AN1——VDDAPER1AD/PPS1ADDisabled
19PAD2KWAD2AN2——VDDAPER1AD/PPS1ADDisabled
20PAD3KWAD3AN3——VDDAPER1AD/PPS1ADDisabled
21PAD4KWAD4AN4——VDDAPER1AD/PPS1ADDisabled
22PAD5KWAD5AN5ACMPO—VDDAPER1AD/PPS1ADDisabled
23PAD6KWAD6AN6ACMPP—VDDAPER1AD/PPS1ADDisabled
24PAD7KWAD7AN7ACMPM—VDDAPER1AD/PPS1ADDisabled
25PS0RXD0———VDDXPERS/PPSSUp
26PS1TXD0———VDDXPERS/PPSSUp
27PS4PWM4MISO0——VDDXPERS/PPSSUp
28PS5IOC4MOSI0——VDDXPERS/PPSSUp
29PS6IOC5SCK0——VDDXPERS/PPSSUp
30PS7API_EXTCLKECLKPWM5SS0VDDXPERS/PPSSUp
31PM0RXD1RXCAN——VDDXPERM/PPSMDisabled
32PM1TXD1TXCAN——VDDXPERM/PPSMDisabled
1The regular I/O characteristics (seeSectionA.2, “I/O Characteristics”) apply if the EXTAL/XTAL function is disabled
Table1-14. 32-Pin LQFP Pinout for S12G48 and S12G64
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
68Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.8.3.2Pinout 48-Pin LQFP
Figure1-10. 48-Pin LQFP Pinout for S12G48 and S12G64
Table1-15. 48-Pin LQFP Pinout for S12G48 and S12G64
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
1RESET————VDDXPULLUP
2VDDXR———————
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
36
35
34
33
32
31
30
29
28
27
26
25
48
47
46
45
44
43
42
41
40
39
38
37
S12G48
S12G64
48-PinLQFP
PAD7/KWAD7/AN7
PAD6/KWAD6/AN6
PAD5/KWAD5/AN5
PAD4/KWAD4/AN4
PAD11/KWAD11/AN11/ACMPM
PAD3/KWAD3/AN3
PAD10/KWAD10/AN10/ACMPP
PAD2/KWAD2/AN2
PAD9/KWAD9/AN9/ACMPO
PAD1/KWAD1/AN1
PAD8/KWAD8/AN8
PAD0/KWAD0/AN0
PWM0/API_EXTCLK/ETRIG0/KWP0/PP0
PWM1/ECLKX2/ETRIG1/KWP1/PP1
PWM2/ETRIG2/KWP2/PP2
PWM3/ETRIG3/KWP3/PP3
PWM4/KWP4/PP4
PWM5/KWP5/PP5
IOC5/PT5
IOC4/PT4
IOC3/PT3
IOC2/PT2
IRQ/IOC1/PT1
XIRQ/IOC0/PT0
RESET
VDDXR
VSSX
EXTAL/PE0
VSS
XTAL/PE1
TEST
MISO1/KWJ0/PJ0
MOSI1/KWJ1/PJ1
SCK1/KWJ2/PJ2
SS1/KWJ3/PJ3
BKGD
PM1/TXCAN
PM0/RXCAN
PS7/API_EXTCLK/ECLK/SS0
PS6/SCK0
PS5/MOSI0
PS4/MISO0
PS3/TXD1
PS2/RXD1
PS1/TXD0
PS0/RXD0
VSSA
VDDA/VRH
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor69
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table1-15. 48-Pin LQFP Pinout for S12G48 and S12G64
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
70Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
32PAD11KWAD11AN11ACMPMVDDAPER0AD/PPS0ADDisabled
33PAD4KWAD4AN4——VDDAPER1AD/PPS1ADDisabled
34PAD5KWAD5AN5——VDDAPER1AD/PPS0ADDisabled
35PAD6KWAD6AN6——VDDAPER1AD/PPS1ADDisabled
36PAD7KWAD7AN7——VDDAPER1AD/PPS1ADDisabled
37VDDAVRH——————
38VSSA———————
39PS0RXD0———VDDXPERS/PPSSUp
40PS1TXD0———VDDXPERS/PPSSUp
41PS2RXD1———VDDXPERS/PPSSUp
42PS3TXD1———VDDXPERS/PPSSUp
43PS4MISO0———VDDXPERS/PPSSUp
44PS5MOSI0———VDDXPERS/PPSSUp
45PS6SCK0———VDDXPERS/PPSSUp
46PS7API_EXTCLKECLKSS0—VDDXPERS/PPSSUp
47PM0RXCAN———VDDXPERM/PPSMDisabled
48PM1TXCAN———VDDXPERM/PPSMDisabled
1The regular I/O characteristics (seeSectionA.2, “I/O Characteristics”) apply if the EXTAL/XTAL function is disabled
Table1-15. 48-Pin LQFP Pinout for S12G48 and S12G64
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor71
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.8.3.3Pinout 64-Pin LQFP
Figure1-11. 64-Pin LQFP Pinout for S12G48 and S12G64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
S12G48
S12G64
64-pin LQFP
PWM0/API_EXTCLK/ETRIG0/KWP0/PP0
PWM1/ECLKX2/ETRIG1/KWP1/PP1
PWM2/ETRIG2/KWP2/PP2
PWM3/ETRIG3/KWP3/PP3
PWM4/KWP4/PP4
PWM5/KWP5/PP5
KWP6/PP6
KWP7/PP7
PT7
PT6
IOC5/PT5
IOC4/PT4
IOC3/PT3
IOC2/PT2
IRQ/IOC1/PT1
XIRQ/IOC0/PT0
KWJ6/PJ6
KWJ5/PJ5
KWJ4/PJ4
RESET
VDDX
VDDR
VSSX
EXTAL/PE0
VSS
XTAL/PE1
TEST
MISO1/KWJ0/PJ0
MOSI1/KWJ1/PJ1
SCK1/KWJ2/PJ2
SS1/KWJ3/PJ3
BKGD
PJ7/KWJ7
PM3
PM2
PM1/TXCAN
PM0/RXCAN
PS7/API_EXTCLK/ECLK/SS0
PS6/SCK0
PS5/MOSI0
PS4/MISO0
PS3/TXD1
PS2/RXD1
PS1/TXD0
PS0/RXD0
VSSA
VDDA
VRH
PAD15/KWAD15
PAD7/KWAD7/AN7
PAD14/KWAD14
PAD6/KWAD6/AN6
PAD13/KWAD13
PAD5/KWAD5/AN5
PAD12/KWAD12
PAD4/KWAD4/AN4
PAD11/KWAD11/AN11/ACMPM
PAD3/KWAD3/AN3
PAD10/KWAD10/AN10/ACMPP
PAD2/KWAD2/AN2
PAD9/KWAD9/AN9/ACMPO
PAD1/KWAD1/AN1
PAD8/KWAD8/AN8
PAD0/KWAD0/AN0
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
72Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table1-16. 64-Pin LQFP Pinout for S12G48 and S12G64
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28PT4IOC4———VDDXPERT/PPSTDisabled
29PT3IOC3———VDDXPERT/PPSTDisabled
30PT2IOC2———VDDXPERT/PPSTDisabled
31PT1IOC1IRQ——VDDXPERT/PPSTDisabled
32PT0IOC0XIRQ——VDDXPERT/PPSTDisabled
33PAD0KWAD0AN0——VDDAPER1AD/PPS1ADDisabled
34PAD8KWAD8AN8——VDDAPER0AD/PPS0ADDisabled
35PAD1KWAD1AN1——VDDAPER1AD/PPS1ADDisabled
36PAD9KWAD9AN9ACMPO—VDDAPER0ADPPS0ADDisabled
37PAD2KWAD2AN2——VDDAPER1AD/PPS1ADDisabled
38PAD10KWAD10AN10ACMPPVDDAPER0AD/PPS0ADDisabled
39PAD3KWAD3AN3——VDDAPER1AD/PPS1ADDisabled
40PAD11KWAD11AN11ACMPMVDDAPER0AD/PPS0ADDisabled
41PAD4KWAD4AN4——VDDAPER1AD/PPS1ADDisabled
42PAD12KWAD12———VDDAPER0AD/PPS0ADDisabled
43PAD5KWAD5AN5——VDDAPER1AD/PPS1ADDisabled
44PAD13KWAD13———VDDAPER0AD/PPS0ADDisabled
45PAD6KWAD6AN6——VDDAPER1AD/PPS1ADDisabled
46PAD14KWAD14———VDDAPER0AD/PPS0ADDisabled
47PAD7KWAD7AN7——VDDAPER1AD/PPS1ADDisabled
48PAD15KWAD15———VDDAPER0AD/PPS0ADDisabled
49VRH———————
50VDDA———————
51VSSA———————
52PS0RXD0———VDDXPERS/PPSSUp
53PS1TXD0———VDDXPERS/PPSSUp
54PS2RXD1———VDDXPERS/PPSSUp
55PS3TXD1———VDDXPERS/PPSSUp
56PS4MISO0———VDDXPERS/PPSSUp
Table1-16. 64-Pin LQFP Pinout for S12G48 and S12G64
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
74Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
57PS5MOSI0———VDDXPERS/PPSSUp
58PS6SCK0———VDDXPERS/PPSSUp
59PS7API_EXTCLKECLKSS0—VDDXPERS/PPSSUp
60PM0RXCAN———VDDXPERM/PPSMDisabled
61PM1TXCAN———VDDXPERM/PPSMDisabled
62PM2————VDDXPERM/PPSMDisabled
63PM3————VDDXPERM/PPSMDisabled
64PJ7KWJ7———VDDXPERJ/PPSJUp
1The regular I/O characteristics (seeSectionA.2, “I/O Characteristics”) apply if the EXTAL/XTAL function is disabled
Table1-16. 64-Pin LQFP Pinout for S12G48 and S12G64
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor75
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.8.4S12G96 and S12G128
1.8.4.1Pinout 48-Pin LQFP
Figure1-12. 48-Pin LQFP Pinout for S12G96 and S12G128
Table1-17. 48-Pin LQFP Pinout for S12G96 and S12G128
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
1RESET————VDDXPULLUP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
36
35
34
33
32
31
30
29
28
27
26
25
48
47
46
45
44
43
42
41
40
39
38
37
S12G96
S12G128
48-PinLQFP
PAD7/KWAD7/AN7
PAD6/KWAD6/AN6
PAD5/KWAD5/AN5
PAD4/KWAD4/AN4
PAD11/KWAD11/AN11
PAD3/KWAD3/AN3
PAD10/KWAD10/AN10
PAD2/KWAD2/AN2
PAD9/KWAD9/AN9
PAD1/KWAD1/AN1
PAD8/KWAD8/AN8
PAD0/KWAD0/AN0
PWM0/API_EXTCLK/ETRIG0/KWP0/PP0
PWM1/ECLKX2/ETRIG1/KWP1/PP1
PWM2/ETRIG2/KWP2/PP2
PWM3/ETRIG3/KWP3/PP3
PWM4/KWP4/PP4
PWM5/KWP5/PP5
IOC5/PT5
IOC4/PT4
IOC3/PT3
IOC2/PT2
IRQ/IOC1/PT1
XIRQ/IOC0/PT0
RESET
VDDXR
VSSX
EXTAL/PE0
VSS
XTAL/PE1
TEST
MISO1/PWM6/KWJ0/PJ0
MOSI1/IOC6/KWJ1/PJ1
SCK1/IOC7/KWJ2/PJ2
SS1/PWM7/KWJ3/PJ3
BKGD
PM1/TXD2/TXCAN
PM0/RXD2/RXCAN
PS7/API_EXTCLK/ECLK/SS0
PS6/SCK0
PS5/MOSI0
PS4/MISO0
PS3/TXD1
PS2/RXD1
PS1/TXD0
PS0/RXD0
VSSA
VDDA/VRH
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
76Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table1-17. 48-Pin LQFP Pinout for S12G96 and S12G128
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor77
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
31PAD3KWAD3AN3——VDDAPER1AD/PPS1ADDisabled
32PAD11KWAD11AN11——VDDAPER0AD/PPS0ADDisabled
33PAD4KWAD4AN4——VDDAPER1AD/PPS1ADDisabled
34PAD5KWAD5AN5——VDDAPER1AD/PPS0ADDisabled
35PAD6KWAD6AN6——VDDAPER1AD/PPS1ADDisabled
36PAD7KWAD7AN7——VDDAPER1AD/PPS1ADDisabled
37VDDAVRH——————
38VSSA———————
39PS0RXD0———VDDXPERS/PPSSUp
40PS1TXD0———VDDXPERS/PPSSUp
41PS2RXD1———VDDXPERS/PPSSUp
42PS3TXD1———VDDXPERS/PPSSUp
43PS4MISO0———VDDXPERS/PPSSUp
44PS5MOSI0———VDDXPERS/PPSSUp
45PS6SCK0———VDDXPERS/PPSSUp
46PS7API_EXTCLKECLKSS0—VDDXPERS/PPSSUp
47PM0RXD2RXCAN——VDDXPERM/PPSMDisabled
48PM1TXD2TXCAN——VDDXPERM/PPSMDisabled
1The regular I/O characteristics (seeSectionA.2, “I/O Characteristics”) apply if the EXTAL/XTAL function is disabled
Table1-17. 48-Pin LQFP Pinout for S12G96 and S12G128
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
78Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.8.4.2Pinout 64-Pin LQFP
Figure1-13. 64-Pin LQFP Pinout for S12G96 and S12G128
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
S12G96
S12G128
64-Pin LQFP
PWM0/API_EXTCLK/ETRIG0/KWP0/PP0
PWM1/ECLKX2/ETRIG1/KWP1/PP1
PWM2/ETRIG2/KWP2/PP2
PWM3/ETRIG3/KWP3/PP3
PWM4/KWP4/PP4
PWM5/KWP5/PP5
PWM6/KWP6/PP6
PWM7/KWP7/PP7
IOC7/PT7
IOC6/PT6
IOC5/PT5
IOC4/PT4
IOC3/PT3
IOC2/PT2
IRQ/IOC1/PT1
XIRQ/IOC0/PT0
SCK2/KWJ6/PJ6
MOSI2/KWJ5/PJ5
MISO2/KWJ4/PJ4
RESET
VDDX
VDDR
VSSX
EXTAL/PE0
VSS
XTAL/PE1
TEST
MISO1/KWJ0/PJ0
MOSI1/KWJ1/PJ1
SCK1/KWJ2/PJ2
SS1/KWJ3/PJ3
BKGD
PJ7/KWJ7/SS2
PM3/TXD2
PM2/RXD2
PM1/TXCAN
PM0/RXCAN
PS7/API_EXTCLK/ECLK/SS0
PS6/SCK0
PS5/MOSI0
PS4/MISO0
PS3/TXD1
PS2/RXD1
PS1/TXD0
PS0/RXD0
VSSA
VDDA
VRH
PAD15/KWAD15
PAD7/KWAD7/AN7
PAD14/KWAD14
PAD6/KWAD6/AN6
PAD13/KWAD13
PAD5/KWAD5/AN5
PAD12/KWAD12
PAD4/KWAD4/AN4
PAD11/KWAD11/AN11
PAD3/KWAD3/AN3
PAD10/KWAD10/AN10
PAD2/KWAD2/AN2
PAD9/KWAD9/AN9
PAD1/KWAD1/AN1
PAD8/KWAD8/AN8
PAD0/KWAD0/AN0
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor79
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table1-18. 64-Pin LQFP Pinout for S12G96 and S12G128
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28PT4IOC4———VDDXPERT/PPSTDisabled
29PT3IOC3———VDDXPERT/PPSTDisabled
30PT2IOC2———VDDXPERT/PPSTDisabled
31PT1IOC1IRQ——VDDXPERT/PPSTDisabled
32PT0IOC0XIRQ——VDDXPERT/PPSTDisabled
33PAD0KWAD0AN0——VDDAPER1AD/PPS1ADDisabled
34PAD8KWAD8AN8——VDDAPER0AD/PPS0ADDisabled
35PAD1KWAD1AN1——VDDAPER1AD/PPS1ADDisabled
36PAD9KWAD9AN9——VDDAPER0ADPPS0ADDisabled
37PAD2KWAD2AN2——VDDAPER1AD/PPS1ADDisabled
38PAD10KWAD10AN10——VDDAPER0AD/PPS0ADDisabled
39PAD3KWAD3AN3——VDDAPER1AD/PPS1ADDisabled
40PAD11KWAD11AN11——VDDAPER0AD/PPS0ADDisabled
41PAD4KWAD4AN4——VDDAPER1AD/PPS1ADDisabled
42PAD12KWAD12——VDDAPER0AD/PPS0ADDisabled
43PAD5KWAD5AN5——VDDAPER1AD/PPS1ADDisabled
44PAD13KWAD13——VDDAPER0AD/PPS0ADDisabled
45PAD6KWAD6AN6——VDDAPER1AD/PPS1ADDisabled
46PAD14KWAD14——VDDAPER0AD/PPS0ADDisabled
47PAD7KWAD7AN7——VDDAPER1AD/PPS1ADDisabled
48PAD15KWAD15——VDDAPER0AD/PPS0ADDisabled
49VRH———————
50VDDA———————
51VSSA———————
52PS0RXD0———VDDXPERS/PPSSUp
53PS1TXD0———VDDXPERS/PPSSUp
54PS2RXD1———VDDXPERS/PPSSUp
55PS3TXD1———VDDXPERS/PPSSUp
56PS4MISO0———VDDXPERS/PPSSUp
Table1-18. 64-Pin LQFP Pinout for S12G96 and S12G128
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor81
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
57PS5MOSI0———VDDXPERS/PPSSUp
58PS6SCK0———VDDXPERS/PPSSUp
59PS7API_EXTCLKECLKSS0—VDDXPERS/PPSSUp
60PM0RXCAN———VDDXPERM/PPSMDisabled
61PM1TXCAN———VDDXPERM/PPSMDisabled
62PM2RXD2———VDDXPERM/PPSMDisabled
63PM3TXD2———VDDXPERM/PPSMDisabled
64PJ7KWJ7SS2——VDDXPERJ/PPSJUp
1The regular I/O characteristics (seeSectionA.2, “I/O Characteristics”) apply if the EXTAL/XTAL function is disabled
Table1-18. 64-Pin LQFP Pinout for S12G96 and S12G128
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
82Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.8.4.3Pinout 100-Pin LQFP
Figure1-14. 100-Pin LQFP Pinout for S12G96 and S12G128
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
VRH
PC7
PC6
PC5
PC4
PAD15/KWAD15/
PAD7/KWAD7/AN7
PAD14/KWAD14
PAD6/KWAD6/AN6
PAD13/KWAD13
PAD5/KWAD5/AN5
PAD12/KWAD12
PAD4/KWAD4/AN4
PAD11/KWAD11/AN11
PAD3/KWAD3/AN3
PAD10/KWAD10/AN10
PAD2/KWAD2/AN2
PAD9/KWAD9/AN9
PAD1/KWAD1/AN1
PAD8/KWAD8/AN8
PAD0/KWAD0/AN0
PC3
PC2
PC1
PC0
API_EXTCLK/PB1
ECLKX2/PB2
PB3
PWM0/ETRIG0/KWP0/PP0
PWM1/ETRIG1/KWP1/PP1
PWM2/ETRIG2/KWP2/PP2
PWM3/ETRIG3/KWP3/PP3
PWM4/KWP4/PP4
PWM5/KWP5/PP5
PWM6/KWP6/PP6
PWM7/KWP7/PP7
VDDX3
VSSX3
IOC7/PT7
IOC6/PT6
IOC5/PT5
IOC4/PT4
IOC3/PT3
IOC2/PT2
IOC1/PT1
IOC0/PT0
IRQ/PB4
XIRQ/PB5
PB6
PB7
75
74
73
72
71
70
69
68
67
66
65
64
63
62
61
60
59
58
57
56
55
54
53
52
51
100
99
98
97
96
95
94
93
92
91
90
89
88
87
86
85
84
83
82
81
80
79
78
77
76
SCK2/KWJ6/PJ6
MOSI2/KWJ5/PJ5
MISO2/KWJ4/PJ4
PA0
PA1
PA2
PA3
RESET
VDDX1
VDDR
VSSX1
EXTAL/PE0
VSS
XTAL/PE1
TEST
PA4
PA5
PA6
PA7
MISO1/KWJ0/PJ0
MOSI1/KWJ1/PJ1
SCK1/KWJ2/PJ2
SS1/KWJ3/PJ3
BKGD
ECLK/PB0
PJ7/KWJ7/SS2
PM3/TXD2
PM2/RXD2
PD7
PD6
PD5
PD4
PM1/TXCAN
PM0/RXCAN
VDDX2
VSSX2
PS7/API_EXTCLK/SS0
PS6/SCK0
PS5/MOSI0
PS4/MISO0
PS3/TXD1
PS2/RXD1
PS1/TXD0
PS0/RXD0
PD3
PD2
PD1
PD0
VSSA
VDDA
S12G96
S12G128
100-Pin LQFP
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor83
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table1-19. 100-Pin LQFP Pinout for S12G96 and S12G128
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func.CTRLReset
State
1PJ6KWJ6SCK2—VDDXPERJ/PPSJUp
2PJ5KWJ5MOSI2—VDDXPERJ/PPSJUp
3PJ4KWJ4MISO2—VDDXPERJ/PPSJUp
4PA0———V
DDXPUCR/PUPAEDisabled
5PA1———V
DDXPUCR/PUPAEDisabled
6PA2———V
DDXPUCR/PUPAEDisabled
7PA3———V
DDXPUCR/PUPAEDisabled
8RESET———VDDXPULLUP
9VDDX1——————
10VDDR——————
11VSSX1——————
12PE01EXTAL——VDDXPUCR/PDPEEDown
13VSS——————
14PE11XTAL——VDDXPUCR/PDPEEDown
15TEST———N.A.RESET pinDown
16PA4———V
DDXPUCR/PUPAEDisabled
17PA5———V
DDXPUCR/PUPAEDisabled
18PA6———V
DDXPUCR/PUPAEDisabled
19PA7———V
DDXPUCR/PUPAEDisabled
20PJ0KWJ0MISO1—VDDXPERJ/PPSJUp
21PJ1KWJ1MOSI1—VDDXPERJ/PPSJUp
22PJ2KWJ2SCK1—VDDXPERJ/PPSJUp
23PJ3KWJ3SS1—VDDXPERJ/PPSJUp
24BKGDMODC——VDDXPUCR/BKPUEUp
25PB0ECLK——VDDXPUCR/PUPBEDisabled
26PB1API_EXTCLK——V
DDXPUCR/PUPBEDisabled
27PB2ECLKX2——VDDXPUCR/PUPBEDisabled
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
84Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28PB3———VDDXPUCR/PUPBEDisabled
29PP0KWP0ETRIG0PWM0VDDXPERP/PPSPDisabled
30PP1KWP1ETRIG1PWM1VDDXPERP/PPSPDisabled
31PP2KWP2ETRIG2PWM2VDDXPERP/PPSPDisabled
32PP3KWP3ETRIG3PWM3VDDXPERP/PPSPDisabled
33PP4KWP4PWM4—VDDXPERP/PPSPDisabled
34PP5KWP5PWM5—VDDXPERP/PPSPDisabled
35PP6KWP6PWM6—VDDXPERP/PPSPDisabled
36PP7KWP7PWM7—VDDXPERP/PPSPDisabled
37VDDX3——————
38VSSX3——————
39PT7IOC7——VDDXPERT/PPSTDisabled
40PT6IOC6——VDDXPERT/PPSTDisabled
41PT5IOC5——VDDXPERT/PPSTDisabled
42PT4IOC4——VDDXPERT/PPSTDisabled
43PT3IOC3——VDDXPERT/PPSTDisabled
44PT2IOC2——VDDXPERT/PPSTDisabled
45PT1IOC1——VDDXPERT/PPSTDisabled
46PT0IOC0——VDDXPERT/PPSTDisabled
47PB4IRQ——VDDXPUCR/PUPBEDisabled
48PB5XIRQ——VDDXPUCR/PUPBEDisabled
49PB6———VDDXPUCR/PUPBEDisabled
50PB7———VDDXPUCR/PUPBEDisabled
51PC0———VDDAPUCR/PUPCEDisabled
52PC1———VDDAPUCR/PUPCEDisabled
53PC2———VDDAPUCR/PUPCEDisabled
54PC3———VDDAPUCR/PUPCEDisabled
55PAD0KWAD0AN0—VDDAPER1AD/PPS1ADDisabled
56PAD8KWAD8AN8—VDDAPER0AD/PPS0ADDisabled
Table1-19. 100-Pin LQFP Pinout for S12G96 and S12G128
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func.CTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor85
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
57PAD1KWAD1AN1—VDDAPER1AD/PPS1ADDisabled
58PAD9KWAD9AN9—VDDAPER0AD/PPS0ADDisabled
59PAD2KWAD2AN2—VDDAPER1AD/PPS1ADDisabled
60PAD10KWAD10AN10—VDDAPER0AD/PPS0ADDisabled
61PAD3KWAD3AN3—VDDAPER1AD/PPS1ADDisabled
62PAD11KWAD11AN11—VDDAPER0AD/PPS0ADDisabled
63PAD4KWAD4AN4—VDDAPER1AD/PPS1ADDisabled
64PAD12KWAD12——VDDAPER0AD/PPS0ADDisabled
65PAD5KWAD5AN5—VDDAPER1AD/PPS1ADDisabled
66PAD13KWAD13——VDDAPER0AD/PPS0ADDisabled
67PAD6KWAD6AN6—VDDAPER1AD/PPS1ADDisabled
68PAD14KWAD14——VDDAPER0AD/PPS0ADDisabled
69PAD7KWAD7AN7—VDDAPER1AD/PPS1ADDisabled
70PAD15KWAD15——VDDAPER0AD/PPS0ADDisabled
71PC4———VDDAPUCR/PUPCEDisabled
72PC5——VDDAPUCR/PUPCEDisabled
73PC6——VDDAPUCR/PUPCEDisabled
74PC7——VDDAPUCR/PUPCEDisabled
75VRH——————
76VDDA——————
77VSSA——————
78PD0———VDDXPUCR/PUPDEDisabled
79PD1———VDDXPUCR/PUPDEDisabled
80PD2———VDDXPUCR/PUPDEDisabled
81PD3———VDDXPUCR/PUPDEDisabled
82PS0RXD0——VDDXPERS/PPSSUp
83PS1TXD0——VDDXPERS/PPSSUp
84PS2RXD1——VDDXPERS/PPSSUp
85PS3TXD1——VDDXPERS/PPSSUp
Table1-19. 100-Pin LQFP Pinout for S12G96 and S12G128
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func.CTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
86Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
86PS4MISO0——VDDXPERS/PPSSUp
87PS5MOSI0——VDDXPERS/PPSSUp
88PS6SCK0——VDDXPERS/PPSSUp
89PS7API_EXTCLKSS0—VDDXPERS/PPSSUp
90VSSX2——————
91VDDX2——————
92PM0RXCAN——VDDXPERM/PPSMDisabled
93PM1TXCAN——VDDXPERM/PPSMDisabled
94PD4———VDDXPUCR/PUPDEDisabled
95PD5———VDDXPUCR/PUPDEDisabled
96PD6———VDDXPUCR/PUPDEDisabled
97PD7———VDDXPUCR/PUPDEDisabled
98PM2RXD2——VDDXPERM/PPSMDisabled
99PM3TXD2——VDDXPERM/PPSMDisabled
100PJ7KWJ7SS2—VDDXPERJ/PPSJUp
1The regular I/O characteristics (seeSectionA.2, “I/O Characteristics”) apply if the EXTAL/XTAL function is disabled
Table1-19. 100-Pin LQFP Pinout for S12G96 and S12G128
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func.CTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor87
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.8.5S12G192 and S12G240
1.8.5.1Pinout 48-Pin LQFP
Figure1-15. 48-Pin LQFP Pinout for S12G192 and S12G240
Table1-20. 48-Pin LQFP Pinout for S12G192 and S12G240
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
1RESET————VDDXPULLUP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
36
35
34
33
32
31
30
29
28
27
26
25
48
47
46
45
44
43
42
41
40
39
38
37
S12G192
S12G240
48-PinLQFP
PAD7/KWAD7/AN7
PAD6/KWAD6/AN6
PAD5/KWAD5/AN5
PAD4/KWAD4/AN4
PAD11/KWAD11/AN11
PAD3/KWAD3/AN3
PAD10/KWAD10/AN10
PAD2/KWAD2/AN2
PAD9/KWAD9/AN9
PAD1/KWAD1/AN1
PAD8/KWAD8/AN8
PAD0/KWAD0/AN0
PWM0/API_EXTCLK/ETRIG0/KWP0/PP0
PWM1/ECLKX2/ETRIG1/KWP1/PP1
PWM2/ETRIG2/KWP2/PP2
PWM3/ETRIG3/KWP3/PP3
PWM4/KWP4/PP4
PWM5/KWP5/PP5
IOC5/PT5
IOC4/PT4
IOC3/PT3
IOC2/PT2
IRQ/IOC1/PT1
XIRQ/IOC0/PT0
RESET
VDDXR
VSSX
EXTAL/PE0
VSS
XTAL/PE1
TEST
MISO1/PWM6/KWJ0/PJ0
MOSI1/IOC6/KWJ1/PJ1
SCK1/IOC7/KWJ2/PJ2
SS1/PWM7/KWJ3/PJ3
BKGD
PM1/TXD2/TXCAN
PM0/RXD2/RXCAN
PS7/API_EXTCLK/ECLK/SS0
PS6/SCK0
PS5/MOSI0
PS4/MISO0
PS3/TXD1
PS2/RXD1
PS1/TXD0
PS0/RXD0
VSSA
VDDA/VRH
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
88Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table1-20. 48-Pin LQFP Pinout for S12G192 and S12G240
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor89
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
31PAD3KWAD3AN3——VDDAPER1AD/PPS1ADDisabled
32PAD11KWAD11AN11——VDDAPER0AD/PPS0ADDisabled
33PAD4KWAD4AN4——VDDAPER1AD/PPS1ADDisabled
34PAD5KWAD5AN5——VDDAPER1AD/PPS0ADDisabled
35PAD6KWAD6AN6——VDDAPER1AD/PPS1ADDisabled
36PAD7KWAD7AN7——VDDAPER1AD/PPS1ADDisabled
37VDDAVRH——————
38VSSA———————
39PS0RXD0———VDDXPERS/PPSSUp
40PS1TXD0———VDDXPERS/PPSSUp
41PS2RXD1———VDDXPERS/PPSSUp
42PS3TXD1———VDDXPERS/PPSSUp
43PS4MISO0———VDDXPERS/PPSSUp
44PS5MOSI0———VDDXPERS/PPSSUp
45PS6SCK0———VDDXPERS/PPSSUp
46PS7API_EXTCLKECLKSS0—VDDXPERS/PPSSUp
47PM0RXD2RXCAN——VDDXPERM/PPSMDisabled
48PM1TXD2TXCAN——VDDXPERM/PPSMDisabled
1The regular I/O characteristics (seeSectionA.2, “I/O Characteristics”) apply if the EXTAL/XTAL function is disabled
Table1-20. 48-Pin LQFP Pinout for S12G192 and S12G240
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
90Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.8.5.2Pinout 64-Pin LQFP
Figure1-16. 64-Pin LQFP Pinout for S12G192 and S12G240
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
S12G192
S12G240
64-Pin LQFP
PWM0/API_EXTCLK/ETRIG0/KWP0/PP0
PWM1/ECLKX2/ETRIG1/KWP1/PP1
PWM2/ETRIG2/KWP2/PP2
PWM3/ETRIG3/KWP3/PP3
PWM4/KWP4/PP4
PWM5/KWP5/PP5
PWM6/KWP6/PP6
PWM7/KWP7/PP7
IOC7/PT7
IOC6/PT6
IOC5/PT5
IOC4/PT4
IOC3/PT3
IOC2/PT2
IRQ/IOC1/PT1
XIRQ/IOC0/PT0
SCK2/KWJ6/PJ6
MOSI2/KWJ5/PJ5
MISO2/KWJ4/PJ4
RESET
VDDX
VDDR
VSSX
EXTAL/PE0
VSS
XTAL/PE1
TEST
MISO1/KWJ0/PJ0
MOSI1/KWJ1/PJ1
SCK1/KWJ2/PJ2
SS1/KWJ3/PJ3
BKGD
PJ7/KWJ7/SS2
PM3/TXD2
PM2/RXD2
PM1/TXCAN
PM0/RXCAN
PS7/API_EXTCLK/ECLK/SS0
PS6/SCK0
PS5/MOSI0
PS4/MISO0
PS3/TXD1
PS2/RXD1
PS1/TXD0
PS0/RXD0
VSSA
VDDA
VRH
PAD15/KWAD15/AN15
PAD7/KWAD7/AN7
PAD14/KWAD14/AN14
PAD6/KWAD6/AN6
PAD13/KWAD13/AN13
PAD5/KWAD5/AN5
PAD12/KWAD12/AN12
PAD4/KWAD4/AN4
PAD11/KWAD11/AN11
PAD3/KWAD3/AN3
PAD10/KWAD10/AN10
PAD2/KWAD2/AN2
PAD9/KWAD9/AN9
PAD1/KWAD1/AN1
PAD8/KWAD8/AN8
PAD0/KWAD0/AN0
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor91
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table1-21. 64-Pin LQFP Pinout for S12G192 and S12G240
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28PT4IOC4———VDDXPERT/PPSTDisabled
29PT3IOC3———VDDXPERT/PPSTDisabled
30PT2IOC2———VDDXPERT/PPSTDisabled
31PT1IOC1IRQ——VDDXPERT/PPSTDisabled
32PT0IOC0XIRQ——VDDXPERT/PPSTDisabled
33PAD0KWAD0AN0——VDDAPER1AD/PPS1ADDisabled
34PAD8KWAD8AN8——VDDAPER0AD/PPS0ADDisabled
35PAD1KWAD1AN1——VDDAPER1AD/PPS1ADDisabled
36PAD9KWAD9AN9——VDDAPER0ADPPS0ADDisabled
37PAD2KWAD2AN2——VDDAPER1AD/PPS1ADDisabled
38PAD10KWAD10AN10——VDDAPER0AD/PPS0ADDisabled
39PAD3KWAD3AN3——VDDAPER1AD/PPS1ADDisabled
40PAD11KWAD11AN11——VDDAPER0AD/PPS0ADDisabled
41PAD4KWAD4AN4——VDDAPER1AD/PPS1ADDisabled
42PAD12KWAD12AN12——VDDAPER0AD/PPS0ADDisabled
43PAD5KWAD5AN5——VDDAPER1AD/PPS1ADDisabled
44PAD13KWAD13AN13——VDDAPER0AD/PPS0ADDisabled
45PAD6KWAD6AN6——VDDAPER1AD/PPS1ADDisabled
46PAD14KWAD14AN14——VDDAPER0AD/PPS0ADDisabled
47PAD7KWAD7AN7——VDDAPER1AD/PPS1ADDisabled
48PAD15KWAD15AN15——VDDAPER0AD/PPS0ADDisabled
49VRH———————
50VDDA———————
51VSSA———————
52PS0RXD0———VDDXPERS/PPSSUp
53PS1TXD0———VDDXPERS/PPSSUp
54PS2RXD1———VDDXPERS/PPSSUp
55PS3TXD1———VDDXPERS/PPSSUp
56PS4MISO0———VDDXPERS/PPSSUp
Table1-21. 64-Pin LQFP Pinout for S12G192 and S12G240
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor93
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
57PS5MOSI0———VDDXPERS/PPSSUp
58PS6SCK0———VDDXPERS/PPSSUp
59PS7API_EXTCLKECLKSS0—VDDXPERS/PPSSUp
60PM0RXCAN———VDDXPERM/PPSMDisabled
61PM1TXCAN———VDDXPERM/PPSMDisabled
62PM2RXD2———VDDXPERM/PPSMDisabled
63PM3TXD2———VDDXPERM/PPSMDisabled
64PJ7KWJ7SS2——VDDXPERJ/PPSJUp
1The regular I/O characteristics (seeSectionA.2, “I/O Characteristics”) apply if the EXTAL/XTAL function is disabled
Table1-21. 64-Pin LQFP Pinout for S12G192 and S12G240
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
94Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.8.5.3Pinout 100-Pin LQFP
Figure1-17. 100-Pin LQFP Pinout for S12G192 and S12G240
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
VRH
PC7
PC6
PC5
PC4
PAD15/KWAD15/AN15
PAD7/KWAD7/AN7
PAD14/KWAD14/AN14
PAD6/KWAD6/AN6
PAD13/KWAD13/AN13
PAD5/KWAD5/AN5
PAD12/KWAD12/AN12
PAD4/KWAD4/AN4
PAD11/KWAD11/AN11
PAD3/KWAD3/AN3
PAD10/KWAD10/AN10
PAD2/KWAD2/AN2
PAD9/KWAD9/AN9
PAD1/KWAD1/AN1
PAD8/KWAD8/AN8
PAD0/KWAD0/AN0
PC3
PC2
PC1
PC0
API_EXTCLK/PB1
ECLKX2/PB2
PB3
PWM0/ETRIG0/KWP0/PP0
PWM1/ETRIG1/KWP1/PP1
PWM2/ETRIG2/KWP2/PP2
PWM3/ETRIG3/KWP3/PP3
PWM4/KWP4/PP4
PWM5/KWP5/PP5
PWM6/KWP6/PP6
PWM7/KWP7/PP7
VDDX3
VSSX3
IOC7/PT7
IOC6/PT6
IOC5/PT5
IOC4/PT4
IOC3/PT3
IOC2/PT2
IOC1/PT1
IOC0/PT0
IRQ/PB4
XIRQ/PB5
PB6
PB7
75
74
73
72
71
70
69
68
67
66
65
64
63
62
61
60
59
58
57
56
55
54
53
52
51
100
99
98
97
96
95
94
93
92
91
90
89
88
87
86
85
84
83
82
81
80
79
78
77
76
SCK2/KWJ6/PJ6
MOSI2/KWJ5/PJ5
MISO2/KWJ4/PJ4
PA0
PA1
PA2
PA3
RESET
VDDX1
VDDR
VSSX1
EXTAL/PE0
VSS
XTAL/PE1
TEST
PA4
PA5
PA6
PA7
MISO1/KWJ0/PJ0
MOSI1/KWJ1/PJ1
SCK1/KWJ2/PJ2
SS1/KWJ3/PJ3
BKGD
ECLK/PB0
PJ7/KWJ7/SS2
PM3/TXD2
PM2/RXD2
PD7
PD6
PD5
PD4
PM1/TXCAN
PM0/RXCAN
VDDX2
VSSX2
PS7/API_EXTCLK/SS0
PS6/SCK0
PS5/MOSI0
PS4/MISO0
PS3/TXD1
PS2/RXD1
PS1/TXD0
PS0/RXD0
PD3
PD2
PD1
PD0
VSSA
VDDA
S12G192
S12G240
100-Pin LQFP
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor95
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table1-22. 100-Pin LQFP Pinout for S12G192 and S12G240
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func.CTRLReset
State
1PJ6KWJ6SCK2—VDDXPERJ/PPSJUp
2PJ5KWJ5MOSI2—VDDXPERJ/PPSJUp
3PJ4KWJ4MISO2—VDDXPERJ/PPSJUp
4PA0———V
DDXPUCR/PUPAEDisabled
5PA1———V
DDXPUCR/PUPAEDisabled
6PA2———V
DDXPUCR/PUPAEDisabled
7PA3———V
DDXPUCR/PUPAEDisabled
8RESET———VDDXPULLUP
9VDDX1——————
10VDDR——————
11VSSX1——————
12PE01EXTAL——VDDXPUCR/PDPEEDown
13VSS——————
14PE11XTAL——VDDXPUCR/PDPEEDown
15TEST———N.A.RESET pinDown
16PA4———V
DDXPUCR/PUPAEDisabled
17PA5———V
DDXPUCR/PUPAEDisabled
18PA6———V
DDXPUCR/PUPAEDisabled
19PA7———V
DDXPUCR/PUPAEDisabled
20PJ0KWJ0MISO1—VDDXPERJ/PPSJUp
21PJ1KWJ1MOSI1—VDDXPERJ/PPSJUp
22PJ2KWJ2SCK1—VDDXPERJ/PPSJUp
23PJ3KWJ3SS1—VDDXPERJ/PPSJUp
24BKGDMODC——VDDXPUCR/BKPUEUp
25PB0ECLK——VDDXPUCR/PUPBEDisabled
26PB1API_EXTCLK——V
DDXPUCR/PUPBEDisabled
27PB2ECLKX2——VDDXPUCR/PUPBEDisabled
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
96Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28PB3———VDDXPUCR/PUPBEDisabled
29PP0KWP0ETRIG0PWM0VDDXPERP/PPSPDisabled
30PP1KWP1ETRIG1PWM1VDDXPERP/PPSPDisabled
31PP2KWP2ETRIG2PWM2VDDXPERP/PPSPDisabled
32PP3KWP3ETRIG3PWM3VDDXPERP/PPSPDisabled
33PP4KWP4PWM4—VDDXPERP/PPSPDisabled
34PP5KWP5PWM5—VDDXPERP/PPSPDisabled
35PP6KWP6PWM6—VDDXPERP/PPSPDisabled
36PP7KWP7PWM7—VDDXPERP/PPSPDisabled
37VDDX3——————
38VSSX3——————
39PT7IOC7——VDDXPERT/PPSTDisabled
40PT6IOC6——VDDXPERT/PPSTDisabled
41PT5IOC5——VDDXPERT/PPSTDisabled
42PT4IOC4——VDDXPERT/PPSTDisabled
43PT3IOC3——VDDXPERT/PPSTDisabled
44PT2IOC2——VDDXPERT/PPSTDisabled
45PT1IOC1——VDDXPERT/PPSTDisabled
46PT0IOC0——VDDXPERT/PPSTDisabled
47PB4IRQ——VDDXPUCR/PUPBEDisabled
48PB5XIRQ——VDDXPUCR/PUPBEDisabled
49PB6———VDDXPUCR/PUPBEDisabled
50PB7———VDDXPUCR/PUPBEDisabled
51PC0———VDDAPUCR/PUPCEDisabled
52PC1———VDDAPUCR/PUPCEDisabled
53PC2———VDDAPUCR/PUPCEDisabled
54PC3———VDDAPUCR/PUPCEDisabled
55PAD0KWAD0AN0—VDDAPER1AD/PPS1ADDisabled
56PAD8KWAD8AN8—VDDAPER0AD/PPS0ADDisabled
Table1-22. 100-Pin LQFP Pinout for S12G192 and S12G240
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func.CTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor97
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
57PAD1KWAD1AN1—VDDAPER1AD/PPS1ADDisabled
58PAD9KWAD9AN9—VDDAPER0AD/PPS0ADDisabled
59PAD2KWAD2AN2—VDDAPER1AD/PPS1ADDisabled
60PAD10KWAD10AN10—VDDAPER0AD/PPS0ADDisabled
61PAD3KWAD3AN3—VDDAPER1AD/PPS1ADDisabled
62PAD11KWAD11AN11—VDDAPER0AD/PPS0ADDisabled
63PAD4KWAD4AN4—VDDAPER1AD/PPS1ADDisabled
64PAD12KWAD12AN12—VDDAPER0AD/PPS0ADDisabled
65PAD5KWAD5AN5—VDDAPER1AD/PPS1ADDisabled
66PAD13KWAD13AN13—VDDAPER0AD/PPS0ADDisabled
67PAD6KWAD6AN6—VDDAPER1AD/PPS1ADDisabled
68PAD14KWAD14AN14—VDDAPER0AD/PPS0ADDisabled
69PAD7KWAD7AN7—VDDAPER1AD/PPS1ADDisabled
70PAD15KWAD15AN15—VDDAPER0AD/PPS0ADDisabled
71PC4———VDDAPUCR/PUPCEDisabled
72PC5———VDDAPUCR/PUPCEDisabled
73PC6———VDDAPUCR/PUPCEDisabled
74PC7———VDDAPUCR/PUPCEDisabled
75VRH——————
76VDDA——————
77VSSA——————
78PD0———VDDXPUCR/PUPDEDisabled
79PD1———VDDXPUCR/PUPDEDisabled
80PD2———VDDXPUCR/PUPDEDisabled
81PD3———VDDXPUCR/PUPDEDisabled
82PS0RXD0——VDDXPERS/PPSSUp
83PS1TXD0——VDDXPERS/PPSSUp
84PS2RXD1——VDDXPERS/PPSSUp
85PS3TXD1——VDDXPERS/PPSSUp
Table1-22. 100-Pin LQFP Pinout for S12G192 and S12G240
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func.CTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
98Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
86PS4MISO0——VDDXPERS/PPSSUp
87PS5MOSI0——VDDXPERS/PPSSUp
88PS6SCK0——VDDXPERS/PPSSUp
89PS7API_EXTCLKSS0—VDDXPERS/PPSSUp
90VSSX2——————
91VDDX2——————
92PM0RXCAN——VDDXPERM/PPSMDisabled
93PM1TXCAN——VDDXPERM/PPSMDisabled
94PD4———VDDXPUCR/PUPDEDisabled
95PD5———VDDXPUCR/PUPDEDisabled
96PD6———VDDXPUCR/PUPDEDisabled
97PD7———VDDXPUCR/PUPDEDisabled
98PM2RXD2——VDDXPERM/PPSMDisabled
99PM3TXD2——VDDXPERM/PPSMDisabled
100PJ7KWJ7SS2—VDDXPERJ/PPSJUp
1The regular I/O characteristics (seeSectionA.2, “I/O Characteristics”) apply if the EXTAL/XTAL function is disabled
Table1-22. 100-Pin LQFP Pinout for S12G192 and S12G240
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func.CTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor99
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.8.6S12GA192 and S12GA240
1.8.6.1Pinout 48-Pin LQFP
Figure1-18. 48-Pin LQFP Pinout for S12GA192 and S12GA240
Table1-23. 48-Pin LQFP Pinout for S12GA192 and S12GA240
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
1RESET————VDDXPULLUP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
36
35
34
33
32
31
30
29
28
27
26
25
48
47
46
45
44
43
42
41
40
39
38
37
S12GA192
S12GA240
48-PinLQFP
PAD7/KWAD7/AN7
PAD6/KWAD6/AN6
PAD5/KWAD5/AN5
PAD4/KWAD4/AN4
PAD11/KWAD11/AN11/DACU0/AMP0
PAD3/KWAD3/AN3
PAD10/KWAD10/AN10/DACU1/AMP1
PAD2/KWAD2/AN2
PAD9/KWAD9/AN9
PAD1/KWAD1/AN1
PAD8/KWAD8/AN8
PAD0/KWAD0/AN0
PWM0/API_EXTCLK/ETRIG0/KWP0/PP0
PWM1/ECLKX2/ETRIG1/KWP1/PP1
PWM2/ETRIG2/KWP2/PP2
PWM3/ETRIG3/KWP3/PP3
PWM4/KWP4/PP4
PWM5/KWP5/PP5
IOC5/PT5
IOC4/PT4
IOC3/PT3
IOC2/PT2
IRQ/IOC1/PT1
XIRQ/IOC0/PT0
RESET
VDDXR
VSSX
EXTAL/PE0
VSS
XTAL/PE1
TEST
MISO1/PWM6/KWJ0/PJ0
MOSI1/IOC6/KWJ1/PJ1
SCK1/IOC7/KWJ2/PJ2
SS1/PWM7/KWJ3/PJ3
BKGD
PM1/TXD2/TXCAN
PM0/RXD2/RXCAN
PS7/API_EXTCLK/ECLK/SS0
PS6/SCK0
PS5/MOSI0
PS4/MISO0
PS3/TXD1
PS2/RXD1
PS1/TXD0
PS0/RXD0
VSSA
VDDA/VRH
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
100Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table1-23. 48-Pin LQFP Pinout for S12GA192 and S12GA240
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor101
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1The regular I/O characteristics (seeSectionA.2, “I/O Characteristics”) apply if the EXTAL/XTAL function is disabled
Table1-23. 48-Pin LQFP Pinout for S12GA192 and S12GA240
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
102Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.8.6.2Pinout 64-Pin LQFP
Figure1-19. 64-Pin LQFP Pinout for S12GA192 and S12GA240
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
S12GA192
S12GA240
64-Pin LQFP
PWM0/API_EXTCLK/ETRIG0/KWP0/PP0
PWM1/ECLKX2/ETRIG1/KWP1/PP1
PWM2/ETRIG2/KWP2/PP2
PWM3/ETRIG3/KWP3/PP3
PWM4/KWP4/PP4
PWM5/KWP5/PP5
PWM6/KWP6/PP6
PWM7/KWP7/PP7
IOC7/PT7
IOC6/PT6
IOC5/PT5
IOC4/PT4
IOC3/PT3
IOC2/PT2
IRQ/IOC1/PT1
XIRQ/IOC0/PT0
SCK2/KWJ6/PJ6
MOSI2/KWJ5/PJ5
MISO2/KWJ4/PJ4
RESET
VDDX
VDDR
VSSX
EXTAL/PE0
VSS
XTAL/PE1
TEST
MISO1/KWJ0/PJ0
MOSI1/KWJ1/PJ1
SCK1/KWJ2/PJ2
SS1/KWJ3/PJ3
BKGD
PJ7/KWJ7/SS2
PM3/TXD2
PM2/RXD2
PM1/TXCAN
PM0/RXCAN
PS7/API_EXTCLK/ECLK/SS0
PS6/SCK0
PS5/MOSI0
PS4/MISO0
PS3/TXD1
PS2/RXD1
PS1/TXD0
PS0/RXD0
VSSA
VDDA
VRH
PAD15/KWAD15/AN15/DACU0
PAD7/KWAD7/AN7
PAD14/KWAD14/AN14/AMPP0
PAD6/KWAD6/AN6
PAD13/KWAD13/AN13/AMPM0
PAD5/KWAD5/AN5
PAD12/KWAD12/AN12
PAD4/KWAD4/AN4
PAD11/KWAD11/AN11/AMP0
PAD3/KWAD3/AN3
PAD10/KWAD10/AN10/DACU1/AMP1
PAD2/KWAD2/AN2
PAD9/KWAD9/AN9
PAD1/KWAD1/AN1
PAD8/KWAD8/AN8
PAD0/KWAD0/AN0
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor103
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table1-24. 64-Pin LQFP Pinout for S12GA192 and S12GA240
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table1-24. 64-Pin LQFP Pinout for S12GA192 and S12GA240
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor105
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
57PS5MOSI0———VDDXPERS/PPSSUp
58PS6SCK0———VDDXPERS/PPSSUp
59PS7API_EXTCLKECLKSS0—VDDXPERS/PPSSUp
60PM0RXCAN———VDDXPERM/PPSMDisabled
61PM1TXCAN———VDDXPERM/PPSMDisabled
62PM2RXD2———VDDXPERM/PPSMDisabled
63PM3TXD2———VDDXPERM/PPSMDisabled
64PJ7KWJ7SS2——VDDXPERJ/PPSJUp
1The regular I/O characteristics (seeSectionA.2, “I/O Characteristics”) apply if the EXTAL/XTAL function is disabled
Table1-24. 64-Pin LQFP Pinout for S12GA192 and S12GA240
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func
5th
FuncCTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
106Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.8.6.3Pinout 100-Pin LQFP
Figure1-20. 100-Pin LQFP Pinout for S12GA192 and S12GA240
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
VRH
PC7/DACU1
PC6/AMPP1
PC5/AMPM1
PC4
PAD15/KWAD15/AN15/DACU0
PAD7/KWAD7/AN7
PAD14/KWAD14/AN14/AMPP0
PAD6/KWAD6/AN6
PAD13/KWAD13/AN13/AMPM0
PAD5/KWAD5/AN5
PAD12/KWAD12/AN12
PAD4/KWAD4/AN4
PAD11/KWAD11/AN11/AMP0
PAD3/KWAD3/AN3
PAD10/KWAD10/AN10/AMP1
PAD2/KWAD2/AN2
PAD9/KWAD9/AN9
PAD1/KWAD1/AN1
PAD8/KWAD8/AN8
PAD0/KWAD0/AN0
PC3
PC2
PC1
PC0
API_EXTCLK/PB1
ECLKX2/PB2
PB3
PWM0/ETRIG0/KWP0/PP0
PWM1/ETRIG1/KWP1/PP1
PWM2/ETRIG2/KWP2/PP2
PWM3/ETRIG3/KWP3/PP3
PWM4/KWP4/PP4
PWM5/KWP5/PP5
PWM6/KWP6/PP6
PWM7/KWP7/PP7
VDDX3
VSSX3
IOC7/PT7
IOC6/PT6
IOC5/PT5
IOC4/PT4
IOC3/PT3
IOC2/PT2
IOC1/PT1
IOC0/PT0
IRQ/PB4
XIRQ/PB5
PB6
PB7
75
74
73
72
71
70
69
68
67
66
65
64
63
62
61
60
59
58
57
56
55
54
53
52
51
100
99
98
97
96
95
94
93
92
91
90
89
88
87
86
85
84
83
82
81
80
79
78
77
76
SCK2/KWJ6/PJ6
MOSI2/KWJ5/PJ5
MISO2/KWJ4/PJ4
PA0
PA1
PA2
PA3
RESET
VDDX1
VDDR
VSSX1
EXTAL/PE0
VSS
XTAL/PE1
TEST
PA4
PA5
PA6
PA7
MISO1/KWJ0/PJ0
MOSI1/KWJ1/PJ1
SCK1/KWJ2/PJ2
SS1/KWJ3/PJ3
BKGD
ECLK/PB0
PJ7/KWJ7/SS2
PM3/TXD2
PM2/RXD2
PD7
PD6
PD5
PD4
PM1/TXCAN
PM0/RXCAN
VDDX2
VSSX2
PS7/API_EXTCLK/SS0
PS6/SCK0
PS5/MOSI0
PS4/MISO0
PS3/TXD1
PS2/RXD1
PS1/TXD0
PS0/RXD0
PD3
PD2
PD1
PD0
VSSA
VDDA
S12GA192
S12GA240
100-Pin LQFP
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor107
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table1-25. 100-Pin LQFP Pinout for S12GA192 and S12GA240
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func.CTRLReset
State
1PJ6KWJ6SCK2—VDDXPERJ/PPSJUp
2PJ5KWJ5MOSI2—VDDXPERJ/PPSJUp
3PJ4KWJ4MISO2—VDDXPERJ/PPSJUp
4PA0———V
DDXPUCR/PUPAEDisabled
5PA1———V
DDXPUCR/PUPAEDisabled
6PA2———V
DDXPUCR/PUPAEDisabled
7PA3———V
DDXPUCR/PUPAEDisabled
8RESET———VDDXPULLUP
9VDDX1——————
10VDDR——————
11VSSX1——————
12PE01EXTAL——VDDXPUCR/PDPEEDown
13VSS——————
14PE11XTAL——VDDXPUCR/PDPEEDown
15TEST———N.A.RESET pinDown
16PA4———V
DDXPUCR/PUPAEDisabled
17PA5———V
DDXPUCR/PUPAEDisabled
18PA6———V
DDXPUCR/PUPAEDisabled
19PA7———V
DDXPUCR/PUPAEDisabled
20PJ0KWJ0MISO1—VDDXPERJ/PPSJUp
21PJ1KWJ1MOSI1—VDDXPERJ/PPSJUp
22PJ2KWJ2SCK1—VDDXPERJ/PPSJUp
23PJ3KWJ3SS1—VDDXPERJ/PPSJUp
24BKGDMODC——VDDXPUCR/BKPUEUp
25PB0ECLK——VDDXPUCR/PUPBEDisabled
26PB1API_EXTCLK——V
DDXPUCR/PUPBEDisabled
27PB2ECLKX2——VDDXPUCR/PUPBEDisabled
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
108Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28PB3———VDDXPUCR/PUPBEDisabled
29PP0KWP0ETRIG0PWM0VDDXPERP/PPSPDisabled
30PP1KWP1ETRIG1PWM1VDDXPERP/PPSPDisabled
31PP2KWP2ETRIG2PWM2VDDXPERP/PPSPDisabled
32PP3KWP3ETRIG3PWM3VDDXPERP/PPSPDisabled
33PP4KWP4PWM4—VDDXPERP/PPSPDisabled
34PP5KWP5PWM5—VDDXPERP/PPSPDisabled
35PP6KWP6PWM6—VDDXPERP/PPSPDisabled
36PP7KWP7PWM7—VDDXPERP/PPSPDisabled
37VDDX3——————
38VSSX3——————
39PT7IOC7——VDDXPERT/PPSTDisabled
40PT6IOC6——VDDXPERT/PPSTDisabled
41PT5IOC5——VDDXPERT/PPSTDisabled
42PT4IOC4——VDDXPERT/PPSTDisabled
43PT3IOC3——VDDXPERT/PPSTDisabled
44PT2IOC2——VDDXPERT/PPSTDisabled
45PT1IOC1——VDDXPERT/PPSTDisabled
46PT0IOC0——VDDXPERT/PPSTDisabled
47PB4IRQ——VDDXPUCR/PUPBEDisabled
48PB5XIRQ——VDDXPUCR/PUPBEDisabled
49PB6———VDDXPUCR/PUPBEDisabled
50PB7———VDDXPUCR/PUPBEDisabled
51PC0———VDDAPUCR/PUPCEDisabled
52PC1———VDDAPUCR/PUPCEDisabled
53PC2———VDDAPUCR/PUPCEDisabled
54PC3———VDDAPUCR/PUPCEDisabled
55PAD0KWAD0AN0—VDDAPER1AD/PPS1ADDisabled
56PAD8KWAD8AN8—VDDAPER0AD/PPS0ADDisabled
Table1-25. 100-Pin LQFP Pinout for S12GA192 and S12GA240
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func.CTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor109
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
57PAD1KWAD1AN1—VDDAPER1AD/PPS1ADDisabled
58PAD9KWAD9AN9—VDDAPER0AD/PPS0ADDisabled
59PAD2KWAD2AN2—VDDAPER1AD/PPS1ADDisabled
60PAD10KWAD10AN10AMP1VDDAPER0AD/PPS0ADDisabled
61PAD3KWAD3AN3—VDDAPER1AD/PPS1ADDisabled
62PAD11KWAD11AN11AMP0VDDAPER0AD/PPS0ADDisabled
63PAD4KWAD4AN4—VDDAPER1AD/PPS1ADDisabled
64PAD12KWAD12AN12—VDDAPER0AD/PPS0ADDisabled
65PAD5KWAD5AN5—VDDAPER1AD/PPS1ADDisabled
66PAD13KWAD13AN13AMPM0VDDAPER0AD/PPS0ADDisabled
67PAD6KWAD6AN6—VDDAPER1AD/PPS1ADDisabled
68PAD14KWAD14AN14AMPP0VDDAPER0AD/PPS0ADDisabled
69PAD7KWAD7AN7—VDDAPER1AD/PPS1ADDisabled
70PAD15KWAD15AN15DACU0VDDAPER0AD/PPS0ADDisabled
71PC4———VDDAPUCR/PUPCEDisabled
72PC5AMPM1——VDDAPUCR/PUPCEDisabled
73PC6AMPP1——VDDAPUCR/PUPCEDisabled
74PC7DACU1——VDDAPUCR/PUPCEDisabled
75VRH——————
76VDDA——————
77VSSA——————
78PD0———VDDXPUCR/PUPDEDisabled
79PD1———VDDXPUCR/PUPDEDisabled
80PD2———VDDXPUCR/PUPDEDisabled
81PD3———VDDXPUCR/PUPDEDisabled
82PS0RXD0——VDDXPERS/PPSSUp
83PS1TXD0——VDDXPERS/PPSSUp
84PS2RXD1——VDDXPERS/PPSSUp
85PS3TXD1——VDDXPERS/PPSSUp
Table1-25. 100-Pin LQFP Pinout for S12GA192 and S12GA240
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func.CTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
110Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The different modes and the security state of the MCU affect the debug features (enabled or disabled).
86PS4MISO0——VDDXPERS/PPSSUp
87PS5MOSI0——VDDXPERS/PPSSUp
88PS6SCK0——VDDXPERS/PPSSUp
89PS7API_EXTCLKSS0—VDDXPERS/PPSSUp
90VSSX2——————
91VDDX2——————
92PM0RXCAN——VDDXPERM/PPSMDisabled
93PM1TXCAN——VDDXPERM/PPSMDisabled
94PD4———VDDXPUCR/PUPDEDisabled
95PD5———VDDXPUCR/PUPDEDisabled
96PD6———VDDXPUCR/PUPDEDisabled
97PD7———VDDXPUCR/PUPDEDisabled
98PM2RXD2——VDDXPERM/PPSMDisabled
99PM3TXD2——VDDXPERM/PPSMDisabled
100PJ7KWJ7SS2—VDDXPERJ/PPSJUp
1The regular I/O characteristics (seeSectionA.2, “I/O Characteristics”) apply if the EXTAL/XTAL function is disabled
Table1-25. 100-Pin LQFP Pinout for S12GA192 and S12GA240
Function
<----lowest-----PRIORITY-----highest---->Power
Supply
Internal Pull
Resistor
Package PinPin2nd
Func.
3rd
Func.
4th
Func.CTRLReset
State
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor111
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The operating mode out of reset is determined by the state of the MODC signal during reset (see
“S12 Clock, Reset and Power Management Unit (S12CPMU)”.
Table1-26. Chip Modes
Chip ModesMODC
Normal single chip1
Special single chip0
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
112Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Vector base+ $DCTIM Pulse accumulator A overflow2I bitPACTL (PAOVI)NoYes
Vector base + $DATIM Pulse accumulator input edge3I bitPACTL (PAI)NoYes
Vector base + $D8SPI0I bitSPI0CR1 (SPIE, SPTIE)NoYes
Vector base+ $D6SCI0I bitSCI0CR2
(TIE, TCIE, RIE, ILIE)
YesYes
Vector base + $D4SCI1I bitSCI1CR2
(TIE, TCIE, RIE, ILIE)
YesYes
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor113
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Vector base + $D2ADCI bitATDCTL2 (ASCIE)NoYes
Vector base + $D0Reserved
Vector base + $CEPort JI bitPIEJ (PIEJ7-PIEJ0)YesYes
Vector base + $CCACMPI bitACMPC (ACIE)NoYes
Vector base + $CAReserved
Vector base + $C8Oscillator status interruptI bitCPMUINT (OSCIE)NoYes
Vector base + $C6 PLL lock interruptI bitCPMUINT (LOCKIE)NoYes
Vector base + $C4Reserved
Vector base + $C2SCI2I bitSCI2CR2
(TIE, TCIE, RIE, ILIE)
YesYes
Vector base + $C0Reserved
Vector base + $BESPI1I bitSPI1CR1 (SPIE, SPTIE)NoYes
Vector base + $BCSPI2I bitSPI2CR1 (SPIE, SPTIE)NoYes
Vector base + $BAFLASH errorI bit FERCNFG (SFDIE, DFDIE)NoNo
Vector base + $B8FLASH commandI bitFCNFG (CCIE)NoYes
Vector base + $B6CAN wake-upI bitCANRIER (WUPIE)YesYes
Vector base + $B4CAN errorsI bitCANRIER (CSCIE, OVRIE)NoYes
Vector base + $B2CAN receiveI bitCANRIER (RXFIE)NoYes
Vector base + $B0CAN transmitI bitCANTIER (TXEIE[2:0])NoYes
Vector base + $AE
to
Vector base + $90
Reserved
Vector base + $8EPort P interruptI bitPIEP (PIEP7-PIEP0)YesYes
Vector base+ $8CReserved
Vector base + $8ALow-voltage interrupt (LVI)I bitCPMUCTRL (LVIE)NoYes
Vector base + $88Autonomous periodical interrupt
(API)I bitCPMUAPICTRL (APIE)YesYes
Vector base + $86Reserved
Vector base + $84ADC compare interruptI bitATDCTL2 (ACMPIE)NoYes
Vector base + $82Port AD interruptI bitPIE1AD(PIE1AD7-PIE1AD0)
PIE0AD(PIE0AD7-PIE0AD0)
YesYes
Vector base + $80Spurious interrupt—None--
116 bits vector address based
2Only available if the 8 channel timer module is instantiated on the device
3Only available if the 8 channel timer module is instantiated on the device
Table1-28. Interrupt Vector Locations (Sheet 2 of 2)
Vector Address1Interrupt SourceCCR
MaskLocal EnableWake up
fromSTOP
Wakeup
fromWAIT
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
114Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
loaded from the Flash register FOPT. SeeTable1-29 andTable1-30 for coding. The FOPT register is
loaded from the Flash configuration field byte at global address 0x3_FF0E during the reset sequence.
Table1-29. Initial COP Rate Configuration
NV[2:0] in
FOPT Register
CR[2:0] in
CPMUCOP Register
000111
001110
010101
011100
100011
101010
110001
111000
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor115
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table1-31. Usage of ADC Special Conversion Channels
ADC ChannelUsage
Internal_0VDDF1
1SeeSection1.17, “ADC Result Reference”.
Internal_1unused
Internal_2unused
Internal_3unused
Internal_4unused
Internal_5unused
Internal_6
unused
Temperature sense of ADC
hardmacro2
2The ADC temperature sensor is only available on S12GA192 and
S12GA240 devices.
Internal_7unused
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
116Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The S12GA192 and the S12GA240 contain a Reverence Voltage Attenuator (RVA) module. The
connection of the ADC’s VRH/VRL inputs on these devices is shown inFigure1-21.
Figure1-21. ADC VRH/VRL Signal Connection
ADC
VRH
VRL
VRH
VSSA
S12GN16, S12GN32, S12GN48, S12G48,
S12G64, S12G96, S12G128, S12G192, S12G240
ADCRVA
VRH
VRL
VRH_INT
VRL_INT
VSSA
VRHVRH
VSSA
S12GA192, S12G240
Device Overview MC9S12G-Family
MC9S12G Family Reference Manual,Rev.1.06
118Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor119
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
PortGroup of general-purpose I/O pins sharing peripheral signals
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
120Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.1.4Block Diagram
Figure2-1. Block Diagram
2.2PIM Routing - External Signal Description
This section lists and describes the signals that do connect off-chip.
Table2-3 shows the availability of I/O port pins for each group in the largest offered package option.
Table2-3. Port Pin Availability (in largest package) per Device
Port
Device Group
G1
(100 pin)
G2
(64 pin)
G3
(48 pin)
A7-0--
B7-0--
C7-0--
D7-0--
E1-01-01-0
T7-07-05-0
S7-07-07-0
M3-03-01-0
P7-07-05-0
J7-07-03-0
AD15-015-011-0
Peripheral
Module
PIM
Ports
PIM
Routing
0
1
n
Pin #0
Package Code
Pin Routing (20 TSSOP only)
Pin #n
Pin Enable, Data
Pin Enable, Data
Data
Data
Control
Control
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
122Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.2.1Package Code
The availability of pins and the related peripheral signals are determined by a package code
(Section2.4.3.33, “Package Code Register (PKGCR)”). The related value is loaded from a factory
programmed non-volatile memory location into the register during the reset sequence.
by the position in the table from top (highest priority) to bottom (lowest
priority).
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor123
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table2-4. Signals and Priorities
PortPinSignal
Signals per Device and Package
(signal priority on pin from top to bottom)
Legend
■Signal available on pin
❍Routing option on pin
❏Routing reset location
Not available on pin
GA240 / GA192
G240 / G192
G128 / G96
GA240 / GA192
G240 / G192
G128 / G96
G64 / G48
GN48
GA240 / GA192
G240 / G192
G128 / G96
G64 / G48
GN48
GN32
GN16
G64 / G48
GN48
GN32
GN16
GN32
GN16
I/ODescription
10064483220
-BKGDMODC■■■■■■■■■■■■■■■■■■■■■IMODC input during
RESET
BKGD■■■■■■■■■■■■■■■■■■■■■I/OBDM communication
APA7-PA0[PA7:PA0]■■■I/OGPIO
BPB7-PB6[PB7:PB6]■■■I/OGPIO
PB5XIRQ■■■INon-maskable
level-sensitive interrupt
[PB5]■■■I/OGPIO
PB4IRQ■■■IMaskable level- or
falling-edge sensitive
interrupt
[PB4]■■■I/OGPIO
PB3[PB3]■■■I/OGPIO
PB2ECLKX2■■■OFree-running clock
(ECLK x 2)
[PB2]■■■I/OGPIO
PB1API_EXTCLK❏❏❏OAPI Clock
[PB1]■■■I/OGPIO
PB0ECLK■■■OFree-running clock
[PB0]■■■I/OGPIO
CPC7DACU1■ODAC1outputunbuffered
[PC7]■■■I/OGPIO
PC6AMPP1■IDAC1 non-inv. input (+)
[PC6]■■■I/OGPIO
PC5AMPM1■IDAC1 inverting input (-)
[PC5]■■■I/OGPIO
PC4-PC2AN15-AN13❍❍IADC analog
[PC4:PC2]■■■I/OGPIO
PC1-PC0AN11-AN10❍❍IADC analog
[PC1:PC0]■■■I/OGPIO
DPD7-PD0[PD7:PD0]■■■I/OGPIO
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
124Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
SPS7SS0■■■■■■■■■■■■■■■■■■■■■I/OSPI slave select
TXD0❍❍I/OSCI transmit
PWM5■■■■OPWM channel
PWM3❏❏OPWM channel
ECLK■■■■■■■■■■■■■■■■■■OFree-running clock
API_EXTCLK❍❍❍❍❍❍❍❍❍❍❍❍❍❍❍❍❍❍❍❍❍OAPI Clock
ETRIG3❏❏IADC external trigger
[PTS7]■■■■■■■■■■■■■■■■■■■■■I/OGPIO
PS6SCK0■■■■■■■■■■■■■■■■■■■■■I/OSPI serial clock
IOC5■■■■I/OTimer channel
IOC3❏❏I/OTimer channel
[PTS6]■■■■■■■■■■■■■■■■■■■■■I/OGPIO
PS5MOSI0■■■■■■■■■■■■■■■■■■■■■I/OSPI master out/slave in
IOC4■■■■I/OTimer channel
IOC2❏❏I/OTimer channel
[PTS5]■■■■■■■■■■■■■■■■■■■■■I/OGPIO
PS4MISO0■■■■■■■■■■■■■■■■■■■■■I/OSPI master in/slave out
RXD0❍❍ISCI receive pin
PWM4■■■■OPWM channel
PWM2❏❏OPWM channel
ETRIG2❏❏IADC external trigger
[PTS4]■■■■■■■■■■■■■■■■■■■■■I/OGPIO
PS3TXD1■■■■■■■■■■■■■I/OSCI transmit
[PTS3]■■■■■■■■■■■■■■■I/OGPIO
PS2RXD1■■■■■■■■■■■■■ISCI receive
[PTS2]■■■■■■■■■■■■■■■I/OGPIO
PS1TXD0■■■■■■■■■■■■■■■■■■■I/OSCI transmit
[PTS1]■■■■■■■■■■■■■■■■■■■I/OGPIO
PS0RXD0■■■■■■■■■■■■■■■■■■■ISCI receive
[PTS0]■■■■■■■■■■■■■■■■■■■I/OGPIO
Table2-4. Signals and Priorities
PortPinSignal
Signals per Device and Package
(signal priority on pin from top to bottom)
Legend
■Signal available on pin
❍Routing option on pin
❏Routing reset location
Not available on pin
GA240 / GA192
G240 / G192
G128 / G96
GA240 / GA192
G240 / G192
G128 / G96
G64 / G48
GN48
GA240 / GA192
G240 / G192
G128 / G96
G64 / G48
GN48
GN32
GN16
G64 / G48
GN48
GN32
GN16
GN32
GN16
I/ODescription
10064483220
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
126Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MPM3TXD2■■■■■■I/OSCI transmit
[PTM3]■■■■■■■■I/OGPIO
PM2RXD2■■■■■■ISCI receive
[PTM2]■■■■■■■■I/OGPIO
PM1TXCAN■■■■■■■■■■■■OMSCAN transmit
TXD2■■■■■I/OSCI transmit
TXD1■■I/OSCI transmit
[PTM1]■■■■■■■■■■■■■■■■■■■I/OGPIO
PM0RXCAN■■■■■■■■■■■■IMSCAN receive
RXD2■■■■■ISCI receive
RXD1■■ISCI receive
[PTM0]■■■■■■■■■■■■■■■■■■■I/OGPIO
Table2-4. Signals and Priorities
PortPinSignal
Signals per Device and Package
(signal priority on pin from top to bottom)
Legend
■Signal available on pin
❍Routing option on pin
❏Routing reset location
Not available on pin
GA240 / GA192
G240 / G192
G128 / G96
GA240 / GA192
G240 / G192
G128 / G96
G64 / G48
GN48
GA240 / GA192
G240 / G192
G128 / G96
G64 / G48
GN48
GN32
GN16
G64 / G48
GN48
GN32
GN16
GN32
GN16
I/ODescription
10064483220
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor127
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
PPP7-PP6PWM7-PWM6■■■■■■OPWM channel
[PTP7:PTP6]/
KWP7-KWP6
■■■■■■■■I/OGPIO with interrupt
PP5-PP4PWM5-PWM4■■■■■■■■■■■■■■■OPWM channel
[PTP5:PTP4]/
KWP5-KWP4
■■■■■■■■■■■■■■■I/OGPIO with interrupt
PP3-PP2PWM3-PWM2■■■■■■■■■■■■■■■■■■■OPWM channel
ETRIG3-
ETRIG2
■■■■■■■■■■■■■■■■■■■IADC external trigger
[PTP3:PTP2]/
KWP3-KWP2
■■■■■■■■■■■■■■■■■■■I/OGPIO with interrupt
PP1PWM1■■■■■■■■■■■■■■■■■■■OPWM channel
ECLKX2■■■■■■■■■■■■■■■■OFree-running clock
(ECLK x 2)
ETRIG1■■■■■■■■■■■■■■■■■■■IADC external trigger
[PTP1]/
KWP1
■■■■■■■■■■■■■■■■■■■I/OGPIO with interrupt
PP0PWM0■■■■■■■■■■■■■■■■■■■OPWM channel
API_EXTCLK❏❏❏❏❏❏❏❏❏❏❏❏❏❏❏❏OAPI Clock
ETRIG0■■■■■■■■■■■■■■■■■■■IADC external trigger
[PTP0]/
KWP0
■■■■■■■■■■■■■■■■■■■I/OGPIO with interrupt
Table2-4. Signals and Priorities
PortPinSignal
Signals per Device and Package
(signal priority on pin from top to bottom)
Legend
■Signal available on pin
❍Routing option on pin
❏Routing reset location
Not available on pin
GA240 / GA192
G240 / G192
G128 / G96
GA240 / GA192
G240 / G192
G128 / G96
G64 / G48
GN48
GA240 / GA192
G240 / G192
G128 / G96
G64 / G48
GN48
GN32
GN16
G64 / G48
GN48
GN32
GN16
GN32
GN16
I/ODescription
10064483220
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
128Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
JPJ7SS2■■■■■■I/OSPI slave select
[PTJ7]/
KWJ7
■■■■■■■■I/OGPIO with interrupt
PJ6SCK2■■■■■■I/OSPI serial clock
[PTJ6]/
KWJ6
■■■■■■■■I/OGPIO with interrupt
PJ5MOSI2■■■■■■I/OSPI master out/slave in
[PTJ5]/
KWJ5
■■■■■■■■I/OGPIO with interrupt
PJ4MISO2■■■■■■I/OSPI master in/slave out
[PTJ4]/
KWJ4
■■■■■■■■I/OGPIO with interrupt
PJ3SS1■■■■■■■■■■■■■I/OSPI slave select
PWM7■■■OPWM channel
[PTJ3]/
KWJ3
■■■■■■■■■■■■■■■I/OGPIO with interrupt
PJ2SCK1■■■■■■■■■■■■■I/OSPI serial clock
IOC7■■■I/OTimer channel
[PTJ2]/
KWJ2
■■■■■■■■■■■■■■■I/OGPIO with interrupt
PJ1MOSI1■■■■■■■■■■■■■I/OSPI master out/slave in
IOC6■■■I/OTimer channel
[PTJ1]/
KWJ1
■■■■■■■■■■■■■■■I/OGPIO with interrupt
PJ0MISO1■■■■■■■■■■■■■I/OSPI master in/slave out
PWM6■■■I/OTimer channel
[PTJ0]/
KWJ0
■■■■■■■■■■■■■■■I/OGPIO with interrupt
Table2-4. Signals and Priorities
PortPinSignal
Signals per Device and Package
(signal priority on pin from top to bottom)
Legend
■Signal available on pin
❍Routing option on pin
❏Routing reset location
Not available on pin
GA240 / GA192
G240 / G192
G128 / G96
GA240 / GA192
G240 / G192
G128 / G96
G64 / G48
GN48
GA240 / GA192
G240 / G192
G128 / G96
G64 / G48
GN48
GN32
GN16
G64 / G48
GN48
GN32
GN16
GN32
GN16
I/ODescription
10064483220
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor129
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
ADPAD15DACU0■■ODAC0outputunbuffered
AN15❏❏■■IADC analog
[PT0AD7]/
KWAD15
■■■■■■■■I/OGPIO with interrupt
PAD14AMPP0■■IDAC0 non-inv. input (+)
AN14❏❏■■IADC analog
[PT0AD6]/
KWAD14
■■■■■■■■I/OGPIO with interrupt
PAD13AMPM0■■IDAC0 inverting input (-)
AN13❏❏■■IADC analog
[PT0AD5]/
KWAD13
■■■■■■■■I/OGPIO with interrupt
PAD12AN12■■■■IADC analog
[PT0AD4]/
KWAD12
■■■■■■■■I/OGPIO with interrupt
PAD11AMP0■■■ODAC0 output buffered
DACU0■ODAC0outputunbuffered
ACMPM■■■■■■IACMPinvertinginput(-)
AN11❏❏■■■■■■■■■■■IADC analog
[PT0AD3]/
KWAD11
■■■■■■■■■■■■■■■I/OGPIO with interrupt
PAD10AMP1■■■ODAC1 output buffered
DACU1■■ODAC1outputunbuffered
ACMPP■■■■■■IACMPnon-inv.input(+)
AN10❏❏■■■■■■■■■■■IADC analog
[PT0AD2]/
KWAD10
■■■■■■■■■■■■■■■I/OGPIO with interrupt
PAD9ACMPO■■■■■■OACMP unsync. dig. out
AN9■■■■■■■■■■■■■IADC analog
[PT0AD1]/
KWAD9
■■■■■■■■■■■■■■■I/OGPIO with interrupt
PAD8AN8■■■■■■■■■■■■■IADC analog
[PT0AD0]/
KWAD8
■■■■■■■■■■■■■■■I/OGPIO with interrupt
Table2-4. Signals and Priorities
PortPinSignal
Signals per Device and Package
(signal priority on pin from top to bottom)
Legend
■Signal available on pin
❍Routing option on pin
❏Routing reset location
Not available on pin
GA240 / GA192
G240 / G192
G128 / G96
GA240 / GA192
G240 / G192
G128 / G96
G64 / G48
GN48
GA240 / GA192
G240 / G192
G128 / G96
G64 / G48
GN48
GN32
GN16
G64 / G48
GN48
GN32
GN16
GN32
GN16
I/ODescription
10064483220
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
130Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
ADPAD7ACMPM■■■■IACMPinvertinginput(-)
AN7■■■■■■■■■■■■■■■■■■■IADC analog
[PT1AD7]/
KWAD7
■■■■■■■■■■■■■■■■■■■I/OGPIO with interrupt
PAD6ACMPP■■■■IACMPnon-inv.input(+)
AN6■■■■■■■■■■■■■■■■■■■IADC analog
[PT1AD6]/
KWAD6
■■■■■■■■■■■■■■■■■■■I/OGPIO with interrupt
PAD5ACMPO■■■■OACMP unsync. dig. out
ACMPM■■IACMPinvertinginput(-)
AN5■■■■■■■■■■■■■■■■■■■■■IADC analog
TXD0❍❍I/OSCI transmit
IOC3❍❍I/OTimer channel
PWM3❍❍OPWM channel
ETRIG3❍❍IADC external trigger
[PT1AD5]/
KWAD5
■■■■■■■■■■■■■■■■■■■■■I/OGPIO with interrupt
PAD4ACMPP■■IACMPnon-inv.input(+)
AN4■■■■■■■■■■■■■■■■■■■■■IADC analog
RXD0❍❍ISCI receive
IOC2❍❍I/OTimer channel
PWM2❍❍OPWM channel
ETRIG2❍❍IADC external trigger
[PT1AD4]/
KWAD4
■■■■■■■■■■■■■■■■■■■■■I/OGPIO with interrupt
PAD3ACMPO■■OACMP unsync. dig. out
AN3■■■■■■■■■■■■■■■■■■■■■IADC analog
[PT1AD3]/
KWAD3
■■■■■■■■■■■■■■■■■■■■■I/OGPIO with interrupt
PAD2-PAD0AN2-AN0■■■■■■■■■■■■■■■■■■■■■IADC analog
[PT1AD2:
PT1AD0]/
KWAD2-
KWAD0
■■■■■■■■■■■■■■■■■■■■■I/OGPIO with interrupt
Table2-4. Signals and Priorities
PortPinSignal
Signals per Device and Package
(signal priority on pin from top to bottom)
Legend
■Signal available on pin
❍Routing option on pin
❏Routing reset location
Not available on pin
GA240 / GA192
G240 / G192
G128 / G96
GA240 / GA192
G240 / G192
G128 / G96
G64 / G48
GN48
GA240 / GA192
G240 / G192
G128 / G96
G64 / G48
GN48
GN32
GN16
G64 / G48
GN48
GN32
GN16
GN32
GN16
I/ODescription
10064483220
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor131
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.3PIM Routing - Functional description
This section describes the signals available on each pin.
Although trying to enable multiple signals on a shared pin is not a proper use case in most applications,
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
PB0 •100 LQFP: The ECLK signal is mapped to this pin when used with the external clock function. The
enabled ECLK signal forces the I/O state to an output.
•Signal priority:
100 LQFP: ECLK > GPO
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor133
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•When routing of ADC channels to PC4-PC0 is selected
(PRR1[PRR1AN]=1) the related bit in the ADC Digital Input Enable
Register (ATDDIEN) must be set to 1 to activate the digital input
function on those pins not used as ADC inputs.
Table2-8. Port C Pins PC7-0
PC7 •100 LQFP: The unbuffered analog output signal DACU1 of the DAC1 module is mapped to this pin if
the DAC is operating in “unbuffered DAC” mode. If this pin is used with the DAC then the digital I/O
the output state. The input buffers are controlled by the related ATDDIEN bits and the ADC trigger
functions.
•Signal priority:
100 LQFP: GPO
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
134Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
PT4 •48/64/100 LQFP: The TIM channel 4 signal is mapped to this pin when used with the timer function.
The TIM forces the I/O state to be an output for a timer port associated with an enabled output
compare.
•Signal priority:
48/64/100 LQFP: IOC4 > GPO
PT3-PT2 •Except 20 TSSOP: The TIM channels 3 and 2 signal are mapped to these pins when used with the
I/O state to be an output for a timer port associated with an enabled output compare.
•Signal priority:
100 LQFP: IOC0 > GPO
Others:XIRQ > IOC0 > GPO
Table2-11. Port T Pins PT7-0 (continued)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
136Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.3.8Pins PS7-0
Table2-12. Port S Pins PS7-0
PS7 •The SPI0SS signal is mapped to this pin when used with the SPI function. Depending on the
configuration of the enabled SPI0 the I/O state is forced to be input or output.
•20 TSSOP: The SCI0 TXD signal is mapped to this pin when used with the SCI function. If the SCI0
TXD signal is enabled and routed here the I/O state will depend on the SCI0 configuration.
output compare signal is enabled and routed here the I/O state will be forced to output.
•Signal priority:
20 TSSOP: MOSI0 > IOC2 > GPO
32 LQFP: MOSI0 > IOC4 > GPO
Others: MOSI0 > GPO
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor137
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
PS4 •The SPI0 MISO signal is mapped to this pin when used with the SPI function. Depending on the
configuration of the enabled SPI0 the I/O state is forced to be input or output.
•20 TSSOP: The SCI0 RXD signal is mapped to this pin when used with the SCI function. If the SCI0
RXD signal is enabled and routed here the I/O state will be forced to input.
SCI0 RXD signal is enabled the I/O state will be forced to be input.
•Signal priority:
20 TSSOP: GPO
Others: RXD0 > GPO
Table2-12. Port S Pins PS7-0 (continued)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
138Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
function. The enabled PWM channel forces the I/O state to be an output.
•64/100 LQFP: Pin interrupts can be generated if enabled in input or output mode.
•Signal priority:
64/100 LQFP: PWM > GPO
PP5-PP4 •48/64/100 LQFP: The PWM channels 5 and 4 signal are mapped to these pins when used with the
PWM function. The enabled PWM channel forces the I/O state to be an output.
•48/64/100 LQFP: Pin interrupts can be generated if enabled in input or output mode.
•Signal priority:
48/64/100 LQFP: PWM > GPO
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor139
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
function. Depending on the configuration of the enabled SPI1 the I/O state is forced to be input or
output.
•48 LQFP: The TIM channel 7 signal is mapped to this pin when used with the TIM function. The TIM
forces the I/O state to be an output for a timer port associated with an enabled output.
•Except 20 TSSOP and 32 LQFP: Pin interrupts can be generated if enabled in input or output mode.
•Signal priority:
48 LQFP: SCK1 > IOC7 > GPO
64/100 LQFP: SCK1 > GPO
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor141
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
if the DAC is operating in “unbuffered DAC with operational amplifier” or “operational amplifier only”
mode. If this pin is used with the DAC then the digital input buffer is disabled.
•64/100 LQFP: If routing is inactive (PRR1[PRR1AN]=0) the ADC analog input channel signal AN14
and the related digital trigger input are mapped to this pin. The ADC function has no effect on the
output state. The input buffer is controlled by the related ATDDIEN bit and the ADC trigger function.
•64/100 LQFP: Pin interrupts can be generated if enabled in digital input or output mode.
•Signal priority:
64/100 LQFP: GPO
Table2-15. Port J Pins PJ7-0 (continued)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
142Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
PAD13 •64/100 LQFP: The inverting analog input signal AMPM0 of the DAC0 module is mapped to this pin if
the DAC is operating in “unbuffered DAC with operational amplifier” or “operational amplifier only”
mode. If this pin is used with the DAC then the digital input buffer is disabled.
•64/100 LQFP: If routing is inactive (PRR1[PRR1AN]=0) the ADC analog input channel signal AN13
and the related digital trigger input are mapped to this pin. The ADC function has no effect on the
output state. The input buffer is controlled by the related ATDDIEN bit and the ADC trigger function.
•64/100 LQFP: Pin interrupts can be generated if enabled in digital input or output mode.
•Signal priority:
64/100 LQFP: GPO
PAD12 •64/100 LQFP: The ADC analog input channel signal AN12 and the related digital trigger input are
and the related digital trigger input are mapped to this pin. The ADC function has no effect on the
output state. The input buffer is controlled by the related ATDDIEN bit and the ADC trigger function.
•48/64/100 LQFP: Pin interrupts can be generated if enabled in digital input or output mode.
•Signal priority:
48/64 LQFP: AMP1 | DACU1 > GPO
100 LQFP: AMP1 > GPO
Table2-16. Port AD Pins AD15-8
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor143
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
PAD9 •48/64 LQFP: The ACMPO signal of the analog comparator is mapped to this pin when used with the
ACMP function. If the ACMP output is enabled (ACMPC[ACOPE]=1) the I/O state will be forced to
output.
•48/64/100 LQFP: The ADC analog input channel signal AN9 and the related digital trigger input are
by the related ATDDIEN bit and the ADC trigger function.
•Except 20 TSSOP: Pin interrupts can be generated if enabled in digital input or output mode.
•Signal priority:
Except 20 TSSOP: GPO
Table2-16. Port AD Pins AD15-8
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
144Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
PAD5 •32 LQFP: The ACMPO signal of the analog comparator is mapped to this pin when used with the
ACMP function. If the ACMP output is enabled (ACMPC[ACOPE]=1) the I/O state will be forced to
output.
•20 TSSOP: The inverting input signal ACMPM of the analog comparator is mapped to this pin when
used with the ACMP function.The ACMP function has no effect on the output state. The input buffer
•Pin interrupts can be generated if enabled in digital input or output mode.
•Signal priority:
20 TSSOP: RXD0 > IOC2 > PWM2 > GPO
Others: GPO
Table2-17. Port AD Pins AD7-0 (continued)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor145
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4PIM Ports - Memory Map and Register Definition
This section provides a detailed description of all PIM registers.
2.4.1Memory Map
Table2-18 shows the memory maps of all groups (for definitions seeTable2-2). Addresses 0x0000 to
0x0007 are only implemented in group G1 otherwise reserved.
PAD3 •20 TSSOP: The ACMPO signal of the analog comparator is mapped to this pin when used with the
ACMP function. If the ACMP output is enabled (ACMPC[ACOPE]=1) the I/O state will be forced to
•Pin interrupts can be generated if enabled in digital input or output mode.
•Signal priority:
GPO
Table2-18. Block Memory Map (0x0000-0x027F)
PortGlobal
AddressRegisterAccessReset ValueSection/Page
(A)
(B)
0x0000PORTA—Port A Data Register1R/W0x002.4.3.1/2-164
0x0001PORTB—Port B Data Register1R/W0x002.4.3.2/2-165
0x0002DDRA—Port A Data Direction Register1R/W0x002.4.3.3/2-166
0x0003DDRB—Port B Data Direction Register1R/W0x002.4.3.4/2-166
(C)
(D)
0x0004PORTC—Port C Data Register1R/W0x002.4.3.5/2-167
0x0005PORTD—Port D Data Register1R/W0x002.4.3.6/2-168
0x0006DDRC—Port C Data Direction Register1R/W0x002.4.3.7/2-168
0x0007DDRD—Port D Data Direction Register1R/W0x002.4.3.8/2-169
E0x0008PORTE—Port E Data RegisterR/W0x00
0x0009DDRE—Port E Data Direction RegisterR/W0x00
0x000A
:
0x000B
Non-PIM address range2---
Table2-17. Port AD Pins AD7-0 (continued)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
146Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
(A)
(B)
(C)
(D)
E
0x000CPUCR—Pull Control RegisterR/W0x502.4.3.11/2-171
0x000DReservedR0x00
0x000E
:
0x001B
Non-PIM address range2---
0x001CECLKCTL—ECLK Control RegisterR/W0xC02.4.3.12/2-173
0x001DReservedR0x00
0x001EIRQCR—IRQ Control RegisterR/W0x002.4.3.13/2-173
0x001FReservedR0x00
0x0020
:
0x023F
Non-PIM address range2---
T0x0240PTT—Port T Data RegisterR/W0x002.4.3.15/2-175
0x0241PTIT—Port T Input RegisterR32.4.3.16/2-175
0x0242DDRT—Port T Data Direction RegisterR/W0x002.4.3.17/2-176
0x0243ReservedR0x00
0x0244PERT—Port T Pull Device Enable RegisterR/W0x002.4.3.18/2-177
0x0245PPST—Port T Polarity Select RegisterR/W0x002.4.3.19/2-178
0x0246ReservedR0x00
0x0247ReservedR0x00
S0x0248PTS—Port S Data RegisterR/W0x002.4.3.20/2-178
0x0249PTIS—Port S Input RegisterR32.4.3.21/2-179
0x024ADDRS—Port S Data Direction RegisterR/W0x002.4.3.22/2-179
0x024BReservedR0x00
0x024CPERS—Port S Pull Device Enable RegisterR/W0xFF2.4.3.23/2-180
0x024DPPSS—Port S Polarity Select RegisterR/W0x002.4.3.24/2-180
0x024EWOMS—Port S Wired-Or Mode RegisterR/W0x002.4.3.25/2-181
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
M0x0250PTM—Port M Data RegisterR/W0x002.4.3.27/2-183
0x0251PTIM—Port M Input RegisterR32.4.3.29/2-184
0x0252DDRM—Port M Data Direction RegisterR/W0x002.4.3.29/2-184
0x0253ReservedR0x00
0x0254PERM—Port M Pull Device Enable RegisterR/W0x002.4.3.30/2-185
0x0255PPSM—Port M Polarity Select RegisterR/W0x002.4.3.31/2-186
0x0256WOMM—Port M Wired-Or Mode RegisterR/W0x002.4.3.32/2-186
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.2Register Map
The following tables show the individual register maps of groups G1 (Table2-19), G2 (Table2-20) and
G3 (Table2-21).
NOTE
To maintain SW compatibility write data to unimplemented register bits
must be zero.
AD0x0270PT0AD—Port AD Data RegisterR/W0x002.4.3.49/2-198
0x0271PT1AD—Port AD Data RegisterR/W0x002.4.3.50/2-199
0x0272PTI0AD—Port AD Input RegisterR32.4.3.51/2-199
0x0273PTI1AD—Port AD Input RegisterR32.4.3.54/2-201
0x0274DDR0AD—Port AD Data Direction RegisterR/W0x002.4.3.53/2-200
0x0275DDR1AD—Port AD Data Direction RegisterR/W0x002.4.3.54/2-201
0x0276Reserved for RVACTL on G(A)240 and G(A)192 onlyR(/W)0x00(4.6.2.1/4-222)
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.2.1Block Register Map (G1)
Table2-19. Block Register Map (G1)
Global Address
Register NameBit 7654321Bit 0
0x0000
PORTA
RPA7PA6PA5PA4PA3PA2PA1PA0
W
0x0001
PORTB
RPB7PB6PB5PB4PB3PB2PB1PB0
W
0x0002
DDRA
RDDRA7DDRA6DDRA5DDRA4DDRA3DDRA2DDRA1DDRA0
W
0x0003
DDRB
RDDRB7DDRB6DDRB5DDRB4DDRB3DDRB2DDRB1DDRB0
W
0x0004
PORTC
RPC7PC6PC5PC4PC3PC2PC1PC0
W
0x0005
PORTD
RPD7PD6PD5PD4PD3PD2PD1PD0
W
0x0006
DDRC
RDDRC7DDRC6DDRC5DDRC4DDRC3DDRC2DDRC1DDRC0
W
0x0007
DDRD
RDDRD7DDRD6DDRD5DDRD4DDRD3DDRD2DDRD1DDRD0
0x0008
PORTE
R000000
PE1PE0
W
0x0009
DDRE
R000000
DDRE1DDRE0
W
0x000A–0x000B
Non-PIM
Address Range
R
Non-PIM Address Range
W
0x000C
PUCR
R0BKPUE0PDPEEPUPDEPUPCEPUPBEPUPAE
W
0x000D
Reserved
R00000000
W
0x000E–0x001B
Non-PIM
Address Range
R
Non-PIM Address Range
W
= Unimplemented or Reserved
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
150Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
0x0259
PTIP
RPTIP7PTIP6PTIP5PTIP4PTIP3PTIP2PTIP1PTIP0
W
0x025A
DDRP
RDDRP7DDRP6DDRP5DDRP4DDRP3DDRP2DDRP1DDRP0
W
0x025B
Reserved
R00000000
W
0x025C
PERP
RPERP7PERP6PERP5PERP4PERP3PERP2PERP1PERP0
W
0x025D
PPSP
RPPSP7PPSP6PPSP5PPSP4PPSP3PPSP2PPSP1PPSP0
W
0x025E
PIEP
RPIEP7PIEP6PIEP5PIEP4PIEP3PIEP2PIEP1PIEP0
W
0x025F
PIFP
RPIFP7PIFP6PIFP5PIFP4PIFP3PIFP2PIFP1PIFP0
W
0x0260–0x0267
Reserved
R00000000
W
0x0268
PTJ
RPTJ7PTJ6PTJ5PTJ4PTJ3PTJ2PTJ1PTJ0
W
0x0269
PTIJ
RPTIJ7PTIJ6PTIJ5PTIJ4PTIJ3PTIJ2PTIJ1PTIJ0
W
0x026A
DDRJ
RDDRJ7DDRJ6DDRJ5DDRJ4DDRJ3DDRJ2DDRJ1DDRJ0
W
0x026B
Reserved
R00000000
W
0x026C
PERJ
RPERJ7PERJ6PERJ5PERJ4PERJ3PERJ2PERJ1PERJ0
W
0x026D
PPSJ
RPPSJ7PPSJ6PPSJ5PPSJ4PPSJ3PPSJ2PPSJ1PPSJ0
W
0x026E
PIEJ
RPIEJ7PIEJ6PIEJ5PIEJ4PIEJ3PIEJ2PIEJ1PIEJ0
W
Table2-19. Block Register Map (G1) (continued)
Global Address
Register NameBit 7654321Bit 0
= Unimplemented or Reserved
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor153
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
0x025B
Reserved
R00000000
W
0x025C
PERP
R00PERP5PERP4PERP3PERP2PERP1PERP0
W
0x025D
PPSP
R00PPSP5PPSP4PPSP3PPSP2PPSP1PPSP0
W
0x025E
PIEP
R00PIEP5PIEP4PIEP3PIEP2PIEP1PIEP0
W
0x025F
PIFP
R00PIFP5PIFP4PIFP3PIFP2PIFP1PIFP0
W
0x0260–0x0261
Reserved
RReserved for ACMP
W
0x0262–0x0267
Reserved
R00000000
W
0x0268
PTJ
R0000
PTJ3PTJ2PTJ1PTJ0
W
0x0269
PTIJ
R0000PTIJ3PTIJ2PTIJ1PTIJ0
W
0x026A
DDRJ
R0000
DDRJ3DDRJ2DDRJ1DDRJ0
W
0x026B
Reserved
R00000000
W
0x026C
PERJ
R0000
PERJ3PERJ2PERJ1PERJ0
W
0x026D
PPSJ
R0000
PPSJ3PPSJ2PPSJ1PPSJ0
W
0x026E
PIEJ
R0000
PIEJ3PIEJ2PIEJ1PIEJ0
W
0x026F
PIFJ
R0000
PIFJ3PIFJ2PIFJ1PIFJ0
W
Table2-21. Block Register Map (G3) (continued)
Global Address
Register NameBit 7654321Bit 0
= Unimplemented or Reserved
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor163
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3Register Descriptions
This section describes the details of all configuration registers. Every register has the same functionality
in all groups if not specified separately. Refer to the register figures for reserved locations. If not stated
differently, writing to reserved bits has not effect and read returns zero.
NOTE
•All register read accesses are synchronous to internal clocks
1Read: Anytime. The data source is depending on the data direction value.
Write: Anytime
76543210
R
PA7PA6PA5PA4PA3PA2PA1PA0
W
Reset00000000
Address0x0000 (G2, G3)Access: User read only
76543210
R00000000
W
Reset00000000
Figure2-2. Port A Data Register (PORTA)
Table2-21. Block Register Map (G3) (continued)
Global Address
Register NameBit 7654321Bit 0
= Unimplemented or Reserved
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor165
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.2Port B Data Register (PORTB)
Table2-22. PORTA Register Field Descriptions
FieldDescription
7-0
PA
Port A general-purpose input/output data—Data Register
If the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the
buffered pin input state is read.
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
166Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.3Port A Data Direction Register (DDRA)
2.4.3.4Port B Data Direction Register (DDRB)
Address0x0002 (G1)Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
DDRA7DDRA6DDRA5DDRA4DDRA3DDRA2DDRA1DDRA0
W
Reset00000000
Address0x0002 (G2, G3)Access: User read only
76543210
R00000000
W
Reset00000000
Figure2-4. Port A Data Direction Register (DDRA)
Table2-24. DDRA Register Field Descriptions
FieldDescription
7-0
DDRA
Port A Data Direction—
This bit determines whether the associated pin is an input or output.
1 Associated pin configured as output
0 Associated pin configured as input
Address0x0003 (G1)Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
DDRB7DDRB6DDRB5DDRB4DDRB3DDRB2DDRB1DDRB0
W
Reset00000000
Address0x0003 (G2, G3)Access: User read only
76543210
R00000000
W
Reset00000000
Figure2-5. Port B Data Direction Register (DDRB)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor167
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.5Port C Data Register (PORTC)
Table2-25. DDRB Register Field Descriptions
FieldDescription
7-0
DDRB
Port B Data Direction—
This bit determines whether the associated pin is an input or output.
1 Associated pin configured as output
0 Associated pin configured as input
Address0x0004 (G1)Access: User read/write1
1Read: Anytime. The data source is depending on the data direction value.
Write: Anytime
76543210
R
PC7PC6PC5PC4PC3PC2PC1PC0
W
Reset00000000
Address0x0004 (G2, G3)Access: User read only
76543210
R00000000
W
Reset00000000
Figure2-6. Port C Data Register (PORTC)
Table2-26. PORTC Register Field Descriptions
FieldDescription
7-0
PC
Port C general-purpose input/output data—Data Register
If the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the
buffered pin input state is read.
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
168Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.6Port D Data Register (PORTD)
2.4.3.7Port C Data Direction Register (DDRC)
Address0x0005 (G1)Access: User read/write1
1Read: Anytime. The data source is depending on the data direction value.
Write: Anytime
76543210
R
PD7PD6PD5PD4PD3PD2PD1PD0
W
Reset00000000
Address0x0005 (G2, G3)Access: User read only
76543210
R00000000
W
Reset00000000
Figure2-7. Port D Data Register (PORTD)
Table2-27. PORTD Register Field Descriptions
FieldDescription
7-0
PD
Port D general-purpose input/output data—Data Register
If the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the
buffered pin input state is read.
Address0x0006 (G1)Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
DDRC7DDRC6DDRC5DDRA4DDRC3DDRC2DDRC1DDRC0
W
Reset00000000
Address0x0006 (G2, G3)Access: User read only
76543210
R00000000
W
Reset00000000
Figure2-8. Port C Data Direction Register (DDRC)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor169
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.8Port D Data Direction Register (DDRD)
2.4.3.9Port E Data Register (PORTE)
Table2-28. DDRC Register Field Descriptions
FieldDescription
7-0
DDRC
Port C Data Direction—
This bit determines whether the associated pin is an input or output.
1 Associated pin configured as output
0 Associated pin configured as input
Address0x0007 (G1)Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
DDRD7DDRD6DDRD5DDRD4DDRD3DDRD2DDRD1DDRD0
W
Reset00000000
Address0x0007 (G2, G3)Access: User read only
76543210
R00000000
W
Reset00000000
Figure2-9. Port D Data Direction Register (DDRD)
Table2-29. DDRD Register Field Descriptions
FieldDescription
7-0
DDRD
Port D Data Direction—
This bit determines whether the associated pin is an input or output.
1 Associated pin configured as output
0 Associated pin configured as input
Address0x0008Access: User read/write1
76543210
R000000
PE1PE0
W
Reset00000000
Figure2-10. Port E Data Register (PORTE)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
170Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.10Port E Data Direction Register (DDRE)
1Read: Anytime. The data source is depending on the data direction value.
Write: Anytime
Table2-30. PORTE Register Field Descriptions
FieldDescription
1-0
PE
Port E general-purpose input/output data—Data Register
When not used with an alternative signal, this pin can be used as general-purpose I/O.
In general-purpose output mode the port data register bit is driven to the pin.
If the associated data direction bit of this pin is set to 1, a read returns the value of the port register, otherwise the
buffered pin input state is read.
Address0x0009Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R000000
DDRE1DDRE0
W
Reset00000000
Figure2-11. Port E Data Direction Register (DDRE)
Table2-31. DDRE Register Field Descriptions
FieldDescription
1-0
DDRE
Port E Data Direction—
This bit determines whether the associated pin is an input or output.
1 Associated pin configured as output
0 Associated pin configured as input
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor171
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.11Ports A, B, C, D, E, BKGD pin Pull Control Register (PUCR)
Address0x000C (G1)Access: User read/write1
1Read:Anytime in normal mode.
Write:Anytime, except BKPUE, which is writable in special mode only.
76543210
R0
BKPUE
0
PDPEEPUPDEPUPCEPUPBEPUPAE
W
Reset01010000
Address0x000C (G2, G3)Access: User read/write
76543210
R0
BKPUE
0
PDPEE
0000
W
Reset01010000
Figure2-12. Ports A, B, C, D, E, BKGD pin Pullup Control Register (PUCR)
Table2-32. PUCR Register Field Descriptions
FieldDescription
6
BKPUE
BKGD pin Pullup Enable—Enable pullup device on pin
This bit configures whether a pullup device is activated, if the pin is used as input. If a pin is used as output this bit
has no effect. Out of reset the pullup device is enabled.
1 Pullup device enabled
0 Pullup device disabled
4
PDPEE
Port E Pulldown Enable—Enable pulldown devices on all port input pins
or used with the CPMU OSC function this bit has no effect. Out of reset the pulldown devices are enabled.
1 Pulldown devices enabled
0 Pulldown devices disabled
3
PUPDE
Port D Pullup Enable—Enable pullup devices on all port input pins
This bit configures whether a pullup device is activated on all associated port input pins. If a pin is used as output
this bit has no effect.
1 Pullup devices enabled
0 Pullup devices disabled
2
PUPCE
Port C Pullup Enable—Enable pullup devices on all port input pins
This bit configures whether a pullup device is activated on all associated port input pins. If a pin is used as output
this bit has no effect.
1 Pullup devices enabled
0 Pullup devices disabled
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
172Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1
PUPBE
Port B Pullup Enable—Enable pullup devices on all port input pins
This bit configures whether a pullup device is activated on all associated port input pins. If a pin is used as output
this bit has no effect.
1 Pullup devices enabled
0 Pullup devices disabled
0
PUPAE
Port A Pullup Enable—Enable pullup devices on all port input pins
This bit configures whether a pullup device is activated on all associated port input pins. If a pin is used as output
this bit has no effect.
1 Pullup devices enabled
0 Pullup devices disabled
Table2-32. PUCR Register Field Descriptions (continued)
FieldDescription
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor173
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
These bits determine the rate of the free-running clock on the ECLK pin.
00000 ECLK rate = bus clock rate
00001 ECLK rate = bus clock rate divided by 2
00010 ECLK rate = bus clock rate divided by 3,...
11111 ECLK rate = bus clock rate divided by 32
Address0x001EAccess: User read/write1
76543210
R
IRQEIRQEN
000000
W
Reset00000000
Figure2-14. IRQ Control Register (IRQCR)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
174Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NOTE
If the input is driven to active level (IRQ=0) a write access to set either
IRQCR[IRQEN] and IRQCR[IRQE] to 1 simultaneously or to set
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.15Port T Data Register (PTT)
2.4.3.16Port T Input Register (PTIT)
Address0x0240 (G1, G2)Access: User read/write1
1Read: Anytime. The data source is depending on the data direction value.
Write: Anytime
76543210
R
PTT7PTT6PTT5PTT4PTT3PTT2PTT1PTT0
W
Reset00000000
Address0x0240 (G3)Access: User read/write1
76543210
R00
PTT5PTT4PTT3PTT2PTT1PTT0
W
Reset00000000
Figure2-16. Port T Data Register (PTT)
Table2-35. PTT Register Field Descriptions
FieldDescription
7-0
PTT
Port T general-purpose input/output data—Data Register
When not used with an alternative signal, the associated pin can be used as general-purpose I/O. In
general-purpose output mode the port data register bit value is driven to the pin.
If the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the
buffered pin input state is read.
Address0x0241 (G1, G2)Access: User read only1
1Read: Anytime
Write:Never
76543210
RPTIT7PTIT6PTIT5PTIT4PTIT3PTIT2PTIT1PTIT0
W
Reset00000000
Address0x0241 (G3)Access: User read only1
76543210
R00PTIT5PTIT4PTIT3PTIT2PTIT1PTIT0
W
Reset00000000
Figure2-17. Port T Input Register (PTIT)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
176Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This bit determines whether the pin is a general-purpose input or output.
1 Associated pin configured as output
0 Associated pin configured as input
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor177
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.18Port T Pull Device Enable Register (PERT)
Address0x0244 (G1, G2)Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
PERT7PERT6PERT5PERT4PERT3PERT2PERT1PERT0
W
Reset00000000
Address0x0244 (G3)Access: User read/write1
76543210
R00
PERT5PERT4PERT3PERT2PERT1PERT0
W
Reset00000000
Figure2-19. Port T Pull Device Enable Register (PERT)
Table2-38. PERT Register Field Descriptions
FieldDescription
7-2
PERT
Port T pull device enable—Enable pull device on input pin
polarity select register bit. If this pin is used as XIRQ only a pullup device can be enabled.
1 Pull device enabled
0 Pull device disabled
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
178Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.19Port T Polarity Select Register (PPST)
2.4.3.20Port S Data Register (PTS)
Address0x0245 (G1, G2)Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
PPST7PPST6PPST5PPST4PPST3PPST2PPST1PPST0
W
Reset00000000
Address0x0245 (G3)Access: User read/write1
76543210
R00
PPST5PPST4PPST3PPST2PPST1PPST0
W
Reset00000000
Figure2-20. Port T Polarity Select Register (PPST)
Table2-39. PPST Register Field Descriptions
FieldDescription
7-0
PPST
Port T pull device select—Configure pull device polarity on input pin
This bit selects a pullup or a pulldown device if enabled on the associated port input pin.
1 Pulldown device selected
0 Pullup device selected
Address0x0248Access: User read/write1
1Read: Anytime. The data source is depending on the data direction value.
Write: Anytime
76543210
R
PTS7PTS6PTS5PTS4PTS3PTS2PTS1PTS0
W
00000000
Figure2-21. Port S Data Register (PTS)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor179
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.21Port S Input Register (PTIS)
2.4.3.22Port S Data Direction Register (DDRS)
Table2-40. PTS Register Field Descriptions
FieldDescription
7-0
PTS
Port S general-purpose input/output data—Data Register
When not used with an alternative signal, the associated pin can be used as general-purpose I/O. In
general-purpose output mode the port data register bit value is driven to the pin.
If the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.23Port S Pull Device Enable Register (PERS)
2.4.3.24Port S Polarity Select Register (PPSS)
Table2-42. DDRS Register Field Descriptions
FieldDescription
7-0
DDRS
Port S data direction—
This bit determines whether the associated pin is a general-purpose input or output.
1 Associated pin configured as output
0 Associated pin configured as input
Address0x024CAccess: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
PERS7PERS6PERS5PERS4PERS3PERS2PERS1PERS0
W
Reset11111111
Figure2-24. Port S Pull Device Enable Register (PERS)
Table2-43. PERS Register Field Descriptions
FieldDescription
7-0
PERS
Port S pull device enable—Enable pull device on input pin or wired-or output pin
polarity select register bit. If a pin is used as output this bit has only effect if used in wired-or mode with a pullup
device.
1 Pull device enabled
0 Pull device disabled
Address0x024DAccess: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
PPSS7PPSS6PPSS5PPSS4PPSS3PPSS2PPSS1PPSS0
W
Reset00000000
Figure2-25. Port S Polarity Select Register (PPSS)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor181
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table2-46. PRR0 Register Field Descriptions
FieldDescription
7
PRR0P3
Pin Routing Register PWM3—Select alternative routing of PWM3 output, ETRIG3 input
This bit programs the routing of the PWM3 channel and the ETRIG3 input to a different external pin in 20 TSSOP.
SeeTable2-47 for more details.
6
PRR0P2
Pin Routing Register PWM2—Select alternative routing of PWM2 output, ETRIG2 input
This bit programs the routing of the PWM2 channel and the ETRIG2 input to a different external pin in 20 TSSOP.
SeeTable2-48 for more details.
5
PRR0T31
Pin Routing Register IOC3—Select alternative routing of IOC3 output and input
Those two bits program the routing of the timer IOC3 channel to different external pins in 20 TSSOP.
SeeTable2-49 for more details.
4
PRR0T30
3
PRR0T21
Pin Routing Register IOC2—Select alternative routing of IOC2 output and input
Those two bits program the routing of the timer IOC2 channel to different external pins in 20 TSSOP.
SeeTable2-50 for more details.
2
PRR0T20
1
PRR0S1
Pin Routing Register Serial Module—Select alternative routing of SCI0 pins
Those bits program the routing of the SCI0 module pins to different external pins in 20 TSSOP.
SeeTable2-51 for more details.
0
PRR0S0
Table2-47. PWM3/ETRIG3 Routing Options
PRR0P3PWM3/ETRIG3 Associated Pin
0PS7 - PWM3, ETRIG3
1PAD5 - PWM3, ETRIG3
Table2-48. PWM2/ETRIG2 Routing Options
PRR0P2PWM2/ETRIG2 Associated Pin
0PS4 - PWM2, ETRIG2
1PAD4 - PWM2, ETRIG2
Table2-49. IOC3 Routing Options
PRR0T31PRR0T30IOC3 Associated Pin
00PS6 - IOC3
01PE1 - IOC3
10PAD5 - IOC3
11Reserved
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor183
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.27Port M Data Register (PTM)
Table2-50. IOC2 Routing Options
PRR0T21PRR0T20IOC2 Associated Pin
00PS5 - IOC2
01PE0 - IOC2
10PAD4 - IOC2
11Reserved
Table2-51. SCI0 Routing Options
PRR0S1PRR0S0SCI0 Associated Pin
00PE0 - RXD, PE1 - TXD
01PS4 - RXD, PS7 - TXD
10PAD4 - RXD, PAD5 - TXD
11Reserved
Address0x0250 (G1, G2)Access: User read/write1
1Read: Anytime. The data source is depending on the data direction value.
Write: Anytime
76543210
R0000
PTM3PTM2PTM1PTM0
W
Reset00000000
Address0x0250 (G3)Access: User read/write1
76543210
R000000
PTM1PTM0
W
Reset00000000
Figure2-28. Port M Data Register (PTM)
Table2-52. PTM Register Field Descriptions
FieldDescription
3-0
PTM
Port M general-purpose input/output data—Data Register
When not used with an alternative signal, the associated pin can be used as general-purpose I/O. In
general-purpose output mode the port data register bit value is driven to the pin.
If the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the
buffered pin input state is read.
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
184Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.30Port M Pull Device Enable Register (PERM)
Table2-54. DDRM Register Field Descriptions
FieldDescription
3-0
DDRM
Port M data direction—
This bit determines whether the associated pin is a general-purpose input or output.
1 Associated pin configured as output
0 Associated pin configured as input
Address0x0254 (G1, G2)Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R0000
PERM3PERM2PERM1PERM0
W
Reset00000000
Address0x0254 (G3)Access: User read/write1
76543210
R000000
PERM1PERM0
W
Reset00000000
Figure2-31. Port M Pull Device Enable Register (PERM)
Table2-55. PERM Register Field Descriptions
FieldDescription
3-1
PERM
Port M pull device enable—Enable pull device on input pin or wired-or output pin
polarity select register bit. If a pin is used as output this bit has only effect if used in wired-or mode with a pullup
device.
If CAN is active the selection of a pulldown device on the RXCAN input will have no effect.
1 Pull device enabled
0 Pull device disabled
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
186Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.31Port M Polarity Select Register (PPSM)
2.4.3.32Port M Wired-Or Mode Register (WOMM)
Address0x0255 (G1, G2)Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R0000
PPSM3PPSM2PPSM1PPSM0
W
Reset00000000
Address0x0255 (G3)Access: User read/write1
76543210
R000000
PPSM1PPSM0
W
Reset00000000
Figure2-32. Port M Polarity Select Register (PPSM)
Table2-56. PPSM Register Field Descriptions
FieldDescription
3-0
PPSM
Port M pull device select—Configure pull device polarity on input pin
This bit selects a pullup or a pulldown device if enabled on the associated port input pin.
1 Pulldown device selected
0 Pullup device selected
Address0x0256 (G1, G2)Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R0000
WOMM3WOMM2WOMM1WOMM0
W
Reset00000000
Address0x0256 (G3)Access: User read/write1
76543210
R000000
WOMM1WOMM0
W
Reset00000000
Figure2-33. Port M Wired-Or Mode Register (WOMM)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor187
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.33Package Code Register (PKGCR)
Table2-57. WOMM Register Field Descriptions
FieldDescription
3-0
WOMM
Port M wired-or mode—Enable open-drain functionality on output pin
This bit configures an output pin as wired-or (open-drain) or push-pull. In wired-or mode a logic “0” is driven
Codes writes of smaller packages than the given device is offered in are not restricted.
Depending on the package selection the input buffers of non-bonded pins are disabled to avoid shoot-through
current. Also a predefined signal routing will take effect.
Refer also toSection2.6.5, “Emulation of Smaller Packages”.
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
188Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.34Port P Data Register (PTP)
Table2-59. API_EXTCLK Routing Options
APICLKS7API_EXTCLK Associated Pin
0PB1 (100 LQFP)
PP0 (64/48/32 LQFP)
N.C. (20TSSOP)
1PS7
Table2-60. Package Options
PKGCR2PKGCR1PKGCR0Selected Package
111Reserved1
1Reading this value indicates an illegal code write or uninitialized factory programming.
110100 LQFP
101Reserved
10064 LQFP
01148 LQFP
010Reserved
00132 LQFP
00020 TSSOP
Address0x0258 (G1, G2)Access: User read/write1
1Read: Anytime. The data source is depending on the data direction value.
Write: Anytime
76543210
R
PTP7PTP6PTP5PTP4PTP3PTP2PTP1PTP0
W
Reset00000000
Address0x0258 (G3)Access: User read/write1
76543210
R00
PTP5PTP4PTP3PTP2PTP1PTP0
W
Reset00000000
Figure2-35. Port P Data Register (PTP)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor189
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.35Port P Input Register (PTIP)
Table2-61. PTP Register Field Descriptions
FieldDescription
7-0
PTP
Port P general-purpose input/output data—Data Register
When not used with an alternative signal, the associated pin can be used as general-purpose I/O. In
general-purpose output mode the port data register bit value is driven to the pin.
If the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.36Port P Data Direction Register (DDRP)
2.4.3.37Port P Pull Device Enable Register (PERP)
Address0x025A (G1, G2)Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
DDRP7DDRP6DDRP5DDRP4DDRP3DDRP2DDRP1DDRP0
W
Reset00000000
Address0x025A (G3)Access: User read/write1
76543210
R00
DDRP5DDRP4DDRP3DDRP2DDRP1DDRP0
W
Reset00000000
Figure2-37. Port P Data Direction Register (DDRP)
Table2-63. DDRP Register Field Descriptions
FieldDescription
7-0
DDRP
Port P data direction—
This bit determines whether the associated pin is an input or output.
1 Associated pin configured as output
0 Associated pin configured as input
Address0x025C (G1, G2)Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
PERP7PERP6PERP5PERP4PERP3PERP2PERP1PERP0
W
Reset00000000
Address0x025C (G3)Access: User read/write1
76543210
R00
PERP5PERP4PERP3PERP2PERP1PERP0
W
Reset00000000
Figure2-38. Port P Pull Device Enable Register (PERP)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor191
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.38Port P Polarity Select Register (PPSP)
Table2-64. PERP Register Field Descriptions
FieldDescription
7-0
PERP
Port P pull device enable—Enable pull device on input pin
no effect. The polarity is selected by the related polarity select register bit.
1 Pull device enabled
0 Pull device disabled
Address0x025D (G1, G2)Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
PPSP7PPSP6PPSP5PPSP4PPSP3PPSP2PPSP1PPSP0
W
Reset00000000
Address0x025D (G3)Access: User read/write1
76543210
R00
PPSP5PPSP4PPSP3PPSP2PPSP1PPSP0
W
Reset00000000
Figure2-39. Port P Polarity Select Register (PPSP)
Table2-65. PPSP Register Field Descriptions
FieldDescription
7-0
PPSP
Port P pull device select—Configure pull device and pin interrupt edge polarity on input pin
This bit selects a pullup or a pulldown device if enabled on the associated port input pin.
This bit also selects the polarity of the active pin interrupt edge.
1 Pulldown device selected; rising edge selected
0 Pullup device selected; falling edge selected
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
192Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.39Port P Interrupt Enable Register (PIEP)
Read: Anytime
2.4.3.40Port P Interrupt Flag Register (PIFP)
Address0x025E (G1, G2)Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
PIEP7PIEP6PIEP5PIEP4PIEP3PIEP2PIEP1PIEP0
W
Reset00000000
Address0x025E (G3)Access: User read/write1
76543210
R00
PIEP5PIEP4PIEP3PIEP2PIEP1PIEP0
W
Reset00000000
Figure2-40. Port P Interrupt Enable Register (PIEP)
the pin is operating in input or output mode when in use with the general-purpose or related peripheral function.
1 Interrupt is enabled
0 Interrupt is disabled (interrupt flag masked)
Address0x025F (G1, G2)Access: User read/write1
76543210
R
PIFP7PIFP6PIFP5PIFP4PIFP3PIFP2PIFP1PIFP0
W
Reset00000000
Address0x025F (G3)Access: User read/write1
76543210
R00
PIFP5PIFP4PIFP3PIFP2PIFP1PIFP0
W
Reset00000000
Figure2-41. Port P Interrupt Flag Register (PIFP)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor193
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.41Reserved Registers
NOTE
Addresses 0x0260-0x0261 are reserved for ACMP registers in G2 and G3
only. Refer toSection3.6.2.1, “ACMP Control Register (ACMPC)” and
(seeSection2.5.4.2, “Pin Interrupts and Wakeup”). This can be a rising or a falling edge based on the state of the
polarity select register.
Writing a logic “1” to the corresponding bit field clears the flag.
1 Active edge on the associated bit has occurred (an interrupt will occur if the associated enable bit is set)
0 No active edge occurred
Address0x0268 (G1, G2)Access: User read/write1
1Read: Anytime. The data source is depending on the data direction value.
Write: Anytime
76543210
R
PTJ7PTJ6PTJ5PTJ4PTJ3PTJ2PTJ1PTJ0
W
Reset00000000
Address0x0268 (G3)Access: User read/write1
76543210
R0000
PTJ3PTJ2PTJ1PTJ0
W
Reset00000000
Figure2-42. Port J Data Register (PTJ)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
194Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.43Port J Input Register (PTIJ)
Table2-69. PTJ Register Field Descriptions
FieldDescription
7-0
PTJ
Port J general-purpose input/output data—Data Register
When not used with an alternative signal, the associated pin can be used as general-purpose I/O. In
general-purpose output mode the port data register bit value is driven to the pin.
If the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.44Port J Data Direction Register (DDRJ)
2.4.3.45Port J Pull Device Enable Register (PERJ)
Address0x026A (G1, G2)Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
DDRJ7DDRJ6DDRJ5DDRJ4DDRJ3DDRJ2DDRJ1DDRJ0
W
Reset00000000
Address0x026A (G3)Access: User read/write1
76543210
R0000
DDRJ3DDRJ2DDRJ1DDRJ0
W
Reset00000000
Figure2-44. Port J Data Direction Register (DDRJ)
Table2-71. DDRJ Register Field Descriptions
FieldDescription
7-0
DDRJ
Port J data direction—
This bit determines whether the associated pin is an input or output.
1 Associated pin configured as output
0 Associated pin configured as input
Address0x026C (G1, G2)Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
PERJ7PERJ6PERJ5PERJ4PERJ3PERJ2PERJ1PERJ0
W
Reset11111111
Address0x026C (G3)Access: User read/write1
76543210
R0000
PERJ3PERJ2PERJ1PERJ0
W
Reset00001111
Figure2-45. Port J Pull Device Enable Register (PERJ)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
196Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.46Port J Polarity Select Register (PPSJ)
Table2-72. PERJ Register Field Descriptions
FieldDescription
7-0
PERJ
Port J pull device enable—Enable pull device on input pin
no effect. The polarity is selected by the related polarity select register bit.
1 Pull device enabled
0 Pull device disabled
Address0x026D (G1, G2)Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
PPSJ7PPSJ6PPSJ5PPSJ4PPSJ3PPSJ2PPSJ1PPSJ0
W
Reset00000000
Address0x026D (G3)Access: User read/write1
76543210
R0000
PPSJ3PPSJ2PPSJ1PPSJ0
W
Reset00000000
Figure2-46. Port J Polarity Select Register (PPSJ)
Table2-73. PPSJ Register Field Descriptions
FieldDescription
7-0
PPSJ
Port J pull device select—Configure pull device and pin interrupt edge polarity on input pin
This bit selects a pullup or a pulldown device if enabled on the associated port input pin.
This bit also selects the polarity of the active pin interrupt edge.
1 Pulldown device selected; rising edge selected
0 Pullup device selected; falling edge selected
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor197
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.47Port J Interrupt Enable Register (PIEJ)
Read: Anytime
2.4.3.48Port J Interrupt Flag Register (PIFJ)
Address0x026E (G1, G2)Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
PIEJ7PIEJ6PIEJ5PIEJ4PIEJ3PIEJ2PIEJ1PIEJ0
W
Reset00000000
Address0x026E (G3)Access: User read/write1
76543210
R0000
PIEJ3PIEJ2PIEJ1PIEJ0
W
Reset00000000
Figure2-47. Port J Interrupt Enable Register (PIEJ)
the pin is operating in input or output mode when in use with the general-purpose or related peripheral function.
1 Interrupt is enabled
0 Interrupt is disabled (interrupt flag masked)
Address0x026F (G1, G2)Access: User read/write1
76543210
R
PIFJ7PIFJ6PIFJ5PIFJ4PIFJ3PIFJ2PIFJ1PIFJ0
W
Reset00000000
Address0x026F (G3)Access: User read/write1
76543210
R0000
PIFJ3PIFJ2PIFJ1PIFJ0
W
Reset00000000
Figure2-48. Port J Interrupt Flag Register (PIFJ)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
198Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
(seeSection2.5.4.2, “Pin Interrupts and Wakeup”). This can be a rising or a falling edge based on the state of the
polarity select register.
Writing a logic “1” to the corresponding bit field clears the flag.
1 Active edge on the associated bit has occurred (an interrupt will occur if the associated enable bit is set)
0 No active edge occurred
Address0x0270 (G1, G2)Access: User read/write1
1Read: Anytime. The data source is depending on the data direction value.
Write: Anytime
76543210
R
PT0AD7PT0AD6PT0AD5PT0AD4PT0AD3PT0AD2PT0AD1PT0AD0
W
Reset00000000
Address0x0270 (G3)Access: User read/write1
76543210
R0000
PT0AD3PT0AD2PT0AD1PT0AD0
W
Reset00000000
Figure2-49. Port AD Data Register (PT0AD)
Table2-76. PT0AD Register Field Descriptions
FieldDescription
7-0
PT0AD
Port AD general-purpose input/output data—Data Register
When not used with an alternative signal, the associated pin can be used as general-purpose I/O. In
general-purpose output mode the port data register bit value is driven to the pin.
If the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the
buffered pin input state is read if the digital input buffers are enabled (Section2.3.12, “Pins AD15-0”).
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor199
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.50Port AD Data Register (PT1AD)
2.4.3.51Port AD Input Register (PTI0AD)
Address0x0271Access: User read/write1
1Read: Anytime. The data source is depending on the data direction value.
Write: Anytime
76543210
R
PT1AD7PT1AD6PT1AD5PT1AD4PT1AD3PT1AD2PT1AD1PT1AD0
W
Reset00000000
Figure2-50. Port AD Data Register (PT1AD)
Table2-77. PT1AD Register Field Descriptions
FieldDescription
7-0
PT1AD
Port AD general-purpose input/output data—Data Register
When not used with an alternative signal, the associated pin can be used as general-purpose I/O. In
general-purpose output mode the port data register bit value is driven to the pin.
If the associated data direction bit is set to 1, a read returns the value of the port data register bit, otherwise the
buffered pin input state is read if the digital input buffers are enabled (Section2.3.12, “Pins AD15-0”).
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure2-53. Port AD Data Direction Register (DDR0AD)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor201
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure2-54. Port AD Data Direction Register (DDR1AD)
Table2-81. DDR1AD Register Field Descriptions
FieldDescription
7-0
DDR1AD
Port AD data direction—
This bit determines whether the associated pin is an input or output.
1 Associated pin configured as output
0 Associated pin configured as input
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
202Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Address0x0277 (G(A)240 and G(A)192 only)Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R0000000
PRR1AN
W
Reset00000000
Address0x0277 (non G(A)240 and G(A)192)Access: User read/write
76543210
R00000000
W
Reset00000000
Figure2-55. Pin Routing Register (PRR1)
Table2-82. PRR1 Register Field Descriptions
FieldDescription
0
PRR1AN
Pin Routing Register ADC channels— Select alternative routing for AN15/14/13/11/10 pins to port C
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure2-57. Port AD Pullup Enable Register (PER1AD)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
204Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.59Port AD Polarity Select Register (PPS0AD)
Table2-85. PER1AD Register Field Descriptions
FieldDescription
7-0
PER1AD
Port AD pull enable—Enable pull device on input pin
Figure2-58. Port AD Polarity Select Register (PPS0AD)
Table2-86. PPS0AD Register Field Descriptions
FieldDescription
7-0
PPS0AD
Port AD pull device select—Configure pull device and pin interrupt edge polarity on input pin
This bit selects a pullup or a pulldown device if enabled on the associated port input pin.
This bit also selects the polarity of the active pin interrupt edge.
1 Pulldown device selected; rising edge selected
0 Pullup device selected; falling edge selected
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor205
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.60Port AD Polarity Select Register (PPS1AD)
2.4.3.61Port AD Interrupt Enable Register (PIE0AD)
Figure2-60. Port AD Interrupt Enable Register (PIE0AD)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
206Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.4.3.62Port AD Interrupt Enable Register (PIE1AD)
the pin is operating in input or output mode when in use with the general-purpose or related peripheral function.
1 Interrupt is enabled
0 Interrupt is disabled (interrupt flag masked)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor207
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure2-63. Port AD Interrupt Flag Register (PIF1AD)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
208Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
(seeSection2.5.4.2, “Pin Interrupts and Wakeup”). This can be a rising or a falling edge based on the state of the
polarity select register.
Writing a logic “1” to the corresponding bit field clears the flag.
1 Active edge on the associated bit has occurred (an interrupt will occur if the associated enable bit is set)
0 No active edge occurred
Table2-92. Register availability per port1
1Each cell represents one register with individual configuration bits
Port
Data
(Portx,
PTx)
Input
(PTIx)
Data
Direction
(DDRx)
Pull
Enable
(PERx)
Polarity
Select
(PPSx)
Wired-
Or Mode
(WOMx)
Interrupt
Enable
(PIEx)
Interrupt
Flag
(PIFx)
Ayes-yes
yes
----
Byes-yes----
Cyes-yes----
Dyes-yes----
Eyes-yes----
Tyesyesyesyesyes---
Syesyesyesyesyesyes--
Myesyesyesyesyesyes--
Pyesyesyesyesyes-yesyes
Jyesyesyesyesyes-yesyes
ADyesyesyesyesyes-yesyes
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor209
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.5.2.1Data Register (PORTx, PTx)
This register holds the value driven out to the pin if the pin is used as a general-purpose I/O.
Writing to this register has only an effect on the pin if the pin is used as general-purpose output. When
until the correct value is read on port data or port input registers, when
changing the data direction register.
Figure2-64. Illustration of I/O pin functionality
PT
DDR
output enable
module enable
1
0
1
1
0
0
PIN
PTI
data out
Module
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
210Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
output level (IO), pull enable (PE), pull select (PS) on the pin function and pull device activity.
The configuration bit PS is used for two purposes:
1.Configure the sensitive interrupt edge (rising or falling), if interrupt is enabled.
2.Select either a pullup or pulldown device if PE is active.
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor211
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
is cleared while an interrupt is pending, the request will deassert.
DDRIOPEPS1
1Always “0” on port A, B, C, D, BKGD. Always “1” on port E
IE2
2Applicable only on port P, J and AD.
FunctionPull DeviceInterrupt
0x0x0Input3
3Port AD: Assuming digital input buffer enabled in ADC module (ATDDIEN) and ACMP module (ACDIEN)
DisabledDisabled
0x100Input3PullupDisabled
0x110Input3PulldownDisabled
0x001Input3DisabledFalling edge
0x011Input3DisabledRising edge
0x101Input3PullupFalling edge
0x111Input3PulldownRising edge
10xx0Output, drive to 0DisabledDisabled
11xx0Output, drive to 1DisabledDisabled
10x01Output, drive to 0DisabledFalling edge
11x11Output, drive to 1DisabledRising edge
Table2-94. PIM Interrupt Sources
Module Interrupt Sources Local Enable
XIRQNone
IRQIRQCR[IRQEN]
Port P pin interruptPIEP[PIEP5-PIEP0]
PortJ pin interruptPIEJ[PIEJ3-PIEJ0]
Port AD pin interruptPIE0AD[PIE0AD3-PIE0AD0]
PIE1AD[PIE1AD7-PIE1AD0]
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual,Rev.1.06
212Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Both interrupts are capable to wake-up the device from stop mode. Means for glitch filtering are not
In stop mode the clock is generated by an RC-oscillator. The minimum pulse length varies over process
conditions, temperature and voltage (Figure2-65). Pulses with a duration of tPULSE< tP_MASK are
assuredly filtered out while pulses with a duration of tPULSE> tP_PASS guarantee a wakeup event.
Please refer to the appendix table “Pin Interrupt Characteristics” for pulse length limits.
To maximize current saving the RC oscillator is active only if the following condition is true on any
individual pin:
Sample count <= 4 (at active or passive level) and interrupt enabled (PIE=1) and interrupt flag not set
(PIF=0).
Figure2-65.Interrupt Glitch Filter (here: active low level selected)
Glitch, filtered out, no interrupt flag set
Valid pulse, interrupt flag setuncertain
tPULSE(min)tPULSE(max)
Port Integration Module (S12GPIMV0)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor213
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
2.6Initialization/Application Information
2.6.1Initialization
After a system reset, software should:
1.Read the PKGCR and write to it with its preset content to engage the write lock on
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
need to be accounted for when developing cross-functional code.
Table2-95. ETRIG Sources
ATDDIENofADC
&
ACDIEN of ACMP
PWM
Enable
Peripheral
Enable1
1With higher priority than PWM on pin
ETRIG
SourceComment
000Const. 1Forced High
001Const. 1Forced High
010PWMInternal Link
011PWMInternal Link
100PinDriven by General-Purpose Function
101PinDriven by Peripheral
110PinDriven by PWM
111PWMInternal Link
1.Except G128/G96 in 20 TSSOP: Internal routing of PWM to ETRIG is not available.
5V Analog Comparator (ACMPV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor215
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
device overview section for availability on a specific device.
3.2Features
The ACMP has the following features:
•Low offset, low long-term offset drift
•Selectable interrupt on rising, falling, or rising and falling edges of comparator output
•Option to output comparator signal on an external pin
•Option to trigger timer input capture events
3.3Block Diagram
The block diagram of the ACMP is shown below.
Rev. No.
(Item No.)
Date (Submitted
By)
Sections
AffectedSubstantial Change(s)
V00.0701 Jul 2010 •Aligned to S12 register guidelines
V00.0813 Aug 2010 •Added register name to every bitfield reference
V00.0910 Sep 2010 •Internal updates
•
5V Analog Comparator (ACMPV1)
MC9S12G Family Reference Manual,Rev.1.06
216Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure3-1. ACMP Block Diagram
Figure3-2.
3.4External Signals
The ACMP has two analog input signals, ACMPP and ACMPM, and one digital output, ACMPO. The
associated pins are defined by the package option.
The ACMPP signal is connected to the non-inverting input of the comparator. The ACMPM signal is
supply of the analog block is disconnected for power saving. ACMPO drives zero in shutdown
mode.
Interrupt
Control
ACMP IRQ
Control & Status
Register
ACMOD
SET ACIF
ACEACIF
ACIE
ACOPE
ACMPO
ACO
ACMPP
ACMPM
To Input
+
_
(enable)
ACICE
Capture
SyncHold
Channel
ACDIEN
digital
buffer
input
INTERNAL BUS
5V Analog Comparator (ACMPV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor217
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
3.6Memory Map and Register Definition
3.6.1Register Map
Table3-1 shows the ACMP register map.
Table3-1. ACMP Register Map
3.6.2Register Descriptions
3.6.2.1ACMP Control Register (ACMPC)
Global Address
Register NameBit 7654321Bit 0
0x0260
ACMPC
RACIEACOPEACICEACDIENACMOD1ACMOD00ACE
W
0x0261
ACMPS
RACIFACO000000
W
= Unimplemented or Reserved
Address0x0260Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
ACIEACOPEACICEACDIENACMOD1ACMOD0
0
ACE
W
Reset00000000
Figure3-3. ACMP Control Register (ACMPC)
Table3-2. ACMPC Register Field Descriptions
FieldDescription
7
ACIE
ACMP Interrupt Enable—
Enables the ACMP interrupt.
0 Interrupt disabled
1 Interrupt enabled
6
ACOPE
ACMP Output Pin Enable—
Enables raw comparator output on external ACMPO pin.
0 ACMP output not available
1 ACMP output is driven out on ACMPO
5V Analog Comparator (ACMPV1)
MC9S12G Family Reference Manual,Rev.1.06
218Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
3.6.2.2ACMP Status Register (ACMPS)
5
ACICE
ACMP Input Capture Enable—
Establishes internal link to a timer input capture channel. When enabled, the associated timer pin is disconnected
from the timer input. Refer to ACE description to account for initialization delay on this path.
0 Timer link disabled
1 ACMP output connected to input capture channel 5
4
ACDIEN
ACMP Digital Input Buffer Enable—
Enables the input buffers on ACMPP and ACMPM for the pins to be used with digital functions.
Note:If this bit is set while simultaneously using the pin as an analog port, there is potentially increased power
consumption because the digital input buffer may be in the linear region.
When resetting ACE to 0 the current state of the comparator will be maintained.
0 ACMP disabled
1 ACMP enabled
Address0x0261Access: User read/write1
1Read: Anytime
Write:
ACIF: Anytime, write 1 to clear
ACO: Never
76543210
R
ACIF
ACO000000
W
Reset00000000
Figure3-4. ACMP Status Register (ACMPS)
Table3-2. ACMPC Register Field Descriptions (continued)
FieldDescription
5V Analog Comparator (ACMPV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor219
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The comparator output signal synchronized to the bus clock is used to read the comparator output status
(ACMPS[ACO]) and to set the interrupt flag (ACMPS[ACIF]).
The condition causing the interrupt flag (ACMPS[ACIF]) to assert is selected with register bits
ACMPC[ACMOD1:ACMOD0]. This includes any edge configuration, that is rising, or falling, or rising
and falling (toggle) edges of the comparator output. Also flag setting can be disabled.
An interrupt will be generated if the interrupt enable bit (ACMPC[ACIE]) and the interrupt flag
(ACMPS[ACIF]) are both set. ACMPS[ACIF] is cleared by writing a 1.
The raw comparator output signal ACMPO can be driven out on an external pin by setting the
ACMPC[ACOPE] bit.
Table3-3. ACMPS Register Field Descriptions
FieldDescription
7
ACIF
ACMP Interrupt Flag—
ACIF is set when a compare event occurs. Compare events are defined by ACMOD[1:0]. Writing a logic “1” to the
bit field clears the flag.
0 Compare event has not occurred
1 Compare event has occurred
6
ACO
ACMP Output—
Reading ACO returns the current value of the synchronized ACMP output. Refer to ACE description to account for
initialization delay on this path.
Reference Voltage Attenuator (RVAV1)
MC9S12G Family Reference Manual,Rev.1.06
220Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter4
Reference Voltage Attenuator (RVAV1)
Revision History
4.1Introduction
The reference voltage attenuator (RVA) provides a circuit for reduction of the ADC reference voltage
difference VRH-VSSA to gain more ADC resolution.
4.2Features
The RVA has the following features:
•Attenuation of ADC reference voltage with low long-term drift
4.3Block Diagram
The block diagram of the RVA module is shown below.
Refer to device overview section “ADC VRH/VRL Signal Connection” for connection of RVA to pins
and ADC module.
Rev. No.
(Item No.)
Date (Submitted
By)
Sections
AffectedSubstantial Change(s)
V00.0426 May 2010 •Added reference to device overview for internal connections
V00.0509 Jun 2010 •Added appendix title in note to reference reduced ADC clock
•Orthographical corrections aligned to Freescale Publications Style Guide
V00.0601 Jul 2010 •Aligned to S12 register guidelines
Reference Voltage Attenuator (RVAV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor221
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure4-1. RVA Module Block Diagram
4.4External Signals
The RVA has two external input signals, VRH and VSSA.
ladder of the RVA is disconnected for power saving.
VRH_INT
VRL_INT
to ADC
RVA
RVAON
VSSA
VRH
5R
4R
R
STOP
Reference Voltage Attenuator (RVAV1)
MC9S12G Family Reference Manual,Rev.1.06
222Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
mode the attenuation is bypassed and the resistive divider does not draw current.
Global Address
Register NameBit 7654321Bit 0
0x0276
RVACTL
R0000000
RVAON
W
= Unimplemented or Reserved
Address0x0276Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R0000000
RVAON
W
Reset00000000
Figure4-2. RVA Control Register (RVACTL)
Table4-2. RVACTL Register Field Descriptions
FieldDescription
0
RVAON
RVA On —
This bit turns on the reference voltage attenuation.
0 RVA in bypass mode
1 RVA in attenuation mode
Reference Voltage Attenuator (RVAV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor223
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
If the attenuation is turned on the resistive divider is connected to VSSA, VRH_INT and VRL_INT are
connected to intermediate voltage levels:
VRH_INT = 0.9 * (VRH - VSSA) + VSSAEqn.4-1
VRL_INT = 0.4 * (VRH - VSSA) + VSSAEqn.4-2
The attenuated reference voltage difference (VRH_INT - VRL_INT) equals 50% of the input reference
voltage difference (VRH - VSSA). With reference voltage attenuation the resolution of the ADC is
conditions in appendix A “ATD Accuracy”, table “ATD Conversion
Performance 5V range, RVA enabled”.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor224
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Reference Voltage Attenuator (RVAV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor225
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Reference Voltage Attenuator (RVAV1)
MC9S12G Family Reference Manual,Rev.1.06
226Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Reference Voltage Attenuator (RVAV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor227
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Reference Voltage Attenuator (RVAV1)
MC9S12G Family Reference Manual,Rev.1.06
228Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Reference Voltage Attenuator (RVAV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor229
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Reference Voltage Attenuator (RVAV1)
MC9S12G Family Reference Manual,Rev.1.06
230Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor231
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Reference Voltage Attenuator (RVAV1)
MC9S12G Family Reference Manual,Rev.1.06
232Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor233
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter5
S12G Memory Map Controller (S12GMMCV1)
Table5-1. Revision History Table
5.1Introduction
The S12GMMC module controls the access to all internal memories and peripherals for the CPU12 and
S12SBDM module. It regulates access priorities and determines the address mapping of the on-chip
ressources.Figure5-1 shows a block diagram of the S12GMMC module.
Local AddressesAddress within the CPU12’s Local Address Map (Figure5-11)
Global AddressAddress within the Global Address Map (Figure5-11)
Aligned Bus AccessBus access to an even address.
Misaligned Bus AccessBus access to an odd address.
NSNormal Single-Chip Mode
SSSpecial Single-Chip Mode
Unimplemented Address RangesAddress ranges which are not mapped to any on-chip resource.
NVMNon-volatile Memory; Flash or EEPROM
IFRNVM Information Row. Refer to FTMRG Block Guide
S12G Memory Map Controller (S12GMMCV1)
MC9S12G Family Reference Manual,Rev.1.06
234Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
5.1.3Features
The main features of this block are:
•Paging capability to support a global 256 KByte memory address space
•Bus arbitration between the masters CPU12, S12SBDM to different resources.
•MCU operation mode control
•MCU security control
•Generation of system reset when CPU12 accesses an unimplemented address (i.e., an address
which does not belong to any of the on-chip modules) in single-chip modes
5.1.4Modes of Operation
The S12GMMC selects the MCU’s functional mode. It also determines the devices behavior in secured
and unsecured state.
5.1.4.1Functional Modes
Two functional modes are implemented on devices of the S12G product family:
•Normal Single Chip (NS)
The mode used for running applications.
•Special Single Chip Mode (SS)
A debug mode which causes the device to enter BDM Active Mode after each reset. Peripherals
may also provide special debug features in this mode.
5.1.4.2Security
S12G devices can be secured to prohibit external access to the on-chip flash. The S12GMMC module
determines the access permissions to the on-chip memories in secured and unsecured state.
5.1.5Block Diagram
Figure5-1 shows a block diagram of the S12GMMC.
S12G Memory Map Controller (S12GMMCV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor235
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure5-1. S12GMMC Block Diagram
5.2External Signal Description
The S12GMMC uses two external pins to determine the devices operating mode: RESET and MODC
(Figure5-3) See Device User Guide (DUG) for the mapping of these signals to device pins{statement}.
5.3Memory Map and Registers
5.3.1Module Memory Map
A summary of the registers associated with the S12GMMC block is shown inFigure5-2. Detailed
descriptions of the registers and bits are given in the subsections that follow.
Table5-3. External System Pins Associated With S12GMMC
Pin NamePin FunctionsDescription
RESET
(See Section
Device Overview)
RESET
TheRESET pin is used the select the MCU’s operating mode.
MODC
(See Section
Device Overview)
MODCThe MODC pin is captured at the rising edge of theRESET pin. The captured
value determines the MCU’s operating mode.
CPU
BDM
Target Bus Controller
DBG
MMC
Address Decoder & Priority
Peripherals
FlashEEPROMRAM
S12G Memory Map Controller (S12GMMCV1)
MC9S12G Family Reference Manual,Rev.1.06
236Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
5.3.2Register Descriptions
This section consists of the S12GMMC control register descriptions in address order.
5.3.2.1Mode Register (MODE)
AddressRegister
NameBit 7654321Bit 0
0x000AReservedR00000000
W
0x000BMODERMODC0000000
W
0x0010ReservedR00000000
W
0x0011DIRECTRDP15DP14DP13DP12DP11DP10DP9DP8
W
0x0012ReservedR00000000
W
0x0013MMCCTL1R0000000
NVMRES
W
0x0014ReservedR00000000
W
0x0015PPAGER0000
PIX3PIX2PIX1PIX0
W
0x0016-
0x0017
ReservedR00000000
W
= Unimplemented or Reserved
Figure5-2. MMC Register Summary
Address: 0x000B
76543210
RMODC0000000
W
ResetMODC10000000
1. External signal (seeTable5-3).
= Unimplemented or Reserved
Figure5-3. Mode Register (MODE)
S12G Memory Map Controller (S12GMMCV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor237
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Read: Anytime.
Write: Only if a transition is allowed (seeFigure5-4).
The MODC bit of the MODE register is used to select the MCU’s operating mode.
Figure5-4. Mode Transition Diagram when MCU is Unsecured
Mode Select Bit — This bit controls the current operating mode duringRESET high (inactive). The external
mode pin MODC determines the operating mode duringRESET low (active). The state of the pin is registered
into the respective register bit after theRESET signal goes inactive (seeFigure5-4).
Write restrictions exist to disallow transitions between certain modes.Figure5-4 illustrates all allowed mode
changes. Attempting non authorized transitions will not change the MODE bit, but it will block further writes to
the register bit except in special modes.
Write accesses to the MODE register are blocked when the device is secured.
Address: 0x0011
76543210
RDP15DP14DP13DP12DP11DP10DP9DP8
W
Reset00000000
Figure5-5. Direct Register (DIRECT)
Normal
Single-Chip
1
Special
Single-Chip
0
(SS)
RESET
(NS)
1
01
S12G Memory Map Controller (S12GMMCV1)
MC9S12G Family Reference Manual,Rev.1.06
238Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure5-6. DIRECT Address Mapping
Example5-1. This example demonstrates usage of the Direct Addressing Mode
Direct Page Index Bits 15–8 — These bits are used by the CPU when performing accesses using the direct
addressing mode. These register bits form bits [15:8] of the local address (seeFigure5-6).
Address: 0x0013
76543210
R0000000
NVMRES
W
Reset00000000
= Unimplemented or Reserved
Figure5-7. MMC Control Register (MMCCTL1)
Table5-6. MODE Field Descriptions
FieldDescription
0
NVMRES
Map internal NVM resources into the global memory map
Write: Anytime
This bit maps internal NVM resources into the global address space.
0Program flash is mapped to the global address range from 0x04000 to 0x07FFF.
1NVM resources are mapped to the global address range from 0x04000 to 0x07FFF.
Bit15Bit0
Bit7
CPU Address [15:0]
Bit8
DP [15:8]
S12G Memory Map Controller (S12GMMCV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor239
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The reset value of 0xE ensures that there is linear Flash space available between addresses 0x0000 and
0xFFFF out of reset.
The fixed 16KB page from 0xC000-0xFFFF is the page number 0xF.
5.4Functional Description
The S12GMMC block performs several basic functions of the S12G sub-system operation: MCU
page window located from address 0x8000 to address 0xBFFF in the local CPU memory map.
S12G Memory Map Controller (S12GMMCV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor241
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The page value for the program page window is stored in the PPAGE register. The value of the PPAGE
in the case the CPU is executing a firmware command which uses CPU instructions, or by a BDM
hardware commands. See the BDM Block Guide for further details. (seeFigure5-10).
S12G Memory Map Controller (S12GMMCV1)
MC9S12G Family Reference Manual,Rev.1.06
242Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure5-10.
BDM HARDWARE COMMAND
BDM FIRMWARE COMMAND
Bit14Bit0
BDM Local Address [13:0]
BDMPPR Register [3:0]
Global Address [17:0]
Bit13
Bit17
Bit14Bit0
CPU Local Address [13:0]
BDMPPR Register [3:0]
Global Address [17:0]
Bit13
Bit17
S12G Memory Map Controller (S12GMMCV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor243
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure5-11. Local to Global Address Mapping
Paging Window
0x3_FFFF
Local CPU and BDM
Memory MapGlobal Memory Map
0xFFFF
0xC000
0x0_0400
0x0_0000
0x3_C000
0x0000
0x8000
0x0400
0x40000x0_4000
Paging Window
Flash
Space
Flash
Space
RAM
RAM
Unimplemented
Unimplemented
Flash Space
Flash Space
Flash Space
Flash Space
Flash Space
Flash Space
Register Space
Register Space
Internal
NVM
Resources
Internal
NVM
Resources
Flash Space
Flash Space
Flash Space
Flash Space
Flash Space
Flash Space
Flash Space
Flash Space
EEPROM
EEPROMEEPROM
EEPROM
Page 0x1
Page 0x1
Page 0xF
Page 0xF
Page 0xD
Page 0xD
Register Space
Register Space
Page 0xC
Page 0xC
Page 0xE
Page 0xE
Page 0xF
Page 0xF
Page 0xD
Page 0xD
Page 0xC
Page 0xC
NVMRES=0
NVMRES=0NVMRES=1
NVMRES=1
Flash Space
Flash Space
Page 0x2
Page 0x2
0x3_0000
0x3_4000
0x3_8000
0x0_8000
RAM
RAM
S12G Memory Map Controller (S12GMMCV1)
MC9S12G Family Reference Manual,Rev.1.06
244Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
5.4.3Unimplemented and Reserved Address Ranges
The S12GMMC is capable of mapping up 240K of flash, up to 4K of EEPROM and up to 11K of RAM
into the global memory map{statement}. Smaller devices of the S12G-family do not utilize all of the
available address space. Address ranges which are not associated with one of the on-chip memories fall
into two categories: Unimplemented addresses and reserved addresses.
does not physically exist. It does not trigger an illegal address reset when accesses to reserved locations
are attempted.
Table5-8 shows the global address ranges of all members of the S12G-family.
Table5-8. Global Address Ranges
S12GN16S12GN32S12G48,
S12GN48S12G64S12G96S12G128S12G192S12G240
0x00000-
0x003FF
Register Space
0x00400-
0x005FF
0.5k1k1.5k2k3k4k4k4k
0x00600-
0x007FF
ReservedEEPROM
0x00800-
0x009FF
0x00A00-
0x00BFF
Reserved
0x00C00-
0x00FFF
0x01000-
0x013FF
Reserved
0x01400-
0x01FFF
Unimplemented
0x02000-
0x2FFF
0x03000-
0x037FF
RAM
0x03800-
0x03BFF
Reserved
0x03C00-
0x03FFF1k2k4k4k8k8k11k11k
S12G Memory Map Controller (S12GMMCV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor245
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
5.4.4Prioritization of Memory Accesses
On S12G devices, the CPU and the BDM are not able to access the memory in parallel. An arbitration
In this case the pending BDM access will be processed immediately.
5.4.5Interrupts
The S12GMMC does not generate any interrupts.
0x04000-
0x07FFF
(NVMRES=1)
Internal NVM Resources (for details refert to section FTMRG)
0x04000-
0x07FFF
(NVMRES=0)
Reserved
0x08000-
0x0FFFF
0x08000-
0x1FFFF
Unimplemented
0x20000-
0x27FFF
Reserved
0x28000-
0x2FFFF
0x30000-
0x33FFF
Reserved
0x34000-
0x37FFF
Flash
0x38000-
0x3BFFF
Reserved
0x3C000-
0x3FFFF16k32k48k64k96k128k192k240k
Table5-8. Global Address Ranges
S12GN16S12GN32S12G48,
S12GN48S12G64S12G96S12G128S12G192S12G240
S12G Memory Map Controller (S12GMMCV1)
MC9S12G Family Reference Manual,Rev.1.06
246Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor247
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
- added low voltage reset as possible source to the pin reset vector
01.0321 Nov
2007
added clarification of “Wake-up from STOP or WAIT by XIRQ with
Xbit set” feature
01.0420 May
2009
added footnote about availability of “Wake-up from STOP or WAIT
by XIRQ with Xbit set” feature
Table6-2. Terminology
TermMeaning
CCRCondition Code Register (in the CPU)
ISRInterrupt Service Routine
MCUMicro-Controller Unit
Interrupt Module (S12SINTV1)
MC9S12G Family Reference Manual,Rev.1.06
248Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•2–58 I bit maskable interrupt vector requests (at addresses vector base + 0x0082–0x00F2).
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure6-1. INT Block Diagram
6.2External Signal Description
The INT module has no external signals.
6.3Memory Map and Register Definition
This section provides a detailed description of all registers accessible in the INT module.
6.3.1Register Descriptions
This section describes in address order all the INT registers and their individual bits.
6.3.1.1Interrupt Vector Base Register (IVBR)
Read: Anytime
Write: Anytime
Address: 0x0120
76543210
RIVB_ADDR[7:0]
W
Reset11111111
Figure6-2. Interrupt Vector Base Register (IVBR)
Wake Up
IVBR
Interrupt
Requests
Interrupt RequestsCPU
Vector
Address
Peripheral
To CPU
Priority
Decoder
Non Ibit Maskable Channels
Ibit Maskable Channels
Interrupt Module (S12SINTV1)
MC9S12G Family Reference Manual,Rev.1.06
250Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
6.4Functional Description
The INT module processes all exception requests to be serviced by the CPU module. These exceptions
to enable handling of all non-maskable interrupts in the BDM firmware.
Interrupt Module (S12SINTV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor251
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
If the interrupt source is unknown (for example, in the case where an interrupt request becomes inactive
after the interrupt has been recognized, but prior to the CPU vector request), the vector address supplied
to the CPU will default to that of the spurious interrupt vector.
NOTE
Care must be taken to ensure that all interrupt requests remain active until
(Vector base + 0x00F6)Software interrupt instruction (SWI) or BDM vector request
(Vector base + 0x00F4)Xbit maskable interrupt request (XIRQ or D2D error interrupt)2
2D2D error interrupt on MCUs featuring a D2D initiator module, otherwise XIRQ pin interrupt
(Vector base + 0x00F2)IRQ or D2D interrupt request3
3D2D interrupt on MCUs featuring a D2D initiator module, otherwise IRQ pin interrupt
(Vectorbase+0x00F0–0x0082)Device specific I bit maskable interrupt sources (priority determined by the low byte of the
vector address, in descending order)
(Vector base + 0x0080)Spurious interrupt
Interrupt Module (S12SINTV1)
MC9S12G Family Reference Manual,Rev.1.06
252Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
6.5Initialization/Application Information
6.5.1Initialization
After system reset, software should:
1.Initialize the interrupt vector base register if the interrupt vector table is not located at the default
location (0xFF80–0xFFF9).
2.Enable Ibit maskable interrupts by clearing the Ibit in the CCR.
3.Enable the Xbit maskable interrupt by clearing the Xbit in the CCR.
6.5.2Interrupt Nesting
The interrupt request scheme makes it possible to nest Ibit maskable interrupt requests handled by the
CPU.
•Ibit maskable interrupt requests can be interrupted by an interrupt request with a higher priority.
Ibit maskable interrupt requests cannot be interrupted by other Ibit maskable interrupt requests per
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
If the X bit maskable interrupt request is used to wake-up the MCU with the X bit in the CCR set, the
care must be taken that the X interrupt request used for wake-up remains active at least until the system
begins execution of the instruction following the WAI or STOP instruction; otherwise, wake-up may not
occur.
Interrupt Module (S12SINTV1)
MC9S12G Family Reference Manual,Rev.1.06
254Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor255
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
the BDM of the S12 family with the following exceptions:
•TAGGO command not supported by S12SBDM
•External instruction tagging feature is part of the DBG module
•S12SBDM register map and register content modified
•Family ID readable from BDM ROM at global address 0x3_FF0F in active BDM
(value for devices with HCS12S core is 0xC2)
•Clock switch removed from BDM (CLKSW bit removed from BDMSTS register)
7.1.1Features
The BDM includes these distinctive features:
•Single-wire communication with host development system
•Enhanced capability for allowing more flexibility in clock rates
•SYNC command to determine communication rate
Revision NumberDateSections
AffectedSummary of Changes
1.0314.May.2009Internal Conditional text only
1.0430.Nov.2009Internal Conditional text only
1.0507.Dec.2010Standardized format of revision history table header.
1.0602.Mar.20117.3.2.2/7-261
7.2/7-257
Corrected BPAE bit description.
Removed references to fixed VCO frequencies
Background Debug Module (S12SBDMV1)
MC9S12G Family Reference Manual,Rev.1.06
256Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•GO_UNTIL command
•Hardware handshake protocol to increase the performance of the serial communication
•Active out of reset in special single chip mode
•Nine hardware commands using free cycles, if available, for minimal CPU intervention
•Hardware commands not requiring active BDM
•14 firmware commands execute from the standard BDM firmware lookup table
•Software control of BDM operation during wait mode
progress and disable the ACK function). The BDM is now ready to receive a new command.
Background Debug Module (S12SBDMV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor257
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
7.1.3Block Diagram
A block diagram of the BDM is shown inFigure7-1.
Figure7-1. BDM Block Diagram
7.2External Signal Description
A single-wire interface pin called the background debug interface (BKGD) pin is used to communicate
with the BDM system. During reset, this pin is a mode select input which selects between normal and
special modes of operation. After reset, this pin becomes the dedicated serial interface pin for the
the communication rate is adapted accordingly and a communication time-out (BDM soft reset) has
occurred.
7.3Memory Map and Register Definition
7.3.1Module Memory Map
Table7-2 shows the BDM memory map when BDM is active.
16-Bit Shift Register
BKGD
Host
SystemSerial
InterfaceData
Control
Register Block
Register
BDMSTS
Instruction Code
and
Execution
Standard BDM Firmware
LOOKUP TABLE
Secured BDM Firmware
LOOKUP TABLE
Bus Interface
and
Control Logic
Address
Data
Control
Clocks
BDMACT
TRACE
ENBDM
SDV
UNSEC
Background Debug Module (S12SBDMV1)
MC9S12G Family Reference Manual,Rev.1.06
258Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
7.3.2Register Descriptions
A summary of the registers associated with the BDM is shown inFigure7-2. Registers are accessed by
host-driven communications to the BDM hardware using READ_BD and WRITE_BD commands.
Table7-2. BDM Memory Map
Global AddressModuleSize
(Bytes)
0x3_FF00–0x3_FF0BBDM registers12
0x3_FF0C–0x3_FF0EBDM firmware ROM3
0x3_FF0FFamily ID (part of BDM firmware ROM)1
0x3_FF10–0x3_FFFFBDM firmware ROM240
Global
Address
Register
NameBit 7654321Bit 0
0x3_FF00ReservedRXXXXXX00
W
0x3_FF01BDMSTSRENBDMBDMACT0SDVTRACE0UNSEC0
W
0x3_FF02ReservedRXXXXXXXX
W
0x3_FF03ReservedRXXXXXXXX
W
0x3_FF04ReservedRXXXXXXXX
W
0x3_FF05ReservedRXXXXXXXX
W
0x3_FF06BDMCCRRCCR7CCR6CCR5CCR4CCR3CCR2CCR1CCR0
W
0x3_FF07ReservedR00000000
W
= Unimplemented, Reserved = Implemented (do not alter)
X = Indeterminate0 = Always read zero
Figure7-2. BDM Register Summary
Background Debug Module (S12SBDMV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor259
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
7.3.2.1BDM Status Register (BDMSTS)
Figure7-3. BDM Status Register(BDMSTS)
Read: All modes through BDM operation when not secured
Write: All modes through BDM operation when not secured, but subject to the following:
2UNSEC is read as 1 by a debugging environment in special single chip mode when the device is secured and fully erased,
else it is 0 and can only be read if not secure (see also bit description).
0
All Other Modes00000000
= Unimplemented, Reserved = Implemented (do not alter)
0 = Always read zero
Global
Address
Register
NameBit 7654321Bit 0
= Unimplemented, Reserved = Implemented (do not alter)
X = Indeterminate0 = Always read zero
Figure7-2. BDM Register Summary (continued)
Background Debug Module (S12SBDMV1)
MC9S12G Family Reference Manual,Rev.1.06
260Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
when the security byte in the Flash EEPROM is configured for unsecure mode.
Background Debug Module (S12SBDMV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor261
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure7-4. BDM CCR Holding Register (BDMCCR)
Read: All modes through BDM operation when not secured
Write: All modes through BDM operation when not secured
and WRITE_BD) can not be used for program page accesses even if the BPAE bit is set.
0BDM Program Paging disabled
1BDM Program Paging enabled
3–0
BPP[3:0]
BDM Program Page Index Bits 3–0— These bits define the selected program page. For more detailed
information regarding the program page window scheme, please refer to the S12S_MMC Block Guide.
Background Debug Module (S12SBDMV1)
MC9S12G Family Reference Manual,Rev.1.06
262Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
7.3.3Family ID Assignment
The family ID is an 8-bit value located in the BDM ROM in active BDM (at global address: 0x3_FF0F).
The read-only value is a unique family ID which is 0xC2 for devices with an HCS12S core.
7.4Functional Description
The BDM receives and executes commands from a host via a single wire serial interface. There are two
types of BDM commands: hardware and firmware commands.
Hardware commands are used to read and write target system memory locations and to enter active
background debug mode, seeSection7.4.3, “BDM Hardware Commands”. Target system memory
includes all memory that is accessible by the CPU.
only after being enabled. BDM is enabled by setting the ENBDM bit in the BDM status (BDMSTS)
register. The ENBDM bit is set by writing to the BDM status (BDMSTS) register, via the single-wire
interface, using a hardware command such as WRITE_BD_BYTE.
After being enabled, BDM is activated by one of the following1:
1.BDM is enabled and active immediately out of special single-chip reset.
Background Debug Module (S12SBDMV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor263
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
enabled just for the READ_BD and WRITE_BD access cycle. This allows the BDM to access BDM
locations unobtrusively, even if the addresses conflict with the application memory map.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The GO_UNTIL command will not get an Acknowledge if CPU executes the wait or stop instruction before the “UNTIL”
condition (BDM active again) is reached (seeSection7.4.7, “Serial Interface Hardware Handshake Protocol”last note).
0CnoneGo to user program. If enabled, ACK will occur upon returning to active
background mode.
TRACE110noneExecute one user instruction then return to active BDM. If enabled,
ACK will occur upon returning to active background mode.
TAGGO -> GO18none(Previous enable tagging and go to user program.)
This command will be deprecated and should not be used anymore.
Opcode will be executed as a GO command.
Background Debug Module (S12SBDMV1)
MC9S12G Family Reference Manual,Rev.1.06
266Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16-bit misaligned reads and writes are generally not allowed. If attempted
by BDM hardware command, the BDM ignores the least significant bit of
the address and assumes an even address from the remaining bits.
in the high state. The time for an 8-bit command is 8× 16 target clock cycles.1
1.Target clock cycles are cycles measured using the target MCU’s serial clock rate. SeeSection7.4.6, “BDM Serial Interface”
andSection7.3.2.1, “BDM Status Register (BDMSTS)” for information on how serial clock rate is selected.
Background Debug Module (S12SBDMV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor267
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
earlier. Synchronization between the host and target is established in this manner at the start of every bit
time.
Figure7-7 shows an external host transmitting a logic 1 and transmitting a logic 0 to the BKGD pin of a
target system. The host is asynchronous to the target, so there is up to a one clock-cycle delay from the
host-generated falling edge to where the target recognizes this edge as the beginning of the bit time. Ten
target clock cycles later, the target senses the bit level on the BKGD pin. Internal glitch detect logic
requires the pin be driven high no later that eight target clock cycles after the falling edge for a logic 1
perceived start of the bit time. The host should sample the bit level about 10 target clock cycles after it
started the bit time.
Target Senses Bit
10 Cycles
Synchronization
Uncertainty
BDM Clock
(Target MCU)
Host
Transmit 1
Host
Transmit 0
Perceived
Start of Bit TimeEarliest
Start of
Next Bit
Background Debug Module (S12SBDMV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor269
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure7-8. BDM Target-to-Host Serial Bit Timing (Logic 1)
Figure7-9. BDM Target-to-Host Serial Bit Timing (Logic 0)
High-Impedance
Earliest
Start of
Next Bit
R-C Rise
10 Cycles
10 Cycles
Host Samples
BKGD Pin
Perceived
Start of Bit Time
BKGD Pin
BDM Clock
(Target MCU)
Host
Drive to
BKGD Pin
Target System
Speedup
Pulse
High-Impedance
High-Impedance
Earliest
Start of
Next Bit
BDM Clock
(Target MCU)
Host
Drive to
BKGD Pin
BKGD Pin
Perceived
Start of Bit Time
10 Cycles
10 Cycles
Host Samples
BKGD Pin
Target System
Drive and
Speedup Pulse
Speedup Pulse
High-Impedance
Background Debug Module (S12SBDMV1)
MC9S12G Family Reference Manual,Rev.1.06
270Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
hardware command, the ACK pulse will not be issued meaning that the
BDM command was not executed. After entering wait or stop mode, the
BDM command is no longer pending.
16 Cycles
BDM Clock
(Target MCU)
Target
Transmits
ACK Pulse
High-Impedance
BKGD Pin
Minimum Delay
From the BDM Command
32 Cycles
Earliest
Start of
Next Bit
Speedup Pulse
16th Tick of the
Last Command Bit
High-Impedance
Background Debug Module (S12SBDMV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor271
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Therefore, the command is not acknowledged by the target, which means that the ACK pulse will not be
issued in this case. After a certain time the host (not aware of stop or wait) should decide to abort any
possible pending ACK pulse in order to be sure a new command can be issued. Therefore, the protocol
provides a mechanism in which a command, and its corresponding ACK, can be aborted.
READ_BYTE
BDM Issues the
BKGD PinByte Address
BDM Executes the
READ_BYTE Command
HostTarget
HostTarget
BDM Decodes
the Command
ACK Pulse (out of scale)
HostTarget
(2) Bytes are
Retrieved
New BDM
Command
Background Debug Module (S12SBDMV1)
MC9S12G Family Reference Manual,Rev.1.06
272Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
for the reader to better understand the BDM internal behavior. It is not
recommended that this procedure be used in a real application.
Background Debug Module (S12SBDMV1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor273
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Since the host knows the target serial clock frequency, the SYNC command (used to abort a command)
does not need to consider the lower possible target frequency. In this case, the host could issue a SYNC
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
7.4.9SYNC — Request Timed Reference Pulse
The SYNC command is unlike other BDM commands because the host does not necessarily know the
tracing through the user code one instruction at a time.
Background Debug Module (S12SBDMV1)
MC9S12G Family Reference Manual,Rev.1.06
276Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
handshake protocol is enabled, the time out between a read command and the data retrieval is disabled.
Therefore, the host could wait for more then 512 serial clock cycles and still be able to retrieve the data
from an issued read command. However, once the handshake pulse (ACK pulse) is issued, the time-out
feature is re-activated, meaning that the target will time out after 512 clock cycles. Therefore, the host
target as the start of a new BDM command, or the start of a SYNC request pulse.
Background Debug Module (S12SBDMV1)
MC9S12G Family Reference Manual,Rev.1.06
278Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor279
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter8
S12S Debug Module (S12SDBG)
Revision History
8.1Introduction
The S12SDBG module provides an on-chip trace buffer with flexible triggering capability to allow
non-intrusive debug of application software. The S12SDBG module is optimized for S12SCPU
debugging.
Typically the S12SDBG module is used in conjunction with the S12SBDM module, whereby the user
configures the S12SDBG module for a debugging session over the BDM interface. Once configured the
S12SDBG module is armed and the device leaves BDM returning control to the user program, which is
then monitored by the S12SDBG module. Alternatively the S12SDBG module can be configured over a
02.0417.OCT.2007Reverted to final state transition priority
02.0519.OCT.2007Table8-33 DB byte access configuration corrected
02.0622.NOV.2007
Table8-39 Correction
Section8.4.5.6, “Trace Buffer Reset State Added NOTE
02.0713.DEC.2007Section8.5, “Application Information Added application
information
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual,Rev.1.06
280Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
BDM: Background Debug Mode
S12SBDM: Background Debug Module
DUG: Device User Guide, describing the features of the device into which the DBG is integrated.
standard 16-bit word reads. Tracing is disabled when the MCU system is secured.
8.1.3Features
•Three comparators (A, B and C)
—Comparators A compares the full address bus and full 16-bit data bus
—Comparator A features a data bus mask register
—Comparators B and C compare the full address bus only
—Each comparator features selection of read or write access cycles
—Comparator B allows selection of byte or word access cycles
—Comparator matches can initiate state sequencer transitions
•Three comparator modes
—Simple address/data comparator match mode
—Inside address range mode, Addmin≤ Address≤Addmax
—Outside address range match mode, Address<Addminor Address> Addmax
•Two types of matches
—Tagged — This matches just before a specific instruction begins execution
—Force — This is valid on the first instruction boundary after a match occurs
•Two types of breakpoints
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor281
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
the CPU enters active BDM Mode through a BACKGROUND command, the DBG module, if already
armed, remains armed.
The DBG module tracing is disabled if the MCU is secure, however, breakpoints can still be generated
Table8-1. Mode Dependent Restriction Summary
BDM
Enable
BDM
Active
MCU
Secure
Comparator
Matches Enabled
Breakpoints
Possible
Tagging
Possible
Tracing
Possible
xx1YesYesYesNo
000YesOnly SWIYesYes
010 Active BDM not possible when not enabled
100YesYesYesYes
110NoNoNoNo
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual,Rev.1.06
282Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
8.1.5Block Diagram
Figure8-1. Debug Module Block Diagram
8.2External Signal Description
There are no external signals associated with this module.
8.3Memory Map and Registers
8.3.1Module Memory Map
A summary of the registers associated with the DBG sub-block is shown inFigure8-2. Detailed
descriptions of the registers and bits are given in the subsections that follow.
AddressNameBit 7654321Bit 0
0x0020DBGC1RARM00
BDMDBGBRK0COMRV
WTRIG
0x0021DBGSRR1TBF0000SSF2SSF1SSF0
W
0x0022DBGTCRR0TSOURCE00TRCMOD0TALIGN
W
0x0023DBGC2R000000ABCM
W
Figure8-2. Quick Reference to DBG Registers
CPU BUS
TRACE BUFFER
BUS INTERFACE
TRANSITION
MATCH0
STATE
COMPARATOR B
COMPARATOR C
COMPARATOR A
STATE SEQUENCER
MATCH1
MATCH2
TRACE
READ TRACE DATA (DBG READ DATA BUS)
CONTROL
SECURE
BREAKPOINTREQUESTS
COMPARATOR
MATCH CONTROL
TRIGGER
TAG &
MATCH
CONTROL
LOGIC
TAGS
TAGHITS
STATE
TO CPU
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor283
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
8.3.2Register Descriptions
This section consists of the DBG control and trace buffer register descriptions in address order. Each
2This represents the contents if the Comparator A control register is blended into this address.
3This represents the contents if the Comparator B control register is blended into this address
4This represents the contents if the Comparator C control register is blended into this address
AddressNameBit 7654321Bit 0
Figure8-2. Quick Reference to DBG Registers
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual,Rev.1.06
284Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
8.3.2.1Debug Control Register 1 (DBGC1)
Read: Anytime
Write: Bits 7, 1, 0 anytime
Bit 6 can be written anytime but always reads back as 0.
of the tracing session. If tracing is not enabled, the breakpoint is generated immediately.
0No Breakpoint generated
1Breakpoint generated
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor285
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
sequencer enters state1 and these bits are forced to SSF[2:0] = 001. SeeTable8-5.
Table8-2. DBGC1 Field Descriptions
FieldDescription
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual,Rev.1.06
286Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
8.3.2.3Debug Trace Control Register (DBGTCR)
Read: Anytime
Write: Bit 6 only when DBG is neither secure nor armed.Bits 3,2,0 anytime the module is disarmed.
Table8-5. SSF[2:0] — State Sequence Flag Bit Encoding
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
8.3.2.4Debug Control Register2 (DBGC2)
Read: Anytime
Write: Anytime the module is disarmed.
This register configures the comparators for range matching.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
8.3.2.7Debug State Control Registers
There is a dedicated control register for each of the state sequencer states 1 to 3 that determines if
transitions from that state are allowed, depending upon comparator matches or tag hits, and defines the
This register is visible at 0x0027 only with COMRV[1:0] = 00. The state control register 1 selects the
targeted next state whilst in State1. The matches refer to the match channels of the comparator match
0000001
000010
000100
000110
..
111111
1 line valid
2 lines valid
4 lines valid
6 lines valid
..
63 lines valid
100000064 lines valid; if using Begin trigger alignment,
ARM bit will be cleared and the tracing session ends.
1000001
..
..
111110
64 lines valid,
oldest data has been overwritten by most recent data
Table8-13. State Control Register Access Encoding
COMRVVisible State Control Register
00 DBGSCR1
01 DBGSCR2
10 DBGSCR3
11 DBGMFR
Address: 0x0027
76543210
R0000
SC3SC2SC1SC0
W
Reset00000000
= Unimplemented or Reserved
Figure8-9. Debug State Control Register 1 (DBGSCR1)
Table8-12. CNT Decoding Table
TBFCNT[5:0]Description
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual,Rev.1.06
290Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
final state has priority followed by the match on the lower channel number (0,1,2). Thus with
SC[3:0]=1101 a simultaneous match0/match1 transitions to final state.
8.3.2.7.2Debug State Control Register 2 (DBGSCR2)
Read: If COMRV[1:0] = 01
Write: If COMRV[1:0] = 01 and DBG is not armed.
Table8-14. DBGSCR1 Field Descriptions
FieldDescription
3–0
SC[3:0]
These bits select the targeted next state whilst in State1, based upon the match event.
Table8-15. State1 Sequencer Next State Selection
SC[3:0]Description (Unspecified matches have no effect)
0000Any match to Final State
0001 Match1 to State3
0010Match2 to State2
0011Match1 to State2
0100Match0 to State2....... Match1 to State3
0101 Match1 to State3.........Match0 to Final State
0110Match0 to State2....... Match2 to State3
0111 Either Match0 or Match1 to State2
1000Reserved
1001 Match0 to State3
1010Reserved
1011Reserved
1100Reserved
1101Either Match0 or Match2 to Final State........Match1 to State2
1110Reserved
1111Reserved
Address: 0x0027
76543210
R0000
SC3SC2SC1SC0
W
Reset00000000
= Unimplemented or Reserved
Figure8-10. Debug State Control Register 2 (DBGSCR2)
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor291
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This register is visible at 0x0027 only with COMRV[1:0] = 01. The state control register 2 selects the
targeted next state whilst in State2. The matches refer to the match channels of the comparator match
control logic as depicted inFigure8-1 and described inSection8.3.2.8.1, “Debug Comparator Control
final state has priority followed by the match on the lower channel number (0,1,2)
8.3.2.7.3Debug State Control Register 3 (DBGSCR3)
Read: If COMRV[1:0] = 10
Table8-16. DBGSCR2 Field Descriptions
FieldDescription
3–0
SC[3:0]
These bits select the targeted next state whilst in State2, based upon the match event.
Table8-17. State2 —Sequencer Next State Selection
SC[3:0]Description (Unspecified matches have no effect)
0000Match0 to State1....... Match2 to State3.
0001Match1 to State3
0010Match2 to State3
0011Match1 to State3....... Match0 Final State
0100Match1 to State1....... Match2 to State3.
0101Match2 to Final State
0110Match2 to State1..... Match0 to Final State
0111Either Match0 or Match1 to Final State
1000Reserved
1001Reserved
1010Reserved
1011Reserved
1100Either Match0 or Match1 to Final State........Match2 to State3
1101Reserved
1110Reserved
1111Either Match0 or Match1 to Final State........Match2 to State1
Address: 0x0027
76543210
R0000
SC3SC2SC1SC0
W
Reset00000000
= Unimplemented or Reserved
Figure8-11. Debug State Control Register 3 (DBGSCR3)
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual,Rev.1.06
292Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
final state has priority followed by the match on the lower channel number (0,1,2).
8.3.2.7.4Debug Match Flag Register (DBGMFR)
Table8-18. DBGSCR3 Field Descriptions
FieldDescription
3–0
SC[3:0]
These bits select the targeted next state whilst in State3, based upon the match event.
Table8-19. State3 — Sequencer Next State Selection
SC[3:0]Description (Unspecified matches have no effect)
0000Match0 to State1
0001 Match2 to State2........ Match1 to Final State
0010Match0 to Final State....... Match1 to State1
0011Match1 to Final State....... Match2 to State1
0100 Match1 to State2
0101Match1 to Final State
0110Match2 to State2........ Match0 to Final State
0111Match0 to Final State
1000Reserved
1001Reserved
1010Either Match1 or Match2 to State1....... Match0 to Final State
1011Reserved
1100Reserved
1101Either Match1 or Match2 to Final State....... Match0 to State1
1110Match0 to State2....... Match2 to Final State
1111Reserved
Address: 0x0027
76543210
R00000MC2MC1MC0
W
Reset00000000
= Unimplemented or Reserved
Figure8-12. Debug Match Flag Register (DBGMFR)
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor293
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Read: If COMRV[1:0] = 11
Write: Never
DBGMFR is visible at 0x0027 only with COMRV[1:0] = 11. It features 3 flag bits each mapped directly
to a channel. Should a match occur on the channel during the debug session, then the corresponding flag
register bytes (three address bus compare registers and a control register).
Each set of comparator registers can be accessed using the COMRV bits in the DBGC1 register.
Unimplemented registers (e.g. Comparator B data bus and data bus masking) read as zero and cannot be
written. The control register for comparator B differs from those of comparators A and C.
8.3.2.8.1Debug Comparator Control Register (DBGXCTL)
The contents of this register bits 7 and 6 differ depending upon which comparator registers are visible in
the 8-byte window of the DBG module register address map.
Table8-20. Comparator Register Layout
0x0028CONTROLRead/WriteComparators A,B and C
0x0029ADDRESS HIGHRead/WriteComparators A,B and C
0x002AADDRESS MEDIUMRead/WriteComparators A,B and C
0x002BADDRESS LOWRead/WriteComparators A,B and C
0x002CDATA HIGH COMPARATORRead/WriteComparator A only
0x002DDATA LOW COMPARATORRead/WriteComparator A only
0x002EDATA HIGH MASKRead/WriteComparator A only
0x002FDATA LOW MASKRead/WriteComparator A only
Address: 0x0028
76543210
RSZESZTAGBRKRWRWENDBCOMPE
W
Reset00000000
= Unimplemented or Reserved
Figure8-13. Debug Comparator Control Register DBGACTL (Comparator A)
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual,Rev.1.06
294Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Read: DBGACTL if COMRV[1:0] = 00
DBGBCTL if COMRV[1:0] = 01
DBGCCTL if COMRV[1:0] = 10
Write: DBGACTL if COMRV[1:0] = 00 and DBG not armed
DBGBCTL if COMRV[1:0] = 01 and DBG not armed
DBGCCTL if COMRV[1:0] = 10 and DBG not armed
Address: 0x0028
76543210
RSZESZTAGBRKRWRWE0COMPE
W
Reset00000000
= Unimplemented or Reserved
Figure8-14. Debug Comparator Control Register DBGBCTL (Comparator B)
Address: 0x0028
76543210
R00TAGBRKRWRWE0COMPE
W
Reset00000000
= Unimplemented or Reserved
Figure8-15. Debug Comparator Control Register DBGCCTL (Comparator C)
Table8-21. DBGXCTL Field Descriptions
FieldDescription
7
SZE
(Comparators
A and B)
Size Comparator Enable Bit— The SZE bit controls whether access size comparison is enabled for the
associated comparator. This bit is ignored if the TAG bit in the same register is set.
0Word/Byte access size is not used in comparison
1Word/Byte access size is used in comparison
6
SZ
(Comparators
A and B)
Size Comparator Value Bit— The SZ bit selects either word or byte access size in comparison for the
of state sequencer state. To generate an immediate breakpoint the module breakpoints must be enabled
using the DBGC1 bit DBGBRK.
0The debug session termination is dependent upon the state sequencer and trigger conditions.
1A match on this channel terminates the debug session immediately; breakpoints if active are generated,
tracing, if active, is terminated and the module disarmed.
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor295
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
register is set. This bit is only available for comparator A.
0Match on data bus equivalence to comparator register contents
1Match on data bus difference to comparator register contents
0
COMPE
Determines if comparator is enabled
0The comparator is not enabled
1The comparator is enabled
Table8-22. Read or Write Comparison Logic Table
RWE BitRW BitRW SignalComment
0x0RW not used in comparison
0x1RW not used in comparison
100Write data bus
101No match
110No match
111Read data bus
Address: 0x0029
76543210
R000000
Bit 17Bit 16
W
Reset00000000
= Unimplemented or Reserved
Figure8-16. Debug Comparator Address High Register (DBGXAH)
Table8-21. DBGXCTL Field Descriptions
FieldDescription
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual,Rev.1.06
296Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table8-23. Comparator Address Register Visibility
Read: Anytime. SeeTable8-23 for visible register encoding.
Write: If DBG not armed. SeeTable8-23 for visible register encoding.
Comparator Address Mid Compare Bits— The Comparator address mid compare bits control whether the
selected comparator compares the address bus bits [15:8] to a logic one or logic zero.
0Compare corresponding address bit to a logic zero
1Compare corresponding address bit to a logic one
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor297
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
only used in comparison if the corresponding data mask bit is logic 1. This register is available only for
comparator A. Data bus comparisons are only performed if the TAG bit in DBGACTL is clear.
0Compare corresponding data bit to a logic zero
1Compare corresponding data bit to a logic one
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual,Rev.1.06
298Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
8.3.2.8.6Debug Comparator Data Low Register (DBGADL)
Read: If COMRV[1:0] = 00
Write: If COMRV[1:0] = 00 and DBG not armed.
8.3.2.8.7Debug Comparator Data High Mask Register (DBGADHM)
Read: If COMRV[1:0] = 00
Write: If COMRV[1:0] = 00 and DBG not armed.
Address: 0x002D
76543210
RBit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
W
Reset00000000
Figure8-20. Debug Comparator Data Low Register (DBGADL)
only used in comparison if the corresponding data mask bit is logic 1. This register is available only for
comparator A. Data bus comparisons are only performed if the TAG bit in DBGACTL is clear
0Compare corresponding data bit to a logic zero
1Compare corresponding data bit to a logic one
Address: 0x002E
76543210
RBit 15Bit 14Bit 13Bit 12Bit 11Bit 10Bit 9Bit 8
W
Reset00000000
Figure8-21. Debug Comparator Data High Mask Register (DBGADHM)
Table8-29. DBGADHM Field Descriptions
FieldDescription
7–0
Bits[15:8]
Comparator Data High Mask Bits— The Comparator data high mask bits control whether the selected
comparator compares the data bus bits [15:8] to the corresponding comparator data compare bits. Data bus
comparisons are only performed if the TAG bit in DBGACTL is clear
0Do not compare corresponding data bit Any value of corresponding data bit allows match.
1Compare corresponding data bit
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor299
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
8.3.2.8.8Debug Comparator Data Low Mask Register (DBGADLM)
Figure8-22. Debug Comparator Data Low Mask Register (DBGADLM)
Table8-30. DBGADLM Field Descriptions
FieldDescription
7–0
Bits[7:0]
Comparator Data Low Mask Bits— The Comparator data low mask bits control whether the selected
comparator compares the data bus bits [7:0] to the corresponding comparator data compare bits. Data bus
comparisons are only performed if the TAG bit in DBGACTL is clear
0Do not compare corresponding data bit. Any value of corresponding data bit allows match
1Compare corresponding data bit
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual,Rev.1.06
300Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
If the TAG bit is clear (forced type match) a comparator match is generated when the selected address
appears on the system address bus. If the selected address is an opcode address, the match is generated
CPU BUS
TRACE BUFFER
BUS INTERFACE
TRANSITION
MATCH0
STATE
COMPARATOR B
COMPARATOR C
COMPARATOR A
STATE SEQUENCER
MATCH1
MATCH2
TRACE
READ TRACE DATA (DBG READ DATA BUS)
CONTROL
SECURE
BREAKPOINTREQUESTS
COMPARATOR
MATCH CONTROL
TRIGGER
TAG &
MATCH
CONTROL
LOGIC
TAGS
TAGHITS
STATE
TO CPU
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor301
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
when the opcode is fetched from the memory, which precedes the instruction execution by an indefinite
number of cycles due to instruction pipelining. For a comparator match of an opcode at an odd address
Condition For Valid MatchCompCAddressRWERWExamples
Read and write accesses of ADDR[n]ADDR[n]1
1A word access of ADDR[n-1] also accesses ADDR[n] but does not generate a match.
The comparator address register must contain the exact address from the code.
0XLDAA ADDR[n]
STAA #$BYTE ADDR[n]
Write accesses of ADDR[n]ADDR[n]10STAA #$BYTE ADDR[n]
Read accesses of ADDR[n]ADDR[n]11LDAA #$BYTE ADDR[n]
Table8-32. Comparator B Access Size Considerations
Condition For Valid MatchCompBAddressRWESZESZ8Examples
Word and byte accesses of ADDR[n]ADDR[n]100XMOVB #$BYTE ADDR[n]
MOVW #$WORD ADDR[n]
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual,Rev.1.06
302Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Access direction can also be used to qualify a match for Comparator B in the same way as described for
Comparator C inTable8-31.
8.4.2.1.3Comparator A
Comparator A offers address, direction (R/W), access size (word/byte) and data bus comparison.
Table8-33 lists access considerations with data bus comparison. On word accesses the data byte of the
lower address is mapped to DBGADH. Access direction can also be used to qualify a match for
Comparator A in the same way as described for Comparator C inTable8-31.
Table8-33. Comparator A Matches When Accessing ADDR[n]
8.4.2.1.4Comparator A Data Bus Comparison NDB Dependency
0X$FFFFByte, data(ADDR[n])=DH, data(ADDR[n+1])=DLPossible unintended match
10$0000WordNo databus comparison
10$00FFWord, data(ADDR[n])=X, data(ADDR[n+1])=DLMatch only data at ADDR[n+1]
10$FF00Word, data(ADDR[n])=DH, data(ADDR[n+1])=XMatch only data at ADDR[n]
10$FFFFWord, data(ADDR[n])=DH, data(ADDR[n+1])=DLMatch data at ADDR[n] & ADDR[n+1]
11$0000ByteNo databus comparison
11$FF00Byte, data(ADDR[n])=DHMatch data at ADDR[n]
Table8-32. Comparator B Access Size Considerations
Condition For Valid MatchCompBAddressRWESZESZ8Examples
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor303
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
match occurs when all data bus bits with corresponding mask bits set are equivalent. If all mask register
bits are clear, then a match is based on the address bus only, the data bus is ignored.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
pointing to final state has highest priority followed by the lower channel number (0,1,2).
Table8-35. Channel Priorities
PrioritySourceAction
HighestTRIGEnter Final State
Channel pointing to Final StateTransition to next state as defined by state control registers
Match0 (force or tag hit)Transition to next state as defined by state control registers
Match1 (force or tag hit)Transition to next state as defined by state control registers
LowestMatch2 (force or tag hit)Transition to next state as defined by state control registers
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor305
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
of flow instruction, the trigger event is not stored in the Trace Buffer.
8.4.5.2Trace Modes
Four trace modes are available. The mode is selected using the TRCMOD bits in the DBGTCR register.
Tracing is enabled using the TSOURCE bit in the DBGTCR register. The modes are described in the
following subsections.
8.4.5.2.1Normal Mode
In Normal Mode, change of flow (COF) program counter (PC) addresses are stored.
COF addresses are defined as follows:
•Source address of taken conditional branches (long, short, bit-conditional, and loop primitives)
•Destination address of indexed JMP, JSR, and CALL instruction
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor307
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Destination address of RTI, RTS, and RTC instructions
•Vector address of interrupts, except for BDM vectors
The execution flow taking into account the IRQ is as follows
LDX#SUB_1
MARK1JMP0,X;
IRQ_ISRLDAB#$F0;
STABVAR_C1
RTI;
SUB_1BRN*
NOP;
ADDR1DBNEA,PART5;
8.4.5.2.2Loop1 Mode
Loop1 Mode, similarly to Normal Mode also stores only COF address information to the trace buffer, it
however allows the filtering out of redundant information.
The intent of Loop1 Mode is to prevent the Trace Buffer from being filled entirely with duplicate
information from a looping construct such as delays using the DBNE instruction or polling loops using
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual,Rev.1.06
308Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
BRSET/BRCLR instructions. Immediately after address information is placed in the Trace Buffer, the
DBG module writes this value into a background register. This prevents consecutive duplicate address
entries in the Trace Buffer resulting from repeated branches.
Loop1 Mode only inhibits consecutive duplicate source address entries that would typically be stored in
most tight looping constructs. It does not inhibit repeated entries of destination addresses or vector
trace buffer byte1 and the byte at the higher address is stored to byte0.
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor309
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
8.4.5.3.1Information Bit Organization
The format of the bits is dependent upon the active trace mode as described below.
Field2 Bits in Detail Mode
In Detail Mode the CSZ and CRW bits indicate the type of access being made by the CPU.
Access Type Indicator— This bit indicates if the access was a byte or word size when tracing in Detail Mode
0Word Access
1Byte Access
2
CRW
Read Write Indicator— This bit indicates if the corresponding stored address corresponds to a read or write
access when tracing in Detail Mode.
0Write Access
1Read Access
1
ADDR[17]
Address Bus bit 17— Corresponds to system address bus bit 17.
0
ADDR[16]
Address Bus bit 16— Corresponds to system address bus bit 16.
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual,Rev.1.06
310Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Field2 Bits in Normal and Loop1 Modes
8.4.5.4Trace Buffer Organization (Compressed Pure PC mode)
Table8-39. Trace Buffer Organization Example (Compressed PurePC mode)
Bit 3Bit 2Bit 1Bit 0
CSDCVAPC17PC16
Figure8-26. Information Bits PCH
Table8-38. PCH Field Descriptions
BitDescription
3
CSD
Source Destination Indicator— In Normal and Loop1 mode this bit indicates if the corresponding stored
address is a source or destination address. This bit has no meaning in Compressed Pure PC mode.
This bit has no meaning in Compressed Pure PC mode .
0Non-Vector Destination Address
1Vector Destination Address
1
PC17
Program Counter bit 17— In Normal and Loop1 mode this bit corresponds to program counter bit 17.
0
PC16
Program Counter bit 16— In Normal and Loop1 mode this bit corresponds to program counter bit 16.
ModeLine
Number
2-bits6-bits6-bits6-bits
Field 3Field 2Field 1Field 0
Compressed
PurePCMode
Line 100PC1 (Initial 18-bit PC Base Address)
Line 211PC4PC3PC2
Line 30100PC5
Line 400PC6 (New 18-bit PC Base Address)
Line 5100PC8PC7
Line 600PC9 (New 18-bit PC Base Address)
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor311
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Field3 Bits in Compressed Pure PC Modes
Each time that PC[17:6] differs form the previous base PC[17:6], then a new base address is stored. The
base address zero value is the lowest address in the 64 address range
The first line of the trace buffer always gets a base PC address, this applies also on rollover.
Table8-40. Compressed Pure PC Mode Field 3 Information Bit Encoding
INF1INF0TRACE BUFFER ROW CONTENT
00Base PC address TB[17:0] contains a full PC[17:0] value
01Trace Buffer[5:0] contain incremental PC relative to base address zero value
10Trace Buffer[11:0] contain next 2 incremental PCs relative to base address zero value
11Trace Buffer[17:0] contain next 3 incremental PCs relative to base address zero value
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual,Rev.1.06
312Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
ta type of access. Thus these bits are ignored if tagging is selected.
When configured for range comparisons and tagging, the ranges are accurate only to word boundaries.
Tagging is disabled when the BDM becomes active.
8.4.7Breakpoints
It is possible to generate breakpoints from channel transitions to final state or using software to write to
the TRIG bit in the DBGC1 register.
8.4.7.1Breakpoints From Comparator Channels
Breakpoints can be generated when the state sequencer transitions to the Final State. If configured for
tagging, then the breakpoint is generated when the tagged opcode reaches the execution stage of the
instruction queue.
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor313
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
If a tracing session is selected by the TSOURCE bit, breakpoints are requested when the tracing session
the breakpoint gives priority to BDM requests over SWI requests if the breakpoint happens to coincide
with a SWI instruction in user code. On returning from BDM, the SWI from user code gets executed.
Table8-41. Breakpoint Setup For CPU Breakpoints
BRKTALIGNDBGBRKBreakpoint Alignment
000Fill Trace Buffer until trigger then disarm (no breakpoints)
001Fill Trace Buffer until trigger, then breakpoint request occurs
010Start Trace Buffer at trigger (no breakpoints)
011Start Trace Buffer at trigger
A breakpoint request occurs when Trace Buffer is full
1x1Terminate tracing and generate breakpoint immediately on trigger
1x0Terminate tracing immediately on trigger
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual,Rev.1.06
314Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
register. Thus the existing encoding for SCRx[2:0] is not changed.
Table8-42. Breakpoint Mapping Summary
DBGBRKBDM Bit
(DBGC1[4])
BDM
Enabled
BDM
Active
Breakpoint
Mapping
0XXXNo Breakpoint
10X0Breakpoint to SWI
XX11No Breakpoint
110XBreakpoint to SWI
1110Breakpoint to BDM
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor315
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
8.5.2Scenario 1
A trigger is generated if a given sequence of 3 code events is executed.
Figure8-27. Scenario 1
Scenario 1 is possible with S12SDBGV1 SCR encoding
8.5.3Scenario 2
A trigger is generated if a given sequence of 2 code events is executed.
into a range (COMPA,COMPB configured for range mode)
Figure8-30. Scenario 2c
All 3 scenarios 2a,2b,2c are possible with the S12SDBGV1 SCR encoding
State1Final State
State3
State2
SCR1=0011SCR2=0010SCR3=0111
M1M2M0
State1Final State
State2
SCR1=0011SCR2=0101
M1M2
State1Final State
State2
SCR1=0111SCR2=0101
M01M2
State1Final State
State2
SCR1=0010SCR2=0011
M2M0
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual,Rev.1.06
316Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
8.5.4Scenario 3
A trigger is generated immediately when one of up to 3 given events occurs
Figure8-31. Scenario 3
Scenario 3 is possible with S12SDBGV1 SCR encoding
and event B must be followed by event A. 2 consecutive occurances of event A without an intermediate
event B cause a trigger. Similarly 2 consecutive occurances of event B without an intermediate event A
cause a trigger. This is possible by using CompA and CompC to match on the same address as shown.
Figure8-32. Scenario 4a
This scenario is currently not possible using 2 comparators only. S12SDBGV2 makes it possible with 2
comparators, State 3 allowing a M0 to return to state 2, whilst a M2 leads to final state as shown.
Figure8-33. Scenario 4b (with 2 comparators)
The advantage of using only 2 channels is that now range comparisons can be included (channel0)
State1Final State
SCR1=0000
M012
State1
State 3Final State
State2
M0
M0
M2
M1
M1
M1
SCR1=0100
SCR2=0011
SCR3=0001
State1
State 3Final State
State2
M0
M01
M0
M2
M2
M2
SCR1=0110
SCR2=1100
SCR3=1110
M1 disabled in
range mode
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor317
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This however violates the S12SDBGV1 specification, which states that a match leading to final state
always has priority in case of a simultaneous match, whilst priority is also given to the lowest channel
number. For S12SDBG the corresponding CPU priority decoder is removed to support this, such that on
simultaneous taghits, taghits pointing to final state have highest priority. If no taghit points to final state
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
OR forks as shown in red this scenario is possible.
Figure8-36. Scenario 7
On simultaneous matches the lowest channel number has priority so with this configuration the forking
from State1 has the peculiar effect that a simultaneous match0/match1 transitions to final state but a
simultaneous match2/match1transitions to state2.
8.5.9Scenario 8
Trigger when a routine/event at M2 follows either M1 or M0.
Figure8-37. Scenario 8a
Trigger when an event M2 is followed by either event M0 or event M1
Figure8-38. Scenario 8b
Scenario 8a and 8b are possible with the S12SDBGV1 and S12SDBGV2 SCR encoding
State1Final State
State3
State2
SCR1=1101SCR2=1100SCR3=1101
M1M2M12
M0
M02
M01
State1Final State
State2
SCR1=0111SCR2=0101
M01M2
State1Final State
State2
SCR1=0010SCR2=0111
M2M01
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor319
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
in code, event M2 must always be followed by M1 before M0. If after any M2, event M0 occurs before
M1 then a trigger is generated.
State1Final State
State2
SCR1=0111SCR2=1111
M01M01
M2
State1Final State
State3
State2
SCR1=0010SCR2=0100SCR3=0010
M2M2M0
M1
M1
State1Final State
State3
State2
SCR1=0010SCR2=0011SCR3=0000
M2M1
M0
M0
S12S Debug Module (S12SDBG)
MC9S12G Family Reference Manual,Rev.1.06
320Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor321
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter9
Security (S12XS9SECV2)
9.1Introduction
This specification describes the function of the security mechanism in the MC9S12G-Family (9SEC).
of security. At the same time, the user may also wish to put a backdoor in the application program. An
example of this is the user downloads a security key through the SCI, which allows access to a
programming routine that updates parameters stored in another section of the Flash memory.
The security features of the MC9S12G-Family (in secure mode) are:
•Protect the content of non-volatile memories (Flash, EEPROM)
•Execution of NVM commands is restricted
•Disable access to internal memory via background debug module (BDM)
9.1.2Modes of Operation
Table9-2 gives an overview over availability of security relevant features in unsecure and secure modes.
Table9-1. Revision History
Revision
Number
Revision
Date
Sections
AffectedDescription of Changes
02.0027 Aug 2004reviewed and updated for S12XD architecture
02.0121 Feb 2007added S12XE, S12XF and S12XS architectures
02.0219 Apr 2007corrected statement about Backdoor key access via BDM on XE, XF, XS
Table9-2. Feature Availability in Unsecure and Secure Modes on S12XS
Unsecure ModeSecure Mode
NSSSNXESEXSTNSSSNXESEXST
Flash Array Access✔✔✔✔
Security (S12XS9SECV2)
MC9S12G Family Reference Manual,Rev.1.06
322Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
9.1.3Securing the Microcontroller
Once the user has programmed the Flash and EEPROM, the chip can be secured by programming the
security bits located in the options/security byte in the Flash memory array. These non-volatile bits will
keep the device secured through reset and power-down.
the device in secured state is the inverse of the unsecured state, i.e. SEC[1:0] = ‘01’.
EEPROM Array Access✔✔✔✔
NVM Commands✔1✔✔1✔1
BDM✔✔—✔2
DBG Module Trace✔✔——
1Restricted NVM command set only. Please refer to the NVM wrapper block guides for detailed information.
2BDM hardware commands restricted to peripheral registers only.
76543210
0xFF0FKEYEN1KEYEN0NV5NV4NV3NV2SEC1SEC0
Figure9-1. Flash Options/Security Byte
Table9-3. Backdoor Key Access Enable Bits
KEYEN[1:0]Backdoor Key
Access Enabled
000 (disabled)
010 (disabled)
101 (enabled)
110 (disabled)
Table9-2. Feature Availability in Unsecure and Secure Modes on S12XS
Unsecure ModeSecure Mode
NSSSNXESEXSTNSSSNXESEXST
Security (S12XS9SECV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor323
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NOTE
Please refer to the Flash block guide for actual security configuration (in
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
options/security byte is not protected (see Flash protection). Thus Flash protection is a useful means of
preventing this method. The microcontroller will enter the unsecured state after the next reset following
the programming of the security bits to the unsecured value.
This method requires that:
Security (S12XS9SECV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor325
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•The application software previously programmed into the microcontroller has been designed to
options/security byte to be programmed to the unsecured value. The security bits SEC[1:0] in the Flash
security register will indicate the unsecure state following the next reset.
Security (S12XS9SECV2)
MC9S12G Family Reference Manual,Rev.1.06
326Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor327
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter10
S12 Clock, Reset and Power Management Unit (S12CPMU)
Revision History
10.1Introduction
This specification describes the function of the Clock, Reset and Power Management Unit (S12CPMU).
•The Pierce oscillator (XOSCLCP) provides a robust, low-noise and low-power external clock
source. It is designed for optimal start-up margin with typical quartz crystals and ceramic
The Pierce Oscillator (XOSCLCP) contains circuitry to dynamically control current gain in the output
amplitude. This ensures a signal with low harmonic distortion, low power and good noise immunity.
•Supports quartz crystals or ceramic resonators from 4MHz to 16MHz.
•High noise immunity due to input hysteresis and spike filtering.
•Low RF emissions with peak-to-peak swing limited dynamically
Version
Number
Revision
Date
Effective
DateAuthorDescription of Changes
V04.0922 Jun 1022 Jun 10
Changed IP-Name from OSCLCP to XOSCLCP, added
OSCCLK_LCP clock name intoFigure10-1 andFigure10-2
updated description ofSection10.2.2, “EXTAL and XTAL.
V04.1001 Jul 1001 Jul 10Added TC trimming to feature list
V04.1123 Aug 1023 Aug 10Removedfeatureofadaptiveoscillatorfilter.Registerbits6and4to
0in the CPMUOSC register are marked reserved and do not alter.
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
328Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Transconductance (gm) sized for optimum start-up margin for typical crystals
•Dynamic gain control eliminates the need for external current limiting resistor
•Integrated resistor eliminates the need for external bias resistor.
The Voltage Regulator (IVREG) has the following features:
•Input voltage range from 3.13V to 5.5V
•Low-voltage detect (LVD) with low-voltage interrupt (LVI)
•Power-on reset (POR)
•Low-voltage reset (LVR)
The Phase Locked Loop (PLL) has the following features:
•highly accurate and phase locked frequency multiplier
•Configurable internal filter for best stability and lock time.
•Frequency modulation for defined jitter and reduced emission
•Automatic frequency lock detector
•Interrupt request on entry or exit from locked condition
•Reference clock either external (crystal) or internal square wave (1MHz IRC1M) based.
•PLL stability is sufficient for LIN communication, even if using IRC1M as reference clock
The Internal Reference Clock (IRC1M) has the following features:
•Frequency trimming
(A factory trim value for 1MHz is loaded from Flash Memory into the IRCTRIM register after
reset, which can be overwritten by application if required)
•Temperature Coefficient (TC) trimming.
(A factory trim value is loaded from Flash Memory into the IRCTRIM register to turned off TC
trimming after reset. Application can trim the TC if required by overwriting the IRCTRIM
register).
•
Other features of the S12CPMU include
•Clock monitor to detect loss of crystal
•Autonomous periodical interrupt (API)
•Bus Clock Generator
—Clock switch to select either PLLCLK or external crystal/resonator based Bus Clock
—PLLCLK divider to adjust system speed
•System Reset generation from the following possible sources:
—Power-on reset (POR)
—Low-voltage reset (LVR)
—Illegal address access
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor329
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
—COP time out
—Loss of oscillation (clock monitor fail)
—External pinRESET
10.1.2Modes of Operation
This subsection lists and briefly describes all operating modes supported by the S12CPMU.
10.1.2.1Run Mode
The voltage regulator is in Full Performance Mode (FPM).
The Phase Locked Loop (PLL) is on.
The Internal Reference Clock (IRC1M) is on.
The API is available.
•PLL Engaged Internal (PEI)
—This is the default mode after System Reset and Power-On Reset.
—The Bus Clock is based on the PLLCLK.
—After reset the PLL is configured for 50 MHz VCOCLK operation
make sure a valid PLL configuration is used for the selected oscillator frequency.
—This mode can be entered from default mode PEI by performing the following steps:
–Make sure the PLL configuration is valid for the selected oscillator frequency.
–Enable the external oscillator (OSCE bit)
–Wait for oscillator to start up (UPOSC=1)
–Select the Oscillator Clock (OSCCLK) as Bus Clock (PLLSEL=0).
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
330Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
—The PLLCLK is on and used to qualify the external oscillator clock.
10.1.2.2Wait Mode
For S12CPMU Wait Mode is the same as Run Mode.
10.1.2.3Stop Mode
This mode is entered by executing the CPU STOP instruction.
The voltage regulator is in Reduced Power Mode (RPM).
The API is available.
The Phase Locked Loop (PLL) is off.
The Internal Reference Clock (IRC1M) is off.
Core Clock, Bus Clock and BDM Clock are stopped.
Depending on the setting of the PSTP and the OSCE bit, Stop Mode can be differentiated between Full
Stop Mode (PSTP = 0 or OSCE=0) and Pseudo Stop Mode (PSTP = 1 and OSCE=1). In addition, the
behavior of the COP in each mode will change based on the clocking method selected by
COPOSCSEL[1:0].
•Full Stop Mode (PSTP = 0 or OSCE=0)
External oscillator (XOSCLCP) is disabled.
—If COPOSCSEL1=0:
The COP and RTI counters halt during Full Stop Mode.
After wake-up from Full Stop Mode the Core Clock and Bus Clock are running on PLLCLK
(PLLSEL=1). COP and RTI are running on IRCCLK (COPOSCSEL0=0, RTIOSCSEL=0).
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor331
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The COP will continue to run on ACLK.
The clock configuration bits PLLSEL, COPOSCSEL0, RTIOSCSEL are unchanged.
NOTE
When starting up the external oscillator (either by programming OSCE bit
oscillator tUPOSC before entering Pseudo Stop Mode.
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
332Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
10.1.3S12CPMU Block Diagram
Figure10-1. Block diagram of S12CPMU
S12CPMU
EXTAL
XTAL
System Reset
Power-On Detect
PLL Lock Interrupt
MMCIllegal Address Access
COP time out
Loop
Reference
Divider
COP
Watchdog
Voltage
VDDR
Internal
Reset
Generator
Divide by
Phase
Post
Divider
1,2,.,32
VCOCLK
ECLK2X
LOCKIE
IRCTRIM[9:0]
SYNDIV[5:0]
LOCK
REFDIV[3:0]
2*(SYNDIV+1)
Pierce
Oscillator
4MHz-16MHz
OSCE
ILAF
PORF
divide
by 2
ECLK
POSTDIV[4:0]
Power-On Reset
Controlled
locked
Loop with
internal
Filter (PLL)
REFCLK
FBCLK
REFFRQ[1:0]
VCOFRQ[1:0]
Lock
detect
Regulator
3.13 to 5.5V
Autonomous
Periodic
Interrupt (API)
API Interrupt
VDDA
VSSA
PLLSEL
(to MSCAN)
VDDX
VSSX
VSSLow Voltage Detect VDDX
LVRF
PLLCLK
Reference
divide
by 8BDM Clock
Clock
(IRC1M)
Clock
Monitor
monitor fail
Real Time
Interrupt (RTI)
RTI Interrupt
PSTP
CPMURTI
Oscillator status Interrupt
(XOSCLCP)
CAN_OSCCLK
Low Voltage Interrupt
ACLK
APICLK
RTICLK
IRCCLK
OSCCLK
RTIOSCSEL
CPMUCOP
COPCLK
IRCCLK
OSCCLK
COPOSCSEL0
to Reset
Generator
COP time out
PCE
PRE
UPOSC=0 sets PLLSEL bit
API_EXTCLK
RC
Osc.
VDD, VDDF
(core supplies)
UPOSC
RESET
OSCIE
APIE
RTIE
LVDSLVIE
Low Voltage Detect VDDA
UPOSC
UPOSC=0 clears
&
OSCCLK
divide
by 4
Bus Clock
IRCCLK
(to LCD)
ACLK
COPOSCSEL1
(Bus Clock)
(Core Clock)
OSCCLK_LCP
External
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor333
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure10-2 shows a block diagram of the XOSCLCP.
Figure10-2. XOSCLCP Block Diagram
10.2Signal Description
This section lists and describes the signals that connect off chip.
10.2.1RESET
PinRESET is an active-low bidirectional pin. As an input it initializes the MCU asynchronously to a
known start-up state. As an open-drain output it indicates that an MCU-internal reset has been triggered.
10.2.2EXTAL and XTAL
These pins provide the interface for a crystal to control the internal clock generator circuitry. EXTAL is
the input to the crystal oscillator amplifier. XTAL is the output of the crystal oscillator amplifier. If
OSCE=0, the EXTAL pin is pulled down by an internal resistor of approximately 200 kΩ and the XTAL
pin is pulled down by an internal resistor of approximately 700 kΩ.
EXTALXTAL
Gain Control
VDD = 1.8 V
Rf
OSCCLK_LCP
Peak
Detector
VSS
VSSVSS
C1C2
Quartz Crystals
Ceramic Resonators
or
Clock
Monitor
monitor fail
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
334Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NOTE
Freescale recommends an evaluation of the application board and chosen
resonator or crystal by the resonator or crystal supplier.
The loop controlled circuit (XOSCLCP) is not suited for overtone
the combined supply pin pair can improve the quality of this supply.
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor335
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
336Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor337
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
10.3.2Register Descriptions
This section describes all the S12CPMU registers and their individual bits.
Address order is as listed inFigure10-3.
10.3.2.1S12CPMU Synthesizer Register (CPMUSYNR)
The CPMUSYNR register controls the multiplication factor of the PLL and selects the VCO frequency
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
338Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor339
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
10.3.2.3S12CPMU Post Divider Register (CPMUPOSTDIV)
The POSTDIV register controls the frequency ratio between the VCOCLK and the PLLCLK.
Read: Anytime
Write: Anytime if PLLSEL=1. Else write has no effect.
10.3.2.4S12CPMU Flags Register (CPMUFLG)
This register provides S12CPMU status bits and flags.
Table10-2. Reference Clock Frequency Selection if OSC_LCP is enabled
REFCLK Frequency Ranges
(OSCE=1)REFFRQ[1:0]
1MHz <= fREF <= 2MHz00
2MHz < fREF <= 6MHz01
6MHz < fREF <= 12MHz10
fREF >12MHz11
0x0036
76543210
R000
POSTDIV[4:0]
W
Reset00000011
= Unimplemented or Reserved
Figure10-6. S12CPMU Post Divider Register (CPMUPOSTDIV)
fPLL
fVCO
POSTDIV1+()
-----------------------------------------
=
If PLL is locked (LOCK=1)
If PLL is not locked (LOCK=0)fPLL
fVCO
4
---------------
=
fbus
fPLL
2
-------------
=
If PLL is selected (PLLSEL=1)
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
340Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Read: Anytime
Write: Refer to each bit for individual write conditions
0x0037
76543210
R
RTIFPORFLVRFLOCKIF
LOCK
ILAFOSCIF
UPOSC
W
Reset0Note 1Note 200Note 300
1. PORF is set to 1 when a power on reset occurs. Unaffected by System Reset.
2. LVRF is set to 1 when a low voltage reset occurs. Unaffected by System Reset. Set by power on reset.
3. ILAF is set to 1 when an illegal address reset occurs. Unaffected by System Reset. Cleared by power on reset.
details. This flag can only be cleared by writing a 1. Writing a 0 has no effect.
0Illegal address reset has not occurred.
1Illegal address reset has occurred.
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor341
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1Interrupt will be requested whenever RTIF is set.
4
LOCKIE
PLL Lock Interrupt Enable Bit
0PLL LOCK interrupt requests are disabled.
1Interrupt will be requested whenever LOCKIF is set.
1
OSCIE
Oscillator Corrupt Interrupt Enable Bit
0Oscillator Corrupt interrupt requests are disabled.
1Interrupt will be requested whenever OSCIF is set.
Table10-3. CPMUFLG Field Descriptions (continued)
FieldDescription
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
342Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor343
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table10-5. CPMUCLKS Descriptions
FieldDescription
7
PLLSEL
PLL Select Bit
This bit selects the PLLCLK as source of the System Clocks (Core Clock and Bus Clock).
PLLSEL can only be set to 0, if UPOSC=1.
UPOSC= 0 sets the PLLSEL bit.
Entering Full Stop Mode sets the PLLSEL bit.
0System clocks are derived from OSCCLK if oscillator is up (UPOSC=1, fbus = fosc / 2.
1System clocks are derived from PLLCLK, fbus = fPLL / 2.
6
PSTP
Pseudo Stop Bit
This bit controls the functionality of the oscillator during Stop Mode.
0Oscillator is disabled in Stop Mode (Full Stop Mode).
1Oscillator continues to run in Stop Mode (Pseudo Stop Mode), option to run RTI and COP.
COP Enable During Pseudo Stop Bit — PCE enables the COP during Pseudo Stop Mode.
0COP stops running during Pseudo Stop Mode if: COPOSCSEL1=0 and COPOSCSEL0=0
1COP continues running during Pseudo Stop Mode if: PSTP=1, COPOSCSEL1=0 and COPOSCSEL0=1
Note:If PCE=0 or COPOSCSEL0=0 while COPOSCSEL1=0 then the COP is static during Stop Mode being
active. The COP counter willnot be reset.
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
344Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Changing the COPOSCSEL0 bit re-starts the COP time-out period.
COPOSCSEL0 can only be set to 1, if UPOSC=1.
UPOSC= 0 clears the COPOSCSEL0 bit.
0COP clock source is IRCCLK.
1COP clock source is OSCCLK
COPOSCSEL1COPOSCSEL0COP clock source
00IRCCLK
01OSCCLK
1xACLK
0x003A
76543210
R00
FM1FM0
0000
W
Reset00000000
Figure10-10. S12CPMU PLL Control Register (CPMUPLL)
Table10-5. CPMUCLKS Descriptions (continued)
FieldDescription
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor345
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NOTE
Care should be taken to ensure that the bus frequency does not exceed the
specified maximum when frequency modulation is enabled.
10.3.2.8S12CPMU RTI Control Register (CPMURTI)
This register selects the time-out period for the Real Time Interrupt.
is to reduce noise emission. The modulation frequency is fref divided by 16. SeeTable10-8 for coding.
Table10-8. FM Amplitude selection
FM1FM0FMAmplitude/
fVCO Variation
00FM off
01±1%
10±2%
11±4%
0x003B
76543210
R
RTDECRTR6RTR5RTR4RTR3RTR2RTR1RTR0
W
Reset00000000
Figure10-11. S12CPMU RTI Control Register (CPMURTI)
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
346Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NOTE
A write to this register starts the RTI time-out period. A change of the
RTIOSCSEL bit (writing a different value or loosing UPOSC status)
re-starts the RTI time-out period.
Table10-9. CPMURTI Field Descriptions
FieldDescription
7
RTDEC
Decimal or Binary Divider Select Bit— RTDEC selects decimal or binary based prescaler values.
0Binary based divider value. SeeTable10-10
1Decimal based divider value. SeeTable10-11
6–4
RTR[6:4]
Real Time Interrupt Prescale Rate Select Bits — These bits select the prescale rate for the RTI. See
Table10-10 andTable10-11.
3–0
RTR[3:0]
Real Time Interrupt Modulus Counter Select Bits — These bits select the modulus counter target value to
provide additional granularity.Table10-10 andTable10-11 show all possible divide values selectable by the
CPMURTI register.
Table10-10. RTI Frequency Divide Rates for RTDEC = 0
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor347
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
10.3.2.9S12CPMU COP Control Register (CPMUCOP)
This register controls the COP (Computer Operating Properly) watchdog.
Table10-10. RTI Frequency Divide Rates for RTDEC = 0
RTR[3:0]
RTR[6:4] =
000
(OFF)
001
(210)
010
(211)
011
(212)
100
(213)
101
(214)
110
(215)
111
(216)
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
348Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The clock source for the COP is either ACLK, IRCCLK or OSCCLK depending on the setting of the
COPOSCSEL0 and COPOSCSEL1 bit (see alsoTable10-6).
while COPOSCSEL1 is clear and COPOSCSEL0 is set, re-starts the COP time-out period.
In Normal Mode the COP time-out period is restarted if either of these conditions is true:
1.Writing a non-zero value to CR[2:0] (anytime in Special Mode, once in Normal Mode) with
WRTMASK = 0.
2.Writing WCOP bit (anytime in Special Mode, once in Normal Mode) with WRTMASK = 0.
3.Changing RSBCK bit from “0” to “1”.
In Special Mode, any write access to CPMUCOP register restarts the COP time-out period.
0x003C
76543210
R
WCOPRSBCK
000
CR2CR1CR0
WWRTMASK
ResetF0000FFF
After de-assert of System Reset the values are automatically loaded from the Flash memory. See Device specification for
details.
= Unimplemented or Reserved
Figure10-12. S12CPMU COP Control Register (CPMUCOP)
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor349
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
highest time-out period (224 cycles) in normal COP mode (Window COP mode disabled):
1) COP is enabled (CR[2:0] is not 000)
2) BDM mode active
3) RSBCK = 0
4) Operation in Special Mode
Table10-13. COP Watchdog Rates if COPOSCSEL1=0
(default out of reset)
CR2CR1CR0
COPCLK
Cycles to Time-out
(COPCLK is either IRCCLK or
OSCCLK depending on the
COPOSCSEL0 bit)
000COP disabled
0012
14
0102
16
0112
18
1002
20
1012
22
1102
23
1112
24
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
350Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
10.3.2.10Reserved Register CPMUTEST0
NOTE
This reserved register is designed for factory test purposes only, and is not
intended for general user access. Writing to this register when in Special
Mode can alter the S12CPMU’s functionality.
Read: Anytime
Write: Only in Special Mode
10.3.2.11Reserved Register CPMUTEST1
NOTE
This reserved register is designed for factory test purposes only, and is not
intended for general user access. Writing to this register when in Special
Mode can alter the S12CPMU’s functionality.
Table10-14. COP Watchdog Rates if COPOSCSEL1=1
CR2CR1CR0
COPCLK
Cycles to Time-out
(COPCLK is ACLK -
internal RC-Oscillator clock)
000COP disabled
0012
7
0102
9
0112
11
1002
13
1012
15
1102
16
1112
17
0x003D
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure10-13. Reserved Register (CPMUTEST0)
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor351
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
in the last 25% of the selected time-out period; writing any value in the first 75% of the selected
period will cause a COP reset.
10.3.2.13Low Voltage Control Register (CPMULVCTL)
The CPMULVCTL register allows the configuration of the low-voltage detect features.
0x003E
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure10-14. Reserved Register (CPMUTEST1)
0x003F
76543210
R00000000
WARMCOP-Bit
7
ARMCOP-Bit
6
ARMCOP-Bit
5
ARMCOP-Bit
4
ARMCOP-Bit
3
ARMCOP-Bit
2
ARMCOP-Bit
1
ARMCOP-Bit
0
Reset00000000
Figure10-15. S12CPMU CPMUARMCOP Register
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
352Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Read: Anytime
Write: LVIE and LVIF are write anytime, LVDS is read only
10.3.2.14Autonomous Periodical Interrupt Control Register (CPMUAPICTL)
The CPMUAPICTL register allows the configuration of the autonomous periodical interrupt features.
Read: Anytime
0x02F1
76543210
R00000LVDS
LVIELVIF
W
Reset00000U0U
The Reset state of LVDS and LVIF depends on the external supplied VDDA level
= Unimplemented or Reserved
Figure10-16. Low Voltage Control Register (CPMULVCTL)
writing a 1. Writing a 0 has no effect. If enabled (LVIE = 1), LVIF causes an interrupt request.
0No change in LVDS bit.
1LVDS bit has changed.
0x02F2
76543210
RAPICLK00
APIESAPIEAAPIFEAPIEAPIF
W
Reset00000000
= Unimplemented or Reserved
Figure10-17. Autonomous Periodical Interrupt Control Register (CPMUAPICTL)
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor353
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Write: Anytime
Figure10-18. Waveform selected on API_EXTCLK pin (APIEA=1, APIFE=1)
Table10-16. CPMUAPICTL Field Descriptions
FieldDescription
7
APICLK
Autonomous Periodical Interrupt Clock Select Bit — Selects the clock source for the API. Writable only if
APIFE = 0. APICLK cannot be changed if APIFE is set by the same write operation.
0Autonomous Clock (ACLK) used as source.
1Bus Clock used as source.
4
APIES
Autonomous Periodical Interrupt External Select Bit — Selects the waveform at the external pin
API_EXTCLK as shown inFigure10-18. See device level specification for connectivity of API_EXTCLK pin.
0If APIEA and APIFE are set, at the external pin API_EXTCLK periodic high pulses are visible at the end of
every selected period with the size of half of the minimum period (APIR=0x0000 inTable10-20).
can be accessed externally. See device level specification for connectivity.
0Waveform selected by APIES can not be accessed externally.
1Waveform selected by APIES can be accessed externally, if APIFE is set.
2
APIFE
Autonomous Periodical Interrupt Feature Enable Bit — Enables the API feature and starts the API timer
when set.
0Autonomous periodical interrupt is disabled.
1Autonomous periodical interrupt is enabled and timer starts running.
1
APIE
Autonomous Periodical Interrupt Enable Bit
0API interrupt request is disabled.
1API interrupt will be requested whenever APIF is set.
0
APIF
Autonomous Periodical Interrupt Flag — APIF is set to 1 when the in the API configured time has elapsed.
This flag can only be cleared by writing a 1. Writing a 0 has no effect. If enabled (APIE = 1), APIF causes an
interrupt request.
0API time-out has not yet occurred.
1API time-out has occurred.
APIES=0
APIES=1
API period
API min. period / 2
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
354Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Autonomous Clock Trimming Bits — SeeTable10-18 for trimming effects. The ACLKTR[5:0] value
represents a signed number influencing the ACLK period time.
Table10-18. Trimming Effect of ACLKTR
BitTrimming Effect
ACLKTR[5]Increases period
ACLKTR[4]Decreases period less than ACLKTR[5] increased it
ACLKTR[3]Decreases period less than ACLKTR[4]
ACLKTR[2]Decreases period less than ACLKTR[3]
ACLKTR[1]Decreases period less than ACLKTR[2]
ACLKTR[0]Decreases period less than ACLKTR[1]
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor355
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Read: Anytime
Write: Anytime if APIFE=0. Else writes have no effect.
The period can be calculated as follows depending on logical value of the APICLK bit:
APICLK=0: Period = 2*(APIR[15:0] + 1) * fACLK
APICLK=1: Period = 2*(APIR[15:0] + 1) * Bus Clock period
Table10-19. CPMUAPIRH / CPMUAPIRL Field Descriptions
FieldDescription
15-0
APIR[15:0]
Autonomous Periodical Interrupt Rate Bits— These bits define the time-out period of the API. See
Table10-20 for details of the effect of the autonomous periodical interrupt rate bits.
Table10-20.Selectable Autonomous Periodical Interrupt Periods
APICLKAPIR[15:0]Selected Period
000000.2 ms1
000010.4 ms1
000020.6 ms1
000030.8 ms1
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
356Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
10.3.2.17Reserved RegisterCPMUTEST3
NOTE
This reserved register is designed for factory test purposes only, and is not
intended for general user access. Writing to this register when in Special
Mode can alter the S12CPMU’s functionality.
Read: Anytime
Write: Only in Special Mode
000041.0 ms1
000051.2 ms1
0..........
0FFFD13106.8 ms1
0FFFE13107.0 ms1
0FFFF13107.2 ms1
100002 * Bus Clock period
100014 * Bus Clock period
100026 * Bus Clock period
100038 * Bus Clock period
1000410 * Bus Clock period
1000512 * Bus Clock period
1..........
1FFFD 131068 * Bus Clock period
1FFFE 131070 * Bus Clock period
1FFFF 131072 * Bus Clock period
1When fACLKis trimmed to 10KHz.
0x02F6
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure10-22. Reserved Register (CPMUTEST3)
Table10-20.Selectable Autonomous Periodical Interrupt Periods (continued)
APICLKAPIR[15:0]Selected Period
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor357
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
10.3.2.18S12CPMU IRC1M Trim Registers (CPMUIRCTRIMH / CPMUIRCTRIML)
Read: Anytime
Write: Anytime if PROT=0 (CPMUPROT register). Else write has no effect
NOTE
Writes to these registers while PLLSEL=1 clears the LOCK and UPOSC
status bits.
0x02F8
15141312111098
R
TCTRIM[4:0]
0
IRCTRIM[9:8]
W
ResetFFFF00FF
After de-assert of System Reset a factory programmed trim value is automatically loaded from the Flash memory to
provide trimmed Internal Reference Frequency fIRC1M_TRIM.
Figure10-23. S12CPMU IRC1M Trim High Register (CPMUIRCTRIMH)
0x02F9
76543210
R
IRCTRIM[7:0]
W
ResetFFFFFFFF
After de-assert of System Reset a factory programmed trim value is automatically loaded from the Flash memory to
provide trimmed Internal Reference Frequency fIRC1M_TRIM.
Figure10-24. S12CPMU IRC1M Trim Low Register (CPMUIRCTRIML)
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
358Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure10-25. IRC1M Frequency Trimming Diagram
Table10-22. CPMUIRCTRIMH/L Field Descriptions
FieldDescription
15-11
TCTRIM[4:0]
IRC1M temperature coefficient Trim Bits
Trim bits for the Temperature Coefficient (TC) of the IRC1M frequency.
Figure10-26 shows the influence of the bits TCTRIM4:0] on the relationship between frequency and
temperature.
Figure10-26 shows an approximate TC variation, relative to the nominal TC of the IRC1M (i.e. for
TCTRIM[4:0]=0x00000 or 0x10000).
9-0
IRCTRIM[9:0]
IRC1M Frequency Trim Bits — Trim bits for Internal Reference Clock
Internal Reference Frequency fIRC1M_TRIM. See device electrical characteristics for value of fIRC1M_TRIM.
The frequency trimming consists of two different trimming methods:
A rough trimming controlled by bits IRCTRIM[9:6] can be done with frequency leaps of about 6% in average.
A fine trimming controlled by the bits IRCTRIM[5:0] can be done with frequency leaps of about 0.3% (this
trimming determines the precision of the frequency setting of 0.15%, i.e. 0.3% is the distance between two
trimming values).
Figure10-25 shows the relationship between the trim bits and the resulting IRC1M frequency.
IRCTRIM[9:0]
$000
IRCTRIM[9:6]
IRCTRIM[5:0]
IRC1M frequency (IRCCLK)
600KHz
1.5MHz
1MHz
$3FF
{
......
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor359
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure10-26. Influence of TCTRIM[4:0] on the Temperature Coefficient
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
360Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table10-23. TC trimming of the IRC1M frequency at ambient temperature
This registers configures the external oscillator (XOSCLCP).
00111-1.9%-2.5%
01000-2.20%-3.0%
01001-2.47%-3.4%
01010-2.77%-3.9%
01011-3.04-4.3%
01100-3.33%-4.7%
01101-3.6%-5.1%
01110-3.91%-5.6%
01111-4.18%-5.9%
100000 (nominal TC of the IRC)0%
10001+0.27%+0.5%
10010+0.54%+0.9%
10011+0.81%+1.3%
10100+1.07%+1.7%
10101+1.34%+2.0%
10110+1.59%+2.2%
10111+1.86%+2.5%
11000+2.11%+3.0%
11001+2.38%+3.4%
11010+2.62%+3.9%
11011+2.89%+4.3%
11100+3.12%+4.7%
11101+3.39%+5.1%
11110+3.62%+5.6%
11111+3.89%+5.9%
TCTRIM[4:0]IRC1M indicative
relative TC variation
IRC1M indicative frequency drift
for relative TC variation
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor361
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
of the COP or RTI. A loss of oscillation will lead to a clock monitor reset.
0External oscillator is disabled.
REFCLK for PLL is IRCCLK.
1External oscillator is enabled.Clock monitor is enabled.External oscillator is qualified by PLLCLK
REFCLK for PLL is the external oscillator clock divided by REFDIV.
Note:When starting up the external oscillator (either by programming OSCE bit to 1 or on exit from Full Stop
Mode with OSCE bit already 1) the software must wait for a minimum time equivalent to the startup-time
of the external oscillator tUPOSC before entering Pseudo Stop Mode.
6
Reserved
Do not alter this bit from its reset value. It is for Manufacturer use only and can change the PLL behavior.
5
OSCPINS_EN
Oscillator Pins EXTAL and XTAL Enable Bit
If OSCE=1 this read-only bit is set. It can only be cleared with the next reset.
Enabling the external oscillator reserves the EXTAL and XTAL pins exclusively for oscillator application.
0EXTAL and XTAL pins are not reserved for oscillator.
1EXTAL and XTAL pins exclusively reserved for oscillator.
4-0
Reserved
Do not alter these bits from their reset value. It is for Manufacturer use only and can change the PLL behavior.
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
362Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CPMUSYNR, CPMUREFDIV, CPMUCLKS, CPMUPLL, CPMUIRCTRIMH/L and CPMUOSC
Read: Anytime
Write: Anytime
10.3.2.21Reserved RegisterCPMUTEST2
NOTE
This reserved register is designed for factory test purposes only, and is not
intended for general user access. Writing to this register when in Special
Clock Configuration Registers Protection Bit — This bit protects the clock configuration registers from
accidental overwrite (see list of affected registers above):
Writing 0x26 to the CPMUPROT register clears the PROT bit, other write accesses set the PROT bit.
0Protection of clock configuration registers is disabled.
1Protection of clock configuration registers is enabled. (see list of protected registers above).
0x02FC
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure10-29. Reserved Register CPMUTEST2
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor363
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
10.4Functional Description
10.4.1Phase Locked Loop with Internal Filter (PLL)
The PLL is used to generate a high speed PLLCLK based on a low frequency REFCLK.
The REFCLK is by default the IRCCLK which is trimmed to fIRC1M_TRIM=1MHz.
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
364Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor365
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
366Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure10-32. Full Stop Mode using Oscillator Clock as Bus Clock
10.4.5External Oscillator
10.4.5.1Enabling the External Oscillator
An example of how to use the oscillator as Bus Clock is shown inFigure10-33.
CPU
UPOSC
tlock
STOP instruction
executioninterruptcontinue execution
wakeup
tSTP_REC
Core
Clock
select OSCCLK as Core/Bus Clock by writing PLLSEL to “0”
PLLSEL
automatically set when going into Full Stop Mode
OSCCLK
PLLCLK
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor367
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure10-33. Enabling the External Oscillator
10.4.6System Clock Configurations
10.4.6.1PLL Engaged Internal Mode (PEI)
This mode is the default mode after System Reset or Power-On Reset.
In this mode, the Bus clock is based on the PLLCLK as well (like PEI). The reference clock for the PLL
is based on the external oscillator.
The clock sources for COP and RTI can be based on the internal reference clock generator or on the
external oscillator clock or the RC-Oscillator (ACLK).
This mode can be entered from default mode PEI by performing the following steps:
1.Configure the PLL for desired bus frequency.
2.Enable the external oscillator (OSCE bit).
3.Wait for oscillator to start-up and the PLL being locked (LOCK = 1) and (UPOSC =1).
PLLSEL
OSCE
EXTAL
OSCCLK
Core
enable external Oscillator by writing OSCE bit to one.
crystal/resonator starts oscillating
UPOSC
UPOSC flag is set upon successful start of oscillation
select OSCCLK as Core/Bus Clock by writing PLLSEL to zero
Clock
based on PLLCLKbased on OSCCLK
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
368Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
4.Clear all flags in the CPMUFLG register to be able to detect any future status bit change.
5.Optionally status interrupts can be enabled (CPMUINT register).
Loosing PLL lock status (LOCK=0) means loosing the oscillator status information as well (UPOSC=0).
The impact of loosing the oscillator status (UPOSC=0) in PEE mode is as follows:
Application software needs to be prepared to deal with the impact of loosing the oscillator status at any
time.
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor369
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
10.5Resets
10.5.1General
All reset sources are listed inTable10-26. Refer to MCU specification for related vector addresses and
While System Reset is asserted the PLLCLK runs with the frequency
fVCORST.
Table10-26. Reset Summary
Reset SourceLocal Enable
Power-On Reset (POR)None
Low Voltage Reset (LVR)None
External pinRESETNone
Illegal Address ResetNone
Clock Monitor ResetOSCE Bit in CPMUOSC register
COP ResetCR[2:0] in CPMUCOP register
Table10-27. Reset Vector Selection
SampledRESET Pin
(256 cycles after
release)
Oscillator monitor
fail pending
COP
time out
pending
Vector Fetch
100POR
LVR
Illegal Address Reset
External pinRESET
11XClock Monitor Reset
101COP Reset
0XXPOR
LVR
Illegal Address Reset
External pinRESET
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
370Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The internal reset of the MCU remains asserted while the reset generator completes the 768 PLLCLK
cycles long reset sequence. In case theRESET pin is externally driven low for more than these 768
PLLCLK cycles (External Reset), the internal reset remains asserted longer.
Figure10-34. RESET Timing
10.5.2.1Clock Monitor Reset
If the external oscillator is enabled (OSCE=1) in case of loss of oscillation or the oscillator frequency is
COP continues to run, else the COP counter halts in Stop Mode with COPOSCSEL1 =0.
In Pseudo Stop Mode and Full Stop Mode with COPOSCSEL1=1 the COP continues to run.
Table10-28.gives an overview of the COP condition (run, static) in Stop Mode depending on legal
configuration and status bit settings:
)
(
)
PLLCLK
512 cycles256 cycles
S12_CPMU drives
possibly
RESET
driven
low
)
(
(
RESET
S12_CPMU releases
fVCORST
RESET pin lowRESET pin
fVCORST
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor371
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table10-28. COP condition (run, static) in Stop Mode
Three control bits in the CPMUCOP register allow selection of seven COP time-out periods.
When COP is enabled, the program must write $55 and $AA (in this order) to the CPMUARMCOP
COPOSCSEL1PSTPPCECOPOSCSEL0OSCEUPOSCCOP counter behavior in Stop Mode
(clock source)
1xxxxxRun (ACLK)
011111Run (OSCCLK)
01100xStatic (IRCCLK)
01101xStatic (IRCCLK)
0100xxStatic (IRCCLK)
010111Static (OSCCLK)
001111Static (OSCCLK)
00101xStatic (IRCCLK)
001000Static (IRCCLK)
000111Satic (OSCCLK)
000011Static (IRCCLK)
000010Static (IRCCLK)
000000Static (IRCCLK)
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
372Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
10.6Interrupts
The interrupt/reset vectors requested by the S12CPMU are listed inTable10-29. Refer to MCU
specification for related vector addresses and priorities.
the oscillator can also cause a status change of UPOSC.
Table10-29. S12CPMU Interrupt Vectors
Interrupt SourceCCR
MaskLocal Enable
RTI time-out interruptI bitCPMUINT (RTIE)
PLL lock interruptI bitCPMUINT (LOCKIE)
Oscillator status
interruptI bitCPMUINT (OSCIE)
Low voltage interruptI bitCPMULVCTL (LVIE)
Autonomous
Periodical InterruptI bitCPMUAPICTL (APIE)
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor373
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1.For details please refer to “<st-blue>10.4.6 System Clock Configurations”
S12 Clock, Reset and Power Management Unit (S12CPMU)
MC9S12G Family Reference Manual,Rev.1.06
374Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
(alternating sequence of $55 and $AA is no longer maintained) which causes a COP reset.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor375
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
in section11.3.2.12.1/11-393 and11.3.2.12.2/11-393 and
addedTable11-21 to improve feature description.
V02.0209 Feb 201009 Feb 2010FixedtypoinTable11-9-conversionresultfor3mVand10bit
resolution
V02.0326 Feb 201026 Feb 2010CorrectedTable11-15AnalogInputChannelSelectCoding-
description of internal channels.
V02.0414 Apr 201014 Apr 2010Corrected typos to be in-line with SoC level pin naming
conventions for VDDA, VSSA, VRL and VRH.
V02.0525 Aug 201025 Aug 2010
Removed feature of conversion during STOP and general
wording clean up done inSection11.4, “Functional
Description
V02.0609 Sep 201009 Sep 2010Update of internal only information.
V02.0711 Feb 201111 Feb 2011Connectivity Information regarding internal channel_6 added
toTable11-15.
Analog-to-Digital Converter (ADC10B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
376Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Programmable sample time.
•Left/right justified result data.
•External trigger control.
•Sequence complete interrupt.
•Analog input multiplexer for 8 analog input channels.
•Special conversions for VRH, VRL, (VRL+VRH)/2.
•1-to-8 conversion sequence lengths.
•Continuous conversion mode.
•Multiple channel scans.
•Configurable external trigger functionality on any AD channel or any of four additional trigger
inputs. The four additional trigger inputs can be chip external or internal. Refer to device
There is software programmable selection between performingsingle orcontinuousconversion on a
single channel ormultiple channels.
11.1.2.2MCU Operating Modes
•Stop Mode
Entering Stop Mode aborts any conversion sequence in progress and if a sequence was aborted
restarts it after exiting stop mode. This has the same effect/consequences as starting a conversion
sequence with write to ATDCTL5. So after exiting from stop mode with a previously aborted
sequence all flags are cleared etc.
•Wait Mode
ADC10B8C behaves same in Run and Wait Mode. For reduced power consumption continuous
conversions should be aborted before entering Wait mode.
•Freeze Mode
In Freeze Mode the ADC10B8C will either continue or finish or stop converting according to the
FRZ1 and FRZ0 bits. This is useful for debugging and emulation.
Analog-to-Digital Converter (ADC10B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor377
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
11.1.3Block Diagram
Figure11-1. ADC10B8C Block Diagram
VSSA
AN6
ATD_12B8C
Analog
MUX
Mode and
Successive
Approximation
Register (SAR)
Results
ATD 0
ATD 1
ATD 2
ATD 3
ATD 4
ATD 5
ATD 6
ATD 7
and DAC
Sample & Hold
VDDA
VRL
VRH
Sequence Complete
+
-
Comparator
Clock
Prescaler
Bus Clock
ATD Clock
AN5
AN4
AN3
AN1
AN0
AN7
ETRIG0
(See device specifi-
cation for availability
ETRIG1
ETRIG2
ETRIG3
and connectivity)
Timing Control
ATDDIENATDCTL1
Trigger
MuxInterrupt
Compare Interrupt
AN2
Analog-to-Digital Converter (ADC10B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
378Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
11.2Signal Description
This section lists all inputs to the ADC10B8C block.
11.2.1Detailed Signal Descriptions
11.2.1.1ANx (x = 7, 6, 5, 4, 3, 2, 1, 0)
This pin serves as the analog input Channelx. It can also be configured as digital port or external trigger
for the ATD conversion.
11.2.1.2ETRIG3, ETRIG2, ETRIG1, ETRIG0
These inputs can be configured to serve as an external trigger for the ATD conversion.
Refer to device specification for availability and connectivity of these inputs!
11.2.1.3VRH, VRL
VRH is the high reference voltage, VRL is the low reference voltage for ATD conversion.
11.2.1.4VDDA, VSSA
These pins are the power supplies for the analog circuitry of the ADC10B8C block.
11.3Memory Map and Register Definition
This section provides a detailed description of all registers accessible in the ADC10B8C.
11.3.1Module Memory Map
Figure11-2 gives an overview on all ADC10B8C registers.
Figure11-2. ADC10B8C Register Summary (Sheet 1 of 2)
Analog-to-Digital Converter (ADC10B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor379
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
0x0003ATDCTL3RDJMS8CS4CS2CS1CFIFOFRZ1FRZ0
W
0x0004ATDCTL4RSMP2SMP1SMP0PRS[4:0]
W
0x0005ATDCTL5R0SCSCANMULTCDCCCBCA
W
0x0006ATDSTAT0RSCF0ETORFFIFORCC3CC2CC1CC0
W
0x0007Unimple-
mented
R00000000
W
0x0008ATDCMPEHR00000000
W
0x0009ATDCMPELRCMPE[7:0]
W
0x000AATDSTAT2HR00000000
W
0x000BATDSTAT2LRCCF[7:0]
W
0x000CATDDIENHR11111111
W
0x000DATDDIENLRIEN[7:0]
W
0x000EATDCMPHTHR00000000
W
0x000FATDCMPHTLRCMPHT[7:0]
W
0x0010ATDDR0RSeeSection11.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection11.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0012ATDDR1RSeeSection11.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection11.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0014ATDDR2RSeeSection11.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection11.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0016ATDDR3RSeeSection11.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection11.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0018ATDDR4RSeeSection11.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection11.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x001AATDDR5RSeeSection11.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection11.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x001CATDDR6RSeeSection11.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection11.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x001EATDDR7RSeeSection11.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection11.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0020-
0x002F
Unimple-
mented
R00000000
W
AddressNameBit 7654321Bit 0
= Unimplemented or Reserved
Figure11-2. ADC10B8C Register Summary (Sheet 2 of 2)
Analog-to-Digital Converter (ADC10B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
380Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
11.3.2Register Descriptions
This section describes in address order all the ADC10B8C registers and their individual bits.
11.3.2.1ATD Control Register 0 (ATDCTL0)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime, in special modes always write 0 to Reserved Bit 7.
Module Base + 0x0000
76543210
RReserved000
WRAP3WRAP2WRAP1WRAP0
W
Reset00001111
= Unimplemented or Reserved
Figure11-3. ATD Control Register 0 (ATDCTL0)
Table11-1. ATDCTL0 Field Descriptions
FieldDescription
3-0
WRAP[3-0]
Wrap Around Channel Select Bits — These bits determine the channel for wrap around when doing
multi-channel conversions. The coding is summarized inTable11-2.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
11.3.2.2ATD Control Register 1 (ATDCTL1)
Writes to this register will abort current conversion sequence.
as source for the external trigger. The coding is summarized inTable11-5.
Table11-4. A/D Resolution Coding
SRES1SRES0A/D Resolution
008-bit data
0110-bit data
10
11Reserved
Table11-5. External Trigger Channel Select Coding
ETRIGSELETRIGCH3ETRIGCH2ETRIGCH1ETRIGCH0External trigger source is
00000AN0
00001AN1
Analog-to-Digital Converter (ADC10B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
382Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
11.3.2.3ATD Control Register 2 (ATDCTL2)
Writes to this register will abort current conversion sequence.
external trigger source is still on one of the AD channels selected by ETRIGCH3-0
Module Base + 0x0002
76543210
R0
AFFCReservedETRIGLEETRIGPETRIGEASCIEACMPIE
W
Reset00000000
= Unimplemented or Reserved
Figure11-5. ATD Control Register 2 (ATDCTL2)
Table11-5. External Trigger Channel Select Coding
ETRIGSELETRIGCH3ETRIGCH2ETRIGCH1ETRIGCH0External trigger source is
Analog-to-Digital Converter (ADC10B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor383
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
11.3.2.4ATD Control Register 3 (ATDCTL3)
Writes to this register will abort current conversion sequence.
Table11-6. ATDCTL2 Field Descriptions
FieldDescription
6
AFFC
ATD Fast Flag Clear All
0ATD flag clearing done by write 1 to respective CCF[n] flag.
1Changes all ATD conversion complete flags to a fast clear sequence.
register) this bit enables the compare interrupt. If the CCF[n] flag is set (showing a successful compare for
conversionn), the compare interrupt is triggered.
0ATD Compare interrupt requests are disabled.
1For the conversions in a sequence for which automatic compare is enabled (CMPE[n]=1), an ATD Compare
Interrupt will be requested whenever any of the respective CCF flags is set.
Table11-7. External Trigger Configurations
ETRIGLEETRIGPExternal Trigger Sensitivity
00Falling edge
01Rising edge
10Low level
11High level
Analog-to-Digital Converter (ADC10B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
384Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Read: Anytime
Write: Anytime
Module Base + 0x0003
76543210
R
DJMS8CS4CS2CS1CFIFOFRZ1FRZ0
W
Reset00100000
= Unimplemented or Reserved
Figure11-6. ATD Control Register 3 (ATDCTL3)
Table11-8. ATDCTL3 Field Descriptions
FieldDescription
7
DJM
Result Register Data Justification — Result data format is always unsigned. This bit controls justification of
conversion data in the result registers.
0Left justified data in the result registers.
1Right justified data in the result registers.
Table11-9 gives example ATD results for an input signal range between 0 and 5.12 Volts.
6–3
S8C, S4C,
S2C, S1C
Conversion Sequence Length — These bits control the number of conversions per sequence.Table11-10
shows all combinations. At reset, S4C is set to 1 (sequence length is 4). This is to maintain software continuity
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table11-9. Examples of ideal decimal ATD Results
Input Signal
VRL = 0 Volts
VRH = 5.12 Volts
8-Bit
Codes
(resolution=20mV)
10-Bit
Codes
(resolution=5mV)
5.120 Volts
...
0.022
0.020
0.018
0.016
0.014
0.012
0.010
0.008
0.006
0.004
0.003
0.002
0.000
255
...
1
1
1
1
1
1
1
0
0
0
0
0
0
1023
...
4
4
4
3
3
2
2
2
1
1
1
0
0
Table11-10. Conversion Sequence Length Coding
S8CS4CS2CS1CNumber of Conversions
per Sequence
00008
00011
00102
00113
01004
01015
01106
01117
10008
10018
10108
10118
11008
11018
11108
11118
Table11-11. ATD Behavior in Freeze Mode (Breakpoint)
FRZ1FRZ0Behavior in Freeze Mode
00Continue conversion
01Reserved
10Finish current conversion, then freeze
Analog-to-Digital Converter (ADC10B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
386Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
11.3.2.5ATD Control Register 4 (ATDCTL4)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime
11Freeze Immediately
Module Base + 0x0004
76543210
R
SMP2SMP1SMP0PRS[4:0]
W
Reset00000101
Figure11-7. ATD Control Register 4 (ATDCTL4)
Table11-12. ATDCTL4 Field Descriptions
FieldDescription
7–5
SMP[2:0]
Sample Time Select — These three bits select the length of the sample time in units of ATD conversion clock
cycles. Note that the ATD conversion clock period is itself a function of the prescaler value (bits PRS4-0).
Table11-13 lists the available sample time lengths.
Refer to Device Specification for allowed frequency range of fATDCLK.
Table11-13. Sample Time Select
SMP2SMP1SMP0
Sample Time
in Number of
ATD Clock Cycles
0004
0016
0108
01110
10012
10116
11020
11124
Table11-11. ATD Behavior in Freeze Mode (Breakpoint)
FRZ1FRZ0Behavior in Freeze Mode
fATDCLK
fBUS
2PRS1+()×
-------------------------------------=
Analog-to-Digital Converter (ADC10B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor387
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
11.3.2.6ATD Control Register 5 (ATDCTL5)
Writes to this register will abort current conversion sequence and start a new conversion sequence. If the
subsequent channels sampled in the sequence are determined by incrementing the channel selection code or
wrapping around to AN0 (channel 0).
0Sample only one channel
1Sample across several channels
3–0
CD, CC,
CB, CA
Analog Input Channel Select Code — These bits select the analog input channel(s).Table11-15 lists the
coding used to select the various analog input channels.
In the case of single channel conversions (MULT=0), this selection code specifies the channel to be examined.
In the case of multiple channel conversions (MULT=1), this selection code specifies the first channel to be
examined in the conversion sequence. Subsequent channels are determined by incrementing the channel
selection code or wrapping around to AN0 (after converting the channel defined by the Wrap Around Channel
Select Bits WRAP3-0 in ATDCTL0). When starting with a channel number higher than the one defined by
WRAP3-0 the first wrap around will be AN7 to AN0.
Analog-to-Digital Converter (ADC10B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
388Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Read: Anytime
Write: Anytime (No effect on (CC3, CC2, CC1, CC0))
Module Base + 0x0006
76543210
R
SCF
0
ETORFFIFOR
CC3CC2CC1CC0
W
Reset00000000
= Unimplemented or Reserved
Figure11-9. ATD Status Register 0 (ATDSTAT0)
Table11-16. ATDSTAT0 Field Descriptions
FieldDescription
7
SCF
Sequence Complete Flag — This flag is set upon completion of a conversion sequence. If conversion
If in FIFO mode (FIFO=1) the register counter is not initialized. The conversion counter wraps around when its
maximum value is reached.
Aborting a conversion or starting a new conversion clears the conversion counter even if FIFO=1.
Analog-to-Digital Converter (ADC10B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
390Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
11.3.2.8ATD Compare Enable Register (ATDCMPE)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime
11.3.2.9ATD Status Register 2 (ATDSTAT2)
This read-only register contains the Conversion Complete Flags CCF[7:0].
For each conversion number with CMPE[n]=1 do the following:
1) Write compare value to ATDDRnresult register
2) Write compare operator with CMPHT[n] in ATDCPMHT register
CCF[n] in ATDSTAT2 register will flag individual success of any comparison.
0No automatic compare
1Automatic compare of results for conversionn of a sequence is enabled.
Module Base + 0x000A
1514131211109876543210
R00000000CCF[7:0]
W
Reset0000000000000000
= Unimplemented or Reserved
Figure11-11. ATD Status Register 2 (ATDSTAT2)
Analog-to-Digital Converter (ADC10B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor391
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
11.3.2.10ATD Input Enable Register (ATDDIEN)
Read: Anytime
Write: Anytime
Table11-18. ATDSTAT2 Field Descriptions
FieldDescription
7–0
CCF[7:0]
Conversion Complete Flagn (n= 7, 6, 5, 4, 3, 2, 1, 0) (n conversion number, NOT channel number!)— A
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
11.3.2.11ATD Compare Higher Than Register (ATDCMPHT)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime
11.3.2.12ATD Conversion Result Registers (ATDDRn)
The A/D conversion results are stored in 8 result registers. Results are always in unsigned data
representation. Left and right justification is selected using the DJM control bit in ATDCTL3.
0If result of conversionn islower or same thancompare value in ATDDRn, this is flagged in ATDSTAT2
1If result of conversionn ishigher than compare value in ATDDRn, this is flagged in ATDSTAT2
Analog-to-Digital Converter (ADC10B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor393
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
11.3.2.12.1Left Justified Result Data (DJM=0)
Table11-21 shows how depending on the A/D resolution the conversion result is transferred to the ATD
Figure11-15. Right justified ATD conversion result register (ATDDRn)
Analog-to-Digital Converter (ADC10B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
394Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
11.4Functional Description
The ADC10B8C consists of an analog sub-block and a digital sub-block.
11.4.1Analog Sub-Block
The analog sub-block contains all analog electronics required to perform a single conversion. Separate
When not converting the A/D machine is automatically powered down.
Table11-22. Conversion result mapping to ATDDRn
A/D
resolutionDJMconversion result mapping toATDDRn
8-bit data1Result-Bit[7:0] = result,
Result-Bit[11:8]=0000
10-bit data1Result-Bit[9:0] = result,
Result-Bit[11:10]=00
Analog-to-Digital Converter (ADC10B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor395
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
active in level sensitive mode when a sequence is about to complete, another sequence will be triggered
immediately.
Table11-23. External Trigger Control Bits
ETRIGLEETRIGPETRIGESCANDescription
XX00Ignores external trigger. Performs one
conversion sequence and stops.
XX01Ignores external trigger. Performs
continuous conversion sequences.
001XTrigger falling edge sensitive. Performs
one conversion sequence per trigger.
011XTriggerrisingedgesensitive.Performsone
conversion sequence per trigger.
101XTrigger low level sensitive. Performs
continuous conversions while trigger level
is active.
111XTrigger high level sensitive. Performs
continuous conversions while trigger level
is active.
Analog-to-Digital Converter (ADC10B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
396Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The interrupts requested by the ADC10B8C are listed inTable11-24. Refer to MCU specification for
related vector address and priority.
SeeSection11.3.2, “Register Descriptions” for further details.
Table11-24. ATD Interrupt Vectors
Interrupt SourceCCR
MaskLocal Enable
Sequence Complete InterruptI bitASCIE in ATDCTL2
Compare InterruptI bitACMPIE in ATDCTL2
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor397
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter12
Analog-to-Digital Converter (ADC10B12CV2)
Revision History
12.1Introduction
The ADC10B12C is a 12-channel, , multiplexed input successive approximation analog-to-digital
converter. Refer to device electrical specifications for ATD accuracy.
12.1.1Features
•8-, 10-bit resolution.
Version
Number
Revision
Date
Effective
DateAuthorDescription of Changes
V02.0013 May 200913 May 2009Initial version copied from V01.06,
changed unused Bits in ATDDIEN to read logic 1
V02.0130.Nov 200930.Nov 2009
UpdatedTable12-15 Analog Input Channel Select Coding -
CB, CA. Last sentence contained a wrong highest channel
number (it is not AN7 to AN0 instead it is AN11 to AN0).
Analog-to-Digital Converter (ADC10B12CV2)
MC9S12G Family Reference Manual,Rev.1.06
398Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Automatic return to low power after conversion sequence
•Automatic compare with interrupt for higher than or less/equal than programmable value
•Programmable sample time.
•Left/right justified result data.
•External trigger control.
•Sequence complete interrupt.
•Analog input multiplexer for 8 analog input channels.
•Special conversions for VRH, VRL, (VRL+VRH)/2.
•1-to-12 conversion sequence lengths.
•Continuous conversion mode.
•Multiple channel scans.
•Configurable external trigger functionality on any AD channel or any of four additional trigger
inputs. The four additional trigger inputs can be chip external or internal. Refer to device
FRZ1 and FRZ0 bits. This is useful for debugging and emulation.
Analog-to-Digital Converter (ADC10B12CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor399
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
12.1.3Block Diagram
Figure12-1. ADC10B12C Block Diagram
VSSA
AN6
ATD_12B12C
Analog
MUX
Mode and
Successive
Approximation
Register (SAR)
Results
ATD 0
ATD 1
ATD 2
ATD 3
ATD 4
ATD 5
ATD 6
ATD 7
and DAC
Sample & Hold
VDDA
VRL
VRH
Sequence Complete
+
-
Comparator
Clock
Prescaler
Bus Clock
ATD Clock
AN5
AN4
AN3
AN1
AN0
AN7
ETRIG0
(See device specifi-
cation for availability
ETRIG1
ETRIG2
ETRIG3
and connectivity)
Timing Control
ATDDIENATDCTL1
Trigger
MuxInterrupt
Compare Interrupt
AN2
AN8
AN9
AN10
AN11
ATD 8
ATD 9
ATD 10
ATD 11
Analog-to-Digital Converter (ADC10B12CV2)
MC9S12G Family Reference Manual,Rev.1.06
400Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
12.2Signal Description
This section lists all inputs to the ADC10B12C block.
Figure12-2. ADC10B12C Register Summary (Sheet 1 of 3)
Analog-to-Digital Converter (ADC10B12CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor401
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
0x0003ATDCTL3RDJMS8CS4CS2CS1CFIFOFRZ1FRZ0
W
0x0004ATDCTL4RSMP2SMP1SMP0PRS[4:0]
W
0x0005ATDCTL5R0SCSCANMULTCDCCCBCA
W
0x0006ATDSTAT0RSCF0ETORFFIFORCC3CC2CC1CC0
W
0x0007Unimple-
mented
R00000000
W
0x0008ATDCMPEHR0000CMPE[11:8]
W
0x0009ATDCMPELRCMPE[7:0]
W
0x000AATDSTAT2HR0000CCF[11:8]
W
0x000BATDSTAT2LRCCF[7:0]
W
0x000CATDDIENHR1111IEN[11:8]
W
0x000DATDDIENLRIEN[7:0]
W
0x000EATDCMPHTHR0000CMPHT[11:8]
W
0x000FATDCMPHTLRCMPHT[7:0]
W
0x0010ATDDR0RSeeSection12.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection12.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0012ATDDR1RSeeSection12.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection12.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0014ATDDR2RSeeSection12.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection12.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0016ATDDR3RSeeSection12.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection12.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0018ATDDR4RSeeSection12.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection12.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x001AATDDR5RSeeSection12.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection12.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x001CATDDR6RSeeSection12.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection12.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x001EATDDR7RSeeSection12.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection12.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0020ATDDR8RSeeSection12.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection12.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0022ATDDR9RSeeSection12.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection12.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
AddressNameBit 7654321Bit 0
= Unimplemented or Reserved
Figure12-2. ADC10B12C Register Summary (Sheet 2 of 3)
Analog-to-Digital Converter (ADC10B12CV2)
MC9S12G Family Reference Manual,Rev.1.06
402Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
12.3.2Register Descriptions
This section describes in address order all the ADC10B12C registers and their individual bits.
12.3.2.1ATD Control Register 0 (ATDCTL0)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime, in special modes always write 0 to Reserved Bit 7.
0x0024ATDDR10RSeeSection12.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection12.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0026ATDDR11RSeeSection12.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection12.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0028-
0x002F
Unimple-
mented
R00000000
W
Module Base + 0x0000
76543210
RReserved000
WRAP3WRAP2WRAP1WRAP0
W
Reset00001111
= Unimplemented or Reserved
Figure12-3. ATD Control Register 0 (ATDCTL0)
Table12-1. ATDCTL0 Field Descriptions
FieldDescription
3-0
WRAP[3-0]
Wrap Around Channel Select Bits — These bits determine the channel for wrap around when doing
multi-channel conversions. The coding is summarized inTable12-2.
Figure12-2. ADC10B12C Register Summary (Sheet 3 of 3)
Analog-to-Digital Converter (ADC10B12CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor403
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
12.3.2.2ATD Control Register 1 (ATDCTL1)
Writes to this register will abort current conversion sequence.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
external trigger source is still on one of the AD channels selected by ETRIGCH3-0
10001ETRIG11
10010ETRIG21
10011ETRIG31
101XXReserved
11XXXReserved
Table12-3. ATDCTL1 Field Descriptions (continued)
FieldDescription
Analog-to-Digital Converter (ADC10B12CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor405
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
12.3.2.3ATD Control Register 2 (ATDCTL2)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime
Module Base + 0x0002
76543210
R0
AFFCReservedETRIGLEETRIGPETRIGEASCIEACMPIE
W
Reset00000000
= Unimplemented or Reserved
Figure12-5. ATD Control Register 2 (ATDCTL2)
Table12-6. ATDCTL2 Field Descriptions
FieldDescription
6
AFFC
ATD Fast Flag Clear All
0ATD flag clearing done by write 1 to respective CCF[n] flag.
1Changes all ATD conversion complete flags to a fast clear sequence.
register) this bit enables the compare interrupt. If the CCF[n] flag is set (showing a successful compare for
conversionn), the compare interrupt is triggered.
0ATD Compare interrupt requests are disabled.
1For the conversions in a sequence for which automatic compare is enabled (CMPE[n]=1), an ATD Compare
Interrupt will be requested whenever any of the respective CCF flags is set.
Analog-to-Digital Converter (ADC10B12CV2)
MC9S12G Family Reference Manual,Rev.1.06
406Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
12.3.2.4ATD Control Register 3 (ATDCTL3)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime
Table12-7. External Trigger Configurations
ETRIGLEETRIGPExternal Trigger Sensitivity
00Falling edge
01Rising edge
10Low level
11High level
Module Base + 0x0003
76543210
R
DJMS8CS4CS2CS1CFIFOFRZ1FRZ0
W
Reset00100000
= Unimplemented or Reserved
Figure12-6. ATD Control Register 3 (ATDCTL3)
Table12-8. ATDCTL3 Field Descriptions
FieldDescription
7
DJM
Result Register Data Justification — Result data format is always unsigned. This bit controls justification of
conversion data in the result registers.
0Left justified data in the result registers.
1Right justified data in the result registers.
Table12-9 gives example ATD results for an input signal range between 0 and 5.12 Volts.
6–3
S8C, S4C,
S2C, S1C
Conversion Sequence Length — These bits control the number of conversions per sequence.Table12-10
shows all combinations. At reset, S4C is set to 1 (sequence length is 4). This is to maintain software continuity
to HC12 family.
Analog-to-Digital Converter (ADC10B12CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor407
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
12.3.2.5ATD Control Register 4 (ATDCTL4)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime
Table12-10. Conversion Sequence Length Coding
S8CS4CS2CS1CNumber of Conversions
per Sequence
000012
00011
00102
00113
01004
01015
01106
01117
10008
10019
101010
101111
110012
110112
111012
111112
Table12-11. ATD Behavior in Freeze Mode (Breakpoint)
FRZ1FRZ0Behavior in Freeze Mode
00Continue conversion
01Reserved
10Finish current conversion, then freeze
11Freeze Immediately
Module Base + 0x0004
76543210
R
SMP2SMP1SMP0PRS[4:0]
W
Reset00000101
Figure12-7. ATD Control Register 4 (ATDCTL4)
Analog-to-Digital Converter (ADC10B12CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor409
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
12.3.2.6ATD Control Register 5 (ATDCTL5)
Writes to this register will abort current conversion sequence and start a new conversion sequence. If the
Refer to Device Specification for allowed frequency range of fATDCLK.
Table12-13. Sample Time Select
SMP2SMP1SMP0
Sample Time
in Number of
ATD Clock Cycles
0004
0016
0108
01110
10012
10116
11020
11124
Module Base + 0x0005
76543210
R0
SCSCANMULTCDCCCBCA
W
Reset00000000
= Unimplemented or Reserved
Figure12-8. ATD Control Register 5 (ATDCTL5)
fATDCLK
fBUS
2PRS1+()×
-------------------------------------=
Analog-to-Digital Converter (ADC10B12CV2)
MC9S12G Family Reference Manual,Rev.1.06
410Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
subsequent channels sampled in the sequence are determined by incrementing the channel selection code or
wrapping around to AN0 (channel 0).
0Sample only one channel
1Sample across several channels
3–0
CD, CC,
CB, CA
Analog Input Channel Select Code — These bits select the analog input channel(s).Table12-15 lists the
coding used to select the various analog input channels.
In the case of single channel conversions (MULT=0), this selection code specifies the channel to be examined.
In the case of multiple channel conversions (MULT=1), this selection code specifies the first channel to be
examined in the conversion sequence. Subsequent channels are determined by incrementing the channel
selection code or wrapping around to AN0 (after converting the channel defined by the Wrap Around Channel
Select Bits WRAP3-0 in ATDCTL0). When starting with a channel number higher than the one defined by
WRAP3-0 the first wrap around will be AN11 to AN0.
Analog-to-Digital Converter (ADC10B12CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor411
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Read: Anytime
Write: Anytime (No effect on (CC3, CC2, CC1, CC0))
Module Base + 0x0006
76543210
R
SCF
0
ETORFFIFOR
CC3CC2CC1CC0
W
Reset00000000
= Unimplemented or Reserved
Figure12-9. ATD Status Register 0 (ATDSTAT0)
Table12-16. ATDSTAT0 Field Descriptions
FieldDescription
7
SCF
Sequence Complete Flag — This flag is set upon completion of a conversion sequence. If conversion
If in FIFO mode (FIFO=1) the register counter is not initialized. The conversion counter wraps around when its
maximum value is reached.
Aborting a conversion or starting a new conversion clears the conversion counter even if FIFO=1.
Analog-to-Digital Converter (ADC10B12CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor413
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
12.3.2.8ATD Compare Enable Register (ATDCMPE)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime
12.3.2.9ATD Status Register 2 (ATDSTAT2)
This read-only register contains the Conversion Complete Flags CCF[11:0].
For each conversion number with CMPE[n]=1 do the following:
1) Write compare value to ATDDRnresult register
2) Write compare operator with CMPHT[n] in ATDCPMHT register
CCF[n] in ATDSTAT2 register will flag individual success of any comparison.
0No automatic compare
1Automatic compare of results for conversionn of a sequence is enabled.
Module Base + 0x000A
1514131211109876543210
R0000CCF[11:0]
W
Reset0000000000000000
= Unimplemented or Reserved
Figure12-11. ATD Status Register 2 (ATDSTAT2)
Analog-to-Digital Converter (ADC10B12CV2)
MC9S12G Family Reference Manual,Rev.1.06
414Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
12.3.2.11ATD Compare Higher Than Register (ATDCMPHT)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime
12.3.2.12ATD Conversion Result Registers (ATDDRn)
The A/D conversion results are stored in 12 result registers. Results are always in unsigned data
representation. Left and right justification is selected using the DJM control bit in ATDCTL3.
0If result of conversionn islower or same thancompare value in ATDDRn, this is flagged in ATDSTAT2
1If result of conversionn ishigher than compare value in ATDDRn, this is flagged in ATDSTAT2
Analog-to-Digital Converter (ADC10B12CV2)
MC9S12G Family Reference Manual,Rev.1.06
416Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table12-21 shows how depending on the A/D resolution the conversion result is transferred to the ATD
Figure12-15. Right justified ATD conversion result register (ATDDRn)
Analog-to-Digital Converter (ADC10B12CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor417
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
12.4Functional Description
The ADC10B12C consists of an analog sub-block and a digital sub-block.
12.4.1Analog Sub-Block
The analog sub-block contains all analog electronics required to perform a single conversion. Separate
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
12.4.2Digital Sub-Block
This subsection describes some of the digital features in more detail. SeeSection12.3.2, “Register
Descriptions” for all details.
12.4.2.1External Trigger Input
The external trigger feature allows the user to synchronize ATD conversions to an external event rather
active in level sensitive mode when a sequence is about to complete, another sequence will be triggered
immediately.
Table12-23. External Trigger Control Bits
ETRIGLEETRIGPETRIGESCANDescription
XX00Ignores external trigger. Performs one
conversion sequence and stops.
XX01Ignores external trigger. Performs
continuous conversion sequences.
001XTrigger falling edge sensitive. Performs
one conversion sequence per trigger.
011XTriggerrisingedgesensitive.Performsone
conversion sequence per trigger.
101XTrigger low level sensitive. Performs
continuous conversions while trigger level
is active.
111XTrigger high level sensitive. Performs
continuous conversions while trigger level
is active.
Analog-to-Digital Converter (ADC10B12CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor419
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
makes each ATD input pin selected as analog input available to the A/D converter.
The pad of the ATD input pin is always connected to the analog input channel of the analog mulitplexer.
Each pad input signal is buffered to the digital port register.
This buffer can be turned on or off with the ATDDIEN register for each ATD input pin.
This is important so that the buffer does not draw excess current when an ATD input pin is selected as
analog input to the ADC10B12C.
12.5Resets
At reset the ADC10B12C is in a power down state. The reset state of each individual bit is listed within
the Register Description section (seeSection12.3.2, “Register Descriptions”) which details the registers
and their bit-field.
12.6Interrupts
The interrupts requested by the ADC10B12C are listed inTable12-24. Refer to MCU specification for
related vector address and priority.
SeeSection12.3.2, “Register Descriptions” for further details.
Table12-24. ATD Interrupt Vectors
Interrupt SourceCCR
MaskLocal Enable
Sequence Complete InterruptI bitASCIE in ATDCTL2
Compare InterruptI bitACMPIE in ATDCTL2
Analog-to-Digital Converter (ADC10B12CV2)
MC9S12G Family Reference Manual,Rev.1.06
420Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor421
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter13
Analog-to-Digital Converter (ADC10B16CV2)
Revision History
13.1Introduction
The ADC10B16C is a 16-channel, , multiplexed input successive approximation analog-to-digital
converter. Refer to device electrical specifications for ATD accuracy.
13.1.1Features
•8-, 10-bit resolution.
Version
Number
Revision
Date
Effective
DateAuthorDescription of Changes
V02.0018 June 200918 June 2009Initial version copied 12 channel block guide
V02.0109 Feb 201009 Feb 2010
UpdatedTable13-15 Analog Input Channel Select Coding -
CB, CA. Last sentence contained a wrong highest channel
number (it is not AN7 to AN0 instead it is AN15 to AN0).
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual,Rev.1.06
422Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Automatic return to low power after conversion sequence
•Automatic compare with interrupt for higher than or less/equal than programmable value
•Programmable sample time.
•Left/right justified result data.
•External trigger control.
•Sequence complete interrupt.
•Analog input multiplexer for 8 analog input channels.
•Special conversions for VRH, VRL, (VRL+VRH)/2.
•1-to-16 conversion sequence lengths.
•Continuous conversion mode.
•Multiple channel scans.
•Configurable external trigger functionality on any AD channel or any of four additional trigger
inputs. The four additional trigger inputs can be chip external or internal. Refer to device
FRZ1 and FRZ0 bits. This is useful for debugging and emulation.
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor423
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
13.1.3Block Diagram
Figure13-1. ADC10B16C Block Diagram
VSSA
AN9
ATD_12B12C
Analog
MUX
Mode and
Successive
Approximation
Register (SAR)
Results
ATD 0
ATD 1
ATD 2
ATD 3
ATD 4
ATD 5
ATD 6
ATD 7
and DAC
Sample & Hold
VDDA
VRL
VRH
Sequence Complete
+
-
Comparator
Clock
Prescaler
Bus Clock
ATD Clock
AN7
AN6
AN5
AN10
ETRIG0
(See device specifi-
cation for availability
ETRIG1
ETRIG2
ETRIG3
and connectivity)
Timing Control
ATDDIENATDCTL1
Trigger
MuxInterrupt
Compare Interrupt
AN4
AN11
AN12
AN13
AN14
ATD 8
ATD 9
ATD 10
ATD 11
ATD 13
ATD 14
ATD 12
ATD 15
AN3
AN2
AN1
AN0
AN8
AN15
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual,Rev.1.06
424Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
13.2Signal Description
This section lists all inputs to the ADC10B16C block.
Figure13-2. ADC10B16C Register Summary (Sheet 1 of 3)
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor425
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
0x0003ATDCTL3RDJMS8CS4CS2CS1CFIFOFRZ1FRZ0
W
0x0004ATDCTL4RSMP2SMP1SMP0PRS[4:0]
W
0x0005ATDCTL5R0SCSCANMULTCDCCCBCA
W
0x0006ATDSTAT0RSCF0ETORFFIFORCC3CC2CC1CC0
W
0x0007Unimple-
mented
R00000000
W
0x0008ATDCMPEHRCMPE[15:8]
W
0x0009ATDCMPELRCMPE[7:0]
W
0x000AATDSTAT2HRCCF[15:8]
W
0x000BATDSTAT2LRCCF[7:0]
W
0x000CATDDIENHRIEN[15:8]
W
0x000DATDDIENLRIEN[7:0]
W
0x000EATDCMPHTHRCMPHT[15:8]
W
0x000FATDCMPHTLRCMPHT[7:0]
W
0x0010ATDDR0RSeeSection13.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection13.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0012ATDDR1RSeeSection13.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection13.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0014ATDDR2RSeeSection13.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection13.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0016ATDDR3RSeeSection13.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection13.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0018ATDDR4RSeeSection13.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection13.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x001AATDDR5RSeeSection13.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection13.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x001CATDDR6RSeeSection13.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection13.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x001EATDDR7RSeeSection13.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection13.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0020ATDDR8RSeeSection13.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection13.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0022ATDDR9RSeeSection13.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection13.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
AddressNameBit 7654321Bit 0
= Unimplemented or Reserved
Figure13-2. ADC10B16C Register Summary (Sheet 2 of 3)
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual,Rev.1.06
426Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
13.3.2Register Descriptions
This section describes in address order all the ADC10B16C registers and their individual bits.
13.3.2.1ATD Control Register 0 (ATDCTL0)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime, in special modes always write 0 to Reserved Bit 7.
0x0024ATDDR10RSeeSection13.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection13.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0026ATDDR11RSeeSection13.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection13.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0028ATDDR12RSeeSection13.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection13.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x002AATDDR13RSeeSection13.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection13.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x002CATDDR14RSeeSection13.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection13.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x002EATDDR15RSeeSection13.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection13.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
W
Module Base + 0x0000
76543210
RReserved000
WRAP3WRAP2WRAP1WRAP0
W
Reset00001111
= Unimplemented or Reserved
Figure13-3. ATD Control Register 0 (ATDCTL0)
Table13-1. ATDCTL0 Field Descriptions
FieldDescription
3-0
WRAP[3-0]
Wrap Around Channel Select Bits — These bits determine the channel for wrap around when doing
multi-channel conversions. The coding is summarized inTable13-2.
AddressNameBit 7654321Bit 0
= Unimplemented or Reserved
Figure13-2. ADC10B16C Register Summary (Sheet 3 of 3)
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor427
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
13.3.2.2ATD Control Register 1 (ATDCTL1)
Writes to this register will abort current conversion sequence.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table13-3. ATDCTL1 Field Descriptions
FieldDescription
7
ETRIGSEL
External Trigger Source Select— This bit selects the external trigger source to be either one of the AD
as source for the external trigger. The coding is summarized inTable13-5.
Table13-4. A/D Resolution Coding
SRES1SRES0A/D Resolution
008-bit data
0110-bit data
10
11Reserved
Table13-5. External Trigger Channel Select Coding
ETRIGSELETRIGCH3ETRIGCH2ETRIGCH1ETRIGCH0External trigger source is
00000AN0
00001AN1
00010AN2
00011AN3
00100AN4
00101AN5
00110AN6
00111AN7
01000AN8
01001AN9
01010AN10
01011AN11
01100AN12
01101AN13
01110AN14
01111AN15
10000ETRIG01
10001ETRIG11
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor429
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
13.3.2.3ATD Control Register 2 (ATDCTL2)
Writes to this register will abort current conversion sequence.
input buffer of this channel is enabled. The external trigger allows to synchronize the start of conversion with
external events.
0Disable external trigger
1Enable external trigger
Table13-5. External Trigger Channel Select Coding
ETRIGSELETRIGCH3ETRIGCH2ETRIGCH1ETRIGCH0External trigger source is
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual,Rev.1.06
430Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
13.3.2.4ATD Control Register 3 (ATDCTL3)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime
1
ASCIE
ATD Sequence Complete Interrupt Enable
0ATD Sequence Complete interrupt requests are disabled.
1ATD Sequence Complete interrupt will be requested whenever SCF=1 is set.
register) this bit enables the compare interrupt. If the CCF[n] flag is set (showing a successful compare for
conversionn), the compare interrupt is triggered.
0ATD Compare interrupt requests are disabled.
1For the conversions in a sequence for which automatic compare is enabled (CMPE[n]=1), an ATD Compare
Interrupt will be requested whenever any of the respective CCF flags is set.
Table13-7. External Trigger Configurations
ETRIGLEETRIGPExternal Trigger Sensitivity
00Falling edge
01Rising edge
10Low level
11High level
Module Base + 0x0003
76543210
R
DJMS8CS4CS2CS1CFIFOFRZ1FRZ0
W
Reset00100000
= Unimplemented or Reserved
Figure13-6. ATD Control Register 3 (ATDCTL3)
Table13-6. ATDCTL2 Field Descriptions (continued)
FieldDescription
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor431
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table13-8. ATDCTL3 Field Descriptions
FieldDescription
7
DJM
Result Register Data Justification — Result data format is always unsigned. This bit controls justification of
conversion data in the result registers.
0Left justified data in the result registers.
1Right justified data in the result registers.
Table13-9 gives example ATD results for an input signal range between 0 and 5.12 Volts.
6–3
S8C, S4C,
S2C, S1C
Conversion Sequence Length — These bits control the number of conversions per sequence.Table13-10
shows all combinations. At reset, S4C is set to 1 (sequence length is 4). This is to maintain software continuity
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table13-9. Examples of ideal decimal ATD Results
Input Signal
VRL = 0 Volts
VRH = 5.12 Volts
8-Bit
Codes
(resolution=20mV)
10-Bit
Codes
(resolution=5mV)
5.120 Volts
...
0.022
0.020
0.018
0.016
0.014
0.012
0.010
0.008
0.006
0.004
0.003
0.002
0.000
255
...
1
1
1
1
1
1
1
0
0
0
0
0
0
1023
...
4
4
4
3
3
2
2
2
1
1
1
0
0
Table13-10. Conversion Sequence Length Coding
S8CS4CS2CS1CNumber of Conversions
per Sequence
000016
00011
00102
00113
01004
01015
01106
01117
10008
10019
101010
101111
110012
110113
111014
111115
Table13-11. ATD Behavior in Freeze Mode (Breakpoint)
FRZ1FRZ0Behavior in Freeze Mode
00Continue conversion
01Reserved
10Finish current conversion, then freeze
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor433
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
13.3.2.5ATD Control Register 4 (ATDCTL4)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime
11Freeze Immediately
Module Base + 0x0004
76543210
R
SMP2SMP1SMP0PRS[4:0]
W
Reset00000101
Figure13-7. ATD Control Register 4 (ATDCTL4)
Table13-12. ATDCTL4 Field Descriptions
FieldDescription
7–5
SMP[2:0]
Sample Time Select — These three bits select the length of the sample time in units of ATD conversion clock
cycles. Note that the ATD conversion clock period is itself a function of the prescaler value (bits PRS4-0).
Table13-13 lists the available sample time lengths.
Refer to Device Specification for allowed frequency range of fATDCLK.
Table13-13. Sample Time Select
SMP2SMP1SMP0
Sample Time
in Number of
ATD Clock Cycles
0004
0016
0108
01110
10012
10116
11020
11124
Table13-11. ATD Behavior in Freeze Mode (Breakpoint)
FRZ1FRZ0Behavior in Freeze Mode
fATDCLK
fBUS
2PRS1+()×
-------------------------------------=
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual,Rev.1.06
434Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
13.3.2.6ATD Control Register 5 (ATDCTL5)
Writes to this register will abort current conversion sequence and start a new conversion sequence. If the
subsequent channels sampled in the sequence are determined by incrementing the channel selection code or
wrapping around to AN0 (channel 0).
0Sample only one channel
1Sample across several channels
3–0
CD, CC,
CB, CA
Analog Input Channel Select Code — These bits select the analog input channel(s).Table13-15 lists the
coding used to select the various analog input channels.
In the case of single channel conversions (MULT=0), this selection code specifies the channel to be examined.
In the case of multiple channel conversions (MULT=1), this selection code specifies the first channel to be
examined in the conversion sequence. Subsequent channels are determined by incrementing the channel
selection code or wrapping around to AN0 (after converting the channel defined by the Wrap Around Channel
Select Bits WRAP3-0 in ATDCTL0). When starting with a channel number higher than the one defined by
WRAP3-0 the first wrap around will be AN16 to AN0.
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor435
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Read: Anytime
Write: Anytime (No effect on (CC3, CC2, CC1, CC0))
Module Base + 0x0006
76543210
R
SCF
0
ETORFFIFOR
CC3CC2CC1CC0
W
Reset00000000
= Unimplemented or Reserved
Figure13-9. ATD Status Register 0 (ATDSTAT0)
Table13-16. ATDSTAT0 Field Descriptions
FieldDescription
7
SCF
Sequence Complete Flag — This flag is set upon completion of a conversion sequence. If conversion
If in FIFO mode (FIFO=1) the register counter is not initialized. The conversion counter wraps around when its
maximum value is reached.
Aborting a conversion or starting a new conversion clears the conversion counter even if FIFO=1.
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor437
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
13.3.2.8ATD Compare Enable Register (ATDCMPE)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime
13.3.2.9ATD Status Register 2 (ATDSTAT2)
This read-only register contains the Conversion Complete Flags CCF[15:0].
For each conversion number with CMPE[n]=1 do the following:
1) Write compare value to ATDDRnresult register
2) Write compare operator with CMPHT[n] in ATDCPMHT register
CCF[n] in ATDSTAT2 register will flag individual success of any comparison.
0No automatic compare
1Automatic compare of results for conversionn of a sequence is enabled.
Module Base + 0x000A
1514131211109876543210
RCCF[15:0]
W
Reset0000000000000000
= Unimplemented or Reserved
Figure13-11. ATD Status Register 2 (ATDSTAT2)
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual,Rev.1.06
438Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
13.3.2.11ATD Compare Higher Than Register (ATDCMPHT)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime
13.3.2.12ATD Conversion Result Registers (ATDDRn)
The A/D conversion results are stored in 16 result registers. Results are always in unsigned data
representation. Left and right justification is selected using the DJM control bit in ATDCTL3.
0If result of conversionn islower or same thancompare value in ATDDRn, this is flagged in ATDSTAT2
1If result of conversionn ishigher than compare value in ATDDRn, this is flagged in ATDSTAT2
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual,Rev.1.06
440Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
13.3.2.12.1Left Justified Result Data (DJM=0)
Table13-21 shows how depending on the A/D resolution the conversion result is transferred to the ATD
Figure13-15. Right justified ATD conversion result register (ATDDRn)
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor441
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table13-22 shows how depending on the A/D resolution the conversion result is transferred to the ATD
result registers for right justified data. Compare is always done using all 12 bits of both the conversion
result and the compare value in ATDDRn.
13.4Functional Description
The ADC10B16C consists of an analog sub-block and a digital sub-block.
13.4.1Analog Sub-Block
The analog sub-block contains all analog electronics required to perform a single conversion. Separate
When not converting the A/D machine is automatically powered down.
Table13-22. Conversion result mapping to ATDDRn
A/D
resolutionDJMconversion result mapping toATDDRn
8-bit data1Result-Bit[7:0] = result,
Result-Bit[11:8]=0000
10-bit data1Result-Bit[9:0] = result,
Result-Bit[11:10]=00
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual,Rev.1.06
442Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
active in level sensitive mode when a sequence is about to complete, another sequence will be triggered
immediately.
Table13-23. External Trigger Control Bits
ETRIGLEETRIGPETRIGESCANDescription
XX00Ignores external trigger. Performs one
conversion sequence and stops.
XX01Ignores external trigger. Performs
continuous conversion sequences.
001XTrigger falling edge sensitive. Performs
one conversion sequence per trigger.
011XTriggerrisingedgesensitive.Performsone
conversion sequence per trigger.
101XTrigger low level sensitive. Performs
continuous conversions while trigger level
is active.
111XTrigger high level sensitive. Performs
continuous conversions while trigger level
is active.
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor443
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
makes each ATD input pin selected as analog input available to the A/D converter.
The pad of the ATD input pin is always connected to the analog input channel of the analog mulitplexer.
Each pad input signal is buffered to the digital port register.
This buffer can be turned on or off with the ATDDIEN register for each ATD input pin.
This is important so that the buffer does not draw excess current when an ATD input pin is selected as
analog input to the ADC10B16C.
13.5Resets
At reset the ADC10B16C is in a power down state. The reset state of each individual bit is listed within
the Register Description section (seeSection13.3.2, “Register Descriptions”) which details the registers
and their bit-field.
13.6Interrupts
The interrupts requested by the ADC10B16C are listed inTable13-24. Refer to MCU specification for
related vector address and priority.
SeeSection13.3.2, “Register Descriptions” for further details.
Table13-24. ATD Interrupt Vectors
Interrupt SourceCCR
MaskLocal Enable
Sequence Complete InterruptI bitASCIE in ATDCTL2
Compare InterruptI bitACMPIE in ATDCTL2
Analog-to-Digital Converter (ADC10B16CV2)
MC9S12G Family Reference Manual,Rev.1.06
444Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor445
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter14
Analog-to-Digital Converter (ADC12B16CV2)
Revision History
14.1Introduction
The ADC12B16C is a 16-channel, 12-bit, multiplexed input successive approximation analog-to-digital
converter. Refer to device electrical specifications for ATD accuracy.
14.1.1Features
•8-, 10-, or 12-bit resolution.
Version
Number
Revision
Date
Effective
DateAuthorDescription of Changes
V02.0018 June 200918 June 2009Initial version copied 12 channel block guide
V02.0109 Feb 201009 Feb 2010
UpdatedTable14-15 Analog Input Channel Select Coding -
CB, CA. Last sentence contained a wrong highest channel
number (it is not AN7 to AN0 instead it is AN15 to AN0).
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual,Rev.1.06
446Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Automatic return to low power after conversion sequence
•Automatic compare with interrupt for higher than or less/equal than programmable value
•Programmable sample time.
•Left/right justified result data.
•External trigger control.
•Sequence complete interrupt.
•Analog input multiplexer for 8 analog input channels.
•Special conversions for VRH, VRL, (VRL+VRH)/2 and ADC temperature sensor.
•1-to-16 conversion sequence lengths.
•Continuous conversion mode.
•Multiple channel scans.
•Configurable external trigger functionality on any AD channel or any of four additional trigger
inputs. The four additional trigger inputs can be chip external or internal. Refer to device
FRZ1 and FRZ0 bits. This is useful for debugging and emulation.
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor447
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
14.1.3Block Diagram
Figure14-1. ADC12B16C Block Diagram
VSSA
AN9
ATD_12B12C
Analog
MUX
Mode and
Successive
Approximation
Register (SAR)
Results
ATD 0
ATD 1
ATD 2
ATD 3
ATD 4
ATD 5
ATD 6
ATD 7
and DAC
Sample & Hold
VDDA
VRL
VRH
Sequence Complete
+
-
Comparator
Clock
Prescaler
Bus Clock
ATD Clock
AN7
AN6
AN5
AN10
ETRIG0
(See device specifi-
cation for availability
ETRIG1
ETRIG2
ETRIG3
and connectivity)
Timing Control
ATDDIENATDCTL1
Trigger
MuxInterrupt
Compare Interrupt
AN4
AN11
AN12
AN13
AN14
ATD 8
ATD 9
ATD 10
ATD 11
ATD 13
ATD 14
ATD 12
ATD 15
AN3
AN2
AN1
AN0
AN8
AN15
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual,Rev.1.06
448Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
14.2Signal Description
This section lists all inputs to the ADC12B16C block.
Figure14-2. ADC12B16C Register Summary (Sheet 1 of 3)
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor449
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
0x0003ATDCTL3RDJMS8CS4CS2CS1CFIFOFRZ1FRZ0
W
0x0004ATDCTL4RSMP2SMP1SMP0PRS[4:0]
W
0x0005ATDCTL5R0SCSCANMULTCDCCCBCA
W
0x0006ATDSTAT0RSCF0ETORFFIFORCC3CC2CC1CC0
W
0x0007Unimple-
mented
R00000000
W
0x0008ATDCMPEHRCMPE[15:8]
W
0x0009ATDCMPELRCMPE[7:0]
W
0x000AATDSTAT2HRCCF[15:8]
W
0x000BATDSTAT2LRCCF[7:0]
W
0x000CATDDIENHRIEN[15:8]
W
0x000DATDDIENLRIEN[7:0]
W
0x000EATDCMPHTHRCMPHT[15:8]
W
0x000FATDCMPHTLRCMPHT[7:0]
W
0x0010ATDDR0RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0012ATDDR1RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0014ATDDR2RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0016ATDDR3RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0018ATDDR4RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x001AATDDR5RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x001CATDDR6RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x001EATDDR7RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0020ATDDR8RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0022ATDDR9RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
AddressNameBit 7654321Bit 0
= Unimplemented or Reserved
Figure14-2. ADC12B16C Register Summary (Sheet 2 of 3)
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual,Rev.1.06
450Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
14.3.2Register Descriptions
This section describes in address order all the ADC12B16C registers and their individual bits.
14.3.2.1ATD Control Register 0 (ATDCTL0)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime, in special modes always write 0 to Reserved Bit 7.
0x0024ATDDR10RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0026ATDDR11RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0028ATDDR12RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x002AATDDR13RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x002CATDDR14RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x002EATDDR15RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
W
Module Base + 0x0000
76543210
RReserved000
WRAP3WRAP2WRAP1WRAP0
W
Reset00001111
= Unimplemented or Reserved
Figure14-3. ATD Control Register 0 (ATDCTL0)
Table14-1. ATDCTL0 Field Descriptions
FieldDescription
3-0
WRAP[3-0]
Wrap Around Channel Select Bits — These bits determine the channel for wrap around when doing
multi-channel conversions. The coding is summarized inTable14-2.
AddressNameBit 7654321Bit 0
= Unimplemented or Reserved
Figure14-2. ADC12B16C Register Summary (Sheet 3 of 3)
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor451
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
14.3.2.2ATD Control Register 1 (ATDCTL1)
Writes to this register will abort current conversion sequence.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table14-3. ATDCTL1 Field Descriptions
FieldDescription
7
ETRIGSEL
External Trigger Source Select— This bit selects the external trigger source to be either one of the AD
as source for the external trigger. The coding is summarized inTable14-5.
Table14-4. A/D Resolution Coding
SRES1SRES0A/D Resolution
008-bit data
0110-bit data
1012-bit data
11Reserved
Table14-5. External Trigger Channel Select Coding
ETRIGSELETRIGCH3ETRIGCH2ETRIGCH1ETRIGCH0External trigger source is
00000AN0
00001AN1
00010AN2
00011AN3
00100AN4
00101AN5
00110AN6
00111AN7
01000AN8
01001AN9
01010AN10
01011AN11
01100AN12
01101AN13
01110AN14
01111AN15
10000ETRIG01
10001ETRIG11
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor453
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
14.3.2.3ATD Control Register 2 (ATDCTL2)
Writes to this register will abort current conversion sequence.
input buffer of this channel is enabled. The external trigger allows to synchronize the start of conversion with
external events.
0Disable external trigger
1Enable external trigger
Table14-5. External Trigger Channel Select Coding
ETRIGSELETRIGCH3ETRIGCH2ETRIGCH1ETRIGCH0External trigger source is
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual,Rev.1.06
454Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
14.3.2.4ATD Control Register 3 (ATDCTL3)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime
1
ASCIE
ATD Sequence Complete Interrupt Enable
0ATD Sequence Complete interrupt requests are disabled.
1ATD Sequence Complete interrupt will be requested whenever SCF=1 is set.
register) this bit enables the compare interrupt. If the CCF[n] flag is set (showing a successful compare for
conversionn), the compare interrupt is triggered.
0ATD Compare interrupt requests are disabled.
1For the conversions in a sequence for which automatic compare is enabled (CMPE[n]=1), an ATD Compare
Interrupt will be requested whenever any of the respective CCF flags is set.
Table14-7. External Trigger Configurations
ETRIGLEETRIGPExternal Trigger Sensitivity
00Falling edge
01Rising edge
10Low level
11High level
Module Base + 0x0003
76543210
R
DJMS8CS4CS2CS1CFIFOFRZ1FRZ0
W
Reset00100000
= Unimplemented or Reserved
Figure14-6. ATD Control Register 3 (ATDCTL3)
Table14-6. ATDCTL2 Field Descriptions (continued)
FieldDescription
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor455
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table14-8. ATDCTL3 Field Descriptions
FieldDescription
7
DJM
Result Register Data Justification — Result data format is always unsigned. This bit controls justification of
conversion data in the result registers.
0Left justified data in the result registers.
1Right justified data in the result registers.
Table14-9 gives example ATD results for an input signal range between 0 and 5.12 Volts.
6–3
S8C, S4C,
S2C, S1C
Conversion Sequence Length — These bits control the number of conversions per sequence.Table14-10
shows all combinations. At reset, S4C is set to 1 (sequence length is 4). This is to maintain software continuity
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table14-9. Examples of ideal decimal ATD Results
Input Signal
VRL = 0 Volts
VRH = 5.12 Volts
8-Bit
Codes
(resolution=20mV)
10-Bit
Codes
(resolution=5mV)
12-Bit
Codes
(transfer curve has
1.25mV offset)
(resolution=1.25mV)
5.120 Volts
...
0.022
0.020
0.018
0.016
0.014
0.012
0.010
0.008
0.006
0.004
0.003
0.002
0.000
255
...
1
1
1
1
1
1
1
0
0
0
0
0
0
1023
...
4
4
4
3
3
2
2
2
1
1
1
0
0
4095
...
17
16
14
12
11
9
8
6
4
3
2
1
0
Table14-10. Conversion Sequence Length Coding
S8CS4CS2CS1CNumber of Conversions
per Sequence
000016
00011
00102
00113
01004
01015
01106
01117
10008
10019
101010
101111
110012
110113
111014
111115
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor457
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
14.3.2.5ATD Control Register 4 (ATDCTL4)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime
Table14-11. ATD Behavior in Freeze Mode (Breakpoint)
FRZ1FRZ0Behavior in Freeze Mode
00Continue conversion
01Reserved
10Finish current conversion, then freeze
11Freeze Immediately
Module Base + 0x0004
76543210
R
SMP2SMP1SMP0PRS[4:0]
W
Reset00000101
Figure14-7. ATD Control Register 4 (ATDCTL4)
Table14-12. ATDCTL4 Field Descriptions
FieldDescription
7–5
SMP[2:0]
Sample Time Select — These three bits select the length of the sample time in units of ATD conversion clock
cycles. Note that the ATD conversion clock period is itself a function of the prescaler value (bits PRS4-0).
Table14-13 lists the available sample time lengths.
Refer to Device Specification for allowed frequency range of fATDCLK.
Table14-13. Sample Time Select
SMP2SMP1SMP0
Sample Time
in Number of
ATD Clock Cycles
0004
0016
0108
01110
10012
10116
11020
fATDCLK
fBUS
2PRS1+()×
-------------------------------------=
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual,Rev.1.06
458Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
14.3.2.6ATD Control Register 5 (ATDCTL5)
Writes to this register will abort current conversion sequence and start a new conversion sequence. If the
CC, CB and CA of ATDCTL5.Table14-15 lists the coding.
0Special channel conversions disabled
1Special channel conversions enabled
5
SCAN
Continuous Conversion Sequence Mode — This bit selects whether conversion sequences are performed
continuously or only once. If the external trigger function is enabled (ETRIGE=1) setting this bit has no effect,
thus the external trigger always starts a single conversion sequence.
0Single conversion sequence
1Continuous conversion sequences (scan mode)
Table14-13. Sample Time Select
SMP2SMP1SMP0
Sample Time
in Number of
ATD Clock Cycles
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor459
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
subsequent channels sampled in the sequence are determined by incrementing the channel selection code or
wrapping around to AN0 (channel 0).
0Sample only one channel
1Sample across several channels
3–0
CD, CC,
CB, CA
Analog Input Channel Select Code — These bits select the analog input channel(s).Table14-15 lists the
coding used to select the various analog input channels.
In the case of single channel conversions (MULT=0), this selection code specifies the channel to be examined.
In the case of multiple channel conversions (MULT=1), this selection code specifies the first channel to be
examined in the conversion sequence. Subsequent channels are determined by incrementing the channel
selection code or wrapping around to AN0 (after converting the channel defined by the Wrap Around Channel
Select Bits WRAP3-0 in ATDCTL0). When starting with a channel number higher than the one defined by
WRAP3-0 the first wrap around will be AN16 to AN0.
Table14-15. Analog Input Channel Select Coding
SCCDCCCBCAAnalog Input
Channel
00000AN0
0001AN1
0010AN2
0011AN3
0100AN4
0101AN5
0110AN6
0111AN7
1000AN8
1001AN9
1010AN10
1011AN11
1100AN12
1101AN13
1110AN14
1111AN15
Table14-14. ATDCTL5 Field Descriptions (continued)
FieldDescription
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual,Rev.1.06
460Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Write: Anytime (No effect on (CC3, CC2, CC1, CC0))
10000Internal_6,
Temperature sense of ADC
hardmacro
0001 Internal_7
0010Internal_0
0011Internal_1
0100VRH
0101VRL
0110(VRH+VRL) / 2
0111 Reserved
1000Internal_2
1001Internal_3
1010Internal_4
1011Internal_5
11XX Reserved
Module Base + 0x0006
76543210
R
SCF
0
ETORFFIFOR
CC3CC2CC1CC0
W
Reset00000000
= Unimplemented or Reserved
Figure14-9. ATD Status Register 0 (ATDSTAT0)
Table14-15. Analog Input Channel Select Coding
SCCDCCCBCAAnalog Input
Channel
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor461
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
14.3.2.8ATD Compare Enable Register (ATDCMPE)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime
Table14-16. ATDSTAT0 Field Descriptions
FieldDescription
7
SCF
Sequence Complete Flag — This flag is set upon completion of a conversion sequence. If conversion
If in FIFO mode (FIFO=1) the register counter is not initialized. The conversion counter wraps around when its
maximum value is reached.
Aborting a conversion or starting a new conversion clears the conversion counter even if FIFO=1.
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual,Rev.1.06
462Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
14.3.2.9ATD Status Register 2 (ATDSTAT2)
This read-only register contains the Conversion Complete Flags CCF[15:0].
For each conversion number with CMPE[n]=1 do the following:
1) Write compare value to ATDDRnresult register
2) Write compare operator with CMPHT[n] in ATDCPMHT register
CCF[n] in ATDSTAT2 register will flag individual success of any comparison.
0No automatic compare
1Automatic compare of results for conversionn of a sequence is enabled.
Module Base + 0x000A
1514131211109876543210
RCCF[15:0]
W
Reset0000000000000000
= Unimplemented or Reserved
Figure14-11. ATD Status Register 2 (ATDSTAT2)
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor463
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
14.3.2.11ATD Compare Higher Than Register (ATDCMPHT)
Writes to this register will abort current conversion sequence.
Read: Anytime
Write: Anytime
14.3.2.12ATD Conversion Result Registers (ATDDRn)
The A/D conversion results are stored in 16 result registers. Results are always in unsigned data
representation. Left and right justification is selected using the DJM control bit in ATDCTL3.
0If result of conversionn islower or same thancompare value in ATDDRn, this is flagged in ATDSTAT2
1If result of conversionn ishigher than compare value in ATDDRn, this is flagged in ATDSTAT2
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor465
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
14.3.2.12.1Left Justified Result Data (DJM=0)
Table14-21 shows how depending on the A/D resolution the conversion result is transferred to the ATD
Figure14-15. Right justified ATD conversion result register (ATDDRn)
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual,Rev.1.06
466Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table14-22 shows how depending on the A/D resolution the conversion result is transferred to the ATD
result registers for right justified data. Compare is always done using all 12 bits of both the conversion
result and the compare value in ATDDRn.
14.4Functional Description
The ADC12B16C consists of an analog sub-block and a digital sub-block.
14.4.1Analog Sub-Block
The analog sub-block contains all analog electronics required to perform a single conversion. Separate
When not converting the A/D machine is automatically powered down.
Table14-22. Conversion result mapping to ATDDRn
A/D
resolutionDJMconversion result mapping toATDDRn
8-bit data1Result-Bit[7:0] = result,
Result-Bit[11:8]=0000
10-bit data1Result-Bit[9:0] = result,
Result-Bit[11:10]=00
12-bit data1Result-Bit[11:0] = result
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor467
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
active in level sensitive mode when a sequence is about to complete, another sequence will be triggered
immediately.
Table14-23. External Trigger Control Bits
ETRIGLEETRIGPETRIGESCANDescription
XX00Ignores external trigger. Performs one
conversion sequence and stops.
XX01Ignores external trigger. Performs
continuous conversion sequences.
001XTrigger falling edge sensitive. Performs
one conversion sequence per trigger.
011XTriggerrisingedgesensitive.Performsone
conversion sequence per trigger.
101XTrigger low level sensitive. Performs
continuous conversions while trigger level
is active.
111XTrigger high level sensitive. Performs
continuous conversions while trigger level
is active.
Analog-to-Digital Converter (ADC12B16CV2)
MC9S12G Family Reference Manual,Rev.1.06
468Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
makes each ATD input pin selected as analog input available to the A/D converter.
The pad of the ATD input pin is always connected to the analog input channel of the analog mulitplexer.
Each pad input signal is buffered to the digital port register.
This buffer can be turned on or off with the ATDDIEN register for each ATD input pin.
This is important so that the buffer does not draw excess current when an ATD input pin is selected as
analog input to the ADC12B16C.
14.5Resets
At reset the ADC12B16C is in a power down state. The reset state of each individual bit is listed within
the Register Description section (seeSection14.3.2, “Register Descriptions”) which details the registers
and their bit-field.
14.6Interrupts
The interrupts requested by the ADC12B16C are listed inTable14-24. Refer to MCU specification for
related vector address and priority.
SeeSection14.3.2, “Register Descriptions” for further details.
Table14-24. ATD Interrupt Vectors
Interrupt SourceCCR
MaskLocal Enable
Sequence Complete InterruptI bitASCIE in ATDCTL2
Compare InterruptI bitACMPIE in ATDCTL2
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor469
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter15
Digital Analog Converter (DAC_8B5V)
15.1Revision History
Glossary
Table15-1. Revision History Table
Rev. No.
(Item No.)
DataSections
AffectedSubstantial Change(s)
0.128-Oct.-09allInitial Version
0.428-Oct.-09 (Thomas Becker)allInitial Version
0.512-Nov.-09 (Thomas Becker)allReworked all sections, renamed pin names
0.617-Nov.-09 (Thomas Becker)1.2.4Added CPU stop mode
1.012-Apr.-101.4.2.1Added DACCTL register bit DACDIEN
1.0104-May-10,Table 1.2,
Section 1.4
Replaced VRL,VRL with variable
correct wrong figure, table numbering
1.0212-May-10Section 1.4replaced ipt_test_mode with ips_test_access
new description/address of DACDEBUG register
1.125-May-1015.4.2.1Removed DACCTL register bit DACDIEN
1.225-Jun.-1015.4Correct table and figure title format
1.329-Jul.-1015.2Fixed typos
1.417-Nov.-1015.2.2Update the behavior of the DACU pin during stop mode
Table15-2. Terminology
TermMeaning
DACDigital to Analog Converter
VRLLow Reference Voltage
Digital Analog Converter (DAC_8B5V)
MC9S12G Family Reference Manual,Rev.1.06
470Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
from the operational amplifier output is available on the external AMP pin.
The operational amplifier is also stand alone usable.
Figure15-1 shows the block diagram of the DAC_8B5V module.
15.2.1Features
The DAC_8B5V module includes these distinctive features:
•1 digital-analog converter channel with:
—8 bit resolution
—full and reduced output voltage range
—buffered or unbuffered analog output voltage usable
•operational amplifier stand alone usable
15.2.2Modes of Operation
The DAC_8B5V module behaves as follows in the system power modes:
1.CPU run mode
The functionality of the DAC_8B5V module is available.
2.CPU stop mode
Independent from the mode settings, the operational amplifier is disabled, switch S1 and S2 are
open.
VRHHigh Reference Voltage
FVRFull Voltage Range
SSCSpecial Single Chip
Table15-2. Terminology (continued)
TermMeaning
Digital Analog Converter (DAC_8B5V)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor471
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
15.3.4AMPM Input Pin
This analog pin is used as input for the operational amplifier negative input pin, if the according mode is
selected.
15.4Memory Map and Register Definition
This sections provides the detailed information of all registers for the DAC_8B5V module.
15.4.1Register Summary
Figure15-2 shows the summary of all implemented registers inside the DAC_8B5V module.
NOTE
Register Address = Module Base Address + Address Offset, where the
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
15.4.2.1Control Register (DACCTL)
)
Module Base + 0x0000Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
FVRDRIVE
000
DACM[2:0]
W
Reset10000000
= Unimplemented
Figure15-3. Control Register (DACCTL)
Table15-3. DACCTL Field Description
FieldDescription
7
FVR
Full Voltage Range— This bit defines the voltage range of the DAC.
0DAC resistor network operates with the reduced voltage range
1DAC resistor network operates with the full voltage range
Note:For more details seeSection15.5.7, “Analog output voltage calculation”.
6
DRIVE
Drive Select— This bit selects the output drive capability of the operational amplifier, see electrical Spec. for
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
15.4.2.2Analog Output Voltage Level Register (DACVOL)
15.4.2.3Reserved Register
15.5Functional Description
15.5.1Functional Overview
The DAC resistor network and the operational amplifier can be used together or stand alone. Following
modes are supported:
Module Base + 0x0002Access: User read/write1
1Read: Anytime
Write: Anytime
76543210
R
VOLTAGE[7:0]
W
Reset00000000
Figure15-4. Analog Output Voltage Level Register (DACVOL)
Table15-4. DACVOL Field Description
FieldDescription
7:0
VOLTAGE[7:0]
VOLTAGE— This register defines (together with the FVR bit) the analog output voltage. For more detail see
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The DAC resistor network itself can work on two different voltage ranges:
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
15.5.4Mode “Unbuffered DAC”
The “Unbuffered DAC” mode is selected by DACCNTL.DACM[2:0] = 0x4. During this mode the
analog output voltage = VOLTAGE[7:0] x (VRH-VRL) / 256 +VRLEqn.15-2
Digital Analog Converter (DAC_8B5V)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor477
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
SeeTable15-8 for an example for VRL = 0.0 V and VRH = 5.0 V.
Table15-8. Analog output voltage calculation
FVRmin.
voltage
max.
voltageResolutionEquation
00.5V4.484V15.625mVVOLTAGE[7:0] x (4.0V) / 256) + 0.5V
10.0V4.980V19.531mVVOLTAGE[7:0] x (5.0V) / 256
Digital Analog Converter (DAC_8B5V)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor478
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Digital Analog Converter (DAC_8B5V)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor479
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Digital Analog Converter (DAC_8B5V)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor480
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor481
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter16
Freescale’s Scalable Controller Area Network
(S12MSCANV3)
16.1Introduction
Freescale’s scalable controller area network (S12MSCANV3) definition is based on the MSCAN12
definition, which is the specific implementation of the MSCAN concept targeted for the M68HC12
microcontroller family.
The module is a communication controller implementing the CAN 2.0A/B protocol as defined in the
Bosch specification dated September 1991. For users to fully understand the MSCAN specification, it is
recommended that the Bosch specification be read first to familiarize the reader with the terms and
concepts contained within this document.
Though not exclusively intended for automotive applications, CAN protocol is designed to meet the
specific requirements of a vehicle serial data bus: real-time processing, reliable operation in the EMI
environment of a vehicle, cost-effectiveness, and required bandwidth.
MSCAN uses an advanced buffer arrangement resulting in predictable real-time behavior and simplified
application software.
Table16-1.Revision History
Revision
NumberRevision DateSections
AffectedDescription of Changes
V03.1131 Mar 2009 •Orthographic corrections
V03.1209 Aug 2010Table16-37 •Added ‘Bosch CAN 2.0A/B’ to bit time settings table
V03.1303 Mar 2011Figure16-4
Table16-3
•Corrected CANE write restrictions
•Removed footnote from RXFRM bit
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
482Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.1.1Glossary
16.1.2Block Diagram
Figure16-1. MSCAN Block Diagram
Table16-2. Terminology
ACKAcknowledge of CAN message
CANController Area Network
CRCCyclic Redundancy Code
EOFEnd of Frame
FIFOFirst-In-First-Out Memory
IFSInter-Frame Sequence
SOFStart of Frame
CPU busCPU related read/write data bus
CAN busCAN protocol related serial bus
oscillator clockDirect clock from external oscillator
bus clockCPU bus related clock
CAN clockCAN protocol related clock
RXCAN
TXCAN
Receive/
Transmit
Engine
Message
Filtering
and
Buffering
Control
and
Status
Wake-Up Interrupt Req.
Errors Interrupt Req.
Receive Interrupt Req.
Transmit Interrupt Req.
CANCLK
Bus Clock
Configuration
Oscillator Clock
MUX
Presc.
Tq Clk
MSCAN
Low Pass Filter
Wake-Up
Registers
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor483
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.1.3Features
The basic features of the MSCAN are as follows:
•Implementation of the CAN protocol — Version 2.0A/B
—Standard and extended data frames
—Zero to eight bytes data length
—Programmable bit rate up to 1 Mbps1
—Support for remote frames
•Five receive buffers with FIFO storage scheme
•Three transmit buffers with internal prioritization using a “local priority” concept
modes refer toSection16.4.4, “Modes of Operation”.
16.2External Signal Description
The MSCAN uses two external pins.
NOTE
On MCUs with an integrated CAN physical interface (transceiver) the
MSCAN interface is connected internally to the transceiver interface. In
these cases the external availability of signals TXCAN and RXCAN is
optional.
16.2.1RXCAN — CAN Receiver Input Pin
RXCAN is the MSCAN receiver input pin.
1.Depending on the actual bit timing and the clock jitter of the PLL.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
484Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.2.2TXCAN — CAN Transmitter Output Pin
TXCAN is the MSCAN transmitter output pin. The TXCAN output pin represents the logic level on the
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor485
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The detailed register descriptions follow in the order they appear in the register map.
Register
NameBit 7654321Bit 0
0x0000
CANCTL0
RRXFRMRXACTCSWAISYNCHTIMEWUPESLPRQINITRQ
W
0x0001
CANCTL1
RCANECLKSRCLOOPBLISTENBORMWUPMSLPAKINITAK
W
0x0002
CANBTR0
RSJW1SJW0BRP5BRP4BRP3BRP2BRP1BRP0
W
0x0003
CANBTR1
RSAMPTSEG22TSEG21TSEG20TSEG13TSEG12TSEG11TSEG10
W
0x0004
CANRFLG
RWUPIFCSCIFRSTAT1RSTAT0TSTAT1TSTAT0OVRIFRXF
W
0x0005
CANRIER
RWUPIECSCIERSTATE1RSTATE0TSTATE1TSTATE0OVRIERXFIE
W
0x0006
CANTFLG
R00000
TXE2TXE1TXE0
W
0x0007
CANTIER
R00000
TXEIE2TXEIE1TXEIE0
W
0x0008
CANTARQ
R00000
ABTRQ2ABTRQ1ABTRQ0
W
0x0009
CANTAAK
R00000ABTAK2ABTAK1ABTAK0
W
0x000A
CANTBSEL
R00000
TX2TX1TX0
W
0x000B
CANIDAC
R00IDAM1IDAM00IDHIT2IDHIT1IDHIT0
W
0x000C
Reserved
R00000000
W
0x000D
CANMISC
R0000000
BOHOLD
W
= Unimplemented or Reserved
Figure16-3. MSCAN Register Summary
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
486Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
includes a standard register diagram with an associated figure number. Details of register bit and field
function follow the register diagrams, in bit order. All bits of all registers in this module are completely
synchronous to internal clocks during a register read.
16.3.2.1MSCAN Control Register 0 (CANCTL0)
The CANCTL0 register provides various control bits of the MSCAN module as described below.
0x000E
CANRXERR
RRXERR7RXERR6RXERR5RXERR4RXERR3RXERR2RXERR1RXERR0
W
0x000F
CANTXERR
RTXERR7TXERR6TXERR5TXERR4TXERR3TXERR2TXERR1TXERR0
W
0x0010–0x0013
CANIDAR0–3
RAC7AC6AC5AC4AC3AC2AC1AC0
W
0x0014–0x0017
CANIDMRx
RAM7AM6AM5AM4AM3AM2AM1AM0
W
0x0018–0x001B
CANIDAR4–7
RAC7AC6AC5AC4AC3AC2AC1AC0
W
0x001C–0x001F
CANIDMR4–7
RAM7AM6AM5AM4AM3AM2AM1AM0
W
0x0020–0x002F
CANRXFG
RSeeSection16.3.3, “Programmer’s Model of Message Storage”
W
0x0030–0x003F
CANTXFG
RSeeSection16.3.3, “Programmer’s Model of Message Storage”
W
Register
NameBit 7654321Bit 0
= Unimplemented or Reserved
Figure16-3. MSCAN Register Summary (continued)
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor487
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Storage”). The internal timer is reset (all bits set to 0) when disabled. This bit is held low in initialization mode.
0Disable internal MSCAN timer
1Enable internal MSCAN timer
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
488Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.3.2.2MSCAN Control Register 1 (CANCTL1)
The CANCTL1 register provides various control bits and handshake status information of the MSCAN
module as described below.
2
WUPE3Wake-Up Enable — This configuration bit allows the MSCAN to restart from sleep mode or from power down
4The CPU cannot clear SLPRQ before the MSCAN has entered sleep mode (SLPRQ = 1 and SLPAK = 1).
5The CPU cannot clear INITRQ before the MSCAN has entered initialization mode (INITRQ = 1 and INITAK = 1).
6In order to protect from accidentally violating the CAN protocol, TXCAN is immediately forced to a recessive state when the
initialization mode is requested by the CPU. Thus, the recommended procedure is to bring the MSCAN into sleep mode
(SLPRQ = 1 and SLPAK = 1) before requesting initialization mode.
7Not including WUPE, INITRQ, and SLPRQ.
8TSTAT1 and TSTAT0 are not affected by initialization mode.
9RSTAT1 and RSTAT0 are not affected by initialization mode.
Table16-3. CANCTL0 Register Field Descriptions (continued)
FieldDescription
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor489
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
messages with matching ID are received, but no acknowledgement or error frames are sent out (see
Section16.4.4.4, “Listen-Only Mode”). In addition, the error counters are frozen. Listen only mode supports
applications which require “hot plugging” or throughput analysis. The MSCAN is unable to transmit any
messages when listen only mode is active.
0Normal operation
1Listen only mode activated
3
BORM
Bus-Off Recovery Mode — This bit configures the bus-off state recovery mode of the MSCAN. Refer to
Section16.5.2, “Bus-Off Recovery,” for details.
0Automatic bus-off recovery (see Bosch CAN 2.0A/B protocol specification)
1Bus-off recovery upon user request
2
WUPM
Wake-Up Mode — If WUPE in CANCTL0 is enabled, this bit defines whether the integrated low-pass filter is
applied to protect the MSCAN from spurious wake-up (seeSection16.4.5.5, “MSCAN Sleep Mode”).
0MSCAN wakes up on any dominant level on the CAN bus
1MSCAN wakes up only in case of a dominant pulse on the CAN bus that has a length of Twup
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
490Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.3.2.3MSCAN Bus Timing Register 0 (CANBTR0)
The CANBTR0 register configures various CAN bus timing parameters of the MSCAN module.
1
SLPAK
Sleep Mode Acknowledge — This flag indicates whether the MSCAN module has entered sleep mode (see
Section16.4.5.5, “MSCAN Sleep Mode”). It is used as a handshake flag for the SLPRQ sleep mode request.
Sleep mode is active when SLPRQ=1 and SLPAK=1. Depending on the setting of WUPE, the MSCAN will
clear the flag if it detects activity on the CAN bus while in sleep mode.
0Running — The MSCAN operates normally
1Sleep mode active — The MSCAN has entered sleep mode
0
INITAK
Initialization Mode Acknowledge — This flag indicates whether the MSCAN module is in initialization mode
Table16-4. CANCTL1 Register Field Descriptions (continued)
FieldDescription
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor491
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.3.2.4MSCAN Bus Timing Register 1 (CANBTR1)
The CANBTR1 register configures various CAN bus timing parameters of the MSCAN module.
Table16-7. Baud Rate Prescaler
BRP5BRP4BRP3BRP2BRP1BRP0Prescaler value (P)
0000001
0000012
0000103
0000114
:::::::
11111164
Module Base + 0x0003Access: User read/write1
1Read: Anytime
Write: Anytime in initialization mode (INITRQ=1 and INITAK=1)
76543210
R
SAMPTSEG22TSEG21TSEG20TSEG13TSEG12TSEG11TSEG10
W
Reset:00000000
Figure16-7. MSCAN Bus Timing Register 1(CANBTR1)
Table16-8. CANBTR1 Register Field Descriptions
FieldDescription
7
SAMP
Sampling — This bit determines the number of CAN bus samples taken per bit time.
0One sample per bit.
1Three samples per bit1.
If SAMP = 0, the resulting bit value is equal to the value of the single bit positioned at the sample point. If
of the sample point (seeFigure16-44). Time segment 1 (TSEG1) values are programmable as shown in
Table16-10.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
492Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The bit time is determined by the oscillator frequency, the baud rate prescaler, and the number of time
quanta (Tq) clock cycles per bit (as shown inTable16-9 andTable16-10).
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor493
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NOTE
The CANRFLG register is held in the reset state1 when the initialization
bus status of the MSCAN. The coding for the bits RSTAT1, RSTAT0 is:
00RxOK:0≤ receive error counter≤ 96
01RxWRN: 96< receive error counter≤ 127
10RxERR: 127< receive error counter
11Bus-off1: transmit error counter> 255
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
494Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table16-11. CANRFLG Register Field Descriptions (continued)
FieldDescription
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor495
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.3.2.7MSCAN Transmitter Flag Register (CANTFLG)
The transmit buffer empty flags each have an associated interrupt enable bit in the CANTIER register.
Table16-12. CANRIER Register Field Descriptions
FieldDescription
7
WUPIE1
1WUPIE and WUPE(seeSection16.3.2.1, “MSCAN Control Register 0 (CANCTL0)”) must both be enabled if the recovery
mechanism from stop or wait is required.
Wake-Up Interrupt Enable
0No interrupt request is generated from this event.
1A wake-up event causes a Wake-Up interrupt request.
6
CSCIE
CAN Status Change Interrupt Enable
0No interrupt request is generated from this event.
1A CAN Status Change event causes an error interrupt request.
state changes are causing CSCIF interrupts. Independent of the chosen sensitivity level, the TSTAT flags
continue to indicate the actual transmitter state and are only updated if no CSCIF interrupt is pending.
00Do not generate any CSCIF interrupt caused by transmitter state changes.
01Generate CSCIF interrupt only if the transmitter enters or leaves “bus-off” state. Discard other transmitter
state changes for generating CSCIF interrupt.
10Generate CSCIF interrupt only if the transmitter enters or leaves “TxErr” or “bus-off” state. Discard other
transmitter state changes for generating CSCIF interrupt.
11Generate CSCIF interrupt on all state changes.
1
OVRIE
Overrun Interrupt Enable
0No interrupt request is generated from this event.
1An overrun event causes an error interrupt request.
0
RXFIE
Receiver Full Interrupt Enable
0No interrupt request is generated from this event.
1A receive buffer full (successful message reception) event causes a receiver interrupt request.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
496Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NOTE
The CANTFLG register is held in the reset state when the initialization
the MSCAN when the transmission request is successfully aborted due to a pending abort request (see
Section16.3.2.9, “MSCAN Transmitter Message Abort Request Register (CANTARQ)”). If not masked, a
transmit interrupt is pending while this flag is set.
Clearing a TXEx flag also clears the corresponding ABTAKx (seeSection16.3.2.10, “MSCAN Transmitter
Message Abort Acknowledge Register (CANTAAK)”). When a TXEx flag is set, the corresponding ABTRQx bit
is cleared (seeSection16.3.2.9, “MSCAN Transmitter Message Abort Request Register (CANTARQ)”).
When listen-mode is active (seeSection16.3.2.2, “MSCAN Control Register 1 (CANCTL1)”) the TXEx flags
cannot be cleared and no transmission is started.
Read and write accesses to the transmit buffer will be blocked, if the corresponding TXEx bit is cleared
(TXEx=0) and the buffer is scheduled for transmission.
0The associated message buffer is full (loaded with a message due for transmission)
1The associated message buffer is empty (not scheduled)
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor497
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
498Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Abort Acknowledge — This flag acknowledges that a message was aborted due to a pending abort request
from the CPU. After a particular message buffer is flagged empty, this flag can be used by the application
software to identify whether the message was aborted successfully or was sent anyway. The ABTAKx flag is
cleared whenever the corresponding TXE flag is cleared.
0The message was not aborted.
1The message was aborted.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor499
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NOTE
The CANTBSEL register is held in the reset state when the initialization
bit is cleared and the buffer is scheduled for transmission (seeSection16.3.2.7, “MSCAN Transmitter Flag
Register (CANTFLG)”).
0The associated message buffer is deselected
1The associated message buffer is selected, if lowest numbered bit
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
500Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The IDHITx indicators are always related to the message in the foreground buffer (RxFG). When a
message gets shifted into the foreground buffer of the receiver FIFO the indicators are updated as well.
Module Base + 0x000BAccess: User read/write1
1Read: Anytime
Write: Anytime in initialization mode (INITRQ = 1 and INITAK = 1), except bits IDHITx, which are read-only
76543210
R00
IDAM1IDAM0
0IDHIT2IDHIT1IDHIT0
W
Reset:00000000
= Unimplemented
Figure16-15. MSCAN Identifier Acceptance Control Register (CANIDAC)
mode, no message is accepted such that the foreground buffer is never reloaded.
2-0
IDHIT[2:0]
Identifier Acceptance Hit Indicator — The MSCAN sets these flags to indicate an identifier acceptance hit (see
Section16.4.3, “Identifier Acceptance Filter”).Table16-20 summarizes the different settings.
Table16-19. Identifier Acceptance Mode Settings
IDAM1IDAM0Identifier Acceptance Mode
00Two 32-bit acceptance filters
01Four 16-bit acceptance filters
10Eight 8-bit acceptance filters
11Filter closed
Table16-20. Identifier Acceptance Hit Indication
IDHIT2IDHIT1IDHIT0Identifier Acceptance Hit
000Filter 0 hit
001Filter 1 hit
010Filter 2 hit
011Filter 3 hit
100Filter 4 hit
101Filter 5 hit
110Filter 6 hit
111Filter 7 hit
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor501
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.3.2.13MSCAN Reserved Register
This register is reserved for factory testing of the MSCAN module and is not available in normal system
Refer toSection16.5.2, “Bus-Off Recovery,” for details.
0Module is not bus-off or recovery has been requested by user in bus-off state
1Module is bus-off and holds this state until user request
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
502Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.3.2.15MSCAN Receive Error Counter (CANRXERR)
This register reflects the status of the MSCAN receive error counter.
NOTE
Reading this register when in any other mode other than sleep or
initialization mode may return an incorrect value. For MCUs with dual
CPUs, this may result in a CPU fault condition.
Writing to this register when in special modes can alter the MSCAN
functionality.
16.3.2.16MSCAN Transmit Error Counter (CANTXERR)
This register reflects the status of the MSCAN transmit error counter.
NOTE
Reading this register when in any other mode other than sleep or
initialization mode, may return an incorrect value. For MCUs with dual
CPUs, this may result in a CPU fault condition.
Module Base + 0x000EAccess: User read/write1
1Read: Only when in sleep mode (SLPRQ = 1 and SLPAK = 1) or initialization mode (INITRQ = 1 and INITAK=1)
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor503
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Writing to this register when in special modes can alter the MSCAN
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
504Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor505
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.3.3Programmer’s Model of Message Storage
The following section details the organization of the receive and transmit message buffers and the
associated control registers.
To simplify the programmer interface, the receive and transmit message buffers have the same outline.
Each message buffer allocates 16 bytes in the memory map containing a 13 byte data structure.
An additional transmit buffer priority register (TBPR) is defined for the transmit buffers. Within the last
acceptance register does not affect whether or not the message is accepted.
0Match corresponding acceptance code register and identifier bits
1Ignore corresponding acceptance code register bit
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
506Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure16-24 shows the common 13-byte data structure of receive and transmit buffers for extended
identifiers. The mapping of standard identifiers into the IDR registers is shown inFigure16-25.
All bits of the receive and transmit buffers are ‘x’ out of reset because of RAM-based implementation1.
All reserved or unused bits of the receive and transmit buffers always read ‘x’.
Table16-26. Message Buffer Organization
Offset
AddressRegisterAccess
0x00X0Identifier Register 0R/W
0x00X1Identifier Register 1R/W
0x00X2Identifier Register 2R/W
0x00X3Identifier Register 3R/W
0x00X4Data Segment Register 0R/W
0x00X5Data Segment Register 1R/W
0x00X6Data Segment Register 2R/W
0x00X7Data Segment Register 3R/W
0x00X8Data Segment Register 4R/W
0x00X9Data Segment Register 5R/W
0x00XAData Segment Register 6R/W
0x00XBData Segment Register 7R/W
0x00XCData Length RegisterR/W
0x00XDTransmit Buffer Priority Register1
1Not applicable for receive buffers
R/W
0x00XETime Stamp Register (High Byte)R
0x00XFTime Stamp Register (Low Byte)R
1.Exception: The transmit buffer priority registers are 0 out of reset.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor507
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
508Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor509
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.3.3.1.1IDR0–IDR3 for Extended Identifier Mapping
Extended Format Identifier —The identifiers consist of 29 bits (ID[28:0]) for the extended format. ID28 is the
most significant bit and is transmitted first on the CAN bus during the arbitration procedure. The priority of an
identifier is defined to be highest for the smallest binary number.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
510Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table16-30. IDR3 Register Field Descriptions— Extended
FieldDescription
7-1
ID[6:0]
Extended Format Identifier —The identifiers consist of 29 bits (ID[28:0]) for the extended format. ID28 is the
most significant bit and is transmitted first on the CAN bus during the arbitration procedure. The priority of an
identifier is defined to be highest for the smallest binary number.
0
RTR
Remote Transmission Request — This flag reflects the status of the remote transmission request bit in the
CAN frame. In the case of a receive buffer, it indicates the status of the received frame and supports the
transmission of an answering frame in software. In the case of a transmit buffer, this flag defines the setting of
the RTR bit to be sent.
0Data frame
1Remote frame
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor511
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.3.3.1.2IDR0–IDR3 for Standard Identifier Mapping
Module Base + 0x00X0
76543210
R
ID10ID9ID8ID7ID6ID5ID4ID3
W
Reset:xxxxxxxx
Figure16-30. Identifier Register 0 — Standard Mapping
Table16-31. IDR0 Register Field Descriptions— Standard
FieldDescription
7-0
ID[10:3]
Standard Format Identifier —The identifiers consist of 11 bits (ID[10:0]) for the standard format. ID10 is the
most significant bit and is transmitted first on the CAN bus during the arbitration procedure. The priority of an
identifier is defined to be highest for the smallest binary number. See also ID bits inTable16-32.
Module Base + 0x00X1
76543210
R
ID2ID1ID0RTRIDE (=0)
W
Reset:xxxxxxxx
= Unused; always read ‘x’
Figure16-31. Identifier Register 1 — Standard Mapping
Table16-32. IDR1 Register Field Descriptions
FieldDescription
7-5
ID[2:0]
Standard Format Identifier —The identifiers consist of 11 bits (ID[10:0]) for the standard format. ID10 is the
most significant bit and is transmitted first on the CAN bus during the arbitration procedure. The priority of an
identifier is defined to be highest for the smallest binary number. See also ID bits inTable16-31.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
512Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.3.3.2Data Segment Registers (DSR0-7)
The eight data segment registers, each with bits DB[7:0], contain the data to be transmitted or received.
The number of bytes to be transmitted or received is determined by the data length code in the
corresponding DLR register.
Module Base + 0x00X2
76543210
R
W
Reset:xxxxxxxx
= Unused; always read ‘x’
Figure16-32. Identifier Register 2 — Standard Mapping
Module Base + 0x00X3
76543210
R
W
Reset:xxxxxxxx
= Unused; always read ‘x’
Figure16-33. Identifier Register 3 — Standard Mapping
Module Base + 0x00X4 to Module Base + 0x00XB
76543210
R
DB7DB6DB5DB4DB3DB2DB1DB0
W
Reset:xxxxxxxx
Figure16-34. Data Segment Registers (DSR0–DSR7) — Extended Identifier Mapping
Table16-33. DSR0–DSR7 Register Field Descriptions
FieldDescription
7-0
DB[7:0]
Data bits 7-0
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor513
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.3.3.3Data Length Register (DLR)
This register keeps the data length field of the CAN frame.
16.3.3.4Transmit Buffer Priority Register (TBPR)
This register defines the local priority of the associated message buffer. The local priority is used for the
the number of transmitted data bytes is always 0. The data byte count ranges from 0 to 8 for a data frame.
Table16-35 shows the effect of setting the DLC bits.
Table16-35. Data Length Codes
Data Length CodeData Byte
Count
DLC3DLC2DLC1DLC0
00000
00011
00102
00113
01004
01015
01106
01117
10008
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
514Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•The transmission buffer with the lowest local priority field wins the prioritization.
Figure16-37. Time Stamp Register — High Byte (TSRH)
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor515
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.4Functional Description
16.4.1General
This section provides a complete functional description of the MSCAN.
Module Base + 0x00XFAccess: User read/write1
1Read: Anytime when TXEx flag is set (seeSection16.3.2.7, “MSCAN Transmitter Flag Register (CANTFLG)”) and the
Figure16-38. Time Stamp Register — Low Byte (TSRL)
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
516Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.4.2Message Storage
Figure16-39. User Model for Message Buffer Organization
The MSCAN facilitates a sophisticated message storage system which addresses the requirements of a
broad range of network applications.
16.4.2.1Message Transmit Background
Modern application layer software is built upon two fundamental assumptions:
MSCAN
Rx0
Rx1
CAN Receive / Transmit EngineMemory Mapped I/O
CPU bus
MSCAN
Tx2
TXE2
PRIO
Receiver
Transmitter
RxBG
TxBG
Tx0
TXE0
PRIO
TxBG
Tx1
PRIO
TXE1
TxFG
CPU bus
Rx2
Rx3
Rx4
RXF
RxFG
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor517
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CANTBSEL register simplifies the transmit buffer selection. In addition, this scheme makes the handler
software simpler because only one address area is applicable for the transmit process, and the required
address space is minimized.
The CPU then stores the identifier, the control bits, and the data content into one of the transmit buffers.
Finally, the buffer is flagged as ready for transmission by clearing the associated TXE flag.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
518Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The MSCAN then schedules the message for transmission and signals the successful transmission of the
field of the CAN frame, is received into the next available RxBG. If the MSCAN receives an invalid
1.The transmit interrupt occurs only if not masked. A polling scheme can be applied on TXEx also.
2.The receive interrupt occurs only if not masked. A polling scheme can be applied on RXF also.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor519
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
message in its RxBG (wrong identifier, transmission errors, etc.) the actual contents of the buffer will be
over-written by the next message. The buffer will then not be shifted into the FIFO.
When the MSCAN module is transmitting, the MSCAN receives its own transmitted messages into the
This mode implements two filters for a full length CAN 2.0B compliant extended identifier.
Although this mode can be used for standard identifiers, it is recommended to use the four or
eight identifier acceptance filters.
Figure16-40 shows how the first 32-bit filter bank (CANIDAR0–CANIDAR3,
CANIDMR0–CANIDMR3) produces a filter 0 hit. Similarly, the second filter bank
(CANIDAR4–CANIDAR7, CANIDMR4–CANIDMR7) produces a filter 1 hit.
•Four identifier acceptance filters, each to be applied to:
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
520Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor521
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
522Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor523
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CAN protocol are met. Additionally, for high CAN bus rates (1 Mbps), a 45% to 55% duty cycle of the
clock is required.
If the bus clock is generated from a PLL, it is recommended to select the oscillator clock rather than the
bus clock due to jitter considerations, especially at the faster CAN bus rates.
Bus Clock
Oscillator Clock
MSCAN
CANCLK
CLKSRC
CLKSRC
Prescaler
(1 .. 64)
Time quanta clock (Tq)
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
524Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
For microcontrollers without a clock and reset generator (CRG), CANCLK is driven from the crystal
oscillator (oscillator clock).
A programmable prescaler generates the time quanta (Tq) clock from CANCLK. A time quantum is the
atomic unit of time handled by the MSCAN.
Eqn.16-2
A bit time is subdivided into three segments as described in the Bosch CAN 2.0A/B specification. (see
Figure16-44):
•SYNC_SEG: This segment has a fixed length of one time quantum. Signal edges are expected to
happen within this section.
•Time Segment 1: This segment includes the PROP_SEG and the PHASE_SEG1 of the CAN
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor525
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
SYNC_SEGSystem expects transitions to occur on the CAN bus during this
period.
Transmit PointA node in transmit mode transfers a new value to the CAN bus at
this point.
Sample Point
A node in receive mode samples the CAN bus at this point. If the
three samples per bit option is selected, then this point marks the
position of the third sample.
Table16-37. Bosch CAN 2.0A/B Compliant Bit Time Segment Settings
Time Segment 1TSEG1Time Segment 2TSEG2 Synchronization
Jump WidthSJW
5 .. 104 .. 9211 .. 20 .. 1
4 .. 113 .. 10321 .. 30 .. 2
5 .. 124 .. 11431 .. 40 .. 3
6 .. 135 .. 12541 .. 40 .. 3
7 .. 146 .. 13651 .. 40 .. 3
8 .. 157 .. 14761 .. 40 .. 3
9 .. 168 .. 15871 .. 40 .. 3
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
526Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
is used to reset the CANCTL0, CANRFLG, CANRIER, CANTFLG, CANTIER, CANTARQ,
CANTAAK, and CANTBSEL registers to their default values. In addition, the MSCAN enables the
configuration of the CANBTR0, CANBTR1 bit timing registers; CANIDAC; and the CANIDAR,
CANIDMR message filters. SeeSection16.3.2.1, “MSCAN Control Register 0 (CANCTL0),” for a
detailed description of the initialization mode.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor527
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
is reduced by stopping all clocks except those to access the registers from the CPU side. In power down
mode, all clocks are stopped and no power is consumed.
Table16-38 summarizes the combinations of MSCAN and CPU modes. A particular combination of
modes is entered by the given settings on the CSWAI and SLPRQ/SLPAK bits.
SYNC
SYNC
Bus Clock DomainCAN Clock Domain
CPU
Init Request
INIT
Flag
INITAK
Flag
INITRQ
sync.
INITAK
sync.
INITRQ
INITAK
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
528Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
mode. In this mode the module can either be in initialization mode or out of initialization mode. See
Section16.4.4.5, “MSCAN Initialization Mode”.
Table16-38. CPU vs. MSCAN Operating Modes
CPU Mode
MSCAN Mode
Normal
Reduced Power Consumption
SleepPower DownDisabled
(CANE=0)
RUN
CSWAI = X1
SLPRQ = 0
SLPAK = 0
1‘X’ means don’t care.
CSWAI = X
SLPRQ = 1
SLPAK = 1
CSWAI = X
SLPRQ = X
SLPAK = X
WAIT
CSWAI = 0
SLPRQ = 0
SLPAK = 0
CSWAI = 0
SLPRQ = 1
SLPAK = 1
CSWAI = 1
SLPRQ = X
SLPAK = X
CSWAI = X
SLPRQ = X
SLPAK = X
STOP
CSWAI = X
SLPRQ = X
SLPAK = X
CSWAI = X
SLPRQ = X
SLPAK = X
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor529
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.4.5.5MSCAN Sleep Mode
The CPU can request the MSCAN to enter this low power mode by asserting the SLPRQ bit in the
CANCTL0 register. The time when the MSCAN enters sleep mode depends on a fixed synchronization
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
530Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
If the WUPE bit in CANCTL0 is not asserted, the MSCAN will mask any activity it detects on CAN.
RXCAN is therefore held internally in a recessive state. This locks the MSCAN in sleep mode. WUPE
must be set before entering sleep mode to take effect.
The MSCAN is able to leave sleep mode (wake up) only when:
•CAN bus activity occurs and WUPE = 1
or
•the CPU clears the SLPRQ bit
NOTE
The CPU cannot clear the SLPRQ bit before sleep mode (SLPRQ = 1 and
SLPAK=1) is active.
After wake-up, the MSCAN waits for 11 consecutive recessive bits to synchronize to the CAN bus. As a
consequence, if the MSCAN is woken-up by a CAN frame, this frame is not received.
powering up. This causes some fixed delay before the module enters normal mode again.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor531
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
532Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.4.7.3ReceiveInterrupt
A message is successfully received and shifted into the foreground buffer (RxFG) of the receiver FIFO.
used to clear interrupt flags. These instructions may cause accidental
clearing of interrupt flags which are set after entering the current interrupt
service routine.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor533
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16.5Initialization/Application Information
16.5.1MSCAN initialization
The procedure to initially start up the MSCAN module out of reset is as follows:
1.Assert CANE
2.Write to the configuration registers in initialization mode
3.Clear INITRQ to leave initialization mode
If the configuration of registers which are only writable in initialization mode shall be changed:
recovery from bus-off starts after both independent events have become true:
•128 occurrences of 11 consecutive recessive bits on the CAN bus have been monitored
•BOHOLD inMSCAN Miscellaneous Register (CANMISC) has been cleared by the user
These two events may occur in any order.
Freescale’s Scalable Controller Area Network (S12MSCANV3)
MC9S12G Family Reference Manual,Rev.1.06
534Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor535
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter17
Pulse-Width Modulator (S12PWM8B8CV2)
17.1Introduction
The Version 2 of S12 PWM module is a channel scalable and optimized implementation of S12
PWM8B8C Version 1. The channel is scalable in pairs from PWM0 to PWM7 and the available channel
number is 2, 4, 6 and 8. The shutdown feature has been removed and the flexibility to select one of four
clock sources per channel has improved. If the corresponding channels exist and shutdown feature is not
used, the Version 2 is fully software compatible to Version 1.
17.1.1Features
The scalable PWM block includes these distinctive features:
•Up to eight independent PWM channels, scalable in pairs (PWM0 to PWM7)
•Available channel number could be 2, 4, 6, 8 (refer to device specification for exact number)
•Programmable period and duty cycle for each channel
•Dedicated counter for each PWM channel
•Programmable PWM enable/disable for each channel
•Software selection of PWM duty pulse polarity for each channel
Wait:The prescaler keeps on running, unless PSWAI in PWMCTL is set to 1.
Freeze:The prescaler keeps on running, unless PFRZ in PWMCTL is set to 1.
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
536Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
17.1.3Block Diagram
Figure17-1 shows the block diagram for the 8-bit up to 8-channel scalable PWM block.
Those pins serve as waveform output of PWM channel 7 - 0.
Period and DutyCounter
Channel 6
Clock SelectPWM Clock
Period and DutyCounter
Channel 5
Period and DutyCounter
Channel 4
Period and DutyCounter
Channel 3
Period and DutyCounter
Channel 2
Period and DutyCounter
Channel 1
Alignment
Polarity
Control
PWM8B8C
PWM6
PWM5
PWM4
PWM3
PWM2
PWM1
Enable
PWM Channels
Period and DutyCounter
Channel 7
Period and DutyCounter
Channel 0
PWM0
PWM7
Bus Clock
Maximum possible channels, scalable in pairs from PWM0 to PWM7.
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor537
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
17.3Memory Map and Register Definition
17.3.1Module Memory Map
This section describes the content of the registers in the scalable PWM module. The base address of the
Figure17-2. The scalable PWM Register Summary (Sheet 1 of 4)
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
538Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
0x0007
RESERVED
R00000000
W
0x0008
PWMSCLA
RBit 7 6 5 4 3 2 1 Bit 0
W
0x0009
PWMSCLB
RBit 7 6 5 4 3 2 1 Bit 0
W
0x000A
RESERVED
R00000000
W
0x000B
RESERVED
R00000000
W
0x000C
PWMCNT02RBit 7 6 5 4 3 2 1 Bit 0
W00000000
0x000D
PWMCNT12RBit 7 6 5 4 3 2 1 Bit 0
W00000000
0x000E
PWMCNT22RBit 7 6 5 4 3 2 1 Bit 0
W00000000
0x000F
PWMCNT32RBit 7 6 5 4 3 2 1 Bit 0
W00000000
0x0010
PWMCNT42RBit 7 6 5 4 3 2 1 Bit 0
W00000000
0x0011
PWMCNT52RBit 7 6 5 4 3 2 1 Bit 0
W00000000
0x0012
PWMCNT62RBit 7 6 5 4 3 2 1 Bit 0
W00000000
0x0013
PWMCNT72RBit 7 6 5 4 3 2 1 Bit 0
W00000000
0x0014
PWMPER02RBit 7 6 5 4 3 2 1 Bit 0
W
0x0015
PWMPER12RBit 7 6 5 4 3 2 1 Bit 0
W
Register
NameBit 7654321Bit 0
= Unimplemented or Reserved
Figure17-2. The scalable PWM Register Summary (Sheet 1 of 4)
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor539
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
0x0016
PWMPER22RBit 7 6 5 4 3 2 1 Bit 0
W
0x0017
PWMPER32RBit 7 6 5 4 3 2 1 Bit 0
W
0x0018
PWMPER42RBit 7 6 5 4 3 2 1 Bit 0
W
0x0019
PWMPER52RBit 7 6 5 4 3 2 1 Bit 0
W
0x001A
PWMPER62RBit 7 6 5 4 3 2 1 Bit 0
W
0x001B
PWMPER72RBit 7 6 5 4 3 2 1 Bit 0
W
0x001C
PWMDTY02RBit 7 6 5 4 3 2 1 Bit 0
W
0x001D
PWMDTY12RBit 7 6 5 4 3 2 1 Bit 0
W
0x001E
PWMDTY22RBit 7 6 5 4 3 2 1 Bit 0
W
0x001F
PWMDTY32RBit 7 6 5 4 3 2 1 Bit 0
W
0x0010
PWMDTY42RBit 7 6 5 4 3 2 1 Bit 0
W
0x0021
PWMDTY52RBit 7 6 5 4 3 2 1 Bit 0
W
0x0022
PWMDTY62RBit 7 6 5 4 3 2 1 Bit 0
W
0x0023
PWMDTY72RBit 7 6 5 4 3 2 1 Bit 0
W
0x0024
RESERVED
R00000000
W
Register
NameBit 7654321Bit 0
= Unimplemented or Reserved
Figure17-2. The scalable PWM Register Summary (Sheet 1 of 4)
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
540Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
17.3.2.1PWM Enable Register (PWME)
Each PWM channel has an enable bit (PWMEx) to start its waveform output. When any of the PWMEx
1The related bit is available only if corresponding channel exists.
2The register is available only if corresponding channel exists.
Module Base + 0x0000
76543210
RPWME7PWME6PWME5PWME4PWME3PWME2PWME1PWME0
W
Reset00000000
Figure17-3. PWM Enable Register (PWME)
Register
NameBit 7654321Bit 0
= Unimplemented or Reserved
Figure17-2. The scalable PWM Register Summary (Sheet 1 of 4)
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor541
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
17.3.2.2PWM Polarity Register (PWMPOL)
The starting polarity of each PWM channel waveform is determined by the associated PPOLx bit in the
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
a PWM signal is being generated, a truncated or stretched pulse can occur
during the transition
17.3.2.3PWM Clock Select Register (PWMCLK)
Each PWM channel has a choice of four clocks to use as the clock source for that channel as described
below.
Read: Anytime
Write: Anytime
NOTE
Register bits PCLK0 to PCLK7 can be written anytime. If a clock select is
changed while a PWM signal is being generated, a truncated or stretched
pulse can occur during the transition.
Module Base + 0x0001
76543210
RPPOL7PPOL6PPOL5PPOL4PPOL3PPOL2PPOL1PPOL0
W
Reset00000000
Figure17-4. PWM Polarity Register (PWMPOL)
Table17-3. PWMPOL Field Descriptions
Note:Bits related to available channels have functional significance. Writing to unavailable bits has no effect. Read from
unavailable bits return a zero
FieldDescription
7–0
PPOL[7:0]
Pulse Width Channel 7–0 Polarity Bits
0PWM channel 7–0 outputs are low at the beginning of the period, then go high when the duty count is
reached.
1PWM channel 7–0 outputs are high at the beginning of the period, then go low when the duty count is
reached.
Module Base + 0x0002
76543210
RPCLK7PCLKL6PCLK5PCLK4PCLK3PCLK2PCLK1PCLK0
W
Reset00000000
Figure17-5. PWM Clock Select Register (PWMCLK)
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor543
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The clock source of each PWM channel is determined by PCLKx bits in PWMCLK and PCLKABx bits
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
three bits determine the rate of clock A, as shown inTable17-8.
Table17-8. Clock A or Clock B Prescaler Selects
PCKA/B2PCKA/B1PCKA/B0Value of Clock A/B
000Bus clock
001Bus clock / 2
010Bus clock / 4
011Bus clock / 8
100Bus clock / 16
101Bus clock / 32
110 Bus clock / 64
111Bus clock / 128
Module Base + 0x0004
76543210
RCAE7CAE6CAE5CAE4CAE3CAE2CAE1CAE0
W
Reset00000000
Figure17-7. PWM Center Align Enable Register (PWMCAE)
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor545
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
17.3.2.6PWM Control Register (PWMCTL)
The PWMCTL register provides for various control of the PWM module.
Read: Anytime
Write: Anytime
There are up to four control bits for concatenation, each of which is used to concatenate a pair of PWM
Change these bits only when both corresponding channels are disabled.
Table17-9. PWMCAE Field Descriptions
Note:Bits related to available channels have functional significance. Writing to unavailable bits has no effect. Read from
unavailable bits return a zero
FieldDescription
7–0
CAE[7:0]
Center Aligned Output Modes on Channels 7–0
0Channels 7–0 operate in left aligned output mode.
1Channels 7–0 operate in center aligned output mode.
Module Base + 0x0005
76543210
RCON67CON45CON23CON01PSWAIPFRZ00
W
Reset00000000
= Unimplemented or Reserved
Figure17-8. PWM Control Register (PWMCTL)
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
546Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
17.3.2.7PWM Clock A/B Select Register (PWMCLKAB)
Each PWM channel has a choice of four clocks to use as the clock source for that channel as described
below.
Table17-10. PWMCTL Field Descriptions
Note:Bits related to available channels have functional significance. Writing to unavailable bits has no effect. Read from
unavailable bits return a zero
FieldDescription
7
CON67
Concatenate Channels 6 and 7
0Channels 6 and 7 are separate 8-bit PWMs.
1Channels 6 and 7 are concatenated to create one 16-bit PWM channel. Channel 6 becomes the high order
byte and channel 7 becomes the low order byte. Channel 7 output pin is used as the output for this 16-bit
1Disable PWM input clock to the prescaler whenever the part is in freeze mode. This is useful for emulation.
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor547
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Read: Anytime
Write: Anytime
NOTE
Register bits PCLKAB0 to PCLKAB7 can be written anytime. If a clock
select is changed while a PWM signal is being generated, a truncated or
Note:Bits related to available channels have functional significance. Writing to unavailable bits has no effect. Read from
unavailable bits return a zero
FieldDescription
7
PCLKAB7
Pulse Width Channel 7 Clock A/B Select
0Clock B or SB is the clock source for PWM channel 7, as shown inTable17-6.
1Clock A or SA is the clock source for PWM channel 7, as shown inTable17-6.
6
PCLKAB6
Pulse Width Channel 6 Clock A/B Select
0Clock B or SB is the clock source for PWM channel 6, as shown inTable17-6.
1Clock A or SA is the clock source for PWM channel 6, as shown inTable17-6.
5
PCLKAB5
Pulse Width Channel 5 Clock A/B Select
0Clock A or SA is the clock source for PWM channel 5, as shown inTable17-5.
1Clock B or SB is the clock source for PWM channel 5, as shown inTable17-5.
4
PCLKAB4
Pulse Width Channel 4 Clock A/B Select
0Clock A or SA is the clock source for PWM channel 4, as shown inTable17-5.
1Clock B or SB is the clock source for PWM channel 4, as shown inTable17-5.
3
PCLKAB3
Pulse Width Channel 3 Clock A/B Select
0Clock B or SB is the clock source for PWM channel 3, as shown inTable17-6.
1Clock A or SA is the clock source for PWM channel 3, as shown inTable17-6.
2
PCLKAB2
Pulse Width Channel 2 Clock A/B Select
0Clock B or SB is the clock source for PWM channel 2, as shown inTable17-6.
1Clock A or SA is the clock source for PWM channel 2, as shown inTable17-6.
1
PCLKAB1
Pulse Width Channel 1 Clock A/B Select
0Clock A or SA is the clock source for PWM channel 1, as shown inTable17-5.
1Clock B or SB is the clock source for PWM channel 1, as shown inTable17-5.
0
PCLKAB0
Pulse Width Channel 0 Clock A/B Select
0Clock A or SA is the clock source for PWM channel 0, as shown inTable17-5.
1Clock B or SB is the clock source for PWM channel 0, as shown inTable17-5.
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
548Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Any value written to this register will cause the scale counter to load the new scale value (PWMSCLB).
Read: Anytime
Write: Anytime (causes the scale counter to load the PWMSCLB value).
Module Base + 0x0008
76543210
RBit 7 6 5 4 3 2 1 Bit 0
W
Reset00000000
Figure17-10. PWM Scale A Register (PWMSCLA)
Module Base + 0x0009
76543210
RBit 7 6 5 4 3 2 1 Bit 0
W
Reset00000000
Figure17-11. PWM Scale B Register (PWMSCLB)
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor549
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
17.3.2.10PWM Channel Counter Registers (PWMCNTx)
Each channel has a dedicated 8-bit up/down counter which runs at the rate of the selected clock source.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure17-13. PWM Channel Period Registers (PWMPERx)
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor551
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
17.4Functional Description
17.4.1PWM Clock Select
There are four available clocks: clock A, clock B, clock SA (scaled A), and clock SB (scaled B). These
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure17-15. PWM Clock Select Block Diagram
128248163264
PCKB2
PCKB1
PCKB0
M
U
X
Clock A
Clock B
Clock SA
Clock A/2, A/4, A/6,....A/512
PrescaleScale
Divide by
PFRZ
Freeze Mode Signal
Bus Clock
Clock Select
M
U
X
Clock to
PWM Ch 0
M
U
X
Clock to
PWM Ch 2
M
U
X
Clock to
PWM Ch 1
M
U
X
Clock to
PWM Ch 4
M
U
X
Clock to
PWM Ch 5
M
U
X
Clock to
PWM Ch 6
M
U
X
Clock to
PWM Ch 7
M
U
X
Clock to
PWM Ch 3
Load
DIV 2
PWMSCLBClock SB
Clock B/2, B/4, B/6,....B/512
M
U
X
PCKA2
PCKA1
PCKA0
PWME7-0
Count = 1
Load
DIV 2
PWMSCLA
Count = 1
8-Bit Down
Counter
8-Bit Down
Counter
Prescaler Taps:
Maximum possible channels, scalable in pairs from PWM0 to PWM7.
PCLK0 PCLKAB0
PCLK1 PCLKAB1
PCLK7 PCLKAB7
PCLK6 PCLKAB6
PCLK5 PCLKAB5
PCLK4 PCLKAB4
PCLK3 PCLKAB3
PCLK2 PCLKAB2
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
554Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
SB. The clock selection is done with the PCLKx control bits in the PWMCLK register and PCLKABx
control bits in PWMCLKAB register. For backward compatibility consideration, the reset value of
PWMCLK and PWMCLKAB configures following default clock selection.
For channels 0, 1, 4, and 5 the clock choices are clock A.
For channels 2, 3, 6, and 7 the clock choices are clock B.
NOTE
Changing clock control bits while channels are operating can cause
irregularities in the PWM outputs.
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor555
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
due to the synchronization of PWMEx and the clock source. An exception to this is when channels are
concatenated. Refer toSection17.4.2.7, “PWM 16-Bit Functions” for more detail.
NOTE
The first PWM cycle after enabling the channel can be irregular.
Clock Source
T
R
Q
Q
PPOLx
From Port PWMP
Data Register
PWMEx
To Pin
Driver
Gate
8-bit Compare =
PWMDTYx
8-bit Compare =
PWMPERx
CAEx
T
R
Q
Q
8-Bit Counter
PWMCNTx
M
U
X
M
U
X
(Clock Edge
Sync)
Up/DownReset
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
556Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Each channel counter can be read at anytime without affecting the count or the operation of the PWM
channel.
Any value written to the counter causes the counter to reset to $00, the counter direction to be set to up,
duty register to the associated registers, as described inSection17.4.2.3, “PWM Period and Duty”. The
counter counts from 0 to the value in the period register – 1.
Table17-12. PWM Timer Counter Conditions
Counter Clears ($00)Counter CountsCounter Stops
When PWMCNTx register written to
any value
When PWM channel is enabled
(PWMEx=1).Countsfromlastvaluein
PWMCNTx.
When PWM channel is disabled
(PWMEx = 0)
Effective period ends
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
558Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•PWMx Frequency = Clock (A, B, SA, or SB) / PWMPERx
•PWMx Duty Cycle (high time as a% of period):
—Polarity = 0 (PPOLx = 0)
Duty Cycle = [(PWMPERx-PWMDTYx)/PWMPERx] * 100%
—Polarity = 1 (PPOLx = 1)
Duty Cycle = [PWMDTYx / PWMPERx] * 100%
As an example of a left aligned output, consider the following case:
Clock Source = E, where E = 10 MHz (100 ns period)
PPOLx = 0
PWMPERx = 4
PWMDTYx = 1
PWMx Frequency = 10 MHz/4 = 2.5 MHz
PWMx Period = 400 ns
PWMx Duty Cycle = 3/4 *100% = 75%
The output waveform generated is shown inFigure17-18.
Figure17-18. PWM Left Aligned Output Example Waveform
PWMDTYx
Period = PWMPERx
PPOLx = 0
PPOLx = 1
Period = 400 ns
E = 100 ns
Duty Cycle = 75%
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor559
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
clock source frequency for the channel (A, B, SA, or SB) and divide it by twice the value in the period
register for that channel.
•PWMx Frequency = Clock (A, B, SA, or SB) / (2*PWMPERx)
•PWMx Duty Cycle (high time as a% of period):
—Polarity = 0 (PPOLx = 0)
Duty Cycle = [(PWMPERx-PWMDTYx)/PWMPERx] * 100%
—Polarity = 1 (PPOLx = 1)
Duty Cycle = [PWMDTYx / PWMPERx] * 100%
As an example of a center aligned output, consider the following case:
PPOLx = 0
PPOLx = 1
PWMDTYxPWMDTYx
Period = PWMPERx*2
PWMPERx
PWMPERx
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
560Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Clock Source = E, where E = 10 MHz (100 ns period)
PPOLx = 0
PWMPERx = 4
PWMDTYx = 1
PWMx Frequency = 10 MHz/8 = 1.25 MHz
PWMx Period = 800 ns
PWMx Duty Cycle = 3/4 *100% = 75%
Shown inFigure17-20 is the output waveform generated.
Figure17-20. PWM Center Aligned Output Example Waveform
17.4.2.7PWM 16-Bit Functions
The scalable PWM timer also has the option of generating up to 8-channels of 8-bits or 4-channels of
16-bits for greater PWM resolution. This 16-bit channel option is achieved through the concatenation of
two 8-bit channels.
The PWMCTL register contains four control bits, each of which is used to concatenate a pair of PWM
PPOLx bit of the corresponding low order 8-bit channel as well.
E = 100 ns
DUTY CYCLE = 75%
E = 100 ns
PERIOD = 800 ns
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor561
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure17-21. PWM 16-Bit Mode
Once concatenated mode is enabled (CONxx bits set in PWMCTL register), enabling/disabling the
bytes PWMEx bits have no effect and their corresponding PWM output is disabled.
PWMCNT6PWMCNT7
PWM7
Clock Source 7HighLow
Period/Duty Compare
PWMCNT4PWMCNT5
PWM5
Clock Source 5
HighLow
Period/Duty Compare
PWMCNT2PWMCNT3
PWM3
Clock Source 3
HighLow
Period/Duty Compare
PWMCNT0PWMCNT1
PWM1
Clock Source 1
HighLow
Period/Duty Compare
Maximum possible 16-bit channels
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
562Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
In concatenated mode, writes to the 16-bit counter by using a 16-bit access or writes to either the low or
high order byte of the counter will reset the 16-bit counter. Reads of the 16-bit counter must be made by
16-bit access to maintain data coherency.
Either left aligned or center aligned output mode can be used in concatenated mode and is controlled by
the low order CAEx bit. The high order CAEx bit has no effect.
Table17-13 is used to summarize which channels are used to set the various control bits when in 16-bit
following reset are described within this section.
•The 8-bit up/down counter is configured as an up counter out of reset.
•All the channels are disabled and all the counters do not count.
Table17-13. 16-bit Concatenation Mode Summary
Note:Bits related to available channels have functional significance.
CONxxPWMExPPOLxPCLKxCAExPWMx
Output
CON67PWME7PPOL7PCLK7CAE7PWM7
CON45PWME5PPOL5PCLK5CAE5PWM5
CON23PWME3PPOL3PCLK3CAE3PWM3
CON01PWME1PPOL1PCLK1CAE1PWM1
Table17-14. PWM Boundary Cases
PWMDTYxPWMPERxPPOLxPWMx Output
$00
(indicates no duty)
>$001Always low
$00
(indicates no duty)
>$000Always high
XX$001
(indicates no period)
1Counter = $00 and does not count.
1Always high
XX$001
(indicates no period)
0Always low
>= PWMPERxXX1Always high
>= PWMPERxXX0Always low
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor563
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•For channels 0, 1, 4, and 5 the clock choices are clock A.
•For channels 2, 3, 6, and 7 the clock choices are clock B.
17.6Interrupts
The PWM module has no interrupt.
Pulse-Width Modulator (S12PWM8B8CV2)
MC9S12G Family Reference Manual,Rev.1.06
564Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor565
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter18
Serial Communication Interface (S12SCIV5)
18.1Introduction
This block guide provides an overview of the serial communication interface (SCI) module.
The SCI allows asynchronous serial communications with peripheral devices and other CPUs.
18.1.1Glossary
IR: InfraRed
IrDA: Infrared Design Associate
IRQ: Interrupt Request
LIN: Local Interconnect Network
LSB: Least Significant Bit
MSB: Most Significant Bit
NRZ: Non-Return-to-Zero
RZI: Return-to-Zero-Inverted
RXD: Receive Pin
SCI : Serial Communication Interface
TXD: Transmit Pin
Table18-1. Revision History
Version
Number
Revision
Date
Effective
DateAuthorDescription of Changes
05.0312/25/2008remove redundancy comments in Figure1-2
05.0408/05/2009fix typo, SCIBDL reset value be 0x04, not 0x00
05.0506/03/2010fix typo,Table18-4,SCICR1 Even parity should be PT=0
fix typo,on page 18-586,should be BKDIF,not BLDIF
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual,Rev.1.06
566Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
18.1.2Features
The SCI includes these distinctive features:
•Full-duplex or single-wire operation
•Standard mark/space non-return-to-zero (NRZ) format
•Selectable IrDA 1.4 return-to-zero-inverted (RZI) format with programmable pulse widths
•13-bit baud rate selection
•Programmable 8-bit or 9-bit data format
•Separately enabled transmitter and receiver
•Programmable polarity for transmitter and receiver
•Programmable transmitter output parity
•Two receiver wakeup methods:
—Idle line wakeup
—Address mark wakeup
•Interrupt-driven operation with eight flags:
—Transmitter empty
—Transmission complete
—Receiver full
—Idle receiver input
—Receiver overrun
—Noise error
—Framing error
—Parity error
—Receive wakeup on active edge
—Transmit collision detect supporting LIN
—Break Detect supporting LIN
•Receiver framing error detection
•Hardware parity checking
•1/16 bit-time noise detection
18.1.3Modes of Operation
The SCI functions the same in normal, special, and emulation modes. It has two low power modes, wait
and stop modes.
•Run mode
•Wait mode
•Stop mode
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor567
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
ignored when the receiver is disabled and should be terminated to a known voltage.
18.3Memory Map and Register Definition
This section provides a detailed description of all the SCI registers.
SCI Data Register
RXD Data In
Data Out TXD
Receive Shift Register
Infrared
Decoder
Receive & Wakeup
Control
Data Format Control
Transmit Control
Baud Rate
Generator
Bus Clock
1/16
Transmit Shift Register
SCI Data Register
Receive
Interrupt
Generation
Transmit
Interrupt
Generation
Infrared
Encoder
IDLE
RDRF/OR
TC
TDRE
BRKD
BERR
RXEDG
SCI
Interrupt
Request
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual,Rev.1.06
568Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
diagram with an associated figure number. Writes to a reserved register locations do not have any effect
and reads of these locations return a zero. Details of register bit and field function follow the register
diagrams, in bit order.
Register
NameBit 7654321Bit 0
0x0000
SCIBDH1RIRENTNP1TNP0SBR12SBR11SBR10SBR9SBR8
W
0x0001
SCIBDL1RSBR7SBR6SBR5SBR4SBR3SBR2SBR1SBR0
W
0x0002
SCICR11RLOOPSSCISWAIRSRCMWAKEILTPEPT
W
0x0000
SCIASR12RRXEDGIF0000
BERRVBERRIFBKDIF
W
0x0001
SCIACR12RRXEDGIE00000
BERRIEBKDIE
W
0x0002
SCIACR22R00000
BERRM1BERRM0BKDFE
W
0x0003
SCICR2
RTIETCIERIEILIETERERWUSBK
W
0x0004
SCISR1
RTDRETCRDRFIDLEORNFFEPF
W
0x0005
SCISR2
RAMAP00
TXPOLRXPOLBRK13TXDIRRAF
W
= Unimplemented or Reserved
Figure18-2. SCI Register Summary (Sheet 1 of 2)
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor569
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
18.3.2.1SCI Baud Rate Registers (SCIBDH, SCIBDL)
Read: Anytime, if AMAP = 0. If only SCIBDH is written to, a read will not return the correct data until
SCIBDL is written to as well, following a write to SCIBDH.
The SCI baud rate register is used by to determine the baud rate of the SCI, and to control the infrared
modulation/demodulation submodule.
0x0006
SCIDRH
RR8T8000000
W
0x0007
SCIDRL
RR7R6R5R4R3R2R1R0
WT7T6T5T4T3T2T1T0
1.These registers are accessible if the AMAP bit in the SCISR2 register is set to zero.
2,These registers are accessible if the AMAP bit in the SCISR2 register is set to one.
Module Base + 0x0000
76543210
RIRENTNP1TNP0SBR12SBR11SBR10SBR9SBR8
W
Reset00000000
Figure18-3. SCI Baud Rate Register (SCIBDH)
Module Base + 0x0001
76543210
RSBR7SBR6SBR5SBR4SBR3SBR2SBR1SBR0
W
Reset00000100
Figure18-4. SCI Baud Rate Register (SCIBDL)
Register
NameBit 7654321Bit 0
= Unimplemented or Reserved
Figure18-2. SCI Register Summary (Sheet 2 of 2)
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual,Rev.1.06
570Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
18.3.2.2SCI Control Register 1 (SCICR1)
Read: Anytime, if AMAP = 0.
Write: Anytime, if AMAP = 0.
NOTE
This register is only visible in the memory map if AMAP = 0 (reset
condition).
Table18-2. SCIBDH and SCIBDL Field Descriptions
FieldDescription
7
IREN
Infrared Enable Bit — This bit enables/disables the infrared modulation/demodulation submodule.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
odd number of 1s clears the parity bit and an even number of 1s sets the parity bit.
0Even parity
1Odd parity
Table18-5. Loop Functions
LOOPSRSRCFunction
0xNormal operation
10Loop mode with transmitter output internally connected to receiver input
11Single-wire mode with TXD pin connected to receiver input
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual,Rev.1.06
572Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
18.3.2.3SCI Alternative Status Register 1 (SCIASR1)
Read: Anytime, if AMAP = 1
Write: Anytime, if AMAP = 1
18.3.2.4SCI Alternative Control Register 1 (SCIACR1)
Read: Anytime, if AMAP = 1
Write: Anytime, if AMAP = 1
Module Base + 0x0000
76543210
RRXEDGIF0000BERRVBERRIFBKDIF
W
Reset00000000
= Unimplemented or Reserved
Figure18-6. SCI Alternative Status Register 1 (SCIASR1)
Table18-6. SCIASR1 Field Descriptions
FieldDescription
7
RXEDGIF
Receive Input Active Edge Interrupt Flag — RXEDGIF is asserted, if an active edge (falling if RXPOL = 0,
rising if RXPOL = 1) on the RXD input occurs. RXEDGIF bit is cleared by writing a “1” to it.
0No active receive on the receive input has occurred
Figure18-7. SCI Alternative Control Register 1 (SCIACR1)
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor573
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
18.3.2.5SCI Alternative Control Register 2 (SCIACR2)
01Receive input sampling occurs during the 9th time tick of a transmitted bit
(refertoFigure18-19)
10Receive input sampling occurs during the 13th time tick of a transmitted bit
(refer toFigure18-19)
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual,Rev.1.06
574Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
18.3.2.6SCI Control Register 2 (SCICR2)
Read: Anytime
Write: Anytime
11Reserved
Module Base + 0x0003
76543210
RTIETCIERIEILIETERERWUSBK
W
Reset00000000
Figure18-9. SCI Control Register 2 (SCICR2)
Table18-10. SCICR2 Field Descriptions
FieldDescription
7
TIE
Transmitter Interrupt Enable Bit — TIE enables the transmit data register empty flag, TDRE, to generate
Idle Line Interrupt Enable Bit — ILIE enables the idle line flag, IDLE, to generate interrupt requests.
0IDLE interrupt requests disabled
1IDLE interrupt requests enabled
3
TE
Transmitter Enable Bit— TE enables the SCI transmitter and configures the TXD pin as being controlled by
the SCI. The TE bit can be used to queue an idle preamble.
0Transmitter disabled
1Transmitter enabled
2
RE
Receiver Enable Bit— RE enables the SCI receiver.
0Receiver disabled
1Receiver enabled
Table18-9. Bit Error Mode Coding
BERRM1BERRM0Function
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor575
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
18.3.2.7SCI Status Register 1 (SCISR1)
The SCISR1 and SCISR2 registers provides inputs to the MCU for generation of SCI interrupts. Also,
these registers can be polled by the MCU to check the status of these bits. The flag-clearing procedures
Send Break Bit— Toggling SBK sends one break character (10 or 11 logic 0s, respectively 13 or 14 logics 0s
if BRK13 is set). Toggling implies clearing the SBK bit before the break character has finished transmitting. As
long as SBK is set, the transmitter continues to send complete break characters (10 or 11 bits, respectively 13
or 14 bits).
0No break characters
1Transmit break characters
Module Base + 0x0004
76543210
RTDRETCRDRFIDLEORNFFEPF
W
Reset11000000
= Unimplemented or Reserved
Figure18-10. SCI Status Register 1 (SCISR1)
Table18-10. SCICR2 Field Descriptions (continued)
FieldDescription
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual,Rev.1.06
576Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table18-11. SCISR1 Field Descriptions
FieldDescription
7
TDRE
Transmit Data Register Empty Flag — TDRE is set when the transmit shift register receives a byte from the
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
18.3.2.9SCI Data Registers (SCIDRH, SCIDRL)
Read: Anytime; reading accesses SCI receive data register
Write: Anytime; writing accesses SCI transmit data register; writing to R8 has no effect
3
RXPOL
Receive Polarity— This bit control the polarity of the received data. In NRZ format, a one is represented by a
mark and a zero is represented by a space for normal polarity, and the opposite for inverted polarity. In IrDA
bit search. RAF is cleared when the receiver detects an idle character.
0No reception in progress
1Reception in progress
Module Base + 0x0006
76543210
RR8T8000000
W
Reset00000000
= Unimplemented or Reserved
Figure18-12. SCI Data Registers (SCIDRH)
Module Base + 0x0007
76543210
RR7R6R5R4R3R2R1R0
WT7T6T5T4T3T2T1T0
Reset00000000
Figure18-13. SCI Data Registers (SCIDRL)
Table18-12. SCISR2 Field Descriptions (continued)
FieldDescription
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor579
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NOTE
If the value of T8 is the same as in the previous transmission, T8 does not
have to be rewritten.The same value is transmitted until T8 is rewritten
In 8-bit data format, only SCI data register low (SCIDRL) needs to be
accessed.
When transmitting in 9-bit data format and using 8-bit write instructions,
write first to SCI data register high (SCIDRH), then SCIDRL.
18.4Functional Description
This section provides a complete functional description of the SCI block, detailing the operation of the
design from the end user perspective in a number of subsections.
Figure18-14 shows the structure of the SCI module. The SCI allows full duplex, asynchronous, serial
communication between the CPU and remote devices, including other CPUs. The SCI transmitter and
receiver operate independently, although they use the same baud rate generator. The CPU monitors the
status of the SCI, writes the data to be transmitted, and processes received data.
Table18-13. SCIDRH and SCIDRL Field Descriptions
FieldDescription
SCIDRH
7
R8
Received Bit 8 — R8 is the ninth data bit received when the SCI is configured for 9-bit data format (M = 1).
SCIDRH
6
T8
Transmit Bit 8 — T8 is the ninth data bit transmitted when the SCI is configured for 9-bit data format (M = 1).
SCIDRL
7:0
R[7:0]
T[7:0]
R7:R0 — Received bits seven through zero for 9-bit or 8-bit data formats
T7:T0— Transmit bits seven through zero for 9-bit or 8-bit formats
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual,Rev.1.06
580Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure18-14. Detailed SCI Block Diagram
18.4.1Infrared Interface Submodule
This module provides the capability of transmitting narrow pulses to an IR LED and receiving narrow
pulses and transforming them to serial bits, which are sent to the SCI. The IrDA physical layer
specification defines a half-duplex infrared communication link for exchange data. The full standard
includes data rates up to 16 Mbits/s. This design covers only data rates between 2.4 Kbits/s and 115.2
Kbits/s.
The infrared submodule consists of two major blocks: the transmit encoder and the receive decoder. The
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
format where zeroes are represented by light pulses and ones remain low. SeeFigure18-15 below.
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual,Rev.1.06
582Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A frame with nine data bits has a total of 11 bits.
Table18-14. Example of 8-Bit Data Formats
Start
Bit
Data
Bits
Address
Bits
Parity
Bits
Stop
Bit
18001
17011
171
1
1The address bit identifies the frame as an address
character. SeeSection18.4.6.6, “Receiver Wakeup”.
01
Table18-15. Example of 9-Bit Data Formats
Start
Bit
Data
Bits
Address
Bits
Parity
Bits
Stop
Bit
19001
18011
181
1
1The address bit identifies the frame as an address
character. SeeSection18.4.6.6, “Receiver Wakeup”.
01
Bit 5
Start
BitBit 0Bit 1
Next
STOP
Bit
Start
Bit
8-Bit Data Format
(Bit M in SCICR1 Clear)
Start
BitBit 0
NEXT
STOP
Bit
START
Bit
9-Bit Data Format
(Bit M in SCICR1 Set)
Bit 1Bit 2Bit 3Bit 4Bit 5Bit 6Bit 7Bit 8
Bit 2Bit 3Bit 4Bit 6Bit 7
POSSIBLE
PARITY
Bit
Possible
Parity
BitStandard
SCI Data
Infrared
SCI Data
Standard
SCI Data
Infrared
SCI Data
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor583
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
18.4.4Baud Rate Generation
A 13-bit modulus counter in the baud rate generator derives the baud rate for both the receiver and the
transmitter. The value from 0 to 8191 written to the SBR12:SBR0 bits determines the bus clock divisor.
The SBR bits are in the SCI baud rate registers (SCIBDH and SCIBDL). The baud rate clock is
synchronized with the bus clock and drives the receiver. The baud rate clock divided by 16 drives the
transmitter. The receiver has an acquisition rate of 16 samples per bit time.
Baud rate generation is subject to one source of error:
•Integer division of the bus clock may not give the exact target frequency.
Table18-16 lists some examples of achieving target baud rates with a bus clock frequency of 25 MHz.
Table18-16. Baud Rates (Example: Bus Clock = 25 MHz)
Bits
SBR[12:0]
Receiver
Clock (Hz)
Transmitter
Clock (Hz)
Target
Baud Rate
Error
(%)
41609,756.138,109.838,400.76
81308,642.019,290.119,200.47
163153,374.29585.99,600.16
32676,687.14792.94,800.15
65138,402.52400.22,400.01
130219,201.21200.11,200.01
26049600.6600.0600.00
52084800.0300.0300.00
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual,Rev.1.06
584Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
18.4.5Transmitter
Figure18-16. Transmitter Block Diagram
18.4.5.1Transmitter Character Length
The SCI transmitter can accommodate either 8-bit or 9-bit data characters. The state of the M bit in SCI
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
data register transfers a byte to the transmit shift register. The TDRE flag indicates that the SCI data
register can accept new data from the internal data bus. If the transmit interrupt enable bit, TIE, in SCI
control register 2 (SCICR2) is also set, the TDRE flag generates a transmitter interrupt request.
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual,Rev.1.06
586Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
If the break detect feature is enabled (BKDFE = 1) there are two scenarios1
The break is detected right from a start bit or is detected during a byte reception.
•Sets the break detect interrupt flag, BKDIF
•Does not change the data register full flag, RDRF or overrun flag OR
•Does not change the framing error flag FE, parity error flag PE.
•Does not clear the SCI data registers (SCIDRH/L)
•May set noise flag NF, or receiver active flag RAF.
1.A Break character in this context are either 10 or 11 consecutive zero received bits
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor587
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure18-17 shows two cases of break detect. In trace RXD_1 the break symbol starts with the start bit,
while in RXD_2 the break starts in the middle of a transmission. If BRKDFE = 1, in RXD_1 case there
stop bit appears on TXDcauses data previously written to the SCI data
register to be lost. Toggle the TE bit for a queued idle character while the
TDRE flag is set and immediately before writing the next byte to the SCI
data register.
If the TE bit is clear and the transmission is complete, the SCI is not the
master of the TXD pin
Start Bit PositionStop Bit Position
BRKDIF = 1
FE = 1BRKDIF = 1
RXD_1
RXD_2
12345678910
12345678910
Zero Bit Counter
Zero Bit Counter. . .
. . .
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual,Rev.1.06
588Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
18.4.5.5LIN Transmit Collision Detection
This module allows to check for collisions on the LIN bus.
Figure18-18. Collision Detect Principle
If the bit error circuit is enabled (BERRM[1:0] = 0:1 or = 1:0]), the error detect circuit will compare the
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
18.4.6Receiver
Figure18-20. SCI Receiver Block Diagram
18.4.6.1Receiver Character Length
The SCI receiver can accommodate either 8-bit or 9-bit data characters. The state of the M bit in SCI
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
indicating that the received byte can be read. If the receive interrupt enable bit, RIE, in SCI control
register2 (SCICR2) is also set, the RDRF flag generates an RDRF interrupt request.
18.4.6.3Data Sampling
The RT clock rate. The RT clock is an internal signal with a frequency 16 times the baud rate. To adjust
for baud rate mismatch, the RT clock (seeFigure18-21) is re-synchronized:
•After every start bit
•After the receiver detects a data bit change from logic 1 to logic 0 (after the majority of data bit
1s.When the falling edge of a possible start bit occurs, the RT clock begins to count to 16.
Figure18-21. Receiver Data Sampling
To verify the start bit and to detect noise, data recovery logic takes samples at RT3, RT5, and RT7.
Figure18-17 summarizes the results of the start bit verification samples.
If start bit verification is not successful, the RT clock is reset and a new search for a start bit begins.
Table18-17. Start Bit Verification
RT3, RT5, and RT7 SamplesStart Bit VerificationNoise Flag
000Yes0
001Yes1
010Yes1
011No0
100Yes1
101No0
110No0
111No0
Reset RT Clock
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT2
RT3
RT4
RT5
RT8
RT7
RT6
RT11
RT10
RT9
RT15
RT14
RT13
RT12
RT16
RT1
RT2
RT3
RT4
Samples
RT Clock
RT CLock Count
Start Bit
RXD
Start Bit
Qualification
Start BitData
Sampling
111111110000000
LSB
Verification
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor591
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
To determine the value of a data bit and to detect noise, recovery logic takes samples at RT8, RT9, and
RT10.Table18-18 summarizes the results of the data bit samples.
not the beginning of a start bit. The RT clock is reset and the start bit search begins again. The noise flag
is not set because the noise occurred before the start bit was found.
Table18-18. Data Bit Recovery
RT8, RT9, and RT10 SamplesData Bit DeterminationNoise Flag
00000
00101
01001
01111
10001
10111
11011
11110
Table18-19. Stop Bit Recovery
RT8, RT9, and RT10 SamplesFraming Error FlagNoise Flag
00010
00111
01011
01101
10011
10101
11001
11100
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual,Rev.1.06
592Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure18-22. Start Bit Search Example 1
InFigure18-23, verification sample at RT3 is high. The RT3 sample sets the noise flag. Although the
perceived bit time is misaligned, the data samples RT8, RT9, and RT10 are within the bit time and data
bit time, the data samples RT8, RT9, and RT10 are within the bit time and data recovery is successful.
Reset RT Clock
RT1
RT1
RT1
RT1
RT2
RT3
RT4
RT5
RT1
RT1
RT2
RT3
RT4
RT7
RT6
RT5
RT10
RT9
RT8
RT14
RT13
RT12
RT11
RT15
RT16
RT1
RT2
RT3
Samples
RT Clock
RT Clock Count
Start Bit
RXD
110111100000
LSB
00
Reset RT Clock
RT1
RT1
RT1
RT1
RT1
RT1
RT2
RT3
RT4
RT5
RT6
RT7
RT8
RT11
RT10
RT9
RT14
RT13
RT12
RT2
RT1
RT16
RT15
RT3
RT4
RT5
RT6
RT7
Samples
RT Clock
RT Clock Count
Actual Start Bit
RXD
1111110000
LSB
00
Perceived Start Bit
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor593
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
RT8, RT9, and RT10 stop bit samples are a logic zero.
Reset RT Clock
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT2
RT3
RT4
RT7
RT6
RT5
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT1
Samples
RT Clock
RT Clock Count
Start Bit
RXD
11111010
LSB
1111100000000
No Start Bit Found
Reset RT Clock
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT2
RT3
RT4
RT7
RT6
RT5
RT10
RT9
RT8
RT14
RT13
RT12
RT11
RT15
RT16
RT1
RT2
RT3
Samples
RT Clock
RT Clock Count
Start Bit
RXD
11111000
LSB
11110110
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor595
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
As the receiver samples an incoming frame, it re-synchronizes the RT clock on any valid falling edge
within the frame. Re synchronization within frames will correct a misalignment between transmitter bit
times and receiver bit times.
18.4.6.5.1Slow Data Tolerance
Figure18-28 shows how much a slow received frame can be misaligned without causing a noise error or
a framing error. The slow stop bit begins at RT8 instead of RT1 but arrives in time for the stop bit data
samples at RT8, RT9, and RT10.
Figure18-28. Slow Data
Let’s take RTras receiver RT clock and RTt as transmitter RT clock.
the count of the transmitting device is 10 bit times x 16 RTt cycles = 160 RTt cycles.
The maximum percent difference between the receiver count and the transmitter count of a slow 9-bit
character with no errors is:
((167 – 160) / 167) X 100 = 4.19%
18.4.6.5.2 Fast Data Tolerance
Figure18-29 shows how much a fast received frame can be misaligned. The fast stop bit ends at RT10
instead of RT16 but is still sampled at RT8, RT9, and RT10.
MSBStop
RT1
RT2
RT3
RT4
RT5
RT6
RT7
RT8
RT9
RT10
RT11
RT12
RT13
RT14
RT15
RT16
Data
Samples
Receiver
RT Clock
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual,Rev.1.06
596Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
an input (TXDIR = 0) or an output (TXDIR = 1) in this mode of operation.
RXD
Transmitter
Receiver
TXD
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual,Rev.1.06
598Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
To initialize a SCI transmission, seeSection18.4.5.2, “Character Transmission”.
18.5.2.2Wait Mode
SCI operation in wait mode depends on the state of the SCISWAI bit in the SCI control register 1
(SCICR1).
•If SCISWAI is clear, the SCI operates normally when the CPU is in wait mode.
•If SCISWAI is set, SCI clock generation ceases and the SCI module enters a power-conservation
state when the CPU is in wait mode. Setting SCISWAI does not affect the state of the receiver
enable bit, RE, or the transmitter enable bit, TE.
RXD
Transmitter
Receiver
TXD
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor599
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
If SCISWAI is set, any transmission or reception in progress stops at wait mode entry. The
BKDIFSCIASR1[0]BRKDIEActive high level. Indicates that a break character has been received.
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual,Rev.1.06
600Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
new byte can be written to the SCIDRH/L for transmission.Clear TDRE by reading SCI status register 1
with TDRE set and then writing to SCI data register low (SCIDRL).
18.5.3.1.2TC Description
The TC interrupt is set by the SCI when a transmission has been completed. Transmission is completed
when all bits including the stop bit (if transmitted) have been shifted out and no data is queued to be
transmitted. No stop bit is transmitted when sending a break character and the TC flag is set (providing
there is no more data queued for transmission) when the break character has been shifted out. A TC
set and then reading SCI data register low (SCIDRL).
18.5.3.1.6RXEDGIF Description
The RXEDGIF interrupt is set when an active edge (falling if RXPOL = 0, rising if RXPOL = 1) on the
RXD pin is detected. Clear RXEDGIF by writing a “1” to the SCIASR1 SCI alternative status register 1.
18.5.3.1.7BERRIF Description
The BERRIF interrupt is set when a mismatch between the transmitted and the received data in a single
wire application like LIN was detected. Clear BERRIF by writing a “1” to the SCIASR1 SCI alternative
status register 1. This flag is also cleared if the bit error detect feature is disabled.
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor601
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
18.5.3.1.8BKDIF Description
The BKDIF interrupt is set when a break signal was received. Clear BKDIF by writing a “1” to the
SCIASR1 SCI alternative status register 1. This flag is also cleared if break detect feature is disabled.
18.5.4Recovery from Wait Mode
The SCI interrupt request can be used to bring the CPU out of wait mode.
18.5.5Recovery from Stop Mode
An active edge on the receive input can be used to bring the CPU out of stop mode.
Serial Communication Interface (S12SCIV5)
MC9S12G Family Reference Manual,Rev.1.06
602Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor603
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter19
Serial Peripheral Interface (S12SPIV5)
Revision History
19.1Introduction
The SPI module allows a duplex, synchronous, serial communication between the MCU and peripheral
devices. Software can poll the SPI status flags or the SPI operation can be interrupt driven.
19.1.1Glossary of Terms
19.1.2Features
The SPI includes these distinctive features:
•Master mode and slave mode
•Selectable 8 or 16-bit transfer width
•Bidirectional mode
•Slave select output
•Mode fault error flag with CPU interrupt capability
Revision NumberDateAuthorSummary of Changes
05.0024 MAR 2005Added 16-bit transfer width feature.
SPISerial Peripheral Interface
SSSlave Select
SCKSerial Clock
MOSIMaster Output, Slave Input
MISOMaster Input, Slave Output
MOMIMaster Output, Master Input
SISOSlave Input, Slave Output
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual,Rev.1.06
604Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Double-buffered data register
•Serial clock with programmable polarity and phase
•Control of SPI operation during wait mode
19.1.3Modes of Operation
The SPI functions in three modes: run, wait, and stop.
•Run mode
This is the basic mode of operation.
•Wait mode
SPI operation in wait mode is a configurable low power mode, controlled by the SPISWAI bit
located in the SPICR2 register. In wait mode, if the SPISWAI bit is clear, the SPI operates like in
Figure19-1 gives an overview on the SPI architecture. The main parts of the SPI are status, control and
data registers, shifter logic, baud rate generator, master/slave control logic, and port control logic.
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor605
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
19.2.2MISO — Master In/Slave Out Pin
This pin is used to transmit data out of the SPI module when it is configured as a slave and receive data
when it is configured as master.
19.2.3SS — Slave Select Pin
This pin is used to output the select signal from the SPI module to another peripheral with which a data
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
diagram with an associated figure number. Details of register bit and field function follow the register
diagrams, in bit order.
19.3.2.1SPI Control Register 1 (SPICR1)
Read: Anytime
Write: Anytime
SPIDRLRR7R6R5R4R3R2R1R0
T7T6T5T4T3T2T1T0W
ReservedR
W
ReservedR
W
76543210
RSPIESPESPTIEMSTRCPOLCPHASSOELSBFE
W
Reset00000100
Figure19-3. SPI Control Register 1 (SPICR1)
Table19-1. SPICR1 Field Descriptions
FieldDescription
7
SPIE
SPI Interrupt Enable Bit — This bit enables SPI interrupt requests, if SPIF or MODF status flag is set.
0SPI interrupts disabled.
1SPI interrupts enabled.
6
SPE
SPI System Enable Bit — This bit enables the SPI system and dedicates the SPI port pins to SPI system
functions. If SPE is cleared, SPI is disabled and forced into idle state, status bits in SPISR register are reset.
0SPI disabled (lower power consumption).
1SPI enabled, port pins are dedicated to SPI functions.
5
SPTIE
SPI Transmit Interrupt Enable — This bit enables SPI interrupt requests, if SPTEF flag is set.
0SPTEF interrupt disabled.
1SPTEF interrupt enabled.
4
MSTR
SPI Master/Slave Mode Select Bit — This bit selects whether the SPI operates in master or slave mode.
Switching the SPI from master to slave or vice versa forces the SPI system into idle state.
0SPI is in slave mode.
1SPI is in master mode.
Register
NameBit 7654321Bit 0
= Unimplemented or Reserved
Figure19-2. SPI Register Summary
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual,Rev.1.06
608Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
19.3.2.2SPI Control Register 2 (SPICR2)
Read: Anytime
Write: Anytime; writes to the reserved bits have no effect
will abort a transmission in progress and force the SPI system into idle state.
0Data is transferred most significant bit first.
1Data is transferred least significant bit first.
Table19-2.SS Input / Output Selection
MODFENSSOEMaster ModeSlave Mode
00SS not used by SPISS input
01SS not used by SPISS input
10SS input with MODF featureSS input
11SS is slave select outputSS input
76543210
R0XFRW0MODFENBIDIROE0SPISWAISPC0
W
Reset00000000
= Unimplemented or Reserved
Figure19-4. SPI Control Register 2 (SPICR2)
Table19-1. SPICR1 Field Descriptions
FieldDescription
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor609
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
set, a change of this bit will abort a transmission in progress and force the SPI into idle state.
0Output buffer disabled.
1Output buffer enabled.
1
SPISWAI
SPI Stop in Wait Mode Bit — This bit is used for power conservation while in wait mode.
0SPI clock operates normally in wait mode.
1Stop SPI clock generation when in wait mode.
0
SPC0
Serial Pin Control Bit 0 — This bit enables bidirectional pin configurations as shown inTable19-4. In master
mode, a change of this bit will abort a transmission in progress and force the SPI system into idle state.
Table19-4. Bidirectional Pin Configurations
Pin ModeSPC0BIDIROEMISOMOSI
Master Mode of Operation
Normal0XMaster InMaster Out
Bidirectional10MISO not used by SPIMaster In
1Master I/O
Slave Mode of Operation
Normal0XSlave OutSlave In
Bidirectional10Slave InMOSI not used by SPI
1Slave I/O
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual,Rev.1.06
610Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
19.3.2.3SPI Baud Rate Register (SPIBR)
Read: Anytime
Write: Anytime; writes to the reserved bits have no effect
The baud rate divisor equation is as follows:
BaudRateDivisor = (SPPR + 1)• 2(SPR + 1)Eqn.19-1
The baud rate can be calculated with the following equation:
Baud Rate = BusClock / BaudRateDivisorEqn.19-2
NOTE
For maximum allowed baud rates, please refer to the SPI Electrical
Specification in the Electricals chapter of this data sheet.
a change of these bits will abort a transmission in progress and force the SPI system into idle state.
Table19-6. Example SPI Baud Rate Selection (25 MHz Bus Clock)
SPPR2SPPR1SPPR0SPR2SPR1SPR0Baud Rate
DivisorBaud Rate
000000212.5 Mbit/s
00000146.25 Mbit/s
00001083.125 Mbit/s
000011161.5625 Mbit/s
00010032781.25 kbit/s
00010164390.63 kbit/s
000110128195.31 kbit/s
00011125697.66 kbit/s
00100046.25 Mbit/s
00100183.125 Mbit/s
001010161.5625 Mbit/s
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor611
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
00101132781.25 kbit/s
00110064390.63 kbit/s
001101128195.31 kbit/s
00111025697.66 kbit/s
00111151248.83 kbit/s
01000064.16667 Mbit/s
010001122.08333 Mbit/s
010010241.04167 Mbit/s
01001148520.83 kbit/s
01010096260.42 kbit/s
010101192130.21 kbit/s
01011038465.10 kbit/s
01011176832.55 kbit/s
01100083.125 Mbit/s
011001161.5625 Mbit/s
01101032781.25 kbit/s
01101164390.63 kbit/s
011100128195.31 kbit/s
01110125697.66 kbit/s
01111051248.83 kbit/s
011111102424.41 kbit/s
100000102.5 Mbit/s
100001201.25 Mbit/s
10001040625 kbit/s
10001180312.5 kbit/s
100100160156.25 kbit/s
10010132078.13 kbit/s
10011064039.06 kbit/s
100111128019.53 kbit/s
101000122.08333 Mbit/s
101001241.04167 Mbit/s
10101048520.83 kbit/s
10101196260.42 kbit/s
101100192130.21 kbit/s
10110138465.10 kbit/s
10111076832.55 kbit/s
101111153616.28 kbit/s
110000141.78571 Mbit/s
11000128892.86 kbit/s
Table19-6. Example SPI Baud Rate Selection (25 MHz Bus Clock)
SPPR2SPPR1SPPR0SPR2SPR1SPR0Baud Rate
DivisorBaud Rate
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual,Rev.1.06
612Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
19.3.2.4SPI Status Register (SPISR)
Read: Anytime
Write: Has no effect
11001056446.43 kbit/s
110011112223.21 kbit/s
110100224111.61 kbit/s
11010144855.80 kbit/s
11011089627.90 kbit/s
110111179213.95 kbit/s
111000161.5625 Mbit/s
11100132781.25 kbit/s
11101064390.63 kbit/s
111011128195.31 kbit/s
11110025697.66 kbit/s
11110151248.83 kbit/s
111110102424.41 kbit/s
111111204812.21 kbit/s
76543210
RSPIF0SPTEFMODF0000
W
Reset00100000
= Unimplemented or Reserved
Figure19-6. SPI Status Register (SPISR)
Table19-7. SPISR Field Descriptions
FieldDescription
7
SPIF
SPIF Interrupt Flag — This bit is set after received data has been transferred into the SPI data register. For
information about clearing SPIF Flag, please refer toTable19-8.
0Transfer not yet complete.
1New data copied to SPIDR.
Table19-6. Example SPI Baud Rate Selection (25 MHz Bus Clock)
SPPR2SPPR1SPPR0SPR2SPR1SPR0Baud Rate
DivisorBaud Rate
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor613
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table19-8. SPIF Interrupt Flag Clearing Sequence
Table19-9. SPTEF Interrupt Flag Clearing Sequence
5
SPTEF
SPI Transmit Empty Interrupt Flag — If set, this bit indicates that the transmit data register is empty. For
information about clearing this bit and placing data into the transmit data register, please refer toTable19-9.
1Any write to SPIDRH or SPIDRL with SPTEF == 0 is effectively ignored.
1Read SPISR with SPTEF == 1
then
Byte Write to SPIDRL12
2Data in SPIDRH is undefined in this case.
or
Byte Write to SPIDRH13Byte Write to SPIDRL1
or
Word Write to (SPIDRH:SPIDRL)1
Table19-7. SPISR Field Descriptions
FieldDescription
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual,Rev.1.06
614Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
19.3.2.5SPI Data Register (SPIDR = SPIDRH:SPIDRL)
Read: Anytime; read data only valid when SPIF is set
Write: Anytime
The SPI data register is both the input and output register for SPI data. A write to this register
allows data to be queued and transmitted. For an SPI configured as a master, queued data is
third transmission, the data in the receive shift register has become invalid and is not transferred
into the SPIDR (seeFigure19-10).
3SPIDRH can be written repeatedly without any effect on SPTEF. SPTEF Flag is cleared only by
writing to SPIDRL after reading SPISR with SPTEF == 1.
76543210
RR15R14R13R12R11R10R9R8
WT15T14T13T12T11T10T9T8
Reset00000000
Figure19-7. SPI Data Register High (SPIDRH)
76543210
RR7R6R5R4R3R2R1R0
WT7T6T5T4T3T2T1T0
Reset00000000
Figure19-8. SPI Data Register Low (SPIDRL)
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor615
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure19-9. Reception with SPIF serviced in Time
Figure19-10. Reception with SPIF serviced too late
19.4Functional Description
The SPI module allows a duplex, synchronous, serial communication between the MCU and peripheral
devices. Software can poll the SPI status flags or SPI operation can be interrupt driven.
the four associated SPI port pins are dedicated to the SPI function as:
•Slave select (SS)
•Serial clock (SCK)
•Master out/slave in (MOSI)
•Master in/slave out (MISO)
Receive Shift Register
SPIF
SPI Data Register
Data AData B
Data A
Data A ReceivedData B Received
Data C
Data C
SPIF Serviced
Data C Received
Data B
= Unspecified= Reception in progress
Receive Shift Register
SPIF
SPI Data Register
Data AData B
Data A
Data A ReceivedData B Received
Data C
Data C
SPIF Serviced
Data C Received
Data B Lost
= Unspecified= Reception in progress
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual,Rev.1.06
616Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
determine the speed of the transmission. The SCK pin is the SPI clock output. Through the SCK
pin, the baud rate generator of the master controls the shift register of the slave peripheral.
•MOSI, MISO pin
In master mode, the function of the serial data output pin (MOSI) and the serial data input pin
(MISO) is determined by the SPC0 and BIDIROE control bits.
•SS pin
If MODFEN and SSOE are set, theSS pin is configured as slave select output. TheSS output
becomes low during each transmission and is high when the SPI is in idle state.
1.n depends on the selected transfer width, please refer toSection19.3.2.2, “SPI Control Register 2 (SPICR2)
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor617
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
the serial data output pin. Also, if the slave is not selected (SS is high), then the SCK input is
ignored and no internal shifting of the SPI shift register occurs.
Although the SPI is capable of duplex operation, some SPI peripherals are capable of only
receiving SPI data in a slave mode. For these simpler devices, there is no serial data out pin.
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual,Rev.1.06
618Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NOTE
When peripherals with duplex capability are used, take care not to
simultaneously enable two receivers whose serial outputs drive the same
line can be used to indicate multiple-master bus contention.
Figure19-11. Master/Slave Transfer Block Diagram
1.n depends on the selected transfer width, please refer toSection19.3.2.2, “SPI Control Register 2 (SPICR2)
SHIFT REGISTER
SHIFT REGISTER
BAUD RATE
GENERATOR
MASTER SPISLAVE SPI
MOSIMOSI
MISOMISO
SCKSCK
SSSS
VDD
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor619
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
is the output from the slave and the MOSI signal is the output from the master. TheSS pin of the master
must be either high or reconfigured as a general-purpose output not affecting the SPI.
1.n depends on the selected transfer width, please refer toSection19.3.2.2, “SPI Control Register 2 (SPICR2)
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual,Rev.1.06
620Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure19-12. SPI Clock Format 0 (CPHA = 0), with 8-bit Transfer Width selected (XFRW = 0)
tL
BeginEnd
SCK (CPOL = 0)
SAMPLE I
CHANGE O
SELSS (O)
Transfer
SCK (CPOL = 1)
MSB first (LSBFE = 0):
LSB first (LSBFE = 1):
MSB
LSB
LSB
MSB
Bit 5
Bit 2
Bit 6
Bit 1
Bit 4
Bit 3
Bit 3
Bit 4
Bit 2
Bit 5
Bit 1
Bit 6
CHANGE O
SELSS (I)
MOSI pin
MISO pin
Master only
MOSI/MISO
tT
If next transfer begins here
for tT
, tl, tL
Minimum 1/2 SCK
tItL
tL = Minimum leading time before the first SCK edge
tT = Minimum trailing time after the last SCK edge
tI = Minimum idling time between transfers (minimumSS high time)
tL, tT
, and tI are guaranteed for the master mode and required for the slave mode.
12345678910111213141516
SCK Edge Number
End of Idle StateBegin of Idle State
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor621
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure19-13. SPI Clock Format 0 (CPHA = 0), with 16-Bit Transfer Width selected (XFRW = 1)
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A half SCK cycle later, the second edge appears on the SCK pin. This is the latching edge for both the
master and slave.
When the third edge occurs, the value previously latched from the serial data input pin is shifted into the
and the slave. The MISO signal is the output from the slave, and the MOSI signal is the output from the
master. TheSS line is the slave select input to the slave. TheSS pin of the master must be either high or
reconfigured as a general-purpose output not affecting the SPI.
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor623
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure19-14. SPI Clock Format 1 (CPHA = 1), with 8-Bit Transfer Width selected (XFRW = 0)
tLtT
for tT
, tl, tL
Minimum 1/2 SCK
tItL
If next transfer begins here
BeginEnd
SCK (CPOL = 0)
SAMPLE I
CHANGE O
SELSS (O)
Transfer
SCK (CPOL = 1)
MSB first (LSBFE = 0):
LSB first (LSBFE = 1):
MSB
LSB
LSB
MSB
Bit 5
Bit 2
Bit 6
Bit 1
Bit 4
Bit 3
Bit 3
Bit 4
Bit 2
Bit 5
Bit 1
Bit 6
CHANGE O
SELSS (I)
MOSI pin
MISO pin
Master only
MOSI/MISO
tL = Minimum leading time before the first SCK edge, not required for back-to-back transfers
tT = Minimum trailing time after the last SCK edge
tI = Minimum idling time between transfers (minimumSS high time), not required for back-to-back transfers
12345678910111213141516SCK Edge Number
End of Idle StateBegin of Idle State
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual,Rev.1.06
624Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure19-15. SPI Clock Format 1 (CPHA = 1), with 16-Bit Transfer Width selected (XFRW = 1)
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
BaudRateDivisor = (SPPR + 1)• 2(SPR + 1)Eqn.19-3
When all bits are clear (the default condition), the SPI module clock is divided by 2. When the selection
bits (SPR2–SPR0) are 001 and the preselection bits (SPPR2–SPPR0) are 000, the module clock divisor
becomes 4. When the selection bits are 010, the module clock divisor becomes 8, etc.
When the preselection bits are 001, the divisor determined by the selection bits is multiplied by 2. When
the preselection bits are 010, the divisor is multiplied by 3, etc. SeeTable19-6 for baud rate calculations
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The direction of each serial I/O pin depends on the BIDIROE bit. If the pin is configured as an output,
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
send out bytes consistent with the operation mode at the start of wait mode (i.e., if the slave is
currently sending its SPIDR to the master, it will continue to send the same byte. Else if the
slave is currently sending the last received byte from the master, it will continue to send each
previous master byte).
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual,Rev.1.06
628Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The MODF interrupt is reflected in the status register MODF flag. Clearing the flag will also clear the
interrupt. This interrupt will stay active while the MODF flag is set. MODF has an automatic clearing
process which is described inSection19.3.2.4, “SPI Status Register (SPISR)”.
Serial Peripheral Interface (S12SPIV5)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor629
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor631
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter20
Timer Module (TIM16B8CV3)
20.1Introduction
The basic scalable timer consists of a 16-bit, software-programmable counter driven by a flexible
available only on channel 7. The input capture function is used to detect a selected transition edge and
record the time. The output compare function is used for generating output signals or for timer software
delays. The 16-bit pulse accumulator is used to operate as a simple event counter or a gated time
accumulator. The pulse accumulator shares timer channel 7 when the channel is available and when in
event mode.
A full access for the counter registers or the input capture/output compare registers should take place in
one clock cycle. Accessing high byte and low byte separately for all of these registers may not yield the
same result as accessing them in one word.
20.1.1Features
The TIM16B8CV3 includes these distinctive features:
•Up to 8 channels available. (refer to device specification for exact number)
•All channels have same input capture/output compare functionality.
Table20-1.
V03.00Jan. 28, 2009Initial version
V03.01Aug. 26, 200920.1.2/20-632
Figure20-4./20-
635
20.3.2.15/20-64
8
20.3.2.2/20-638,
20.3.2.3/20-639,
20.3.2.4/20-639,
20.4.3/20-655
- Correct typo: TSCR ->TSCR1;
- Correct typo: ECTxxx->TIMxxx
- Correct reference:Figure20-25 ->Figure20-30
- Add description, “a counter overflow when TTOV[7] is set”, to be the
condition of channel 7 override event.
- Phrase the description of OC7M to make it more explicit
V03.02Apri,12,201020.3.2.8/20-642
20.3.2.11/20-64
5
20.4.3/20-655
-AddTable20-10
-update TCRE bit description
-addFigure20-31
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual,Rev.1.06
632Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Clock prescaling.
•16-bit counter.
•16-bit pulse accumulator on channel 7 if channel 7 exists.
20.1.2Modes of Operation
Stop:Timer is off because clocks are stopped.
Freeze:Timer counter keeps on running, unless TSFRZ in TSCR1 is set to 1.
Wait:Counters keeps on running, unless TSWAI in TSCR1 is set to 1.
Normal:Timer counter keep on running, unless TEN in TSCR1 is cleared to 0.
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor633
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
20.1.3Block Diagrams
Figure20-1. TIM16B8CV3 Block Diagram
Prescaler
16-bit Counter
Input capture
Output compare
16-bit
Pulse accumulator
IOC0
IOC2
IOC1
IOC5
IOC3
IOC4
IOC6
IOC7
PA input
interrupt
PA overflow
interrupt
Timer overflow
interrupt
Timer channel 0
interrupt
Timer channel 7
interrupt
Registers
Bus clock
Input capture
Output compare
Input capture
Output compare
Input capture
Output compare
Input capture
Output compare
Input capture
Output compare
Input capture
Output compare
Input capture
Output compare
Channel 0
Channel 1
Channel 2
Channel 3
Channel 4
Channel 5
Channel 6
Channel 7
Maximum possible channels, scalable from 0 to 7.
Pulse Accumulator is available only if channel 7 exists.
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual,Rev.1.06
634Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
register is the address offset. The total address for each register is the sum of the base address for the
TIM16B8CV3 module and the address offset for each register.
PULSE
ACCUMULATORPAD
TEN
CHANNEL 7 OUTPUT COMPARE
OCPD
TIOS7
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual,Rev.1.06
636Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
diagram with an associated figure number. Details of register bit and field function follow the register
diagrams, in bit order.
Only bits related to implemented channels are valid.
Register
NameBit 7654321Bit 0
0x0000
TIOS1RIOS7IOS6IOS5IOS4IOS3IOS2IOS1IOS0
W
0x0001
CFORC1R00000000
WFOC7FOC6FOC5FOC4FOC3FOC2FOC1FOC0
0x0002
OC7M2ROC7M7OC7M6OC7M5OC7M4OC7M3OC7M2OC7M1OC7M0
W
0x0003
OC7D2ROC7D7OC7D6OC7D5OC7D4OC7D3OC7D2OC7D1OC7D0
W
0x0004
TCNTH
RTCNT15TCNT14TCNT13TCNT12TCNT11TCNT10TCNT9TCNT8
W
0x0005
TCNTL
RTCNT7TCNT6TCNT5TCNT4TCNT3TCNT2TCNT1TCNT0
W
0x0006
TSCR1
RTENTSWAITSFRZTFFCAPRNT000
W
0x0007
TTOV1RTOV7TOV6TOV5TOV4TOV3TOV2TOV1TOV0
W
0x0008
TCTL11ROM7OL7OM6OL6OM5OL5OM4OL4
W
0x0009
TCTL21ROM3OL3OM2OL2OM1OL1OM0OL0
W
0x000A
TCTL31REDG7BEDG7AEDG6BEDG6AEDG5BEDG5AEDG4BEDG4A
W
0x000B
TCTL41REDG3BEDG3AEDG2BEDG2AEDG1BEDG1AEDG0BEDG0A
W
0x000C
TIE1RC7IC6IC5IC4IC3IC2IC1IC0I
W
0x000D
TSCR21RTOI000
TCREPR2PR1PR0
W
= Unimplemented or Reserved
Figure20-5. TIM16B8CV3 Register Summary (Sheet 1 of 2)
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor637
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1The related bit is available only if corresponding channel exists
2The register is available only if channel 7 exists.
3The register is available only if corresponding channel exists.
Register
NameBit 7654321Bit 0
= Unimplemented or Reserved
Figure20-5. TIM16B8CV3 Register Summary (Sheet 2 of 2)
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual,Rev.1.06
638Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
timer port data register depending on the output compare 7 mask register.
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual,Rev.1.06
640Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
20.3.2.5Timer Count Register (TCNT)
The 16-bit main timer is an up counter.
A full access for the counter register should take place in one clock cycle. A separate read/write for high
byte and low byte will give a different result than accessing them as a word.
Read: Anytime
Write: Has no meaning or effect in the normal mode; only writable in special modes (test_mode = 1).
Figure20-12. Timer System Control Register 1 (TSCR1)
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor641
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
20.3.2.7Timer Toggle On Overflow Register 1 (TTOV)
Read: Anytime
Write: Anytime
Table20-6. TSCR1 Field Descriptions
FieldDescription
7
TEN
Timer Enable
0Disables the main timer, including the counter. Can be used for reducing power consumption.
1Allows the timer to function normally.
If for any reason the timer is not active, there is no÷64 clock for the pulse accumulator because the÷64 is
generated by the timer prescaler.
6
TSWAI
Timer Module Stops While in Wait
0Allows the timer module to continue running during wait.
Figure20-13. Timer Toggle On Overflow Register 1 (TTOV)
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual,Rev.1.06
642Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
20.3.2.8Timer Control Register 1/Timer Control Register 2 (TCTL1/TCTL2)
Read: Anytime
Write: Anytime
Table20-7. TTOV Field Descriptions
Note:Bits related to available channels have functional significance. Writing to unavailable bits has no effect. Read from
of a successful OCx compare. When either OMx or OLx is 1, the pin associated with OCx becomes an output
tied to OCx.
Note:To enable output action by OLx bits on timer port, the corresponding bit in OC7M should be cleared. For
an output line to be driven by an OCx the OCPDx must be cleared.
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor643
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
20.3.2.9Timer Control Register 3/Timer Control Register 4 (TCTL3 and TCTL4)
Read: Anytime
Write: Anytime.
20.3.2.10Timer Interrupt Enable Register (TIE)
76543210
R
EDG7BEDG7AEDG6BEDG6AEDG5BEDG5AEDG4BEDG4A
W
Reset00000000
Figure20-16. Timer Control Register 3 (TCTL3)
76543210
R
EDG3BEDG3AEDG2BEDG2AEDG1BEDG1AEDG0BEDG0A
W
Reset00000000
Figure20-17. Timer Control Register 4 (TCTL4)
Table20-11. TCTL3/TCTL4 Field Descriptions
Note:Bits related to available channels have functional significance. Writing to unavailable bits has no effect. Read from
unavailable bits return a zero.
FieldDescription
7:0
EDGnB
EDGnA
Input Capture Edge Control— These eight pairs of control bits configure the input capture edge detector
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Read: Anytime
Write: Anytime.
20.3.2.11Timer System Control Register 2 (TSCR2)
Read: Anytime
Write: Anytime.
Table20-13. TIE Field Descriptions
Note:Bits related to available channels have functional significance. Writing to unavailable bits has no effect. Read from
unavailable bits return a zero
FieldDescription
7:0
C7I:C0I
Input Capture/Output Compare “x” Interrupt Enable —The bits in TIE correspond bit-for-bit with the bits in
Writing to reserved bit has no effect. Read from reserved bit return a zero.
2
PR[2:0]
Timer Prescaler Select — These three bits select the frequency of the timer prescaler clock derived from the
Bus Clock as shown inTable20-15.
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual,Rev.1.06
646Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NOTE
The newly selected prescale factor will not take effect until the next
synchronized edge where all prescale counter stages equal zero.
20.3.2.12Main Timer Interrupt Flag 1 (TFLG1)
Read: Anytime
Write: Used in the clearing mechanism (set bits cause corresponding bits to be cleared). Writing a zero
will not affect current status of the bit.
Table20-15. Timer Clock Selection
PR2PR1PR0Timer Clock
000Bus Clock / 1
001Bus Clock / 2
010Bus Clock / 4
011Bus Clock / 8
100Bus Clock / 16
101Bus Clock / 32
110Bus Clock / 64
111Bus Clock / 128
76543210
R
C7FC6FC5FC4FC3FC2FC1FC0F
W
Reset00000000
Figure20-20. Main Timer Interrupt Flag 1 (TFLG1)
Table20-16. TRLG1 Field Descriptions
Note:Bits related to available channels have functional significance. Writing to unavailable bits has no effect. Read from
unavailable bits return a zero.
FieldDescription
7:0
C[7:0]F
Input Capture/Output Compare Channel “x” Flag — These flags are set when an input capture or output
Note:When TFFCA bit in TSCR register is set, a read from an input capture or a write into an output compare
channel (0x0010–0x001F) will cause the corresponding channel flag CxF to be cleared.
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor647
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
20.3.2.13Main Timer Interrupt Flag 2 (TFLG2)
TFLG2 indicates when interrupt conditions have occurred. To clear a bit in the flag register, write the bit
to one while TEN bit of TSCR1 or PAEN bit of PACTL is set to one.
Read: Anytime
Write: Used in clearing mechanism (set bits cause corresponding bits to be cleared).
Any access to TCNT will clear TFLG2 register if the TFFCA bit in TSCR register is set.
20.3.2.14Timer Input Capture/Output Compare Registers High and Low 0–7
Figure20-22. Timer Input Capture/Output Compare Register x High (TCxH)
76543210
R
Bit 7Bit 6Bit 5Bit 4Bit 3Bit 2Bit 1Bit 0
W
Reset00000000
Figure20-23. Timer Input Capture/Output Compare Register x Low (TCxL)
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual,Rev.1.06
648Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
have no functional effect. Reads from a reserved register return zeroes.
Read: Any time
Write: Any time
When PAEN is set, the Pulse Accumulator counter is enabled.The Pulse Accumulator counter shares the
input pin with IOC7.
76543210
R0
PAENPAMODPEDGECLK1CLK0PAOVIPAI
W
Reset00000000
Unimplemented or Reserved
Figure20-24. 16-Bit Pulse Accumulator Control Register (PACTL)
Table20-18. PACTL Field Descriptions
FieldDescription
6
PAEN
Pulse Accumulator System Enable — PAEN is independent from TEN. With timer disabled, the pulse
accumulator can function unless pulse accumulator is disabled.
016-Bit Pulse Accumulator system disabled.
1Pulse Accumulator system enabled.
5
PAMOD
Pulse Accumulator Mode — This bit is active only when the Pulse Accumulator is enabled (PAEN = 1).See
Table20-19.
0Event counter mode.
1Gated time accumulation mode.
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor649
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NOTE
If the timer is not active (TEN = 0 in TSCR), there is no divide-by-64
because the÷64 clock is generated by the timer prescaler.
For the description of PACLK please referFigure20-30.
If the pulse accumulator is disabled (PAEN = 0), the prescaler clock from the timer is always used as an
input clock to the timer counter. The change from one selected clock to the other happens immediately
00Use timer prescaler clock as timer counter clock
01Use PACLK as input to timer counter clock
10Use PACLK/256 as timer counter clock frequency
11Use PACLK/65536 as timer counter clock frequency
Table20-18. PACTL Field Descriptions (continued)
FieldDescription
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual,Rev.1.06
650Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure20-26. Pulse Accumulator Count Register High (PACNTH)
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor651
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
the detailed timer block diagram inFigure20-30 as necessary.
000000114
---------
---------
---------
0001001120
0001010021
0001010122
---------
---------
---------
11111100253
11111101254
11111110255
11111111256
PTPS7PTPS6PTPS5PTPS4PTPS3PTPS2PTPS1PTPS0Prescale
Factor
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual,Rev.1.06
654Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure20-30. Detailed Timer Block Diagram
PRESCALER
CHANNEL 0
IOC0 PIN
16-BIT COUNTER
LOGIC
PR[2:1:0]
DIVIDE-BY-64
TC0
EDGE
DETECT
PACNT(hi):PACNT(lo)
PAOVFPEDGE
PAOVI
TEN
PAEN
16-BIT COMPARATOR
TCNT(hi):TCNT(lo)
CHANNEL 1
TC1
16-BIT COMPARATOR
16-BIT COUNTER
INTERRUPT
LOGIC
TOF
TOI
C0F
C1F
EDGE
DETECT
IOC1 PIN
LOGIC
EDGE
DETECT
CxF
CHANNEL7
TC7
16-BIT COMPARATORC7F
IOC7 PIN
LOGIC
EDGE
DETECT
OM:OL0
TOV0
OM:OL1
TOV1
OM:OL7
TOV7
EDG1AEDG1B
EDG7A
EDG7B
EDG0B
TCRE
PAIF
CLEAR COUNTER
PAIF
PAI
INTERRUPT
LOGIC
CxI
INTERRUPT
REQUEST
PAOVF
CH. 7 COMPARE
CH.7 CAPTURE
CH. 1 CAPTURE
MUX
CLK[1:0]
PACLK
PACLK/256
PACLK/65536
IOC1 PIN
IOC0 PIN
IOC7 PIN
PACLK
PACLK/256
PACLK/65536
TE
CH. 1 COMPARE
CH. 0COMPARE
CH. 0 CAPTURE
PA INPUT
CHANNEL2
EDG0A
channel 7 output
compare
IOC0
IOC1
IOC7
Bus Clock
PAOVF
PAOVI
TOF
C0F
C1F
C7F
MUX
PRE-PRESCALER
PTPSR[7:0]
Bus Clock
1
0
PRNT
Maximum possible channels, scalable from 0 to 7.
Pulse Accumulator is available only if channel 7 exists.
MUX
PAMOD
PEDGE
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor655
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
output compare 7 data register. The timer counter reset enable bit, TCRE, enables channel 7 output
compares to reset the timer counter. A channel 7 output compare can reset the timer counter even if the
IOC7 pin is being used as the pulse accumulator input.
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual,Rev.1.06
656Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Writing to the timer port bit of an output compare pin does not affect the pin state. The value written is
stored in an internal latch. When the pin becomes available for general-purpose output, the last value
The minimum pulse width for the PAI input is greater than two bus clocks.
TC701-----TC7-1TC70
TC7 eventTC7 event
prescaler
counter1 bus
clock
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor657
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This section describes interrupts originated by the TIM16B8CV3 block.Table20-25 lists the interrupts
generated by the TIM16B8CV3 to communicate with the MCU.
Timer Module (TIM16B8CV3)
MC9S12G Family Reference Manual,Rev.1.06
658Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
only generates the interrupt and does not service it.
Table20-25. TIM16B8CV1 Interrupts
InterruptOffset1
1Chip Dependent.
2 This feature is available only when channel 7 exists.
3 Bits related to available channels have functional significance
Vector1Priority1SourceDescription
C[7:0]F3———Timer Channel 7–0Active high timer channel interrupts 7–0
PAOVI2———Pulse Accumulator
Input
Active high pulse accumulator input interrupt
PAOVF2———Pulse Accumulator
Overflow
Pulse accumulator overflow interrupt
TOF———Timer OverflowTimer Overflow interrupt
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor659
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter21
16 KByte Flash Module (S12FTMRG16K1V1)
21.1Introduction
The FTMRG16K1 module implements the following:
•16Kbytes of P-Flash (Program Flash) memory
•512 bytes of EEPROM memory
The Flash memory is ideal for single-supply applications allowing for field reprogramming without
requiring external high voltage sources for program or erase operations. The Flash module includes a
memory controller that executes commands to modify Flash memory contents. The user interface to the
memory controller consists of the indexed Flash Common Command Object (FCCOB) register which is
written to with the command, global address, data, and any required command parameters. The memory
Updated description of the commands RD1BLK, MLOADU and MLOADF
Rev.1.0631 Jan 201121.3.2.9/21-675Updated description of protection onSection21.3.2.9
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor660
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The Flash memory may be read as bytes and aligned words. Read access time is one bus cycle for bytes
and aligned words. For misaligned words access, the CPU has to perform twice the byte read access
command. For Flash memory, an erased bit reads 1 and a programmed bit reads 0.
P-Flash Sector— The P-Flash sector is the smallest portion of the P-Flash memory that can be erased.
Each P-Flash sector contains 512 bytes.
Program IFR— Nonvolatile information register located in the P-Flash block that contains the Version
ID, and the Program Once field.
21.1.2Features
21.1.2.1P-Flash Features
•16 Kbytes of P-Flash memory composed of one 16 Kbyte Flash block divided into 32 sectors of
512 bytes
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor661
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Single bit fault correction and double bit fault detection within a 32-bit double word during read
operations
•Automated program and erase algorithm with verify and generation of ECC parity bits
•Fast sector erase and phrase program operation
•Ability to read the P-Flash memory while programming a word in the EEPROM memory
•Flexible protection scheme to prevent accidental program or erase of P-Flash memory
•Single bit fault correction and double bit fault detection within a word during read operations
•Automated program and erase algorithm with verify and generation of ECC parity bits
•Fast sector erase and word program operation
•Protection scheme to prevent accidental program or erase of EEPROM memory
•Ability to program up to four words in a burst sequence
21.1.2.3Other Flash Module Features
•No external high-voltage power supply required for Flash memory program and erase operations
•Interrupt generation on Flash command completion and Flash error detection
•Security mechanism to prevent unauthorized access to the Flash memory
21.1.3Block Diagram
The block diagram of the Flash module is shown inFigure21-1.
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual,Rev.1.06
662Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure21-1. FTMRG16K1 Block Diagram
21.2External Signal Description
The Flash module contains no signals that connect off-chip.
Bus
Clock
Divider
Clock
Command
Interrupt
Request
FCLK
Protection
Security
Registers
Flash
Interface
16bit
internal
bus
sector 0
sector 1
sector 31
4Kx39
P-Flash
Error
Interrupt
Request
CPU
256x22
sector 0
sector 1
sector 127
EEPROM
Memory Controller
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor663
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
in the Flash module will be ignored by the Flash module.
CAUTION
Writing to the Flash registers while a Flash command is executing (that is
indicated when the value of flag CCIF reads as ’0’) is not allowed. If such
action is attempted the write operation will not change the register value.
Writing to the Flash registers is allowed when the Flash is not busy
executing commands (CCIF = 1) and during initialization right after reset,
despite the value of flag CCIF in that case (refer toSection21.6 for a
complete description of the reset sequence).
.
21.3.1Module Memory Map
The S12 architecture places the P-Flash memory between global addresses 0x3_C000 and 0x3_FFFF as
shown inTable21-3.The P-Flash memory map is shown inFigure21-2.
Table21-2. FTMRG Memory Map
Global Address (in Bytes)Size
(Bytes)Description
0x0_0000 - 0x0_03FF1,024Register Space
0x0_0400 – 0x0_05FF512EEPROM Memory
0x0_0600 – 0x0_07FF512FTMRG reserved area
0x0_4000 – 0x0_7FFF16,284NVMRES1=1 : NVM Resource area (seeFigure21-3)
1See NVMRES description inSection21.4.3
0x3_8000 – 0x3_BFFF16,384FTMRG reserved area
0x3_C000 – 0x3_FFFF16,384P-Flash Memory
Table21-3. P-Flash Memory Addressing
Global AddressSize
(Bytes)Description
0x3_C000 – 0x3_FFFF16 K
P-Flash Block
Contains Flash Configuration Field
(seeTable21-4)
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual,Rev.1.06
664Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table21-5. Program IFR Fields
Global AddressSize
(Bytes)Field Description
0x0_4000 – 0x0_40078Reserved
0x0_4008 – 0x0_40B5174Reserved
0x0_40B6 – 0x0_40B72Version ID1
1Used to track firmware patch versions, seeSection21.4.2
1NVMRES - SeeSection21.4.3 for NVMRES (NVM Resource) detail.
Global AddressSize
(Bytes)Description
0x0_4000 – 0x040FF256P-Flash IFR (seeTable21-5)
0x0_4100 – 0x0_41FF256Reserved.
0x0_4200 – 0x0_57FFReserved
0x0_5800 – 0x0_59FF512Reserved
0x0_5A00 – 0x0_5FFF1,536Reserved
0x0_6000 – 0x0_6BFF3,072Reserved
0x0_6C00 – 0x0_7FFF5,120Reserved
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual,Rev.1.06
666Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A summary of the Flash module registers is given inFigure21-4 with detailed descriptions in the
following subsections.
Address
& Name76543210
0x0000
FCLKDIV
RFDIVLDFDIVLCKFDIV5FDIV4FDIV3FDIV2FDIV1FDIV0
W
0x0001
FSEC
RKEYEN1KEYEN0RNV5RNV4RNV3RNV2SEC1SEC0
W
0x0002
FCCOBIX
R00000CCOBIX2CCOBIX1CCOBIX0
W
Figure21-4. FTMRG16K1 Register Summary
P-Flash IFR 1 Kbyte (NVMRES=1)
0x0_4000
RAM End = 0x0_59FF
RAM Start = 0x0_5800
Reserved 5120 bytes
Reserved 4608 bytes
0x0_6C00
0x0_7FFF
0x0_4400Reserved 5k bytes
Reserved 512 bytes
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor667
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.3.2.1Flash Clock Divider Register (FCLKDIV)
The FCLKDIV register is used to control timed events in program and erase algorithms.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.3.2.2Flash Security Register (FSEC)
The FSEC register holds all bits associated with the security of the MCU and Flash module.
6
FDIVLCK
Clock Divider Locked
0FDIV field is open for writing
1FDIV value is locked and cannot be changed. Once the lock bit is set high, only reset can clear this bit and
restore writability to the FDIV field in normal mode.
BUSCLK frequency. Please refer toSection21.4.4, “Flash Command Operations,” for more information.
Table21-8. FDIV values for various BUSCLK Frequencies
BUSCLK Frequency
(MHz)FDIV[5:0]
BUSCLK Frequency
(MHz)FDIV[5:0]
MIN1
1BUSCLK is Greater Than this value.
MAX2
2BUSCLK is Less Than or Equal to this value.
MIN1MAX2
1.01.60x0016.617.60x10
1.62.60x0117.618.60x11
2.63.60x0218.619.60x12
3.64.60x0319.620.60x13
4.65.60x0420.621.60x14
5.66.60x0521.622.60x15
6.67.60x0622.623.60x16
7.68.60x0723.624.60x17
8.69.60x0824.625.60x18
9.610.60x09
10.611.60x0A
11.612.60x0B
12.613.60x0C
13.614.60x0D
14.615.60x0E
15.616.60x0F
Table21-7. FCLKDIV Field Descriptions (continued)
FieldDescription
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual,Rev.1.06
670Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All bits in the FSEC register are readable but not writable.
During the reset sequence, the FSEC register is loaded with the contents of the Flash security byte in the
Flash configuration field at global address 0x3_FF0F located in P-Flash memory (seeTable21-4) as
indicated by reset condition F inFigure21-6. If a double bit fault is detected while reading the P-Flash
Reserved Nonvolatile Bits— The RNV bits should remain in the erased state for future enhancements.
1–0
SEC[1:0]
Flash Security Bits — The SEC[1:0] bits define the security state of the MCU as shown inTable21-11. If the
Flash module is unsecured using backdoor key access, the SEC bits are forced to 10.
Table21-10. Flash KEYEN States
KEYEN[1:0]Status of Backdoor Key Access
00DISABLED
01DISABLED1
1Preferred KEYEN state to disable backdoor key access.
10ENABLED
11DISABLED
Table21-11. Flash Security States
SEC[1:0]Status of Security
00SECURED
01SECURED1
1Preferred SEC state to set MCU to secured state.
10UNSECURED
11SECURED
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor671
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The security function in the Flash module is described inSection21.5.
21.3.2.3Flash CCOB Index Register (FCCOBIX)
The FCCOBIX register is used to index the FCCOB register for Flash memory operations.
CCOBIX bits are readable and writable while remaining bits read 0 and are not writable.
21.3.2.4Flash Reserved0 Register (FRSV0)
This Flash register is reserved for factory testing.
All bits in the FRSV0 register read 0 and are not writable.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CCIE, IGNSF, FDFD, and FSFD bits are readable and writable while remaining bits read 0 and are not
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All assigned bits in the FERCNFG register are readable and writable.
21.3.2.7Flash Status Register (FSTAT)
The FSTAT register reports the operational status of the Flash module.
CCIF, ACCERR, and FPVIOL bits are readable and writable, MGBUSY and MGSTAT bits are readable
but not writable, while remaining bits read 0 and are not writable.
0SFDIF interrupt disabled whenever the SFDIF flag is set (seeSection21.3.2.8)
1An interrupt will be requested whenever the SFDIF flag is set (seeSection21.3.2.8)
OffsetModule Base + 0x0006
76543210
RCCIF0ACCERRFPVIOLMGBUSYRSVDMGSTAT[1:0]
W
Reset1000000
1
1Reset value can deviate from the value shown if a double bit fault is detected during the reset sequence (seeSection21.6).
01
= Unimplemented or Reserved
Figure21-11. Flash Status Register (FSTAT)
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual,Rev.1.06
674Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.3.2.8Flash Error Status Register (FERSTAT)
The FERSTAT register reflects the error status of internal Flash operations.
All flags in the FERSTAT register are readable and only writable to clear the flag.
Table21-15. FSTAT Field Descriptions
FieldDescription
7
CCIF
Command Complete Interrupt Flag — The CCIF flag indicates that a Flash command has completed. The
CCIF flag is cleared by writing a 1 to CCIF to launch a command and CCIF will stay low until command
completion or command violation.
0Flash command in progress
1Flash command has completed
5
ACCERR
Flash Access Error Flag — The ACCERR bit indicates an illegal access has occurred to the Flash memory
is detected during execution of a Flash command or during the Flash reset sequence. SeeSection21.4.6,
“Flash Command Description,” andSection21.6, “Initialization” for details.
OffsetModule Base + 0x0007
76543210
R000000
DFDIFSFDIF
W
Reset00000000
= Unimplemented or Reserved
Figure21-12. Flash Error Status Register (FERSTAT)
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor675
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.3.2.9P-Flash Protection Register (FPROT)
The FPROT register defines which P-Flash sectors are protected against program and erase operations.
command operation.1 The SFDIF flag is cleared by writing a 1 to SFDIF. Writing a 0 to SFDIF has no effect on
SFDIF.
0No single bit fault detected
1Single bit fault detected and corrected or a Flash array read operation returning invalid data was attempted
while command running
OffsetModule Base + 0x0008
76543210
RFPOPENRNV6FPHDISFPHS[1:0]RNV[2:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
= Unimplemented or Reserved
Figure21-13. Flash Protection Register (FPROT)
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual,Rev.1.06
676Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
in P-Flash memory as shown inTable21-19. The FPHS bits can only be written to while the FPHDIS bit is set.
2–0
RNV[2:0]
Reserved Nonvolatile Bits — These RNV bits should remain in the erased state.
Table21-18. P-Flash Protection Function
FPOPENFPHDISFunction1
1For range sizes, refer toTable21-19.
11No P-Flash Protection
10Protected High Range
01Full P-Flash Memory Protected
00Unprotected High Range
Table21-19. P-Flash Protection Higher Address Range
FPHS[1:0] Global Address RangeProtected Size
000x3_F800–0x3_FFFF2 Kbytes
010x3_F000–0x3_FFFF4 Kbytes
100x3_E000–0x3_FFFF8 Kbytes
110x3_C000–0x3_FFFF16 Kbytes
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor677
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1Disables EEPROM memory protection from program and erase
4–0
DPS[4:0]
EEPROM Protection Size — The DPS[4:0] bits determine the size of the protected area in the EEPROM
memory as shown inTable21-21 .
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual,Rev.1.06
678Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.3.2.11Flash Common Command Object Register (FCCOB)
The FCCOB is an array of six words addressed via the CCOBIX index found in the FCCOBIX register.
Byte wide reads and writes are allowed to the FCCOB register.
21.3.2.11.1FCCOB - NVM Command Mode
NVM command mode uses the indexed FCCOB register to provide a command code and its relevant
parameters to the Memory Controller. The user first sets up all required FCCOB fields and then initiates
Table21-21. EEPROM Protection Address Range
DPS[4:0] Global Address RangeProtected Size
000000x0_0400 – 0x0_041F32 bytes
000010x0_0400 – 0x0_043F64 bytes
000100x0_0400 – 0x0_045F96 bytes
000110x0_0400 – 0x0_047F128 bytes
001000x0_0400 – 0x0_049F160 bytes
001010x0_0400 – 0x0_04BF192 bytes
The Protection Size goes on enlarging in step of 32 bytes, for each DPS
value increasing of one.
.
.
.
01111-to-111110x0_0400 – 0x0_05FF512 bytes
OffsetModule Base + 0x000A
76543210
RCCOB[15:8]
W
Reset00000000
Figure21-15. Flash Common Command Object High Register (FCCOBHI)
OffsetModule Base + 0x000B
76543210
RCCOB[7:0]
W
Reset00000000
Figure21-16. Flash Common Command Object Low Register (FCCOBLO)
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor679
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.3.2.13Flash Reserved2 Register (FRSV2)
This Flash register is reserved for factory testing.
All bits in the FRSV2 register read 0 and are not writable.
21.3.2.14Flash Reserved3 Register (FRSV3)
This Flash register is reserved for factory testing.
All bits in the FRSV3 register read 0 and are not writable.
21.3.2.15Flash Reserved4 Register (FRSV4)
This Flash register is reserved for factory testing.
All bits in the FRSV4 register read 0 and are not writable.
OffsetModule Base + 0x000D
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure21-18. Flash Reserved2 Register (FRSV2)
OffsetModule Base + 0x000E
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure21-19. Flash Reserved3 Register (FRSV3)
OffsetModule Base + 0x000F
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure21-20. Flash Reserved4 Register (FRSV4)
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor681
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.3.2.16Flash Option Register (FOPT)
The FOPT register is the Flash option register.
All bits in the FOPT register are readable but are not writable.
During the reset sequence, the FOPT register is loaded from the Flash nonvolatile byte in the Flash
configuration field at global address 0x3_FF0E located in P-Flash memory (seeTable21-4) as indicated
by reset condition F inFigure21-21. If a double bit fault is detected while reading the P-Flash phrase
containing the Flash nonvolatile byte during the reset sequence, all bits in the FOPT register will be set.
21.3.2.17Flash Reserved5 Register (FRSV5)
This Flash register is reserved for factory testing.
All bits in the FRSV5 register read 0 and are not writable.
21.3.2.18Flash Reserved6 Register (FRSV6)
This Flash register is reserved for factory testing.
OffsetModule Base + 0x0010
76543210
RNV[7:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All bits in the FRSV6 register read 0 and are not writable.
21.3.2.19Flash Reserved7 Register (FRSV7)
This Flash register is reserved for factory testing.
All bits in the FRSV7 register read 0 and are not writable.
OffsetModule Base + 0x0012
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure21-23. Flash Reserved6 Register (FRSV6)
OffsetModule Base + 0x0013
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure21-24. Flash Reserved7 Register (FRSV7)
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor683
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.4Functional Description
21.4.1Modes of Operation
The FTMRG16K1 module provides the modes of operation normal and special . The operating mode is
determined by module-level inputs and affects the FCLKDIV, FCNFG, and EEPROT registers (see
Table21-25).
21.4.2IFR Version ID Word
The version ID word is stored in the IFR at address 0x0_40B6. The contents of the word are defined in
values for the FDIV field based on BUSCLK frequency.
Table21-24. IFR Version ID Fields
[15:4][3:0]
ReservedVERNUM
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual,Rev.1.06
684Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NOTE
Programming or erasing the Flash memory cannot be performed if the bus
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.4.4.3Valid Flash Module Commands
Table21-25 present the valid Flash commands, as enabled by the combination of the functional MCU
Table21-26 summarizes the valid P-Flash commands along with the effects of the commands on the
P-Flash block and other resources within the Flash module.
Table21-25. Flash Commands by Mode and Security State
FCMDCommand
UnsecuredSecured
NS1
1Unsecured Normal Single Chip mode
SS2
2Unsecured Special Single Chip mode.
NS3
3Secured Normal Single Chip mode.
SS4
4Secured Special Single Chip mode.
0x01Erase Verify All Blocks∗∗∗∗
0x02Erase Verify Block∗∗∗∗
0x03Erase Verify P-Flash Section∗∗∗
0x04Read Once∗∗∗
0x06Program P-Flash∗∗∗
0x07Program Once∗∗∗
0x08Erase All Blocks∗∗
0x09Erase Flash Block∗∗∗
0x0AErase P-Flash Sector∗∗∗
0x0BUnsecure Flash∗∗
0x0CVerify Backdoor Access Key∗∗
0x0DSet User Margin Level∗∗∗
0x0ESet Field Margin Level∗
0x10Erase Verify EEPROM Section∗∗∗
0x11Program EEPROM∗∗∗
0x12Erase EEPROM Sector∗∗∗
Table21-26. P-Flash Commands
FCMDCommandFunction on P-Flash Memory
0x01Erase Verify All
Blocks
Verify that all P-Flash (and EEPROM) blocks are erased.
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor687
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.4.4.5EEPROM Commands
Table21-27 summarizes the valid EEPROM commands along with the effects of the commands on the
EEPROM block.
0x02Erase Verify BlockVerify that a P-Flash block is erased.
0x03Erase Verify
P-Flash Section
Verify that a given number of words starting at the address provided are erased.
bits in the FPROT register are set prior to launching the command.
0x0AErase P-Flash
Sector
Erase all bytes in a P-Flash sector.
0x0BUnsecure FlashSupports a method of releasing MCU security by erasing all P-Flash (and EEPROM)
blocks and verifying that all P-Flash (and EEPROM) blocks are erased.
0x0CVerify Backdoor
Access Key
Supports a method of releasing MCU security by verifying a set of security keys.
0x0DSet User Margin
Level
Specifies a user margin read level for all P-Flash blocks.
0x0ESet Field Margin
Level
Specifies a field margin read level for all P-Flash blocks (special modes only).
Table21-27. EEPROM Commands
FCMDCommandFunction on EEPROM Memory
0x01Erase Verify All
Blocks
Verify that all EEPROM (and P-Flash) blocks are erased.
0x02Erase Verify BlockVerify that the EEPROM block is erased.
Table21-26. P-Flash Commands
FCMDCommandFunction on P-Flash Memory
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual,Rev.1.06
688Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.4.5Allowed Simultaneous P-Flash and EEPROM Operations
Only the operations marked ‘OK’ inTable21-28 are permitted to be run simultaneously on the Program
2The ‘Mass Erase’ operations are commands ‘Erase All Blocks’ and ‘Erase
Flash Block’
OK
Table21-27. EEPROM Commands
FCMDCommandFunction on EEPROM Memory
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor689
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual,Rev.1.06
690Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.4.6.2Erase Verify Block Command
The Erase Verify Block command allows the user to verify that an entire P-Flash or EEPROM block has
been erased. The FCCOB FlashBlockSelectionCode[1:0] bits determine which block must be verified.
Upon clearing CCIF to launch the Erase Verify Block command, the Memory Controller will verify that
the selected P-Flash or EEPROM block is erased. The CCIF flag will set after the Erase Verify Block
MGSTAT0Set if any non-correctable errors have been encountered during the read2 or if
blank check failed.
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor691
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Erase Verify P-Flash Section command, the Memory Controller will
MGSTAT0Set if any non-correctable errors have been encountered during the read2 or if
blank check failed.
Table21-36. Read Once Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x04Not Required
001Read Once phrase index (0x0000 - 0x0007)
010Read Once word 0 value
011Read Once word 1 value
100Read Once word 2 value
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual,Rev.1.06
692Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A P-Flash phrase must be in the erased state before being programmed.
Cumulative programming of bits within a Flash phrase is not allowed.
Upon clearing CCIF to launch the Program P-Flash command, the Memory Controller will program the
data words to the supplied global address and will then proceed to verify the data words read back as
expected. The CCIF flag will set after the Program P-Flash operation has completed.
101Read Once word 3 value
Table21-37. Read Once Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 001 at command launch
Set if command not available in current mode (seeTable21-25)
Set if an invalid phrase index is supplied
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read
MGSTAT0Set if any non-correctable errors have been encountered during the read
Table21-38. Program P-Flash Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x06Global address [17:16] to
identify P-Flash block
001Global address [15:0] of phrase location to be programmed1
1Global address [2:0] must be 000
010Word 0 program value
011Word 1 program value
100Word 2 program value
101Word 3 program value
Table21-36. Read Once Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor693
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.4.6.6Program Once Command
The Program Once command restricts programming to a reserved 64 byte field (8 phrases) in the
and any attempt to program one of these phrases a second time will not be allowed. Valid phrase index
values for the Program Once command range from 0x0000 to 0x0007. During execution of the Program
Once command, any attempt to read addresses within P-Flash will return invalid data.
Table21-39. Program P-Flash Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 101 at command launch
Set if command not available in current mode (seeTable21-25)
Set if an invalid global address [17:0] is supplied seeTable21-3)1
1As defined by the memory map for FTMRG32K1.
Set if a misaligned phrase address is supplied (global address [2:0] != 000)
FPVIOLSet if the global address [17:0] points to a protected area
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
Table21-40. Program Once Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x07Not Required
001Program Once phrase index (0x0000 - 0x0007)
010Program Once word 0 value
011Program Once word 1 value
100Program Once word 2 value
101Program Once word 3 value
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual,Rev.1.06
694Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.4.6.7Erase All Blocks Command
The Erase All Blocks operation will erase the entire P-Flash and EEPROM memory space.
The Erase Flash Block operation will erase all addresses in a P-Flash or EEPROM block.
Table21-41. Program Once Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 101 at command launch
Set if command not available in current mode (seeTable21-25)
Set if an invalid phrase index is supplied
Set if the requested phrase has already been programmed1
1If a Program Once phrase is initially programmed to 0xFFFF_FFFF_FFFF_FFFF, the Program Once command will
be allowed to execute again on that same phrase.
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
Table21-42. Erase All Blocks Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x08Not required
Table21-43. Erase All Blocks Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERRSet if CCOBIX[2:0] != 000 at command launch
Set if command not available in current mode (seeTable21-25)
FPVIOLSet if any area of the P-Flash or EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation1
1As found in the memory map for FTMRG32K1.
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation1
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor695
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Erase Flash Block command, the Memory Controller will erase the
selected Flash block and verify that it is erased. The CCIF flag will set after the Erase Flash Block
operation has completed.
21.4.6.9Erase P-Flash Sector Command
The Erase P-Flash Sector operation will erase all addresses in a P-Flash sector.
Upon clearing CCIF to launch the Erase P-Flash Sector command, the Memory Controller will erase the
selected Flash sector and then verify that it is erased. The CCIF flag will be set after the Erase P-Flash
001Global address [15:0] anywhere within the sector to be erased.
Refer toSection21.1.2.1 for the P-Flash sector size.
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual,Rev.1.06
696Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Set if command not available in current mode (seeTable21-25)
FPVIOLSet if any area of the P-Flash or EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation1
1As found in the memory map for FTMRG32K1.
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation1
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor697
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.4.6.11Verify Backdoor Access Key Command
The Verify Backdoor Access Key command will only execute if it is enabled by the KEYEN bits in the
FSEC register (seeTable21-10). The Verify Backdoor Access Key command releases security if
user-supplied keys match those stored in the Flash security bytes of the Flash configuration field (see
Table21-4). The Verify Backdoor Access Key command must not be executed from the Flash block
containing the backdoor comparison key to avoid code runaway.
Upon clearing CCIF to launch the Verify Backdoor Access Key command, the Memory Controller will
check the FSEC KEYEN bits to verify that this command is enabled. If not enabled, the Memory
Controller sets the ACCERR bit in the FSTAT register and terminates. If the command is enabled, the
Memory Controller compares the key provided in FCCOB to the backdoor comparison key in the Flash
configuration field with Key 0 compared to 0x3_FF00, etc. If the backdoor keys match, security will be
Set if backdoor key access has not been enabled (KEYEN[1:0] != 10, see
Section21.3.2.2)
Set if the backdoor key has mismatched since the last reset
FPVIOLNone
MGSTAT1None
MGSTAT0None
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual,Rev.1.06
698Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Set User Margin Level command, the Memory Controller will set the
user margin level for the targeted block and then set the CCIF flag.
Valid margin level settings for the Set User Margin Level command are defined inTable21-53.
Table21-52. Set User Margin Level Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x0DFlashblockselectioncode[1:0].See
Table21-32
001Margin level setting.
Table21-53. Valid Set User Margin Level Settings
CCOB
(CCOBIX=001)Level Description
0x0000Return to Normal Level
0x0001User Margin-1 Level1
1Read margin to the erased state
0x0002User Margin-0 Level2
2Read margin to the programmed state
Table21-54. Set User Margin Level Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 001 at command launch
Set if command not available in current mode (seeTable21-25)
Set if an invalid FlashBlockSelectionCode[1:0] is supplied (SeeTable21-32 )
Set if an invalid margin level setting is supplied
FPVIOLNone
MGSTAT1None
MGSTAT0None
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor699
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NOTE
User margin levels can be used to check that Flash memory contents have
Valid margin level settings for the Set Field Margin Level command are defined inTable21-56.
Table21-55. Set Field Margin Level Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x0EFlash block selection code [1:0]. See
Table21-32
001Margin level setting.
Table21-56. Valid Set Field Margin Level Settings
CCOB
(CCOBIX=001)Level Description
0x0000Return to Normal Level
0x0001User Margin-1 Level1
1Read margin to the erased state
0x0002User Margin-0 Level2
2Read margin to the programmed state
0x0003Field Margin-1 Level1
0x0004Field Margin-0 Level2
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual,Rev.1.06
700Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CAUTION
Field margin levels must only be used during verify of the initial factory
programming.
NOTE
Field margin levels can be used to check that Flash memory contents have
001Global address [15:0] of the first word to be verified
010Number of words to be verified
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor701
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.4.6.15Program EEPROM Command
The Program EEPROM operation programs one to four previously erased words in the EEPROM block.
Set if command not available in current mode (seeTable21-25)
Set if an invalid global address [17:0] is supplied
Set if a misaligned word address is supplied (global address [0] != 0)
Set if the requested section breaches the end of the EEPROM block
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
Table21-60. Program EEPROM Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x11Global address [17:16] to
identify the EEPROM block
001Global address [15:0] of word to be programmed
010Word 0 program value
011Word 1 program value, if desired
100Word 2 program value, if desired
101Word 3 program value, if desired
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual,Rev.1.06
702Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.4.6.16Erase EEPROM Sector Command
The Erase EEPROM Sector operation will erase all addresses in a sector of the EEPROM block.
Set if command not available in current mode (seeTable21-25)
Set if an invalid global address [17:0] is suppliedseeTable21-3)
Set if a misaligned word address is supplied (global address [0] != 0)
FPVIOLSet if the selected area of the EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor703
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.4.7Interrupts
The Flash module can generate an interrupt when a Flash command operation has completed or when a
Flash command operation has detected an ECC fault.
NOTE
Vector addresses and their relative interrupt priority are determined at the
MCU level.
21.4.7.1Description of Flash Interrupt Operation
The Flash module uses the CCIF flag in combination with the CCIE interrupt enable bit to generate the
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
21.4.8Wait Mode
The Flash module is not affected if the MCU enters wait mode. The Flash module can recover the MCU
from wait via the CCIF interrupt (seeSection21.4.7, “Interrupts”).
Access Key command match the backdoor keys stored in the Flash memory, the SEC bits in the FSEC
register (seeTable21-11) will be changed to unsecure the MCU. Key values of 0x0000 and 0xFFFF are
not permitted as backdoor keys. While the Verify Backdoor Access Key command is active, P-Flash
memory and EEPROM memory will not be available for read access and will return invalid data.
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor705
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
7.Send BDM commands to execute the Program P-Flash command write sequence to program the
Flash security byte to the unsecured state
16 KByte Flash Module (S12FTMRG16K1V1)
MC9S12G Family Reference Manual,Rev.1.06
706Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
8.Reset the MCU
21.5.3Mode and Security Effects on Flash Command Availability
The availability of Flash module commands depends on the MCU operating mode and security state as
state of the word being programmed or the sector/block being erased is not guaranteed.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor707
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter22
32 KByte Flash Module (S12FTMRG32K1V1)
22.1Introduction
The FTMRG32K1 module implements the following:
•32Kbytes of P-Flash (Program Flash) memory
•1 Kbytes of EEPROM memory
The Flash memory is ideal for single-supply applications allowing for field reprogramming without
requiring external high voltage sources for program or erase operations. The Flash module includes a
memory controller that executes commands to modify Flash memory contents. The user interface to the
memory controller consists of the indexed Flash Common Command Object (FCCOB) register which is
written to with the command, global address, data, and any required command parameters. The memory
Updated description of the commands RD1BLK, MLOADU and MLOADF
Rev.1.0631 Jan 201122.3.2.9/22-723Updated description of protection onSection22.3.2.9
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor708
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The Flash memory may be read as bytes and aligned words. Read access time is one bus cycle for bytes
and aligned words. For misaligned words access, the CPU has to perform twice the byte read access
command. For Flash memory, an erased bit reads 1 and a programmed bit reads 0.
P-Flash Sector— The P-Flash sector is the smallest portion of the P-Flash memory that can be erased.
Each P-Flash sector contains 512 bytes.
Program IFR— Nonvolatile information register located in the P-Flash block that contains the Version
ID, and the Program Once field.
22.1.2Features
22.1.2.1P-Flash Features
•32 Kbytes of P-Flash memory composed of one 32 Kbyte Flash block divided into 64 sectors of
512 bytes
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor709
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Single bit fault correction and double bit fault detection within a 32-bit double word during read
operations
•Automated program and erase algorithm with verify and generation of ECC parity bits
•Fast sector erase and phrase program operation
•Ability to read the P-Flash memory while programming a word in the EEPROM memory
•Flexible protection scheme to prevent accidental program or erase of P-Flash memory
•Single bit fault correction and double bit fault detection within a word during read operations
•Automated program and erase algorithm with verify and generation of ECC parity bits
•Fast sector erase and word program operation
•Protection scheme to prevent accidental program or erase of EEPROM memory
•Ability to program up to four words in a burst sequence
22.1.2.3Other Flash Module Features
•No external high-voltage power supply required for Flash memory program and erase operations
•Interrupt generation on Flash command completion and Flash error detection
•Security mechanism to prevent unauthorized access to the Flash memory
22.1.3Block Diagram
The block diagram of the Flash module is shown inFigure22-1.
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
710Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure22-1. FTMRG32K1 Block Diagram
22.2External Signal Description
The Flash module contains no signals that connect off-chip.
Bus
Clock
Divider
Clock
Command
Interrupt
Request
FCLK
Protection
Security
Registers
Flash
Interface
16bit
internal
bus
sector 0
sector 1
sector 63
8Kx39
P-Flash
Error
Interrupt
Request
CPU
512x22
sector 0
sector 1
sector 255
EEPROM
Memory Controller
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor711
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
in the Flash module will be ignored by the Flash module.
CAUTION
Writing to the Flash registers while a Flash command is executing (that is
indicated when the value of flag CCIF reads as ’0’) is not allowed. If such
action is attempted the write operation will not change the register value.
Writing to the Flash registers is allowed when the Flash is not busy
executing commands (CCIF = 1) and during initialization right after reset,
despite the value of flag CCIF in that case (refer toSection22.6 for a
complete description of the reset sequence).
.
22.3.1Module Memory Map
The S12 architecture places the P-Flash memory between global addresses 0x3_8000 and 0x3_FFFF as
shown inTable22-3.The P-Flash memory map is shown inFigure22-2.
Table22-2. FTMRG Memory Map
Global Address (in Bytes)Size
(Bytes)Description
0x0_0000 - 0x0_03FF1,024Register Space
0x0_0400 – 0x0_07FF1,024EEPROM Memory
0x0_4000 – 0x0_7FFF16,284NVMRES1=1 : NVM Resource area (seeFigure22-3)
1See NVMRES description inSection22.4.3
0x3_8000 – 0x3_FFFF32,768P-Flash Memory
Table22-3. P-Flash Memory Addressing
Global AddressSize
(Bytes)Description
0x3_8000 – 0x3_FFFF32 K
P-Flash Block
Contains Flash Configuration Field
(seeTable22-4)
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
712Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure22-2. P-Flash Memory Map
Table22-5. Program IFR Fields
Global AddressSize
(Bytes)Field Description
0x0_4000 – 0x0_40078Reserved
0x0_4008 – 0x0_40B5174Reserved
0x0_40B6 – 0x0_40B72Version ID1
1Used to track firmware patch versions, seeSection22.4.2
0x0_40B8 – 0x0_40BF8Reserved
0x0_40C0 – 0x0_40FF64Program Once Field
Refer toSection22.4.6.6, “Program Once Command”
Flash Configuration Field
0x3_C000
Flash Protected/Unprotected Lower Region
1, 2, 4, 8 Kbytes
P-Flash START = 0x3_8000
0x3_9000
0x3_8400
0x3_8800
0x3_A000
P-Flash END = 0x3_FFFF
0x3_F800
0x3_F000
0x3_E000Flash Protected/Unprotected Higher Region
2, 4, 8, 16 Kbytes
Flash Protected/Unprotected Region
8 Kbytes (up to 29 Kbytes)
16 bytes (0x3_FF00 - 0x3_FF0F)
Protection
Protection
Protection
Movable End
Fixed End
Fixed End
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
714Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1NVMRES - SeeSection22.4.3 for NVMRES (NVM Resource) detail.
Global AddressSize
(Bytes)Description
0x0_4000 – 0x040FF256P-Flash IFR (seeTable22-5)
0x0_4100 – 0x0_41FF256Reserved.
0x0_4200 – 0x0_57FFReserved
0x0_5800 – 0x0_59FF512Reserved
0x0_5A00 – 0x0_5FFF1,536Reserved
0x0_6000 – 0x0_6BFF3,072Reserved
0x0_6C00 – 0x0_7FFF5,120Reserved
P-Flash IFR 1 Kbyte (NVMRES=1)
0x0_4000
RAM End = 0x0_59FF
RAM Start = 0x0_5800
Reserved 5120 bytes
Reserved 4608 bytes
0x0_6C00
0x0_7FFF
0x0_4400Reserved 5k bytes
Reserved 512 bytes
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor715
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A summary of the Flash module registers is given inFigure22-4 with detailed descriptions in the
following subsections.
Address
& Name76543210
0x0000
FCLKDIV
RFDIVLDFDIVLCKFDIV5FDIV4FDIV3FDIV2FDIV1FDIV0
W
0x0001
FSEC
RKEYEN1KEYEN0RNV5RNV4RNV3RNV2SEC1SEC0
W
0x0002
FCCOBIX
R00000CCOBIX2CCOBIX1CCOBIX0
W
0x0003
FRSV0
R00000000
W
0x0004
FCNFG
RCCIE00
IGNSF00
FDFDFSFD
W
0x0005
FERCNFG
R000000DFDIESFDIE
W
0x0006
FSTAT
RCCIF0ACCERRFPVIOLMGBUSYRSVDMGSTAT1MGSTAT0
W
0x0007
FERSTAT
R000000DFDIFSFDIF
W
0x0008
FPROT
RFPOPENRNV6FPHDISFPHS1FPHS0FPLDISFPLS1FPLS0
W
0x0009
EEPROT
RDPOPEN00
DPS4DPS3DPS2DPS1DPS0
W
0x000A
FCCOBHI
RCCOB15CCOB14CCOB13CCOB12CCOB11CCOB10CCOB9CCOB8
W
0x000B
FCCOBLO
RCCOB7CCOB6CCOB5CCOB4CCOB3CCOB2CCOB1CCOB0
W
0x000C
FRSV1
R00000000
W
Figure22-4. FTMRG32K1 Register Summary
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
716Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.3.2.1Flash Clock Divider Register (FCLKDIV)
The FCLKDIV register is used to control timed events in program and erase algorithms.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CAUTION
The FCLKDIV register should never be written while a Flash command is
executing (CCIF=0).
Table22-7. FCLKDIV Field Descriptions
FieldDescription
7
FDIVLD
Clock Divider Loaded
0FCLKDIV register has not been written since the last reset
1FCLKDIV register has been written since the last reset
6
FDIVLCK
Clock Divider Locked
0FDIV field is open for writing
1FDIV value is locked and cannot be changed. Once the lock bit is set high, only reset can clear this bit and
restore writability to the FDIV field in normal mode.
BUSCLK frequency. Please refer toSection22.4.4, “Flash Command Operations,” for more information.
Table22-8. FDIV values for various BUSCLK Frequencies
BUSCLK Frequency
(MHz)FDIV[5:0]
BUSCLK Frequency
(MHz)FDIV[5:0]
MIN1
1BUSCLK is Greater Than this value.
MAX2
2BUSCLK is Less Than or Equal to this value.
MIN1MAX2
1.01.60x0016.617.60x10
1.62.60x0117.618.60x11
2.63.60x0218.619.60x12
3.64.60x0319.620.60x13
4.65.60x0420.621.60x14
5.66.60x0521.622.60x15
6.67.60x0622.623.60x16
7.68.60x0723.624.60x17
8.69.60x0824.625.60x18
9.610.60x09
10.611.60x0A
11.612.60x0B
12.613.60x0C
13.614.60x0D
14.615.60x0E
15.616.60x0F
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
718Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.3.2.2Flash Security Register (FSEC)
The FSEC register holds all bits associated with the security of the MCU and Flash module.
All bits in the FSEC register are readable but not writable.
During the reset sequence, the FSEC register is loaded with the contents of the Flash security byte in the
Flash configuration field at global address 0x3_FF0F located in P-Flash memory (seeTable22-4) as
indicated by reset condition F inFigure22-6. If a double bit fault is detected while reading the P-Flash
Reserved Nonvolatile Bits— The RNV bits should remain in the erased state for future enhancements.
1–0
SEC[1:0]
Flash Security Bits — The SEC[1:0] bits define the security state of the MCU as shown inTable22-11. If the
Flash module is unsecured using backdoor key access, the SEC bits are forced to 10.
Table22-10. Flash KEYEN States
KEYEN[1:0]Status of Backdoor Key Access
00DISABLED
01DISABLED1
1Preferred KEYEN state to disable backdoor key access.
10ENABLED
11DISABLED
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor719
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The security function in the Flash module is described inSection22.5.
22.3.2.3Flash CCOB Index Register (FCCOBIX)
The FCCOBIX register is used to index the FCCOB register for Flash memory operations.
CCOBIX bits are readable and writable while remaining bits read 0 and are not writable.
22.3.2.4Flash Reserved0 Register (FRSV0)
This Flash register is reserved for factory testing.
All bits in the FRSV0 register read 0 and are not writable.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All assigned bits in the FERCNFG register are readable and writable.
22.3.2.7Flash Status Register (FSTAT)
The FSTAT register reports the operational status of the Flash module.
CCIF, ACCERR, and FPVIOL bits are readable and writable, MGBUSY and MGSTAT bits are readable
but not writable, while remaining bits read 0 and are not writable.
0SFDIF interrupt disabled whenever the SFDIF flag is set (seeSection22.3.2.8)
1An interrupt will be requested whenever the SFDIF flag is set (seeSection22.3.2.8)
OffsetModule Base + 0x0006
76543210
RCCIF0ACCERRFPVIOLMGBUSYRSVDMGSTAT[1:0]
W
Reset1000000
1
1Reset value can deviate from the value shown if a double bit fault is detected during the reset sequence (seeSection22.6).
01
= Unimplemented or Reserved
Figure22-11. Flash Status Register (FSTAT)
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
722Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.3.2.8Flash Error Status Register (FERSTAT)
The FERSTAT register reflects the error status of internal Flash operations.
All flags in the FERSTAT register are readable and only writable to clear the flag.
Table22-15. FSTAT Field Descriptions
FieldDescription
7
CCIF
Command Complete Interrupt Flag — The CCIF flag indicates that a Flash command has completed. The
CCIF flag is cleared by writing a 1 to CCIF to launch a command and CCIF will stay low until command
completion or command violation.
0Flash command in progress
1Flash command has completed
5
ACCERR
Flash Access Error Flag — The ACCERR bit indicates an illegal access has occurred to the Flash memory
is detected during execution of a Flash command or during the Flash reset sequence. SeeSection22.4.6,
“Flash Command Description,” andSection22.6, “Initialization” for details.
OffsetModule Base + 0x0007
76543210
R000000
DFDIFSFDIF
W
Reset00000000
= Unimplemented or Reserved
Figure22-12. Flash Error Status Register (FERSTAT)
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor723
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.3.2.9P-Flash Protection Register (FPROT)
The FPROT register defines which P-Flash sectors are protected against program and erase operations.
command operation.1 The SFDIF flag is cleared by writing a 1 to SFDIF. Writing a 0 to SFDIF has no effect on
SFDIF.
0No single bit fault detected
1Single bit fault detected and corrected or a Flash array read operation returning invalid data was attempted
while command running
OffsetModule Base + 0x0008
76543210
RFPOPENRNV6FPHDISFPHS[1:0]FPLDISFPLS[1:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
= Unimplemented or Reserved
Figure22-13. Flash Protection Register (FPROT)
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
724Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
in P-Flash memory as shown inTable22-20. The FPLS bits can only be written to while the FPLDIS bit is set.
Table22-18. P-Flash Protection Function
FPOPENFPHDISFPLDISFunction1
1For range sizes, refer toTable22-19 andTable22-20.
111No P-Flash Protection
110Protected Low Range
101Protected High Range
100Protected High and Low Ranges
011Full P-Flash Memory Protected
010Unprotected Low Range
001Unprotected High Range
000Unprotected High and Low Ranges
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor725
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All possible P-Flash protection scenarios are shown inFigure22-14 . Although the protection scheme is
loaded from the Flash memory at global address 0x3_FF0C during the reset sequence, it can be changed
chip mode while providing as much protection as possible if reprogramming is not required.
Table22-19. P-Flash Protection Higher Address Range
FPHS[1:0] Global Address RangeProtected Size
000x3_F800–0x3_FFFF2 Kbytes
010x3_F000–0x3_FFFF4 Kbytes
100x3_E000–0x3_FFFF8 Kbytes
110x3_C000–0x3_FFFF16 Kbytes
Table22-20. P-Flash Protection Lower Address Range
FPLS[1:0]Global Address RangeProtected Size
000x3_8000–0x3_83FF1 Kbyte
010x3_8000–0x3_87FF2 Kbytes
100x3_8000–0x3_8FFF4 Kbytes
110x3_8000–0x3_9FFF8 Kbytes
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
726Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure22-14. P-Flash Protection Scenarios
7654
FPHS[1:0]FPLS[1:0]
3210
FPHS[1:0]FPLS[1:0]
FPHDIS = 1
FPLDIS = 1
FPHDIS = 1
FPLDIS = 0
FPHDIS = 0
FPLDIS = 1
FPHDIS = 0
FPLDIS = 0
Scenario
Scenario
Unprotected regionProtected region with size
Protected regionProtected region with size
defined by FPLS
defined by FPHSnot defined by FPLS, FPHS
0x3_8000
0x3_FFFF
0x3_8000
0x3_FFFF
FLASH START
FLASH START
FPOPEN = 1FPOPEN = 0
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor727
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1Allowed transitions marked with X, seeFigure22-14 for a definition of the scenarios.
01234567
0XXXX
1XX
2XX
3X
4XX
5XXXX
6XXXX
7XXXXXXXX
OffsetModule Base + 0x0009
76543210
RDPOPEN00DPS[4:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
00F
1F1F1F1F1
= Unimplemented or Reserved
Figure22-15. EEPROM Protection Register (EEPROT)
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
728Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1Disables EEPROM memory protection from program and erase
4–0
DPS[4:0]
EEPROM Protection Size — The DPS[4:0] bits determine the size of the protected area in the EEPROM
memory as shown inTable22-23 .
Table22-23. EEPROM Protection Address Range
DPS[4:0] Global Address RangeProtected Size
000000x0_0400 – 0x0_041F32 bytes
000010x0_0400 – 0x0_043F64 bytes
000100x0_0400 – 0x0_045F96 bytes
000110x0_0400 – 0x0_047F128 bytes
001000x0_0400 – 0x0_049F160 bytes
001010x0_0400 – 0x0_04BF192 bytes
The Protection Size goes on enlarging in step of 32 bytes, for each DPS
value increasing of one.
.
.
.
11111-to-111110x0_0400 – 0x0_07FF1,024 bytes
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor729
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.3.2.11Flash Common Command Object Register (FCCOB)
The FCCOB is an array of six words addressed via the CCOBIX index found in the FCCOBIX register.
Byte wide reads and writes are allowed to the FCCOB register.
22.3.2.11.1FCCOB - NVM Command Mode
NVM command mode uses the indexed FCCOB register to provide a command code and its relevant
parameters to the Memory Controller. The user first sets up all required FCCOB fields and then initiates
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.3.2.12Flash Reserved1 Register (FRSV1)
This Flash register is reserved for factory testing.
All bits in the FRSV1 register read 0 and are not writable.
22.3.2.13Flash Reserved2 Register (FRSV2)
This Flash register is reserved for factory testing.
All bits in the FRSV2 register read 0 and are not writable.
22.3.2.14Flash Reserved3 Register (FRSV3)
This Flash register is reserved for factory testing.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All bits in the FRSV3 register read 0 and are not writable.
22.3.2.15Flash Reserved4 Register (FRSV4)
This Flash register is reserved for factory testing.
All bits in the FRSV4 register read 0 and are not writable.
22.3.2.16Flash Option Register (FOPT)
The FOPT register is the Flash option register.
All bits in the FOPT register are readable but are not writable.
During the reset sequence, the FOPT register is loaded from the Flash nonvolatile byte in the Flash
configuration field at global address 0x3_FF0E located in P-Flash memory (seeTable22-4) as indicated
by reset condition F inFigure22-22. If a double bit fault is detected while reading the P-Flash phrase
containing the Flash nonvolatile byte during the reset sequence, all bits in the FOPT register will be set.
OffsetModule Base + 0x000E
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure22-20. Flash Reserved3 Register (FRSV3)
OffsetModule Base + 0x000F
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure22-21. Flash Reserved4 Register (FRSV4)
OffsetModule Base + 0x0010
76543210
RNV[7:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
= Unimplemented or Reserved
Figure22-22. Flash Option Register (FOPT)
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
732Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.3.2.17Flash Reserved5 Register (FRSV5)
This Flash register is reserved for factory testing.
All bits in the FRSV5 register read 0 and are not writable.
22.3.2.18Flash Reserved6 Register (FRSV6)
This Flash register is reserved for factory testing.
All bits in the FRSV6 register read 0 and are not writable.
22.3.2.19Flash Reserved7 Register (FRSV7)
This Flash register is reserved for factory testing.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All bits in the FRSV7 register read 0 and are not writable.
22.4Functional Description
22.4.1Modes of Operation
The FTMRG32K1 module provides the modes of operation normal and special . The operating mode is
determined by module-level inputs and affects the FCLKDIV, FCNFG, and EEPROT registers (see
Table22-27).
22.4.2IFR Version ID Word
The version ID word is stored in the IFR at address 0x0_40B6. The contents of the word are defined in
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.4.3Internal NVM resource (NVMRES)
IFR is an internal NVM resource readable by CPU , when NVMRES is active. The IFR fields are shown
inTable22-5.
The NVMRES global address map is shown inTable22-6.
22.4.4Flash Command Operations
Flash command operations are used to modify Flash memory contents.
The next sections describe:
•How to write the FCLKDIV register that is used to generate a time base (FCLK) derived from
BUSCLK for Flash program and erase command operations
•The command write sequence used to set Flash command parameters and launch execution
•Valid Flash commands available for execution, according to MCU functional mode and MCU
security state.
22.4.4.1Writing the FCLKDIV Register
Prior to issuing any Flash program or erase command after a reset, the user is required to write the
sequence. If CCIF is 0, the previous command write sequence is still active, a new command write
sequence cannot be started, and all writes to the FCCOB register are ignored.
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor735
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.4.4.2.1Define FCCOB Contents
The FCCOB parameter fields must be loaded with all required parameters for the Flash command being
executed. Access to the FCCOB parameter fields is controlled via the CCOBIX bits in the FCCOBIX
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.4.4.3Valid Flash Module Commands
Table22-27 present the valid Flash commands, as enabled by the combination of the functional MCU
Table22-28 summarizes the valid P-Flash commands along with the effects of the commands on the
P-Flash block and other resources within the Flash module.
Table22-27. Flash Commands by Mode and Security State
FCMDCommand
UnsecuredSecured
NS1
1Unsecured Normal Single Chip mode
SS2
2Unsecured Special Single Chip mode.
NS3
3Secured Normal Single Chip mode.
SS4
4Secured Special Single Chip mode.
0x01Erase Verify All Blocks∗∗∗∗
0x02Erase Verify Block∗∗∗∗
0x03Erase Verify P-Flash Section∗∗∗
0x04Read Once∗∗∗
0x06Program P-Flash∗∗∗
0x07Program Once∗∗∗
0x08Erase All Blocks∗∗
0x09Erase Flash Block∗∗∗
0x0AErase P-Flash Sector∗∗∗
0x0BUnsecure Flash∗∗
0x0CVerify Backdoor Access Key∗∗
0x0DSet User Margin Level∗∗∗
0x0ESet Field Margin Level∗
0x10Erase Verify EEPROM Section∗∗∗
0x11Program EEPROM∗∗∗
0x12Erase EEPROM Sector∗∗∗
Table22-28. P-Flash Commands
FCMDCommandFunction on P-Flash Memory
0x01Erase Verify All
Blocks
Verify that all P-Flash (and EEPROM) blocks are erased.
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
738Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.4.4.5EEPROM Commands
Table22-29 summarizes the valid EEPROM commands along with the effects of the commands on the
EEPROM block.
0x02Erase Verify BlockVerify that a P-Flash block is erased.
0x03Erase Verify
P-Flash Section
Verify that a given number of words starting at the address provided are erased.
bits in the FPROT register are set prior to launching the command.
0x0AErase P-Flash
Sector
Erase all bytes in a P-Flash sector.
0x0BUnsecure FlashSupports a method of releasing MCU security by erasing all P-Flash (and EEPROM)
blocks and verifying that all P-Flash (and EEPROM) blocks are erased.
0x0CVerify Backdoor
Access Key
Supports a method of releasing MCU security by verifying a set of security keys.
0x0DSet User Margin
Level
Specifies a user margin read level for all P-Flash blocks.
0x0ESet Field Margin
Level
Specifies a field margin read level for all P-Flash blocks (special modes only).
Table22-29. EEPROM Commands
FCMDCommandFunction on EEPROM Memory
0x01Erase Verify All
Blocks
Verify that all EEPROM (and P-Flash) blocks are erased.
0x02Erase Verify BlockVerify that the EEPROM block is erased.
Table22-28. P-Flash Commands
FCMDCommandFunction on P-Flash Memory
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor739
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.4.5Allowed Simultaneous P-Flash and EEPROM Operations
Only the operations marked ‘OK’ inTable22-30 are permitted to be run simultaneously on the Program
2The ‘Mass Erase’ operations are commands ‘Erase All Blocks’ and ‘Erase
Flash Block’
OK
Table22-29. EEPROM Commands
FCMDCommandFunction on EEPROM Memory
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
740Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MGSTAT0Set if any non-correctable errors have been encountered during the read1 or if
blank check failed.
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor741
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.4.6.2Erase Verify Block Command
The Erase Verify Block command allows the user to verify that an entire P-Flash or EEPROM block has
been erased. The FCCOB FlashBlockSelectionCode[1:0] bits determine which block must be verified.
Upon clearing CCIF to launch the Erase Verify Block command, the Memory Controller will verify that
the selected P-Flash or EEPROM block is erased. The CCIF flag will set after the Erase Verify Block
Set if an invalid FlashBlockSelectionCode[1:0] is supplied
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
742Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Erase Verify P-Flash Section command, the Memory Controller will
Set if command not available in current mode (seeTable22-27)
Set if an invalid global address [17:0] is supplied seeTable22-3)
Set if a misaligned phrase address is supplied (global address [2:0] != 000)
Set if the requested section crosses a the P-Flash address boundary
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
Table22-38. Read Once Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x04Not Required
001Read Once phrase index (0x0000 - 0x0007)
010Read Once word 0 value
011Read Once word 1 value
100Read Once word 2 value
101Read Once word 3 value
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor743
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A P-Flash phrase must be in the erased state before being programmed.
Cumulative programming of bits within a Flash phrase is not allowed.
Upon clearing CCIF to launch the Program P-Flash command, the Memory Controller will program the
data words to the supplied global address and will then proceed to verify the data words read back as
expected. The CCIF flag will set after the Program P-Flash operation has completed.
Table22-39. Read Once Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 001 at command launch
Set if command not available in current mode (seeTable22-27)
Set if an invalid phrase index is supplied
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read
MGSTAT0Set if any non-correctable errors have been encountered during the read
Table22-40. Program P-Flash Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x06Global address [17:16] to
identify P-Flash block
001Global address [15:0] of phrase location to be programmed1
1Global address [2:0] must be 000
010Word 0 program value
011Word 1 program value
100Word 2 program value
101Word 3 program value
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
744Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.4.6.6Program Once Command
The Program Once command restricts programming to a reserved 64 byte field (8 phrases) in the
and any attempt to program one of these phrases a second time will not be allowed. Valid phrase index
values for the Program Once command range from 0x0000 to 0x0007. During execution of the Program
Once command, any attempt to read addresses within P-Flash will return invalid data.
Table22-41. Program P-Flash Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 101 at command launch
Set if command not available in current mode (seeTable22-27)
Set if an invalid global address [17:0] is supplied seeTable22-3)
Set if a misaligned phrase address is supplied (global address [2:0] != 000)
FPVIOLSet if the global address [17:0] points to a protected area
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
Table22-42. Program Once Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x07Not Required
001Program Once phrase index (0x0000 - 0x0007)
010Program Once word 0 value
011Program Once word 1 value
100Program Once word 2 value
101Program Once word 3 value
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor745
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.4.6.7Erase All Blocks Command
The Erase All Blocks operation will erase the entire P-Flash and EEPROM memory space.
The Erase Flash Block operation will erase all addresses in a P-Flash or EEPROM block.
Table22-43. Program Once Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 101 at command launch
Set if command not available in current mode (seeTable22-27)
Set if an invalid phrase index is supplied
Set if the requested phrase has already been programmed1
1If a Program Once phrase is initially programmed to 0xFFFF_FFFF_FFFF_FFFF, the Program Once command will
be allowed to execute again on that same phrase.
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
Table22-44. Erase All Blocks Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x08Not required
Table22-45. Erase All Blocks Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERRSet if CCOBIX[2:0] != 000 at command launch
Set if command not available in current mode (seeTable22-27)
FPVIOLSet if any area of the P-Flash or EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation1
1As found in the memory map for FTMRG32K1.
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
746Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Erase Flash Block command, the Memory Controller will erase the
selected Flash block and verify that it is erased. The CCIF flag will set after the Erase Flash Block
operation has completed.
22.4.6.9Erase P-Flash Sector Command
The Erase P-Flash Sector operation will erase all addresses in a P-Flash sector.
Upon clearing CCIF to launch the Erase P-Flash Sector command, the Memory Controller will erase the
selected Flash sector and then verify that it is erased. The CCIF flag will be set after the Erase P-Flash
001Global address [15:0] anywhere within the sector to be erased.
Refer toSection22.1.2.1 for the P-Flash sector size.
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor747
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Set if command not available in current mode (seeTable22-27)
FPVIOLSet if any area of the P-Flash or EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
748Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
user-supplied keys match those stored in the Flash security bytes of the Flash configuration field (see
Table22-4). The Verify Backdoor Access Key command must not be executed from the Flash block
containing the backdoor comparison key to avoid code runaway.
Upon clearing CCIF to launch the Verify Backdoor Access Key command, the Memory Controller will
check the FSEC KEYEN bits to verify that this command is enabled. If not enabled, the Memory
Controller sets the ACCERR bit in the FSTAT register and terminates. If the command is enabled, the
Memory Controller compares the key provided in FCCOB to the backdoor comparison key in the Flash
configuration field with Key 0 compared to 0x3_FF00, etc. If the backdoor keys match, security will be
Set if backdoor key access has not been enabled (KEYEN[1:0] != 10, see
Section22.3.2.2)
Set if the backdoor key has mismatched since the last reset
FPVIOLNone
MGSTAT1None
MGSTAT0None
Table22-54. Set User Margin Level Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x0DFlashblockselectioncode[1:0].See
Table22-34
001Margin level setting.
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor749
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Set User Margin Level command, the Memory Controller will set the
user margin level for the targeted block and then set the CCIF flag.
Table22-56. Set User Margin Level Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 001 at command launch
Set if command not available in current mode (seeTable22-27)
Set if an invalid FlashBlockSelectionCode[1:0] is supplied (SeeTable22-34 )
Set if an invalid margin level setting is supplied
FPVIOLNone
MGSTAT1None
MGSTAT0None
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
750Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.4.6.13Set Field Margin Level Command
The Set Field Margin Level command, valid in special modes only, causes the Memory Controller to set
the margin level specified for future read operations of the P-Flash or EEPROM block.
Upon clearing CCIF to launch the Set Field Margin Level command, the Memory Controller will set the
field margin level for the targeted block and then set the CCIF flag.
Valid margin level settings for the Set Field Margin Level command are defined inTable22-58.
Table22-57. Set Field Margin Level Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x0EFlash block selection code [1:0]. See
Table22-34
001Margin level setting.
Table22-58. Valid Set Field Margin Level Settings
CCOB
(CCOBIX=001)Level Description
0x0000Return to Normal Level
0x0001User Margin-1 Level1
1Read margin to the erased state
0x0002User Margin-0 Level2
2Read margin to the programmed state
0x0003Field Margin-1 Level1
0x0004Field Margin-0 Level2
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor751
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CAUTION
Field margin levels must only be used during verify of the initial factory
programming.
NOTE
Field margin levels can be used to check that Flash memory contents have
001Global address [15:0] of the first word to be verified
010Number of words to be verified
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
752Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.4.6.15Program EEPROM Command
The Program EEPROM operation programs one to four previously erased words in the EEPROM block.
Set if command not available in current mode (seeTable22-27)
Set if an invalid global address [17:0] is supplied
Set if a misaligned word address is supplied (global address [0] != 0)
Set if the requested section breaches the end of the EEPROM block
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
Table22-62. Program EEPROM Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x11Global address [17:16] to
identify the EEPROM block
001Global address [15:0] of word to be programmed
010Word 0 program value
011Word 1 program value, if desired
100Word 2 program value, if desired
101Word 3 program value, if desired
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor753
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.4.6.16Erase EEPROM Sector Command
The Erase EEPROM Sector operation will erase all addresses in a sector of the EEPROM block.
Set if command not available in current mode (seeTable22-27)
Set if an invalid global address [17:0] is suppliedseeTable22-3)
Set if a misaligned word address is supplied (global address [0] != 0)
FPVIOLSet if the selected area of the EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
754Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.4.7Interrupts
The Flash module can generate an interrupt when a Flash command operation has completed or when a
Flash command operation has detected an ECC fault.
NOTE
Vector addresses and their relative interrupt priority are determined at the
MCU level.
22.4.7.1Description of Flash Interrupt Operation
The Flash module uses the CCIF flag in combination with the CCIE interrupt enable bit to generate the
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
22.4.8Wait Mode
The Flash module is not affected if the MCU enters wait mode. The Flash module can recover the MCU
from wait via the CCIF interrupt (seeSection22.4.7, “Interrupts”).
Access Key command match the backdoor keys stored in the Flash memory, the SEC bits in the FSEC
register (seeTable22-11) will be changed to unsecure the MCU. Key values of 0x0000 and 0xFFFF are
not permitted as backdoor keys. While the Verify Backdoor Access Key command is active, P-Flash
memory and EEPROM memory will not be available for read access and will return invalid data.
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
756Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
7.Send BDM commands to execute the Program P-Flash command write sequence to program the
Flash security byte to the unsecured state
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor757
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
8.Reset the MCU
22.5.3Mode and Security Effects on Flash Command Availability
The availability of Flash module commands depends on the MCU operating mode and security state as
state of the word being programmed or the sector/block being erased is not guaranteed.
32 KByte Flash Module (S12FTMRG32K1V1)
MC9S12G Family Reference Manual,Rev.1.06
758Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor759
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter23
48 KByte Flash Module (S12FTMRG48K1V1)
23.1Introduction
The FTMRG48K1 module implements the following:
•48Kbytes of P-Flash (Program Flash) memory
•1,536bytes of EEPROM memory
The Flash memory is ideal for single-supply applications allowing for field reprogramming without
requiring external high voltage sources for program or erase operations. The Flash module includes a
memory controller that executes commands to modify Flash memory contents. The user interface to the
memory controller consists of the indexed Flash Common Command Object (FCCOB) register which is
written to with the command, global address, data, and any required command parameters. The memory
Updated description of the commands RD1BLK, MLOADU and MLOADF
Rev.1.0631 Jan 201123.3.2.9/23-776Updated description of protection onSection23.3.2.9
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor760
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The Flash memory may be read as bytes and aligned words. Read access time is one bus cycle for bytes
and aligned words. For misaligned words access, the CPU has to perform twice the byte read access
command. For Flash memory, an erased bit reads 1 and a programmed bit reads 0.
P-Flash Sector— The P-Flash sector is the smallest portion of the P-Flash memory that can be erased.
Each P-Flash sector contains 512 bytes.
Program IFR— Nonvolatile information register located in the P-Flash block that contains the Version
ID, and the Program Once field.
23.1.2Features
23.1.2.1P-Flash Features
•48 Kbytes of P-Flash memory composed of one 48 Kbyte Flash block divided into 96 sectors of
512 bytes
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor761
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Single bit fault correction and double bit fault detection within a 32-bit double word during read
operations
•Automated program and erase algorithm with verify and generation of ECC parity bits
•Fast sector erase and phrase program operation
•Ability to read the P-Flash memory while programming a word in the EEPROM memory
•Flexible protection scheme to prevent accidental program or erase of P-Flash memory
23.1.2.2EEPROM Features
•1.5Kbytes of EEPROM memory composed of one 1.5Kbyte Flash block divided into 384 sectors
of 4 bytes
•Single bit fault correction and double bit fault detection within a word during read operations
•Automated program and erase algorithm with verify and generation of ECC parity bits
•Fast sector erase and word program operation
•Protection scheme to prevent accidental program or erase of EEPROM memory
•Ability to program up to four words in a burst sequence
23.1.2.3Other Flash Module Features
•No external high-voltage power supply required for Flash memory program and erase operations
•Interrupt generation on Flash command completion and Flash error detection
•Security mechanism to prevent unauthorized access to the Flash memory
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual,Rev.1.06
762Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.1.3Block Diagram
The block diagram of the Flash module is shown inFigure23-1.
Figure23-1.FTMRG48K1 Block Diagram
23.2External Signal Description
The Flash module contains no signals that connect off-chip.
Bus
Clock
Divider
Clock
Command
Interrupt
Request
FCLK
Protection
Security
Registers
Flash
Interface
16bit
internal
bus
sector 0
sector 1
sector 95
12Kx39
P-Flash
Error
Interrupt
Request
CPU
768x22
sector 0
sector 1
sector 383
EEPROM
Memory Controller
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor763
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
in the Flash module will be ignored by the Flash module.
CAUTION
Writing to the Flash registers while a Flash command is executing (that is
indicated when the value of flag CCIF reads as ’0’) is not allowed. If such
action is attempted the write operation will not change the register value.
Writing to the Flash registers is allowed when the Flash is not busy
executing commands (CCIF = 1) and during initialization right after reset,
despite the value of flag CCIF in that case (refer toSection23.6 for a
complete description of the reset sequence).
.
23.3.1Module Memory Map
The S12 architecture places the P-Flash memory between global addresses 0x3_4000 and 0x3_FFFF as
shown inTable23-3 .The P-Flash memory map is shown inFigure23-2.
Table23-2. FTMRG Memory Map
Global Address (in Bytes)Size
(Bytes)Description
0x0_0000 - 0x0_03FF1,024Register Space
0x0_0400 – 0x0_09FF1,536EEPROM Memory
0x0_0A00 – 0x0_0BFF512FTMRG reserved area
0x0_4000 – 0x0_7FFF16,284NVMRES1=1 : NVM Resource area (seeFigure23-3)
1See NVMRES description inSection23.4.3
0x3_0000 – 0x3_3FFF16,384FTMRG reserved area
0x3_4000 – 0x3_FFFF49,152P-Flash Memory
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual,Rev.1.06
764Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MCU to restrict access to the Flash module are stored in the Flash configuration field as described in
Table23-4.
Table23-3. P-Flash Memory Addressing
Global AddressSize
(Bytes)Description
0x3_4000 – 0x3_FFFF48 K
P-Flash Block
Contains Flash Configuration Field
(seeTable23-4).
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor765
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table23-4. Flash Configuration Field
Global AddressSize
(Bytes)Description
0x3_FF00-0x3_FF078
Backdoor Comparison Key
Refer toSection23.4.6.11, “Verify Backdoor Access Key Command,” and
Section23.5.1, “Unsecuring the MCU using Backdoor Key Access”
0x3_FF08-0x3_FF0B1
10x3FF08-0x3_FF0F form a Flash phrase and must be programmed in a single command write sequence. Each byte in
the 0x3_FF08 - 0x3_FF0B reserved field should be programmed to 0xFF.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure23-2.P-Flash Memory Map
Table23-5. Program IFR Fields
Global AddressSize
(Bytes)Field Description
0x0_4000 – 0x0_40078Reserved
0x0_4008 – 0x0_40B5174Reserved
0x0_40B6 – 0x0_40B72Version ID1
1Used to track firmware patch versions, seeSection23.4.2
0x0_40B8 – 0x0_40BF8Reserved
0x0_40C0 – 0x0_40FF64Program Once Field
Refer toSection23.4.6.6, “Program Once Command”
Flash Configuration Field
0x3_C000
Flash Protected/Unprotected Lower Region
1, 2, 4, 8 Kbytes
0x3_8000
0x3_9000
0x3_8400
0x3_8800
0x3_A000
P-Flash END = 0x3_FFFF
0x3_F800
0x3_F000
0x3_E000Flash Protected/Unprotected Higher Region
2, 4, 8, 16 Kbytes
Flash Protected/Unprotected Region
8 Kbytes (up to 29 Kbytes)
16 bytes (0x3_FF00 - 0x3_FF0F)
Flash Protected/Unprotected Region
16 Kbytes
P-Flash START = 0x3_4000
Protection
Protection
Protection
Movable End
Fixed End
Fixed End
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor767
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1NVMRES - SeeSection23.4.3 for NVMRES (NVM Resource) detail.
Global AddressSize
(Bytes)Description
0x0_4000 – 0x040FF256P-Flash IFR (seeTable23-5)
0x0_4100 – 0x0_41FF256Reserved.
0x0_4200 – 0x0_57FFReserved
0x0_5800 – 0x0_59FF512Reserved
0x0_5A00 – 0x0_5FFF1,536Reserved
0x0_6000 – 0x0_6BFF3,072Reserved
0x0_6C00 – 0x0_7FFF5,120Reserved
P-Flash IFR 1 Kbyte (NVMRES=1)
0x0_4000
RAM End = 0x0_59FF
RAM Start = 0x0_5800
Reserved 5120 bytes
Reserved 4608 bytes
0x0_6C00
0x0_7FFF
0x0_4400Reserved 5k bytes
Reserved 512 bytes
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual,Rev.1.06
768Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A summary of the Flash module registers is given inFigure23-4 with detailed descriptions in the
following subsections.
Address
& Name76543210
0x0000
FCLKDIV
RFDIVLDFDIVLCKFDIV5FDIV4FDIV3FDIV2FDIV1FDIV0
W
0x0001
FSEC
RKEYEN1KEYEN0RNV5RNV4RNV3RNV2SEC1SEC0
W
0x0002
FCCOBIX
R00000CCOBIX2CCOBIX1CCOBIX0
W
0x0003
FRSV0
R00000000
W
0x0004
FCNFG
RCCIE00
IGNSF00
FDFDFSFD
W
0x0005
FERCNFG
R000000DFDIESFDIE
W
0x0006
FSTAT
RCCIF0ACCERRFPVIOLMGBUSYRSVDMGSTAT1MGSTAT0
W
0x0007
FERSTAT
R000000DFDIFSFDIF
W
0x0008
FPROT
RFPOPENRNV6FPHDISFPHS1FPHS0FPLDISFPLS1FPLS0
W
0x0009
EEPROT
RDPOPEN0DPS5DPS4DPS3DPS2DPS1DPS0
W
0x000A
FCCOBHI
RCCOB15CCOB14CCOB13CCOB12CCOB11CCOB10CCOB9CCOB8
W
0x000B
FCCOBLO
RCCOB7CCOB6CCOB5CCOB4CCOB3CCOB2CCOB1CCOB0
W
0x000C
FRSV1
R00000000
W
Figure23-4. FTMRG48K1 Register Summary
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor769
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.3.2.1Flash Clock Divider Register (FCLKDIV)
The FCLKDIV register is used to control timed events in program and erase algorithms.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CAUTION
The FCLKDIV register should never be written while a Flash command is
executing (CCIF=0).
Table23-7. FCLKDIV Field Descriptions
FieldDescription
7
FDIVLD
Clock Divider Loaded
0FCLKDIV register has not been written since the last reset
1FCLKDIV register has been written since the last reset
6
FDIVLCK
Clock Divider Locked
0FDIV field is open for writing
1FDIV value is locked and cannot be changed. Once the lock bit is set high, only reset can clear this bit and
restore writability to the FDIV field in normal mode.
BUSCLK frequency. Please refer toSection23.4.4, “Flash Command Operations,” for more information.
Table23-8. FDIV values for various BUSCLK Frequencies
BUSCLK Frequency
(MHz)FDIV[5:0]
BUSCLK Frequency
(MHz)FDIV[5:0]
MIN1
1BUSCLK is Greater Than this value.
MAX2
2BUSCLK is Less Than or Equal to this value.
MIN1MAX2
1.01.60x0016.617.60x10
1.62.60x0117.618.60x11
2.63.60x0218.619.60x12
3.64.60x0319.620.60x13
4.65.60x0420.621.60x14
5.66.60x0521.622.60x15
6.67.60x0622.623.60x16
7.68.60x0723.624.60x17
8.69.60x0824.625.60x18
9.610.60x09
10.611.60x0A
11.612.60x0B
12.613.60x0C
13.614.60x0D
14.615.60x0E
15.616.60x0F
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor771
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.3.2.2Flash Security Register (FSEC)
The FSEC register holds all bits associated with the security of the MCU and Flash module.
All bits in the FSEC register are readable but not writable.
During the reset sequence, the FSEC register is loaded with the contents of the Flash security byte in the
Flash configuration field at global address 0x3_FF0F located in P-Flash memory (seeTable23-4) as
indicated by reset condition F inFigure23-6. If a double bit fault is detected while reading the P-Flash
Reserved Nonvolatile Bits— The RNV bits should remain in the erased state for future enhancements.
1–0
SEC[1:0]
Flash Security Bits — The SEC[1:0] bits define the security state of the MCU as shown inTable23-11. If the
Flash module is unsecured using backdoor key access, the SEC bits are forced to 10.
Table23-10. Flash KEYEN States
KEYEN[1:0]Status of Backdoor Key Access
00DISABLED
01DISABLED1
1Preferred KEYEN state to disable backdoor key access.
10ENABLED
11DISABLED
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual,Rev.1.06
772Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The security function in the Flash module is described inSection23.5.
23.3.2.3Flash CCOB Index Register (FCCOBIX)
The FCCOBIX register is used to index the FCCOB register for Flash memory operations.
CCOBIX bits are readable and writable while remaining bits read 0 and are not writable.
23.3.2.4Flash Reserved0 Register (FRSV0)
This Flash register is reserved for factory testing.
All bits in the FRSV0 register read 0 and are not writable.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All assigned bits in the FERCNFG register are readable and writable.
23.3.2.7Flash Status Register (FSTAT)
The FSTAT register reports the operational status of the Flash module.
CCIF, ACCERR, and FPVIOL bits are readable and writable, MGBUSY and MGSTAT bits are readable
but not writable, while remaining bits read 0 and are not writable.
0SFDIF interrupt disabled whenever the SFDIF flag is set (seeSection23.3.2.8)
1An interrupt will be requested whenever the SFDIF flag is set (seeSection23.3.2.8)
OffsetModule Base + 0x0006
76543210
RCCIF0ACCERRFPVIOLMGBUSYRSVDMGSTAT[1:0]
W
Reset1000000
1
1Reset value can deviate from the value shown if a double bit fault is detected during the reset sequence (seeSection23.6).
01
= Unimplemented or Reserved
Figure23-11. Flash Status Register (FSTAT)
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor775
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.3.2.8Flash Error Status Register (FERSTAT)
The FERSTAT register reflects the error status of internal Flash operations.
All flags in the FERSTAT register are readable and only writable to clear the flag.
Table23-15. FSTAT Field Descriptions
FieldDescription
7
CCIF
Command Complete Interrupt Flag — The CCIF flag indicates that a Flash command has completed. The
CCIF flag is cleared by writing a 1 to CCIF to launch a command and CCIF will stay low until command
completion or command violation.
0Flash command in progress
1Flash command has completed
5
ACCERR
Flash Access Error Flag — The ACCERR bit indicates an illegal access has occurred to the Flash memory
is detected during execution of a Flash command or during the Flash reset sequence. SeeSection23.4.6,
“Flash Command Description,” andSection23.6, “Initialization” for details.
OffsetModule Base + 0x0007
76543210
R000000
DFDIFSFDIF
W
Reset00000000
= Unimplemented or Reserved
Figure23-12. Flash Error Status Register (FERSTAT)
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual,Rev.1.06
776Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.3.2.9P-Flash Protection Register (FPROT)
The FPROT register defines which P-Flash sectors are protected against program and erase operations.
command operation.1 The SFDIF flag is cleared by writing a 1 to SFDIF. Writing a 0 to SFDIF has no effect on
SFDIF.
0No single bit fault detected
1Single bit fault detected and corrected or a Flash array read operation returning invalid data was attempted
while command running
OffsetModule Base + 0x0008
76543210
RFPOPENRNV6FPHDISFPHS[1:0]FPLDISFPLS[1:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
= Unimplemented or Reserved
Figure23-13. Flash Protection Register (FPROT)
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor777
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
in P-Flash memory as shown inTable23-20. The FPLS bits can only be written to while the FPLDIS bit is set.
Table23-18. P-Flash Protection Function
FPOPENFPHDISFPLDISFunction1
1For range sizes, refer toTable23-19 andTable23-20.
111No P-Flash Protection
110Protected Low Range
101Protected High Range
100Protected High and Low Ranges
011Full P-Flash Memory Protected
010Unprotected Low Range
001Unprotected High Range
000Unprotected High and Low Ranges
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual,Rev.1.06
778Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All possible P-Flash protection scenarios are shown inFigure23-14 . Although the protection scheme is
loaded from the Flash memory at global address 0x3_FF0C during the reset sequence, it can be changed
chip mode while providing as much protection as possible if reprogramming is not required.
Table23-19. P-Flash Protection Higher Address Range
FPHS[1:0] Global Address RangeProtected Size
000x3_F800–0x3_FFFF2 Kbytes
010x3_F000–0x3_FFFF4 Kbytes
100x3_E000–0x3_FFFF8 Kbytes
110x3_C000–0x3_FFFF16 Kbytes
Table23-20. P-Flash Protection Lower Address Range
FPLS[1:0]Global Address RangeProtected Size
000x3_8000–0x3_83FF1 Kbyte
010x3_8000–0x3_87FF2 Kbytes
100x3_8000–0x3_8FFF4 Kbytes
110x3_8000–0x3_9FFF8 Kbytes
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor779
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure23-14. P-Flash Protection Scenarios
7654
FPHS[1:0]FPLS[1:0]
3210
FPHS[1:0]FPLS[1:0]
FPHDIS = 1
FPLDIS = 1
FPHDIS = 1
FPLDIS = 0
FPHDIS = 0
FPLDIS = 1
FPHDIS = 0
FPLDIS = 0
Scenario
Scenario
Unprotected regionProtected region with size
Protected regionProtected region with size
defined by FPLS
defined by FPHSnot defined by FPLS, FPHS
0x3_8000
0x3_FFFF
0x3_8000
0x3_FFFF
FLASH START
FLASH START
FPOPEN = 1FPOPEN = 0
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual,Rev.1.06
780Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1Allowed transitions marked with X, seeFigure23-14 for a definition of the scenarios.
01234567
0XXXX
1XX
2XX
3X
4XX
5XXXX
6XXXX
7XXXXXXXX
OffsetModule Base + 0x0009
76543210
RDPOPEN0DPS[5:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
0F
1F1F1F1F1F1
= Unimplemented or Reserved
Figure23-15. EEPROM Protection Register (EEPROT)
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor781
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
101111 - to - 1111110x0_0400 – 0x0_09FF1,536 bytes
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual,Rev.1.06
782Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.3.2.11Flash Common Command Object Register (FCCOB)
The FCCOB is an array of six words addressed via the CCOBIX index found in the FCCOBIX register.
Byte wide reads and writes are allowed to the FCCOB register.
23.3.2.11.1FCCOB - NVM Command Mode
NVM command mode uses the indexed FCCOB register to provide a command code and its relevant
parameters to the Memory Controller. The user first sets up all required FCCOB fields and then initiates
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.3.2.12Flash Reserved1 Register (FRSV1)
This Flash register is reserved for factory testing.
All bits in the FRSV1 register read 0 and are not writable.
23.3.2.13Flash Reserved2 Register (FRSV2)
This Flash register is reserved for factory testing.
All bits in the FRSV2 register read 0 and are not writable.
23.3.2.14Flash Reserved3 Register (FRSV3)
This Flash register is reserved for factory testing.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All bits in the FRSV3 register read 0 and are not writable.
23.3.2.15Flash Reserved4 Register (FRSV4)
This Flash register is reserved for factory testing.
All bits in the FRSV4 register read 0 and are not writable.
23.3.2.16Flash Option Register (FOPT)
The FOPT register is the Flash option register.
All bits in the FOPT register are readable but are not writable.
During the reset sequence, the FOPT register is loaded from the Flash nonvolatile byte in the Flash
configuration field at global address 0x3_FF0E located in P-Flash memory (seeTable23-4) as indicated
by reset condition F inFigure23-22. If a double bit fault is detected while reading the P-Flash phrase
containing the Flash nonvolatile byte during the reset sequence, all bits in the FOPT register will be set.
OffsetModule Base + 0x000E
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure23-20. Flash Reserved3 Register (FRSV3)
OffsetModule Base + 0x000F
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure23-21. Flash Reserved4 Register (FRSV4)
OffsetModule Base + 0x0010
76543210
RNV[7:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
= Unimplemented or Reserved
Figure23-22. Flash Option Register (FOPT)
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor785
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.3.2.17Flash Reserved5 Register (FRSV5)
This Flash register is reserved for factory testing.
All bits in the FRSV5 register read 0 and are not writable.
23.3.2.18Flash Reserved6 Register (FRSV6)
This Flash register is reserved for factory testing.
All bits in the FRSV6 register read 0 and are not writable.
23.3.2.19Flash Reserved7 Register (FRSV7)
This Flash register is reserved for factory testing.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All bits in the FRSV7 register read 0 and are not writable.
23.4Functional Description
23.4.1Modes of Operation
The FTMRG48K1 module provides the modes of operation normal and special . The operating mode is
determined by module-level inputs and affects the FCLKDIV, FCNFG, and EEPROT registers (see
Table23-27).
23.4.2IFR Version ID Word
The version ID word is stored in the IFR at address 0x0_40B6. The contents of the word are defined in
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.4.3Internal NVM resource (NVMRES)
IFR is an internal NVM resource readable by CPU , when NVMRES is active. The IFR fields are shown
inTable23-5.
The NVMRES global address map is shown inTable23-6.
23.4.4Flash Command Operations
Flash command operations are used to modify Flash memory contents.
The next sections describe:
•How to write the FCLKDIV register that is used to generate a time base (FCLK) derived from
BUSCLK for Flash program and erase command operations
•The command write sequence used to set Flash command parameters and launch execution
•Valid Flash commands available for execution, according to MCU functional mode and MCU
security state.
23.4.4.1Writing the FCLKDIV Register
Prior to issuing any Flash program or erase command after a reset, the user is required to write the
sequence. If CCIF is 0, the previous command write sequence is still active, a new command write
sequence cannot be started, and all writes to the FCCOB register are ignored.
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual,Rev.1.06
788Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.4.4.2.1Define FCCOB Contents
The FCCOB parameter fields must be loaded with all required parameters for the Flash command being
executed. Access to the FCCOB parameter fields is controlled via the CCOBIX bits in the FCCOBIX
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.4.4.3Valid Flash Module Commands
Table23-27 present the valid Flash commands, as enabled by the combination of the functional MCU
Table23-28 summarizes the valid P-Flash commands along with the effects of the commands on the
P-Flash block and other resources within the Flash module.
Table23-27. Flash Commands by Mode and Security State
FCMDCommand
UnsecuredSecured
NS1
1Unsecured Normal Single Chip mode
SS2
2Unsecured Special Single Chip mode.
NS3
3Secured Normal Single Chip mode.
SS4
4Secured Special Single Chip mode.
0x01Erase Verify All Blocks∗∗∗∗
0x02Erase Verify Block∗∗∗∗
0x03Erase Verify P-Flash Section∗∗∗
0x04Read Once∗∗∗
0x06Program P-Flash∗∗∗
0x07Program Once∗∗∗
0x08Erase All Blocks∗∗
0x09Erase Flash Block∗∗∗
0x0AErase P-Flash Sector∗∗∗
0x0BUnsecure Flash∗∗
0x0CVerify Backdoor Access Key∗∗
0x0DSet User Margin Level∗∗∗
0x0ESet Field Margin Level∗
0x10Erase Verify EEPROM Section∗∗∗
0x11Program EEPROM∗∗∗
0x12Erase EEPROM Sector∗∗∗
Table23-28. P-Flash Commands
FCMDCommandFunction on P-Flash Memory
0x01Erase Verify All
Blocks
Verify that all P-Flash (and EEPROM) blocks are erased.
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor791
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.4.4.5EEPROM Commands
Table23-29 summarizes the valid EEPROM commands along with the effects of the commands on the
EEPROM block.
0x02Erase Verify BlockVerify that a P-Flash block is erased.
0x03Erase Verify
P-Flash Section
Verify that a given number of words starting at the address provided are erased.
bits in the FPROT register are set prior to launching the command.
0x0AErase P-Flash
Sector
Erase all bytes in a P-Flash sector.
0x0BUnsecure FlashSupports a method of releasing MCU security by erasing all P-Flash (and EEPROM)
blocks and verifying that all P-Flash (and EEPROM) blocks are erased.
0x0CVerify Backdoor
Access Key
Supports a method of releasing MCU security by verifying a set of security keys.
0x0DSet User Margin
Level
Specifies a user margin read level for all P-Flash blocks.
0x0ESet Field Margin
Level
Specifies a field margin read level for all P-Flash blocks (special modes only).
Table23-29. EEPROM Commands
FCMDCommandFunction on EEPROM Memory
0x01Erase Verify All
Blocks
Verify that all EEPROM (and P-Flash) blocks are erased.
0x02Erase Verify BlockVerify that the EEPROM block is erased.
Table23-28. P-Flash Commands
FCMDCommandFunction on P-Flash Memory
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual,Rev.1.06
792Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.4.5Allowed Simultaneous P-Flash and EEPROM Operations
Only the operations marked ‘OK’ inTable23-30 are permitted to be run simultaneously on the Program
2The ‘Mass Erase’ operations are commands ‘Erase All Blocks’ and ‘Erase
Flash Block’
OK
Table23-29. EEPROM Commands
FCMDCommandFunction on EEPROM Memory
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor793
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table23-31. Erase Verify All Blocks Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x01Not required
Table23-32. Erase Verify All Blocks Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERRSet if CCOBIX[2:0] != 000 at command launch
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the reador if blank check failed .
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual,Rev.1.06
794Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.4.6.2Erase Verify Block Command
The Erase Verify Block command allows the user to verify that an entire P-Flash or EEPROM block has
been erased. The FCCOB FlashBlockSelectionCode[1:0] bits determine which block must be verified.
Upon clearing CCIF to launch the Erase Verify Block command, the Memory Controller will verify that
the selected P-Flash or EEPROM block is erased. The CCIF flag will set after the Erase Verify Block
Set if an invalid FlashBlockSelectionCode[1:0] is supplied
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor795
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Erase Verify P-Flash Section command, the Memory Controller will
Set if command not available in current mode (seeTable23-27)
Set if an invalid global address [17:0] is supplied seeTable23-3)
Set if a misaligned phrase address is supplied (global address [2:0] != 000)
Set if the requested section crosses a the P-Flash address boundary
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
Table23-38. Read Once Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x04Not Required
001Read Once phrase index (0x0000 - 0x0007)
010Read Once word 0 value
011Read Once word 1 value
100Read Once word 2 value
101Read Once word 3 value
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual,Rev.1.06
796Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A P-Flash phrase must be in the erased state before being programmed.
Cumulative programming of bits within a Flash phrase is not allowed.
Upon clearing CCIF to launch the Program P-Flash command, the Memory Controller will program the
data words to the supplied global address and will then proceed to verify the data words read back as
expected. The CCIF flag will set after the Program P-Flash operation has completed.
Table23-39. Read Once Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 001 at command launch
Set if command not available in current mode (seeTable23-27)
Set if an invalid phrase index is supplied
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read
MGSTAT0Set if any non-correctable errors have been encountered during the read
Table23-40. Program P-Flash Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x06Global address [17:16] to
identify P-Flash block
001Global address [15:0] of phrase location to be programmed1
1Global address [2:0] must be 000
010Word 0 program value
011Word 1 program value
100Word 2 program value
101Word 3 program value
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor797
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.4.6.6Program Once Command
The Program Once command restricts programming to a reserved 64 byte field (8 phrases) in the
and any attempt to program one of these phrases a second time will not be allowed. Valid phrase index
values for the Program Once command range from 0x0000 to 0x0007. During execution of the Program
Once command, any attempt to read addresses within P-Flash will return invalid data.
Table23-41. Program P-Flash Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 101 at command launch
Set if command not available in current mode (seeTable23-27)
Set if an invalid global address [17:0] is supplied seeTable23-3)
Set if a misaligned phrase address is supplied (global address [2:0] != 000)
FPVIOLSet if the global address [17:0] points to a protected area
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
Table23-42. Program Once Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x07Not Required
001Program Once phrase index (0x0000 - 0x0007)
010Program Once word 0 value
011Program Once word 1 value
100Program Once word 2 value
101Program Once word 3 value
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual,Rev.1.06
798Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.4.6.7Erase All Blocks Command
The Erase All Blocks operation will erase the entire P-Flash and EEPROM memory space.
The Erase Flash Block operation will erase all addresses in a P-Flash or EEPROM block.
Table23-43. Program Once Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 101 at command launch
Set if command not available in current mode (seeTable23-27)
Set if an invalid phrase index is supplied
Set if the requested phrase has already been programmed1
1If a Program Once phrase is initially programmed to 0xFFFF_FFFF_FFFF_FFFF, the Program Once command will
be allowed to execute again on that same phrase.
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
Table23-44. Erase All Blocks Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x08Not required
Table23-45. Erase All Blocks Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERRSet if CCOBIX[2:0] != 000 at command launch
Set if command not available in current mode (seeTable23-27)
FPVIOLSet if any area of the P-Flash or EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor799
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Erase Flash Block command, the Memory Controller will erase the
selected Flash block and verify that it is erased. The CCIF flag will set after the Erase Flash Block
operation has completed.
23.4.6.9Erase P-Flash Sector Command
The Erase P-Flash Sector operation will erase all addresses in a P-Flash sector.
Upon clearing CCIF to launch the Erase P-Flash Sector command, the Memory Controller will erase the
selected Flash sector and then verify that it is erased. The CCIF flag will be set after the Erase P-Flash
001Global address [15:0] anywhere within the sector to be erased.
Refer toSection23.1.2.1 for the P-Flash sector size.
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual,Rev.1.06
800Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Set if command not available in current mode (seeTable23-27)
FPVIOLSet if any area of the P-Flash or EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor801
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table23-4). The Verify Backdoor Access Key command must not be executed from the Flash block
containing the backdoor comparison key to avoid code runaway.
Upon clearing CCIF to launch the Verify Backdoor Access Key command, the Memory Controller will
check the FSEC KEYEN bits to verify that this command is enabled. If not enabled, the Memory
Controller sets the ACCERR bit in the FSTAT register and terminates. If the command is enabled, the
Memory Controller compares the key provided in FCCOB to the backdoor comparison key in the Flash
configuration field with Key 0 compared to 0x3_FF00, etc. If the backdoor keys match, security will be
Set if backdoor key access has not been enabled (KEYEN[1:0] != 10, see
Section23.3.2.2)
Set if the backdoor key has mismatched since the last reset
FPVIOLNone
MGSTAT1None
MGSTAT0None
Table23-54. Set User Margin Level Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x0DFlashblockselectioncode[1:0].See
001Margin level setting.
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual,Rev.1.06
802Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Set User Margin Level command, the Memory Controller will set the
user margin level for the targeted block and then set the CCIF flag.
Table23-56. Set User Margin Level Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 001 at command launch
Set if command not available in current mode (seeTable23-27)
Set if an invalid FlashBlockSelectionCode[1:0] is supplied (SeeTable23-34 )
Set if an invalid margin level setting is supplied
FPVIOLNone
MGSTAT1None
MGSTAT0None
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor803
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.4.6.13Set Field Margin Level Command
The Set Field Margin Level command, valid in special modes only, causes the Memory Controller to set
the margin level specified for future read operations of the P-Flash or EEPROM block.
Upon clearing CCIF to launch the Set Field Margin Level command, the Memory Controller will set the
field margin level for the targeted block and then set the CCIF flag.
Valid margin level settings for the Set Field Margin Level command are defined inTable23-58.
Table23-57. Set Field Margin Level Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x0EFlash block selection code [1:0]. See
Table23-34
001Margin level setting.
Table23-58. Valid Set Field Margin Level Settings
CCOB
(CCOBIX=001)Level Description
0x0000Return to Normal Level
0x0001User Margin-1 Level1
1Read margin to the erased state
0x0002User Margin-0 Level2
2Read margin to the programmed state
0x0003Field Margin-1 Level1
0x0004Field Margin-0 Level2
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual,Rev.1.06
804Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CAUTION
Field margin levels must only be used during verify of the initial factory
programming.
NOTE
Field margin levels can be used to check that Flash memory contents have
001Global address [15:0] of the first word to be verified
010Number of words to be verified
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor805
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.4.6.15Program EEPROM Command
The Program EEPROM operation programs one to four previously erased words in the EEPROM block.
Set if command not available in current mode (seeTable23-27)
Set if an invalid global address [17:0] is supplied
Set if a misaligned word address is supplied (global address [0] != 0)
Set if the requested section breaches the end of the EEPROM block
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
Table23-62. Program EEPROM Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x11Global address [17:16] to
identify the EEPROM block
001Global address [15:0] of word to be programmed
010Word 0 program value
011Word 1 program value, if desired
100Word 2 program value, if desired
101Word 3 program value, if desired
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual,Rev.1.06
806Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.4.6.16Erase EEPROM Sector Command
The Erase EEPROM Sector operation will erase all addresses in a sector of the EEPROM block.
Set if command not available in current mode (seeTable23-27)
Set if an invalid global address [17:0] is suppliedseeTable23-3)
Set if a misaligned word address is supplied (global address [0] != 0)
FPVIOLSet if the selected area of the EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor807
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.4.7Interrupts
The Flash module can generate an interrupt when a Flash command operation has completed or when a
Flash command operation has detected an ECC fault.
NOTE
Vector addresses and their relative interrupt priority are determined at the
MCU level.
23.4.7.1Description of Flash Interrupt Operation
The Flash module uses the CCIF flag in combination with the CCIE interrupt enable bit to generate the
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
23.4.8Wait Mode
The Flash module is not affected if the MCU enters wait mode. The Flash module can recover the MCU
from wait via the CCIF interrupt (seeSection23.4.7, “Interrupts”).
Access Key command match the backdoor keys stored in the Flash memory, the SEC bits in the FSEC
register (seeTable23-11) will be changed to unsecure the MCU. Key values of 0x0000 and 0xFFFF are
not permitted as backdoor keys. While the Verify Backdoor Access Key command is active, P-Flash
memory and EEPROM memory will not be available for read access and will return invalid data.
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor809
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
7.Send BDM commands to execute the Program P-Flash command write sequence to program the
Flash security byte to the unsecured state
48 KByte Flash Module (S12FTMRG48K1V1)
MC9S12G Family Reference Manual,Rev.1.06
810Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
8.Reset the MCU
23.5.3Mode and Security Effects on Flash Command Availability
The availability of Flash module commands depends on the MCU operating mode and security state as
state of the word being programmed or the sector/block being erased is not guaranteed.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor811
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter24
64 KByte Flash Module (S12FTMRG64K1V1)
24.1Introduction
The FTMRG64K1 module implements the following:
•64Kbytes of P-Flash (Program Flash) memory
•2 Kbytes of EEPROM memory
The Flash memory is ideal for single-supply applications allowing for field reprogramming without
requiring external high voltage sources for program or erase operations. The Flash module includes a
memory controller that executes commands to modify Flash memory contents. The user interface to the
memory controller consists of the indexed Flash Common Command Object (FCCOB) register which is
written to with the command, global address, data, and any required command parameters. The memory
Updated description of the commands RD1BLK, MLOADU and MLOADF
Rev.1.0631 Jan 201124.3.2.9/24-827Updated description of protection onSection24.3.2.9
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor812
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The Flash memory may be read as bytes and aligned words. Read access time is one bus cycle for bytes
and aligned words. For misaligned words access, the CPU has to perform twice the byte read access
command. For Flash memory, an erased bit reads 1 and a programmed bit reads 0.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Single bit fault correction and double bit fault detection within a 32-bit double word during read
operations
•Automated program and erase algorithm with verify and generation of ECC parity bits
•Fast sector erase and phrase program operation
•Ability to read the P-Flash memory while programming a word in the EEPROM memory
•Flexible protection scheme to prevent accidental program or erase of P-Flash memory
•Single bit fault correction and double bit fault detection within a word during read operations
•Automated program and erase algorithm with verify and generation of ECC parity bits
•Fast sector erase and word program operation
•Protection scheme to prevent accidental program or erase of EEPROM memory
•Ability to program up to four words in a burst sequence
24.1.2.3Other Flash Module Features
•No external high-voltage power supply required for Flash memory program and erase operations
•Interrupt generation on Flash command completion and Flash error detection
•Security mechanism to prevent unauthorized access to the Flash memory
24.1.3Block Diagram
The block diagram of the Flash module is shown inFigure24-1.
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
814Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure24-1. FTMRG64K1 Block Diagram
24.2External Signal Description
The Flash module contains no signals that connect off-chip.
Bus
Clock
Divider
Clock
Command
Interrupt
Request
FCLK
Protection
Security
Registers
Flash
Interface
16bit
internal
bus
sector 0
sector 1
sector 127
16Kx39
P-Flash
Error
Interrupt
Request
CPU
1Kx22
sector 0
sector 1
sector 511
EEPROM
Memory Controller
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor815
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
in the Flash module will be ignored by the Flash module.
CAUTION
Writing to the Flash registers while a Flash command is executing (that is
indicated when the value of flag CCIF reads as ’0’) is not allowed. If such
action is attempted the write operation will not change the register value.
Writing to the Flash registers is allowed when the Flash is not busy
executing commands (CCIF = 1) and during initialization right after reset,
despite the value of flag CCIF in that case (refer toSection24.6 for a
complete description of the reset sequence).
.
24.3.1Module Memory Map
The S12 architecture places the P-Flash memory between global addresses 0x3_0000 and 0x3_FFFF as
shown inTable24-3.The P-Flash memory map is shown inFigure24-2.
Table24-2. FTMRG Memory Map
Global Address (in Bytes)Size
(Bytes)Description
0x0_0000 - 0x0_03FF1,024Register Space
0x0_0400 – 0x0_0BFF2,048EEPROM Memory
0x0_4000 – 0x0_7FFF16,284NVMRES1=1 : NVM Resource area (seeFigure24-3)
1See NVMRES description inSection24.4.3
0x3_0000 – 0x3_FFFF65,536P-Flash Memory
Table24-3. P-Flash Memory Addressing
Global AddressSize
(Bytes)Description
0x3_0000 – 0x3_FFFF64 K
P-Flash Block
Contains Flash Configuration Field
(seeTable24-4)
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
816Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure24-2. P-Flash Memory Map
Table24-5. Program IFR Fields
Global AddressSize
(Bytes)Field Description
0x0_4000 – 0x0_40078Reserved
0x0_4008 – 0x0_40B5174Reserved
0x0_40B6 – 0x0_40B72Version ID1
1Used to track firmware patch versions, seeSection24.4.2
0x0_40B8 – 0x0_40BF8Reserved
0x0_40C0 – 0x0_40FF64Program Once Field
Refer toSection24.4.6.6, “Program Once Command”
Flash Configuration Field
0x3_C000
Flash Protected/Unprotected Lower Region
1, 2, 4, 8 Kbytes
0x3_8000
0x3_9000
0x3_8400
0x3_8800
0x3_A000
P-Flash END = 0x3_FFFF
0x3_F800
0x3_F000
0x3_E000Flash Protected/Unprotected Higher Region
2, 4, 8, 16 Kbytes
Flash Protected/Unprotected Region
8 Kbytes (up to 29 Kbytes)
16 bytes (0x3_FF00 - 0x3_FF0F)
Flash Protected/Unprotected Region
32 Kbytes
P-Flash START = 0x3_0000
Protection
Protection
Protection
Movable End
Fixed End
Fixed End
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
818Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1NVMRES - SeeSection24.4.3 for NVMRES (NVM Resource) detail.
Global AddressSize
(Bytes)Description
0x0_4000 – 0x040FF256P-Flash IFR (seeTable24-5)
0x0_4100 – 0x0_41FF256Reserved.
0x0_4200 – 0x0_57FFReserved
0x0_5800 – 0x0_59FF512Reserved
0x0_5A00 – 0x0_5FFF1,536Reserved
0x0_6000 – 0x0_6BFF3,072Reserved
0x0_6C00 – 0x0_7FFF5,120Reserved
P-Flash IFR 1 Kbyte (NVMRES=1)
0x0_4000
RAM End = 0x0_59FF
RAM Start = 0x0_5800
Reserved 5120 bytes
Reserved 4608 bytes
0x0_6C00
0x0_7FFF
0x0_4400Reserved 5k bytes
Reserved 512 bytes
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor819
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A summary of the Flash module registers is given inFigure24-4 with detailed descriptions in the
following subsections.
Address
& Name76543210
0x0000
FCLKDIV
RFDIVLDFDIVLCKFDIV5FDIV4FDIV3FDIV2FDIV1FDIV0
W
0x0001
FSEC
RKEYEN1KEYEN0RNV5RNV4RNV3RNV2SEC1SEC0
W
0x0002
FCCOBIX
R00000CCOBIX2CCOBIX1CCOBIX0
W
0x0003
FRSV0
R00000000
W
0x0004
FCNFG
RCCIE00
IGNSF00
FDFDFSFD
W
0x0005
FERCNFG
R000000DFDIESFDIE
W
0x0006
FSTAT
RCCIF0ACCERRFPVIOLMGBUSYRSVDMGSTAT1MGSTAT0
W
0x0007
FERSTAT
R000000DFDIFSFDIF
W
0x0008
FPROT
RFPOPENRNV6FPHDISFPHS1FPHS0FPLDISFPLS1FPLS0
W
0x0009
EEPROT
RDPOPEN0DPS5DPS4DPS3DPS2DPS1DPS0
W
0x000A
FCCOBHI
RCCOB15CCOB14CCOB13CCOB12CCOB11CCOB10CCOB9CCOB8
W
0x000B
FCCOBLO
RCCOB7CCOB6CCOB5CCOB4CCOB3CCOB2CCOB1CCOB0
W
0x000C
FRSV1
R00000000
W
Figure24-4. FTMRG64K1 Register Summary
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
820Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.3.2.1Flash Clock Divider Register (FCLKDIV)
The FCLKDIV register is used to control timed events in program and erase algorithms.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CAUTION
The FCLKDIV register should never be written while a Flash command is
executing (CCIF=0).
Table24-7. FCLKDIV Field Descriptions
FieldDescription
7
FDIVLD
Clock Divider Loaded
0FCLKDIV register has not been written since the last reset
1FCLKDIV register has been written since the last reset
6
FDIVLCK
Clock Divider Locked
0FDIV field is open for writing
1FDIV value is locked and cannot be changed. Once the lock bit is set high, only reset can clear this bit and
restore writability to the FDIV field in normal mode.
BUSCLK frequency. Please refer toSection24.4.4, “Flash Command Operations,” for more information.
Table24-8. FDIV values for various BUSCLK Frequencies
BUSCLK Frequency
(MHz)FDIV[5:0]
BUSCLK Frequency
(MHz)FDIV[5:0]
MIN1
1BUSCLK is Greater Than this value.
MAX2
2BUSCLK is Less Than or Equal to this value.
MIN1MAX2
1.01.60x0016.617.60x10
1.62.60x0117.618.60x11
2.63.60x0218.619.60x12
3.64.60x0319.620.60x13
4.65.60x0420.621.60x14
5.66.60x0521.622.60x15
6.67.60x0622.623.60x16
7.68.60x0723.624.60x17
8.69.60x0824.625.60x18
9.610.60x09
10.611.60x0A
11.612.60x0B
12.613.60x0C
13.614.60x0D
14.615.60x0E
15.616.60x0F
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
822Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.3.2.2Flash Security Register (FSEC)
The FSEC register holds all bits associated with the security of the MCU and Flash module.
All bits in the FSEC register are readable but not writable.
During the reset sequence, the FSEC register is loaded with the contents of the Flash security byte in the
Flash configuration field at global address 0x3_FF0F located in P-Flash memory (seeTable24-4) as
indicated by reset condition F inFigure24-6. If a double bit fault is detected while reading the P-Flash
Reserved Nonvolatile Bits— The RNV bits should remain in the erased state for future enhancements.
1–0
SEC[1:0]
Flash Security Bits — The SEC[1:0] bits define the security state of the MCU as shown inTable24-11. If the
Flash module is unsecured using backdoor key access, the SEC bits are forced to 10.
Table24-10. Flash KEYEN States
KEYEN[1:0]Status of Backdoor Key Access
00DISABLED
01DISABLED1
1Preferred KEYEN state to disable backdoor key access.
10ENABLED
11DISABLED
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor823
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The security function in the Flash module is described inSection24.5.
24.3.2.3Flash CCOB Index Register (FCCOBIX)
The FCCOBIX register is used to index the FCCOB register for Flash memory operations.
CCOBIX bits are readable and writable while remaining bits read 0 and are not writable.
24.3.2.4Flash Reserved0 Register (FRSV0)
This Flash register is reserved for factory testing.
All bits in the FRSV0 register read 0 and are not writable.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All assigned bits in the FERCNFG register are readable and writable.
24.3.2.7Flash Status Register (FSTAT)
The FSTAT register reports the operational status of the Flash module.
CCIF, ACCERR, and FPVIOL bits are readable and writable, MGBUSY and MGSTAT bits are readable
but not writable, while remaining bits read 0 and are not writable.
0SFDIF interrupt disabled whenever the SFDIF flag is set (seeSection24.3.2.8)
1An interrupt will be requested whenever the SFDIF flag is set (seeSection24.3.2.8)
OffsetModule Base + 0x0006
76543210
RCCIF0ACCERRFPVIOLMGBUSYRSVDMGSTAT[1:0]
W
Reset1000000
1
1Reset value can deviate from the value shown if a double bit fault is detected during the reset sequence (seeSection24.6).
01
= Unimplemented or Reserved
Figure24-11. Flash Status Register (FSTAT)
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
826Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.3.2.8Flash Error Status Register (FERSTAT)
The FERSTAT register reflects the error status of internal Flash operations.
All flags in the FERSTAT register are readable and only writable to clear the flag.
Table24-15. FSTAT Field Descriptions
FieldDescription
7
CCIF
Command Complete Interrupt Flag — The CCIF flag indicates that a Flash command has completed. The
CCIF flag is cleared by writing a 1 to CCIF to launch a command and CCIF will stay low until command
completion or command violation.
0Flash command in progress
1Flash command has completed
5
ACCERR
Flash Access Error Flag — The ACCERR bit indicates an illegal access has occurred to the Flash memory
is detected during execution of a Flash command or during the Flash reset sequence. SeeSection24.4.6,
“Flash Command Description,” andSection24.6, “Initialization” for details.
OffsetModule Base + 0x0007
76543210
R000000
DFDIFSFDIF
W
Reset00000000
= Unimplemented or Reserved
Figure24-12. Flash Error Status Register (FERSTAT)
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor827
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.3.2.9P-Flash Protection Register (FPROT)
The FPROT register defines which P-Flash sectors are protected against program and erase operations.
command operation.1 The SFDIF flag is cleared by writing a 1 to SFDIF. Writing a 0 to SFDIF has no effect on
SFDIF.
0No single bit fault detected
1Single bit fault detected and corrected or a Flash array read operation returning invalid data was attempted
while command running
OffsetModule Base + 0x0008
76543210
RFPOPENRNV6FPHDISFPHS[1:0]FPLDISFPLS[1:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
= Unimplemented or Reserved
Figure24-13. Flash Protection Register (FPROT)
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
828Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
in P-Flash memory as shown inTable24-20. The FPLS bits can only be written to while the FPLDIS bit is set.
Table24-18. P-Flash Protection Function
FPOPENFPHDISFPLDISFunction1
1For range sizes, refer toTable24-19 andTable24-20.
111No P-Flash Protection
110Protected Low Range
101Protected High Range
100Protected High and Low Ranges
011Full P-Flash Memory Protected
010Unprotected Low Range
001Unprotected High Range
000Unprotected High and Low Ranges
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor829
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All possible P-Flash protection scenarios are shown inFigure24-14 . Although the protection scheme is
loaded from the Flash memory at global address 0x3_FF0C during the reset sequence, it can be changed
chip mode while providing as much protection as possible if reprogramming is not required.
Table24-19. P-Flash Protection Higher Address Range
FPHS[1:0] Global Address RangeProtected Size
000x3_F800–0x3_FFFF2 Kbytes
010x3_F000–0x3_FFFF4 Kbytes
100x3_E000–0x3_FFFF8 Kbytes
110x3_C000–0x3_FFFF16 Kbytes
Table24-20. P-Flash Protection Lower Address Range
FPLS[1:0]Global Address RangeProtected Size
000x3_8000–0x3_83FF1 Kbyte
010x3_8000–0x3_87FF2 Kbytes
100x3_8000–0x3_8FFF4 Kbytes
110x3_8000–0x3_9FFF8 Kbytes
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
830Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure24-14. P-Flash Protection Scenarios
7654
FPHS[1:0]FPLS[1:0]
3210
FPHS[1:0]FPLS[1:0]
FPHDIS = 1
FPLDIS = 1
FPHDIS = 1
FPLDIS = 0
FPHDIS = 0
FPLDIS = 1
FPHDIS = 0
FPLDIS = 0
Scenario
Scenario
Unprotected regionProtected region with size
Protected regionProtected region with size
defined by FPLS
defined by FPHSnot defined by FPLS, FPHS
0x3_8000
0x3_FFFF
0x3_8000
0x3_FFFF
FLASH START
FLASH START
FPOPEN = 1FPOPEN = 0
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor831
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1Allowed transitions marked with X, seeFigure24-14 for a definition of the scenarios.
01234567
0XXXX
1XX
2XX
3X
4XX
5XXXX
6XXXX
7XXXXXXXX
OffsetModule Base + 0x0009
76543210
RDPOPEN0DPS[5:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
0F
1F1F1F1F1F1
= Unimplemented or Reserved
Figure24-15. EEPROM Protection Register (EEPROT)
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
832Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.3.2.11Flash Common Command Object Register (FCCOB)
The FCCOB is an array of six words addressed via the CCOBIX index found in the FCCOBIX register.
Byte wide reads and writes are allowed to the FCCOB register.
24.3.2.11.1FCCOB - NVM Command Mode
NVM command mode uses the indexed FCCOB register to provide a command code and its relevant
parameters to the Memory Controller. The user first sets up all required FCCOB fields and then initiates
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.3.2.12Flash Reserved1 Register (FRSV1)
This Flash register is reserved for factory testing.
All bits in the FRSV1 register read 0 and are not writable.
24.3.2.13Flash Reserved2 Register (FRSV2)
This Flash register is reserved for factory testing.
All bits in the FRSV2 register read 0 and are not writable.
24.3.2.14Flash Reserved3 Register (FRSV3)
This Flash register is reserved for factory testing.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All bits in the FRSV3 register read 0 and are not writable.
24.3.2.15Flash Reserved4 Register (FRSV4)
This Flash register is reserved for factory testing.
All bits in the FRSV4 register read 0 and are not writable.
24.3.2.16Flash Option Register (FOPT)
The FOPT register is the Flash option register.
All bits in the FOPT register are readable but are not writable.
During the reset sequence, the FOPT register is loaded from the Flash nonvolatile byte in the Flash
configuration field at global address 0x3_FF0E located in P-Flash memory (seeTable24-4) as indicated
by reset condition F inFigure24-22. If a double bit fault is detected while reading the P-Flash phrase
containing the Flash nonvolatile byte during the reset sequence, all bits in the FOPT register will be set.
OffsetModule Base + 0x000E
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure24-20. Flash Reserved3 Register (FRSV3)
OffsetModule Base + 0x000F
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure24-21. Flash Reserved4 Register (FRSV4)
OffsetModule Base + 0x0010
76543210
RNV[7:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
= Unimplemented or Reserved
Figure24-22. Flash Option Register (FOPT)
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
836Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.3.2.17Flash Reserved5 Register (FRSV5)
This Flash register is reserved for factory testing.
All bits in the FRSV5 register read 0 and are not writable.
24.3.2.18Flash Reserved6 Register (FRSV6)
This Flash register is reserved for factory testing.
All bits in the FRSV6 register read 0 and are not writable.
24.3.2.19Flash Reserved7 Register (FRSV7)
This Flash register is reserved for factory testing.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All bits in the FRSV7 register read 0 and are not writable.
24.4Functional Description
24.4.1Modes of Operation
The FTMRG64K1 module provides the modes of operation normal and special . The operating mode is
determined by module-level inputs and affects the FCLKDIV, FCNFG, and EEPROT registers (see
Table24-27).
24.4.2IFR Version ID Word
The version ID word is stored in the IFR at address 0x0_40B6. The contents of the word are defined in
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.4.3Internal NVM resource (NVMRES)
IFR is an internal NVM resource readable by CPU , when NVMRES is active. The IFR fields are shown
inTable24-5.
The NVMRES global address map is shown inTable24-6.
24.4.4Flash Command Operations
Flash command operations are used to modify Flash memory contents.
The next sections describe:
•How to write the FCLKDIV register that is used to generate a time base (FCLK) derived from
BUSCLK for Flash program and erase command operations
•The command write sequence used to set Flash command parameters and launch execution
•Valid Flash commands available for execution, according to MCU functional mode and MCU
security state.
24.4.4.1Writing the FCLKDIV Register
Prior to issuing any Flash program or erase command after a reset, the user is required to write the
sequence. If CCIF is 0, the previous command write sequence is still active, a new command write
sequence cannot be started, and all writes to the FCCOB register are ignored.
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor839
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.4.4.2.1Define FCCOB Contents
The FCCOB parameter fields must be loaded with all required parameters for the Flash command being
executed. Access to the FCCOB parameter fields is controlled via the CCOBIX bits in the FCCOBIX
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.4.4.3Valid Flash Module Commands
Table24-27 present the valid Flash commands, as enabled by the combination of the functional MCU
Table24-28 summarizes the valid P-Flash commands along with the effects of the commands on the
P-Flash block and other resources within the Flash module.
Table24-27. Flash Commands by Mode and Security State
FCMDCommand
UnsecuredSecured
NS1
1Unsecured Normal Single Chip mode
SS2
2Unsecured Special Single Chip mode.
NS3
3Secured Normal Single Chip mode.
SS4
4Secured Special Single Chip mode.
0x01Erase Verify All Blocks∗∗∗∗
0x02Erase Verify Block∗∗∗∗
0x03Erase Verify P-Flash Section∗∗∗
0x04Read Once∗∗∗
0x06Program P-Flash∗∗∗
0x07Program Once∗∗∗
0x08Erase All Blocks∗∗
0x09Erase Flash Block∗∗∗
0x0AErase P-Flash Sector∗∗∗
0x0BUnsecure Flash∗∗
0x0CVerify Backdoor Access Key∗∗
0x0DSet User Margin Level∗∗∗
0x0ESet Field Margin Level∗
0x10Erase Verify EEPROM Section∗∗∗
0x11Program EEPROM∗∗∗
0x12Erase EEPROM Sector∗∗∗
Table24-28. P-Flash Commands
FCMDCommandFunction on P-Flash Memory
0x01Erase Verify All
Blocks
Verify that all P-Flash (and EEPROM) blocks are erased.
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
842Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.4.4.5EEPROM Commands
Table24-29 summarizes the valid EEPROM commands along with the effects of the commands on the
EEPROM block.
0x02Erase Verify BlockVerify that a P-Flash block is erased.
0x03Erase Verify
P-Flash Section
Verify that a given number of words starting at the address provided are erased.
bits in the FPROT register are set prior to launching the command.
0x0AErase P-Flash
Sector
Erase all bytes in a P-Flash sector.
0x0BUnsecure FlashSupports a method of releasing MCU security by erasing all P-Flash (and EEPROM)
blocks and verifying that all P-Flash (and EEPROM) blocks are erased.
0x0CVerify Backdoor
Access Key
Supports a method of releasing MCU security by verifying a set of security keys.
0x0DSet User Margin
Level
Specifies a user margin read level for all P-Flash blocks.
0x0ESet Field Margin
Level
Specifies a field margin read level for all P-Flash blocks (special modes only).
Table24-29. EEPROM Commands
FCMDCommandFunction on EEPROM Memory
0x01Erase Verify All
Blocks
Verify that all EEPROM (and P-Flash) blocks are erased.
0x02Erase Verify BlockVerify that the EEPROM block is erased.
Table24-28. P-Flash Commands
FCMDCommandFunction on P-Flash Memory
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor843
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.4.5Allowed Simultaneous P-Flash and EEPROM Operations
Only the operations marked ‘OK’ inTable24-30 are permitted to be run simultaneously on the Program
2The ‘Mass Erase’ operations are commands ‘Erase All Blocks’ and ‘Erase
Flash Block’
OK
Table24-29. EEPROM Commands
FCMDCommandFunction on EEPROM Memory
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
844Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table24-31. Erase Verify All Blocks Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x01Not required
Table24-32. Erase Verify All Blocks Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERRSet if CCOBIX[2:0] != 000 at command launch
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the reador if blank check failed .
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor845
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.4.6.2Erase Verify Block Command
The Erase Verify Block command allows the user to verify that an entire P-Flash or EEPROM block has
been erased. The FCCOB FlashBlockSelectionCode[1:0] bits determine which block must be verified.
Upon clearing CCIF to launch the Erase Verify Block command, the Memory Controller will verify that
the selected P-Flash or EEPROM block is erased. The CCIF flag will set after the Erase Verify Block
Set if an invalid FlashBlockSelectionCode[1:0] is supplied
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
846Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Erase Verify P-Flash Section command, the Memory Controller will
Set if command not available in current mode (seeTable24-27)
Set if an invalid global address [17:0] is supplied seeTable24-3)
Set if a misaligned phrase address is supplied (global address [2:0] != 000)
Set if the requested section crosses a the P-Flash address boundary
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
Table24-38. Read Once Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x04Not Required
001Read Once phrase index (0x0000 - 0x0007)
010Read Once word 0 value
011Read Once word 1 value
100Read Once word 2 value
101Read Once word 3 value
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor847
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A P-Flash phrase must be in the erased state before being programmed.
Cumulative programming of bits within a Flash phrase is not allowed.
Upon clearing CCIF to launch the Program P-Flash command, the Memory Controller will program the
data words to the supplied global address and will then proceed to verify the data words read back as
expected. The CCIF flag will set after the Program P-Flash operation has completed.
Table24-39. Read Once Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 001 at command launch
Set if command not available in current mode (seeTable24-27)
Set if an invalid phrase index is supplied
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read
MGSTAT0Set if any non-correctable errors have been encountered during the read
Table24-40. Program P-Flash Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x06Global address [17:16] to
identify P-Flash block
001Global address [15:0] of phrase location to be programmed1
1Global address [2:0] must be 000
010Word 0 program value
011Word 1 program value
100Word 2 program value
101Word 3 program value
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
848Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.4.6.6Program Once Command
The Program Once command restricts programming to a reserved 64 byte field (8 phrases) in the
and any attempt to program one of these phrases a second time will not be allowed. Valid phrase index
values for the Program Once command range from 0x0000 to 0x0007. During execution of the Program
Once command, any attempt to read addresses within P-Flash will return invalid data.
Table24-41. Program P-Flash Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 101 at command launch
Set if command not available in current mode (seeTable24-27)
Set if an invalid global address [17:0] is supplied seeTable24-3)
Set if a misaligned phrase address is supplied (global address [2:0] != 000)
FPVIOLSet if the global address [17:0] points to a protected area
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
Table24-42. Program Once Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x07Not Required
001Program Once phrase index (0x0000 - 0x0007)
010Program Once word 0 value
011Program Once word 1 value
100Program Once word 2 value
101Program Once word 3 value
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor849
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.4.6.7Erase All Blocks Command
The Erase All Blocks operation will erase the entire P-Flash and EEPROM memory space.
The Erase Flash Block operation will erase all addresses in a P-Flash or EEPROM block.
Table24-43. Program Once Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 101 at command launch
Set if command not available in current mode (seeTable24-27)
Set if an invalid phrase index is supplied
Set if the requested phrase has already been programmed1
1If a Program Once phrase is initially programmed to 0xFFFF_FFFF_FFFF_FFFF, the Program Once command will
be allowed to execute again on that same phrase.
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
Table24-44. Erase All Blocks Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x08Not required
Table24-45. Erase All Blocks Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERRSet if CCOBIX[2:0] != 000 at command launch
Set if command not available in current mode (seeTable24-27)
FPVIOLSet if any area of the P-Flash or EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
850Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Erase Flash Block command, the Memory Controller will erase the
selected Flash block and verify that it is erased. The CCIF flag will set after the Erase Flash Block
operation has completed.
24.4.6.9Erase P-Flash Sector Command
The Erase P-Flash Sector operation will erase all addresses in a P-Flash sector.
Upon clearing CCIF to launch the Erase P-Flash Sector command, the Memory Controller will erase the
selected Flash sector and then verify that it is erased. The CCIF flag will be set after the Erase P-Flash
001Global address [15:0] anywhere within the sector to be erased.
Refer toSection24.1.2.1 for the P-Flash sector size.
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor851
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Set if command not available in current mode (seeTable24-27)
FPVIOLSet if any area of the P-Flash or EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
852Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table24-4). The Verify Backdoor Access Key command must not be executed from the Flash block
containing the backdoor comparison key to avoid code runaway.
Upon clearing CCIF to launch the Verify Backdoor Access Key command, the Memory Controller will
check the FSEC KEYEN bits to verify that this command is enabled. If not enabled, the Memory
Controller sets the ACCERR bit in the FSTAT register and terminates. If the command is enabled, the
Memory Controller compares the key provided in FCCOB to the backdoor comparison key in the Flash
configuration field with Key 0 compared to 0x3_FF00, etc. If the backdoor keys match, security will be
Set if backdoor key access has not been enabled (KEYEN[1:0] != 10, see
Section24.3.2.2)
Set if the backdoor key has mismatched since the last reset
FPVIOLNone
MGSTAT1None
MGSTAT0None
Table24-54. Set User Margin Level Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x0DFlashblockselectioncode[1:0].See
Table24-34
001Margin level setting.
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor853
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Set User Margin Level command, the Memory Controller will set the
user margin level for the targeted block and then set the CCIF flag.
Table24-56. Set User Margin Level Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 001 at command launch
Set if command not available in current mode (seeTable24-27)
Set if an invalid FlashBlockSelectionCode[1:0] is supplied (SeeTable24-34 )
Set if an invalid margin level setting is supplied
FPVIOLNone
MGSTAT1None
MGSTAT0None
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
854Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.4.6.13Set Field Margin Level Command
The Set Field Margin Level command, valid in special modes only, causes the Memory Controller to set
the margin level specified for future read operations of the P-Flash or EEPROM block.
Upon clearing CCIF to launch the Set Field Margin Level command, the Memory Controller will set the
field margin level for the targeted block and then set the CCIF flag.
Valid margin level settings for the Set Field Margin Level command are defined inTable24-58.
Table24-57. Set Field Margin Level Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x0EFlash block selection code [1:0]. See
Table24-34
001Margin level setting.
Table24-58. Valid Set Field Margin Level Settings
CCOB
(CCOBIX=001)Level Description
0x0000Return to Normal Level
0x0001User Margin-1 Level1
1Read margin to the erased state
0x0002User Margin-0 Level2
2Read margin to the programmed state
0x0003Field Margin-1 Level1
0x0004Field Margin-0 Level2
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor855
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CAUTION
Field margin levels must only be used during verify of the initial factory
programming.
NOTE
Field margin levels can be used to check that Flash memory contents have
001Global address [15:0] of the first word to be verified
010Number of words to be verified
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
856Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.4.6.15Program EEPROM Command
The Program EEPROM operation programs one to four previously erased words in the EEPROM block.
Set if command not available in current mode (seeTable24-27)
Set if an invalid global address [17:0] is supplied
Set if a misaligned word address is supplied (global address [0] != 0)
Set if the requested section breaches the end of the EEPROM block
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
Table24-62. Program EEPROM Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x11Global address [17:16] to
identify the EEPROM block
001Global address [15:0] of word to be programmed
010Word 0 program value
011Word 1 program value, if desired
100Word 2 program value, if desired
101Word 3 program value, if desired
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor857
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.4.6.16Erase EEPROM Sector Command
The Erase EEPROM Sector operation will erase all addresses in a sector of the EEPROM block.
Set if command not available in current mode (seeTable24-27)
Set if an invalid global address [17:0] is suppliedseeTable24-3)
Set if a misaligned word address is supplied (global address [0] != 0)
FPVIOLSet if the selected area of the EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
858Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.4.7Interrupts
The Flash module can generate an interrupt when a Flash command operation has completed or when a
Flash command operation has detected an ECC fault.
NOTE
Vector addresses and their relative interrupt priority are determined at the
MCU level.
24.4.7.1Description of Flash Interrupt Operation
The Flash module uses the CCIF flag in combination with the CCIE interrupt enable bit to generate the
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
24.4.8Wait Mode
The Flash module is not affected if the MCU enters wait mode. The Flash module can recover the MCU
from wait via the CCIF interrupt (seeSection24.4.7, “Interrupts”).
Access Key command match the backdoor keys stored in the Flash memory, the SEC bits in the FSEC
register (seeTable24-11) will be changed to unsecure the MCU. Key values of 0x0000 and 0xFFFF are
not permitted as backdoor keys. While the Verify Backdoor Access Key command is active, P-Flash
memory and EEPROM memory will not be available for read access and will return invalid data.
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
860Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
7.Send BDM commands to execute the Program P-Flash command write sequence to program the
Flash security byte to the unsecured state
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor861
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
8.Reset the MCU
24.5.3Mode and Security Effects on Flash Command Availability
The availability of Flash module commands depends on the MCU operating mode and security state as
state of the word being programmed or the sector/block being erased is not guaranteed.
64 KByte Flash Module (S12FTMRG64K1V1)
MC9S12G Family Reference Manual,Rev.1.06
862Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor863
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter25
96 KByte Flash Module (S12FTMRG96K1V1)
25.1Introduction
The FTMRG96K1 module implements the following:
•96Kbytes of P-Flash (Program Flash) memory
•3 Kbytes of EEPROM memory
The Flash memory is ideal for single-supply applications allowing for field reprogramming without
requiring external high voltage sources for program or erase operations. The Flash module includes a
memory controller that executes commands to modify Flash memory contents. The user interface to the
memory controller consists of the indexed Flash Common Command Object (FCCOB) register which is
written to with the command, global address, data, and any required command parameters. The memory
Updated description of the commands RD1BLK, MLOADU and MLOADF
Rev.1.0631 Jan 201125.3.2.9/25-879Updated description of protection onSection25.3.2.9
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor864
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The Flash memory may be read as bytes and aligned words. Read access time is one bus cycle for bytes
and aligned words. For misaligned words access, the CPU has to perform twice the byte read access
command. For Flash memory, an erased bit reads 1 and a programmed bit reads 0.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Single bit fault correction and double bit fault detection within a 32-bit double word during read
operations
•Automated program and erase algorithm with verify and generation of ECC parity bits
•Fast sector erase and phrase program operation
•Ability to read the P-Flash memory while programming a word in the EEPROM memory
•Flexible protection scheme to prevent accidental program or erase of P-Flash memory
•Single bit fault correction and double bit fault detection within a word during read operations
•Automated program and erase algorithm with verify and generation of ECC parity bits
•Fast sector erase and word program operation
•Protection scheme to prevent accidental program or erase of EEPROM memory
•Ability to program up to four words in a burst sequence
25.1.2.3Other Flash Module Features
•No external high-voltage power supply required for Flash memory program and erase operations
•Interrupt generation on Flash command completion and Flash error detection
•Security mechanism to prevent unauthorized access to the Flash memory
25.1.3Block Diagram
The block diagram of the Flash module is shown inFigure25-1.
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
866Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure25-1. FTMRG96K1 Block Diagram
25.2External Signal Description
The Flash module contains no signals that connect off-chip.
Bus
Clock
Divider
Clock
Command
Interrupt
Request
FCLK
Protection
Security
Registers
Flash
Interface
16bit
internal
bus
sector 0
sector 1
sector 191
24Kx39
P-Flash
Error
Interrupt
Request
CPU
1.5Kx22
sector 0
sector 1
sector 767
EEPROM
Memory Controller
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor867
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
in the Flash module will be ignored by the Flash module.
CAUTION
Writing to the Flash registers while a Flash command is executing (that is
indicated when the value of flag CCIF reads as ’0’) is not allowed. If such
action is attempted the write operation will not change the register value.
Writing to the Flash registers is allowed when the Flash is not busy
executing commands (CCIF = 1) and during initialization right after reset,
despite the value of flag CCIF in that case (refer toSection25.6 for a
complete description of the reset sequence).
.
25.3.1Module Memory Map
The S12 architecture places the P-Flash memory between global addresses 0x2_8000 and 0x3_FFFF as
shown inTable25-3.The P-Flash memory map is shown inFigure25-2.
Table25-2. FTMRG Memory Map
Global Address (in Bytes)Size
(Bytes)Description
0x0_0000 - 0x0_03FF1,024Register Space
0x0_0400 – 0x0_0FFF3,072EEPROM Memory
0x0_1000 – 0x0_13FF1,024FTMRG reserved area
0x0_4000 – 0x0_7FFF16,284NVMRES1=1 : NVM Resource area (seeFigure25-3)
1See NVMRES description inSection25.4.3
0x2_0000 – 0x2_7FFF32,767FTMRG reserved area
0x2_8000 – 0x3_FFFF98,304P-Flash Memory
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
868Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure25-2. P-Flash Memory Map
Table25-5. Program IFR Fields
Global AddressSize
(Bytes)Field Description
0x0_4000 – 0x0_40078Reserved
0x0_4008 – 0x0_40B5174Reserved
0x0_40B6 – 0x0_40B72Version ID1
1Used to track firmware patch versions, seeSection25.4.2
0x0_40B8 – 0x0_40BF8Reserved
0x0_40C0 – 0x0_40FF64Program Once Field
Refer toSection25.4.6.6, “Program Once Command”
Flash Configuration Field
0x3_C000
Flash Protected/Unprotected Lower Region
1, 2, 4, 8 Kbytes
0x3_8000
0x3_9000
0x3_8400
0x3_8800
0x3_A000
P-Flash END = 0x3_FFFF
0x3_F800
0x3_F000
0x3_E000Flash Protected/Unprotected Higher Region
2, 4, 8, 16 Kbytes
Flash Protected/Unprotected Region
8 Kbytes (up to 29 Kbytes)
16 bytes (0x3_FF00 - 0x3_FF0F)
Flash Protected/Unprotected Region
64 Kbytes
P-Flash START = 0x2_8000
Protection
Protection
Protection
Movable End
Fixed End
Fixed End
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
870Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1NVMRES - SeeSection25.4.3 for NVMRES (NVM Resource) detail.
Global AddressSize
(Bytes)Description
0x0_4000 – 0x040FF256P-Flash IFR (seeTable25-5)
0x0_4100 – 0x0_41FF256Reserved.
0x0_4200 – 0x0_57FFReserved
0x0_5800 – 0x0_59FF512Reserved
0x0_5A00 – 0x0_5FFF1,536Reserved
0x0_6000 – 0x0_6BFF3,072Reserved
0x0_6C00 – 0x0_7FFF5,120Reserved
P-Flash IFR 1 Kbyte (NVMRES=1)
0x0_4000
RAM End = 0x0_59FF
RAM Start = 0x0_5800
Reserved 5120 bytes
Reserved 4608 bytes
0x0_6C00
0x0_7FFF
0x0_4400Reserved 5k bytes
Reserved 512 bytes
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor871
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A summary of the Flash module registers is given inFigure25-4 with detailed descriptions in the
following subsections.
Address
& Name76543210
0x0000
FCLKDIV
RFDIVLDFDIVLCKFDIV5FDIV4FDIV3FDIV2FDIV1FDIV0
W
0x0001
FSEC
RKEYEN1KEYEN0RNV5RNV4RNV3RNV2SEC1SEC0
W
0x0002
FCCOBIX
R00000CCOBIX2CCOBIX1CCOBIX0
W
0x0003
FRSV0
R00000000
W
0x0004
FCNFG
RCCIE00
IGNSF00
FDFDFSFD
W
0x0005
FERCNFG
R000000DFDIESFDIE
W
0x0006
FSTAT
RCCIF0ACCERRFPVIOLMGBUSYRSVDMGSTAT1MGSTAT0
W
0x0007
FERSTAT
R000000DFDIFSFDIF
W
0x0008
FPROT
RFPOPENRNV6FPHDISFPHS1FPHS0FPLDISFPLS1FPLS0
W
0x0009
EEPROT
RDPOPENDPS6DPS5DPS4DPS3DPS2DPS1DPS0
W
0x000A
FCCOBHI
RCCOB15CCOB14CCOB13CCOB12CCOB11CCOB10CCOB9CCOB8
W
0x000B
FCCOBLO
RCCOB7CCOB6CCOB5CCOB4CCOB3CCOB2CCOB1CCOB0
W
0x000C
FRSV1
R00000000
W
Figure25-4. FTMRG96K1 Register Summary
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
872Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.3.2.1Flash Clock Divider Register (FCLKDIV)
The FCLKDIV register is used to control timed events in program and erase algorithms.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CAUTION
The FCLKDIV register should never be written while a Flash command is
executing (CCIF=0).
Table25-7. FCLKDIV Field Descriptions
FieldDescription
7
FDIVLD
Clock Divider Loaded
0FCLKDIV register has not been written since the last reset
1FCLKDIV register has been written since the last reset
6
FDIVLCK
Clock Divider Locked
0FDIV field is open for writing
1FDIV value is locked and cannot be changed. Once the lock bit is set high, only reset can clear this bit and
restore writability to the FDIV field in normal mode.
BUSCLK frequency. Please refer toSection25.4.4, “Flash Command Operations,” for more information.
Table25-8. FDIV values for various BUSCLK Frequencies
BUSCLK Frequency
(MHz)FDIV[5:0]
BUSCLK Frequency
(MHz)FDIV[5:0]
MIN1
1BUSCLK is Greater Than this value.
MAX2
2BUSCLK is Less Than or Equal to this value.
MIN1MAX2
1.01.60x0016.617.60x10
1.62.60x0117.618.60x11
2.63.60x0218.619.60x12
3.64.60x0319.620.60x13
4.65.60x0420.621.60x14
5.66.60x0521.622.60x15
6.67.60x0622.623.60x16
7.68.60x0723.624.60x17
8.69.60x0824.625.60x18
9.610.60x09
10.611.60x0A
11.612.60x0B
12.613.60x0C
13.614.60x0D
14.615.60x0E
15.616.60x0F
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
874Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.3.2.2Flash Security Register (FSEC)
The FSEC register holds all bits associated with the security of the MCU and Flash module.
All bits in the FSEC register are readable but not writable.
During the reset sequence, the FSEC register is loaded with the contents of the Flash security byte in the
Flash configuration field at global address 0x3_FF0F located in P-Flash memory (seeTable25-4) as
indicated by reset condition F inFigure25-6. If a double bit fault is detected while reading the P-Flash
Reserved Nonvolatile Bits— The RNV bits should remain in the erased state for future enhancements.
1–0
SEC[1:0]
Flash Security Bits — The SEC[1:0] bits define the security state of the MCU as shown inTable25-11. If the
Flash module is unsecured using backdoor key access, the SEC bits are forced to 10.
Table25-10. Flash KEYEN States
KEYEN[1:0]Status of Backdoor Key Access
00DISABLED
01DISABLED1
1Preferred KEYEN state to disable backdoor key access.
10ENABLED
11DISABLED
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor875
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The security function in the Flash module is described inSection25.5.
25.3.2.3Flash CCOB Index Register (FCCOBIX)
The FCCOBIX register is used to index the FCCOB register for Flash memory operations.
CCOBIX bits are readable and writable while remaining bits read 0 and are not writable.
25.3.2.4Flash Reserved0 Register (FRSV0)
This Flash register is reserved for factory testing.
All bits in the FRSV0 register read 0 and are not writable.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All assigned bits in the FERCNFG register are readable and writable.
25.3.2.7Flash Status Register (FSTAT)
The FSTAT register reports the operational status of the Flash module.
CCIF, ACCERR, and FPVIOL bits are readable and writable, MGBUSY and MGSTAT bits are readable
but not writable, while remaining bits read 0 and are not writable.
0SFDIF interrupt disabled whenever the SFDIF flag is set (seeSection25.3.2.8)
1An interrupt will be requested whenever the SFDIF flag is set (seeSection25.3.2.8)
OffsetModule Base + 0x0006
76543210
RCCIF0ACCERRFPVIOLMGBUSYRSVDMGSTAT[1:0]
W
Reset1000000
1
1Reset value can deviate from the value shown if a double bit fault is detected during the reset sequence (seeSection25.6).
01
= Unimplemented or Reserved
Figure25-11. Flash Status Register (FSTAT)
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
878Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.3.2.8Flash Error Status Register (FERSTAT)
The FERSTAT register reflects the error status of internal Flash operations.
All flags in the FERSTAT register are readable and only writable to clear the flag.
Table25-15. FSTAT Field Descriptions
FieldDescription
7
CCIF
Command Complete Interrupt Flag — The CCIF flag indicates that a Flash command has completed. The
CCIF flag is cleared by writing a 1 to CCIF to launch a command and CCIF will stay low until command
completion or command violation.
0Flash command in progress
1Flash command has completed
5
ACCERR
Flash Access Error Flag — The ACCERR bit indicates an illegal access has occurred to the Flash memory
is detected during execution of a Flash command or during the Flash reset sequence. SeeSection25.4.6,
“Flash Command Description,” andSection25.6, “Initialization” for details.
OffsetModule Base + 0x0007
76543210
R000000
DFDIFSFDIF
W
Reset00000000
= Unimplemented or Reserved
Figure25-12. Flash Error Status Register (FERSTAT)
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor879
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.3.2.9P-Flash Protection Register (FPROT)
The FPROT register defines which P-Flash sectors are protected against program and erase operations.
command operation.1 The SFDIF flag is cleared by writing a 1 to SFDIF. Writing a 0 to SFDIF has no effect on
SFDIF.
0No single bit fault detected
1Single bit fault detected and corrected or a Flash array read operation returning invalid data was attempted
while command running
OffsetModule Base + 0x0008
76543210
RFPOPENRNV6FPHDISFPHS[1:0]FPLDISFPLS[1:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
= Unimplemented or Reserved
Figure25-13. Flash Protection Register (FPROT)
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
880Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
in P-Flash memory as shown inTable25-20. The FPLS bits can only be written to while the FPLDIS bit is set.
Table25-18. P-Flash Protection Function
FPOPENFPHDISFPLDISFunction1
1For range sizes, refer toTable25-19 andTable25-20.
111No P-Flash Protection
110Protected Low Range
101Protected High Range
100Protected High and Low Ranges
011Full P-Flash Memory Protected
010Unprotected Low Range
001Unprotected High Range
000Unprotected High and Low Ranges
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor881
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All possible P-Flash protection scenarios are shown inFigure25-14 . Although the protection scheme is
loaded from the Flash memory at global address 0x3_FF0C during the reset sequence, it can be changed
chip mode while providing as much protection as possible if reprogramming is not required.
Table25-19. P-Flash Protection Higher Address Range
FPHS[1:0] Global Address RangeProtected Size
000x3_F800–0x3_FFFF2 Kbytes
010x3_F000–0x3_FFFF4 Kbytes
100x3_E000–0x3_FFFF8 Kbytes
110x3_C000–0x3_FFFF16 Kbytes
Table25-20. P-Flash Protection Lower Address Range
FPLS[1:0]Global Address RangeProtected Size
000x3_8000–0x3_83FF1 Kbyte
010x3_8000–0x3_87FF2 Kbytes
100x3_8000–0x3_8FFF4 Kbytes
110x3_8000–0x3_9FFF8 Kbytes
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
882Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure25-14. P-Flash Protection Scenarios
7654
FPHS[1:0]FPLS[1:0]
3210
FPHS[1:0]FPLS[1:0]
FPHDIS = 1
FPLDIS = 1
FPHDIS = 1
FPLDIS = 0
FPHDIS = 0
FPLDIS = 1
FPHDIS = 0
FPLDIS = 0
Scenario
Scenario
Unprotected regionProtected region with size
Protected regionProtected region with size
defined by FPLS
defined by FPHSnot defined by FPLS, FPHS
0x3_8000
0x3_FFFF
0x3_8000
0x3_FFFF
FLASH START
FLASH START
FPOPEN = 1FPOPEN = 0
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor883
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1Allowed transitions marked with X, seeFigure25-14 for a definition of the scenarios.
01234567
0XXXX
1XX
2XX
3X
4XX
5XXXX
6XXXX
7XXXXXXXX
OffsetModule Base + 0x0009
76543210
RDPOPENDPS[6:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
Figure25-15. EEPROM Protection Register (EEPROT)
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
884Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
P-Flash memory (seeTable25-4) as indicated by reset condition F inTable25-23. To change the
EEPROM protection that will be loaded during the reset sequence, the P-Flash sector containing the
1Disables EEPROM memory protection from program and erase
6–0
DPS[6:0]
EEPROM Protection Size — The DPS[6:0] bits determine the size of the protected area in the EEPROM
memory, this size increase in step of 32 bytes, as shown inTable25-23 .
Table25-23. EEPROM Protection Address Range
DPS[6:0] Global Address RangeProtected Size
00000000x0_0400 – 0x0_041F32 bytes
00000010x0_0400 – 0x0_043F64 bytes
00000100x0_0400 – 0x0_045F96 bytes
00000110x0_0400 – 0x0_047F128 bytes
00001000x0_0400 – 0x0_049F160 bytes
00001010x0_0400 – 0x0_04BF192 bytes
The Protection Size goes on enlarging in step of 32 bytes, for each DPS value
increasing of one.
.
.
.
1011111 - to - 11111110x0_0400 – 0x0_0FFF3,072 bytes
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor885
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.3.2.11Flash Common Command Object Register (FCCOB)
The FCCOB is an array of six words addressed via the CCOBIX index found in the FCCOBIX register.
Byte wide reads and writes are allowed to the FCCOB register.
25.3.2.11.1FCCOB - NVM Command Mode
NVM command mode uses the indexed FCCOB register to provide a command code and its relevant
parameters to the Memory Controller. The user first sets up all required FCCOB fields and then initiates
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.3.2.12Flash Reserved1 Register (FRSV1)
This Flash register is reserved for factory testing.
All bits in the FRSV1 register read 0 and are not writable.
25.3.2.13Flash Reserved2 Register (FRSV2)
This Flash register is reserved for factory testing.
All bits in the FRSV2 register read 0 and are not writable.
25.3.2.14Flash Reserved3 Register (FRSV3)
This Flash register is reserved for factory testing.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All bits in the FRSV3 register read 0 and are not writable.
25.3.2.15Flash Reserved4 Register (FRSV4)
This Flash register is reserved for factory testing.
All bits in the FRSV4 register read 0 and are not writable.
25.3.2.16Flash Option Register (FOPT)
The FOPT register is the Flash option register.
All bits in the FOPT register are readable but are not writable.
During the reset sequence, the FOPT register is loaded from the Flash nonvolatile byte in the Flash
configuration field at global address 0x3_FF0E located in P-Flash memory (seeTable25-4) as indicated
by reset condition F inFigure25-22. If a double bit fault is detected while reading the P-Flash phrase
containing the Flash nonvolatile byte during the reset sequence, all bits in the FOPT register will be set.
OffsetModule Base + 0x000E
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure25-20. Flash Reserved3 Register (FRSV3)
OffsetModule Base + 0x000F
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure25-21. Flash Reserved4 Register (FRSV4)
OffsetModule Base + 0x0010
76543210
RNV[7:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
= Unimplemented or Reserved
Figure25-22. Flash Option Register (FOPT)
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
888Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.3.2.17Flash Reserved5 Register (FRSV5)
This Flash register is reserved for factory testing.
All bits in the FRSV5 register read 0 and are not writable.
25.3.2.18Flash Reserved6 Register (FRSV6)
This Flash register is reserved for factory testing.
All bits in the FRSV6 register read 0 and are not writable.
25.3.2.19Flash Reserved7 Register (FRSV7)
This Flash register is reserved for factory testing.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All bits in the FRSV7 register read 0 and are not writable.
25.4Functional Description
25.4.1Modes of Operation
The FTMRG96K1 module provides the modes of operation normal and special . The operating mode is
determined by module-level inputs and affects the FCLKDIV, FCNFG, and EEPROT registers (see
Table25-27).
25.4.2IFR Version ID Word
The version ID word is stored in the IFR at address 0x0_40B6. The contents of the word are defined in
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.4.3Internal NVM resource (NVMRES)
IFR is an internal NVM resource readable by CPU , when NVMRES is active. The IFR fields are shown
inTable25-5.
The NVMRES global address map is shown inTable25-6.
25.4.4Flash Command Operations
Flash command operations are used to modify Flash memory contents.
The next sections describe:
•How to write the FCLKDIV register that is used to generate a time base (FCLK) derived from
BUSCLK for Flash program and erase command operations
•The command write sequence used to set Flash command parameters and launch execution
•Valid Flash commands available for execution, according to MCU functional mode and MCU
security state.
25.4.4.1Writing the FCLKDIV Register
Prior to issuing any Flash program or erase command after a reset, the user is required to write the
sequence. If CCIF is 0, the previous command write sequence is still active, a new command write
sequence cannot be started, and all writes to the FCCOB register are ignored.
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor891
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.4.4.2.1Define FCCOB Contents
The FCCOB parameter fields must be loaded with all required parameters for the Flash command being
executed. Access to the FCCOB parameter fields is controlled via the CCOBIX bits in the FCCOBIX
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.4.4.3Valid Flash Module Commands
Table25-27 present the valid Flash commands, as enabled by the combination of the functional MCU
Table25-28 summarizes the valid P-Flash commands along with the effects of the commands on the
P-Flash block and other resources within the Flash module.
Table25-27. Flash Commands by Mode and Security State
FCMDCommand
UnsecuredSecured
NS1
1Unsecured Normal Single Chip mode
SS2
2Unsecured Special Single Chip mode.
NS3
3Secured Normal Single Chip mode.
SS4
4Secured Special Single Chip mode.
0x01Erase Verify All Blocks∗∗∗∗
0x02Erase Verify Block∗∗∗∗
0x03Erase Verify P-Flash Section∗∗∗
0x04Read Once∗∗∗
0x06Program P-Flash∗∗∗
0x07Program Once∗∗∗
0x08Erase All Blocks∗∗
0x09Erase Flash Block∗∗∗
0x0AErase P-Flash Sector∗∗∗
0x0BUnsecure Flash∗∗
0x0CVerify Backdoor Access Key∗∗
0x0DSet User Margin Level∗∗∗
0x0ESet Field Margin Level∗
0x10Erase Verify EEPROM Section∗∗∗
0x11Program EEPROM∗∗∗
0x12Erase EEPROM Sector∗∗∗
Table25-28. P-Flash Commands
FCMDCommandFunction on P-Flash Memory
0x01Erase Verify All
Blocks
Verify that all P-Flash (and EEPROM) blocks are erased.
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
894Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.4.4.5EEPROM Commands
Table25-29 summarizes the valid EEPROM commands along with the effects of the commands on the
EEPROM block.
0x02Erase Verify BlockVerify that a P-Flash block is erased.
0x03Erase Verify
P-Flash Section
Verify that a given number of words starting at the address provided are erased.
bits in the FPROT register are set prior to launching the command.
0x0AErase P-Flash
Sector
Erase all bytes in a P-Flash sector.
0x0BUnsecure FlashSupports a method of releasing MCU security by erasing all P-Flash (and EEPROM)
blocks and verifying that all P-Flash (and EEPROM) blocks are erased.
0x0CVerify Backdoor
Access Key
Supports a method of releasing MCU security by verifying a set of security keys.
0x0DSet User Margin
Level
Specifies a user margin read level for all P-Flash blocks.
0x0ESet Field Margin
Level
Specifies a field margin read level for all P-Flash blocks (special modes only).
Table25-29. EEPROM Commands
FCMDCommandFunction on EEPROM Memory
0x01Erase Verify All
Blocks
Verify that all EEPROM (and P-Flash) blocks are erased.
0x02Erase Verify BlockVerify that the EEPROM block is erased.
Table25-28. P-Flash Commands
FCMDCommandFunction on P-Flash Memory
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor895
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.4.5Allowed Simultaneous P-Flash and EEPROM Operations
Only the operations marked ‘OK’ inTable25-30 are permitted to be run simultaneously on the Program
2The ‘Mass Erase’ operations are commands ‘Erase All Blocks’ and ‘Erase
Flash Block’
OK
Table25-29. EEPROM Commands
FCMDCommandFunction on EEPROM Memory
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
896Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MGSTAT0Set if any non-correctable errors have been encountered during the read1 or if
blank check failed.
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor897
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.4.6.2Erase Verify Block Command
The Erase Verify Block command allows the user to verify that an entire P-Flash or EEPROM block has
been erased. The FCCOB FlashBlockSelectionCode[1:0] bits determine which block must be verified.
Upon clearing CCIF to launch the Erase Verify Block command, the Memory Controller will verify that
the selected P-Flash or EEPROM block is erased. The CCIF flag will set after the Erase Verify Block
MGSTAT0Set if any non-correctable errors have been encountered during the read2 or if
blank check failed.
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
898Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.4.6.3Erase Verify P-Flash Section Command
The Erase Verify P-Flash Section command will verify that a section of code in the P-Flash memory is
MGSTAT0Set if any non-correctable errors have been encountered during the read2 or if
blank check failed.
Table25-38. Read Once Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x04Not Required
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor899
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A P-Flash phrase must be in the erased state before being programmed.
Cumulative programming of bits within a Flash phrase is not allowed.
001Read Once phrase index (0x0000 - 0x0007)
010Read Once word 0 value
011Read Once word 1 value
100Read Once word 2 value
101Read Once word 3 value
Table25-39. Read Once Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 001 at command launch
Set if command not available in current mode (seeTable25-27)
Set if an invalid phrase index is supplied
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read
MGSTAT0Set if any non-correctable errors have been encountered during the read
Table25-40. Program P-Flash Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x06Global address [17:16] to
identify P-Flash block
001Global address [15:0] of phrase location to be programmed1
010Word 0 program value
011Word 1 program value
100Word 2 program value
101Word 3 program value
Table25-38. Read Once Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
900Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Program P-Flash command, the Memory Controller will program the
data words to the supplied global address and will then proceed to verify the data words read back as
expected. The CCIF flag will set after the Program P-Flash operation has completed.
25.4.6.6Program Once Command
The Program Once command restricts programming to a reserved 64 byte field (8 phrases) in the
Table25-41. Program P-Flash Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 101 at command launch
Set if command not available in current mode (seeTable25-27)
Set if an invalid global address [17:0] is supplied seeTable25-3)1
1As defined by the memory map for FTMRG96K1.
Set if a misaligned phrase address is supplied (global address [2:0] != 000)
FPVIOLSet if the global address [17:0] points to a protected area
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
Table25-42. Program Once Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x07Not Required
001Program Once phrase index (0x0000 - 0x0007)
010Program Once word 0 value
011Program Once word 1 value
100Program Once word 2 value
101Program Once word 3 value
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor901
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Set if command not available in current mode (seeTable25-27)
Set if an invalid phrase index is supplied
Set if the requested phrase has already been programmed1
1If a Program Once phrase is initially programmed to 0xFFFF_FFFF_FFFF_FFFF, the Program Once command will
be allowed to execute again on that same phrase.
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
Table25-44. Erase All Blocks Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x08Not required
Table25-45. Erase All Blocks Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERRSet if CCOBIX[2:0] != 000 at command launch
Set if command not available in current mode (seeTable25-27)
FPVIOLSet if any area of the P-Flash or EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation1
1As found in the memory map for FTMRG96K1.
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation1
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
902Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.4.6.8Erase Flash Block Command
The Erase Flash Block operation will erase all addresses in a P-Flash or EEPROM block.
Upon clearing CCIF to launch the Erase Flash Block command, the Memory Controller will erase the
selected Flash block and verify that it is erased. The CCIF flag will set after the Erase Flash Block
operation has completed.
25.4.6.9Erase P-Flash Sector Command
The Erase P-Flash Sector operation will erase all addresses in a P-Flash sector.
Upon clearing CCIF to launch the Erase P-Flash Sector command, the Memory Controller will erase the
selected Flash sector and then verify that it is erased. The CCIF flag will be set after the Erase P-Flash
001Global address [15:0] anywhere within the sector to be erased.
Refer toSection25.1.2.1 for the P-Flash sector size.
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor903
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Set if command not available in current mode (seeTable25-27)
FPVIOLSet if any area of the P-Flash or EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation1
1As found in the memory map for FTMRG96K1.
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation1
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
904Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.4.6.11Verify Backdoor Access Key Command
The Verify Backdoor Access Key command will only execute if it is enabled by the KEYEN bits in the
FSEC register (seeTable25-10). The Verify Backdoor Access Key command releases security if
user-supplied keys match those stored in the Flash security bytes of the Flash configuration field (see
Table25-4). The Verify Backdoor Access Key command must not be executed from the Flash block
containing the backdoor comparison key to avoid code runaway.
Upon clearing CCIF to launch the Verify Backdoor Access Key command, the Memory Controller will
check the FSEC KEYEN bits to verify that this command is enabled. If not enabled, the Memory
Controller sets the ACCERR bit in the FSTAT register and terminates. If the command is enabled, the
Memory Controller compares the key provided in FCCOB to the backdoor comparison key in the Flash
configuration field with Key 0 compared to 0x3_FF00, etc. If the backdoor keys match, security will be
Set if backdoor key access has not been enabled (KEYEN[1:0] != 10, see
Section25.3.2.2)
Set if the backdoor key has mismatched since the last reset
FPVIOLNone
MGSTAT1None
MGSTAT0None
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor905
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Set User Margin Level command, the Memory Controller will set the
user margin level for the targeted block and then set the CCIF flag.
Valid margin level settings for the Set User Margin Level command are defined inTable25-55.
Table25-54. Set User Margin Level Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x0DFlash block selection code [1:0]. See
Table25-34
001Margin level setting.
Table25-55. Valid Set User Margin Level Settings
CCOB
(CCOBIX=001)Level Description
0x0000Return to Normal Level
0x0001User Margin-1 Level1
1Read margin to the erased state
0x0002User Margin-0 Level2
2Read margin to the programmed state
Table25-56. Set User Margin Level Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 001 at command launch
Set if command not available in current mode (seeTable25-27)
Set if an invalid FlashBlockSelectionCode[1:0] is supplied (SeeTable25-34 )
Set if an invalid margin level setting is supplied
FPVIOLNone
MGSTAT1None
MGSTAT0None
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
906Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NOTE
User margin levels can be used to check that Flash memory contents have
Valid margin level settings for the Set Field Margin Level command are defined inTable25-58.
Table25-57. Set Field Margin Level Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x0EFlash block selection code [1:0]. See
Table25-34
001Margin level setting.
Table25-58. Valid Set Field Margin Level Settings
CCOB
(CCOBIX=001)Level Description
0x0000Return to Normal Level
0x0001User Margin-1 Level1
1Read margin to the erased state
0x0002User Margin-0 Level2
2Read margin to the programmed state
0x0003Field Margin-1 Level1
0x0004Field Margin-0 Level2
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor907
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CAUTION
Field margin levels must only be used during verify of the initial factory
programming.
NOTE
Field margin levels can be used to check that Flash memory contents have
001Global address [15:0] of the first word to be verified
010Number of words to be verified
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
908Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.4.6.15Program EEPROM Command
The Program EEPROM operation programs one to four previously erased words in the EEPROM block.
Set if command not available in current mode (seeTable25-27)
Set if an invalid global address [17:0] is supplied
Set if a misaligned word address is supplied (global address [0] != 0)
Set if the requested section breaches the end of the EEPROM block
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
Table25-62. Program EEPROM Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x11Global address [17:16] to
identify the EEPROM block
001Global address [15:0] of word to be programmed
010Word 0 program value
011Word 1 program value, if desired
100Word 2 program value, if desired
101Word 3 program value, if desired
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor909
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.4.6.16Erase EEPROM Sector Command
The Erase EEPROM Sector operation will erase all addresses in a sector of the EEPROM block.
Set if command not available in current mode (seeTable25-27)
Set if an invalid global address [17:0] is suppliedseeTable25-3)
Set if a misaligned word address is supplied (global address [0] != 0)
FPVIOLSet if the selected area of the EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
910Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.4.7Interrupts
The Flash module can generate an interrupt when a Flash command operation has completed or when a
Flash command operation has detected an ECC fault.
NOTE
Vector addresses and their relative interrupt priority are determined at the
MCU level.
25.4.7.1Description of Flash Interrupt Operation
The Flash module uses the CCIF flag in combination with the CCIE interrupt enable bit to generate the
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
25.4.8Wait Mode
The Flash module is not affected if the MCU enters wait mode. The Flash module can recover the MCU
from wait via the CCIF interrupt (seeSection25.4.7, “Interrupts”).
Access Key command match the backdoor keys stored in the Flash memory, the SEC bits in the FSEC
register (seeTable25-11) will be changed to unsecure the MCU. Key values of 0x0000 and 0xFFFF are
not permitted as backdoor keys. While the Verify Backdoor Access Key command is active, P-Flash
memory and EEPROM memory will not be available for read access and will return invalid data.
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
912Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
7.Send BDM commands to execute the Program P-Flash command write sequence to program the
Flash security byte to the unsecured state
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor913
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
8.Reset the MCU
25.5.3Mode and Security Effects on Flash Command Availability
The availability of Flash module commands depends on the MCU operating mode and security state as
state of the word being programmed or the sector/block being erased is not guaranteed.
96 KByte Flash Module (S12FTMRG96K1V1)
MC9S12G Family Reference Manual,Rev.1.06
914Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor915
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter26
128 KByte Flash Module (S12FTMRG128K1V1)
26.1Introduction
The FTMRG128K1 module implements the following:
•128Kbytes of P-Flash (Program Flash) memory
•4 Kbytes of EEPROM memory
The Flash memory is ideal for single-supply applications allowing for field reprogramming without
requiring external high voltage sources for program or erase operations. The Flash module includes a
memory controller that executes commands to modify Flash memory contents. The user interface to the
memory controller consists of the indexed Flash Common Command Object (FCCOB) register which is
written to with the command, global address, data, and any required command parameters. The memory
Updated description of the commands RD1BLK, MLOADU and MLOADF
Rev.1.0631 Jan 201126.3.2.9/26-932Updated description of protection onSection26.3.2.9
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor916
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The Flash memory may be read as bytes and aligned words. Read access time is one bus cycle for bytes
and aligned words. For misaligned words access, the CPU has to perform twice the byte read access
command. For Flash memory, an erased bit reads 1 and a programmed bit reads 0.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Single bit fault correction and double bit fault detection within a 32-bit double word during read
operations
•Automated program and erase algorithm with verify and generation of ECC parity bits
•Fast sector erase and phrase program operation
•Ability to read the P-Flash memory while programming a word in the EEPROM memory
•Flexible protection scheme to prevent accidental program or erase of P-Flash memory
•Single bit fault correction and double bit fault detection within a word during read operations
•Automated program and erase algorithm with verify and generation of ECC parity bits
•Fast sector erase and word program operation
•Protection scheme to prevent accidental program or erase of EEPROM memory
•Ability to program up to four words in a burst sequence
26.1.2.3Other Flash Module Features
•No external high-voltage power supply required for Flash memory program and erase operations
•Interrupt generation on Flash command completion and Flash error detection
•Security mechanism to prevent unauthorized access to the Flash memory
26.1.3Block Diagram
The block diagram of the Flash module is shown inFigure26-1.
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
918Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure26-1. FTMRG128K1 Block Diagram
26.2External Signal Description
The Flash module contains no signals that connect off-chip.
Bus
Clock
Divider
Clock
Command
Interrupt
Request
FCLK
Protection
Security
Registers
Flash
Interface
16bit
internal
bus
sector 0
sector 1
sector 255
32Kx39
P-Flash
Error
Interrupt
Request
CPU
sector 0
sector 1
sector 1023
2Kx22
EEPROM
Memory Controller
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor919
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
in the Flash module will be ignored by the Flash module.
CAUTION
Writing to the Flash registers while a Flash command is executing (that is
indicated when the value of flag CCIF reads as ’0’) is not allowed. If such
action is attempted the write operation will not change the register value.
Writing to the Flash registers is allowed when the Flash is not busy
executing commands (CCIF = 1) and during initialization right after reset,
despite the value of flag CCIF in that case (refer toSection26.6 for a
complete description of the reset sequence).
.
26.3.1Module Memory Map
The S12 architecture places the P-Flash memory between global addresses 0x2_0000 and 0x3_FFFF as
shown inTable26-3.The P-Flash memory map is shown inFigure26-2.
Table26-2. FTMRG Memory Map
Global Address (in Bytes)Size
(Bytes)Description
0x0_0000 - 0x0_03FF1,024Register Space
0x0_0400 – 0x0_13FF4,096EEPROM Memory
0x0_4000 – 0x0_7FFF16,284NVMRES1=1 : NVM Resource area (seeFigure26-3)
1See NVMRES description inSection26.4.3
0x2_0000 – 0x3_FFFF131,072P-Flash Memory
Table26-3. P-Flash Memory Addressing
Global AddressSize
(Bytes)Description
0x2_0000 – 0x3_FFFF128 K
P-Flash Block
Contains Flash Configuration Field
(seeTable26-4)
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
920Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure26-2. P-Flash Memory Map
Table26-5. Program IFR Fields
Global AddressSize
(Bytes)Field Description
0x0_4000 – 0x0_40078Reserved
0x0_4008 – 0x0_40B5174Reserved
0x0_40B6 – 0x0_40B72Version ID1
Flash Configuration Field
0x3_C000
Flash Protected/Unprotected Lower Region
1, 2, 4, 8 Kbytes
0x3_8000
0x3_9000
0x3_8400
0x3_8800
0x3_A000
P-Flash END = 0x3_FFFF
0x3_F800
0x3_F000
0x3_E000Flash Protected/Unprotected Higher Region
2, 4, 8, 16 Kbytes
Flash Protected/Unprotected Region
8 Kbytes (up to 29 Kbytes)
16 bytes (0x3_FF00 - 0x3_FF0F)
Flash Protected/Unprotected Region
96 Kbytes
P-Flash START = 0x2_0000
Protection
Protection
Protection
Movable End
Fixed End
Fixed End
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
922Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1NVMRES - SeeSection26.4.3 for NVMRES (NVM Resource) detail.
Global AddressSize
(Bytes)Description
0x0_4000 – 0x040FF256P-Flash IFR (seeTable26-5)
0x0_4100 – 0x0_41FF256Reserved.
0x0_4200 – 0x0_57FFReserved
0x0_5800 – 0x0_59FF512Reserved
0x0_5A00 – 0x0_5FFF1,536Reserved
0x0_6000 – 0x0_6BFF3,072Reserved
0x0_6C00 – 0x0_7FFF5,120Reserved
Table26-5. Program IFR Fields
Global AddressSize
(Bytes)Field Description
P-Flash IFR 1 Kbyte (NVMRES=1)
0x0_4000
RAM End = 0x0_59FF
RAM Start = 0x0_5800
Reserved 5120 bytes
Reserved 4608 bytes
0x0_6C00
0x0_7FFF
0x0_4400Reserved 5k bytes
Reserved 512 bytes
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor923
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.3.2Register Descriptions
The Flash module contains a set of 20 control and status registers located between Flash module base +
A summary of the Flash module registers is given inFigure26-4 with detailed descriptions in the
following subsections.
Address
& Name76543210
0x0000
FCLKDIV
RFDIVLDFDIVLCKFDIV5FDIV4FDIV3FDIV2FDIV1FDIV0
W
0x0001
FSEC
RKEYEN1KEYEN0RNV5RNV4RNV3RNV2SEC1SEC0
W
0x0002
FCCOBIX
R00000CCOBIX2CCOBIX1CCOBIX0
W
0x0003
FRSV0
R00000000
W
0x0004
FCNFG
RCCIE00
IGNSF00
FDFDFSFD
W
0x0005
FERCNFG
R000000DFDIESFDIE
W
0x0006
FSTAT
RCCIF0ACCERRFPVIOLMGBUSYRSVDMGSTAT1MGSTAT0
W
0x0007
FERSTAT
R000000DFDIFSFDIF
W
0x0008
FPROT
RFPOPENRNV6FPHDISFPHS1FPHS0FPLDISFPLS1FPLS0
W
0x0009
DFPROT
RDPOPENDPS6DPS5DPS4DPS3DPS2DPS1DPS0
W
Figure26-4. FTMRG128K1 Register Summary
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
924Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.3.2.1Flash Clock Divider Register (FCLKDIV)
The FCLKDIV register is used to control timed events in program and erase algorithms.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
BUSCLK frequency. Please refer toSection26.4.4, “Flash Command Operations,” for more information.
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
926Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.3.2.2Flash Security Register (FSEC)
The FSEC register holds all bits associated with the security of the MCU and Flash module.
All bits in the FSEC register are readable but not writable.
During the reset sequence, the FSEC register is loaded with the contents of the Flash security byte in the
Flash configuration field at global address 0x3_FF0F located in P-Flash memory (seeTable26-4) as
Table26-8. FDIV values for various BUSCLK Frequencies
BUSCLK Frequency
(MHz)FDIV[5:0]
BUSCLK Frequency
(MHz)FDIV[5:0]
MIN1
1BUSCLK is Greater Than this value.
MAX2
2BUSCLK is Less Than or Equal to this value.
MIN1MAX2
1.01.60x0016.617.60x10
1.62.60x0117.618.60x11
2.63.60x0218.619.60x12
3.64.60x0319.620.60x13
4.65.60x0420.621.60x14
5.66.60x0521.622.60x15
6.67.60x0622.623.60x16
7.68.60x0723.624.60x17
8.69.60x0824.625.60x18
9.610.60x09
10.611.60x0A
11.612.60x0B
12.613.60x0C
13.614.60x0D
14.615.60x0E
15.616.60x0F
OffsetModule Base + 0x0001
76543210
RKEYEN[1:0]RNV[5:2]SEC[1:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
= Unimplemented or Reserved
Figure26-6. Flash Security Register (FSEC)
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor927
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
indicated by reset condition F inFigure26-6. If a double bit fault is detected while reading the P-Flash
Reserved Nonvolatile Bits— The RNV bits should remain in the erased state for future enhancements.
1–0
SEC[1:0]
Flash Security Bits — The SEC[1:0] bits define the security state of the MCU as shown inTable26-11. If the
Flash module is unsecured using backdoor key access, the SEC bits are forced to 10.
Table26-10. Flash KEYEN States
KEYEN[1:0]Status of Backdoor Key Access
00DISABLED
01DISABLED1
1Preferred KEYEN state to disable backdoor key access.
10ENABLED
11DISABLED
Table26-11. Flash Security States
SEC[1:0]Status of Security
00SECURED
01SECURED1
1Preferred SEC state to set MCU to secured state.
10UNSECURED
11SECURED
OffsetModule Base + 0x0002
76543210
R00000CCOBIX[2:0]
W
Reset00000000
= Unimplemented or Reserved
Figure26-7. FCCOB Index Register (FCCOBIX)
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
928Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CCOBIX bits are readable and writable while remaining bits read 0 and are not writable.
26.3.2.4Flash Reserved0 Register (FRSV0)
This Flash register is reserved for factory testing.
All bits in the FRSV0 register read 0 and are not writable.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.3.2.7Flash Status Register (FSTAT)
The FSTAT register reports the operational status of the Flash module.
CCIF, ACCERR, and FPVIOL bits are readable and writable, MGBUSY and MGSTAT bits are readable
but not writable, while remaining bits read 0 and are not writable.
is set, it is not possible to launch a command or start a command write sequence.
0No protection violation detected
1Protection violation detected
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor931
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.3.2.8Flash Error Status Register (FERSTAT)
The FERSTAT register reflects the error status of internal Flash operations.
All flags in the FERSTAT register are readable and only writable to clear the flag.
3
MGBUSY
Memory Controller Busy Flag— The MGBUSY flag reflects the active state of the Memory Controller.
0Memory Controller is idle
1Memory Controller is busy executing a Flash command (CCIF = 0)
2
RSVD
Reserved Bit— This bit is reserved and always reads 0.
command operation.1 The SFDIF flag is cleared by writing a 1 to SFDIF. Writing a 0 to SFDIF has no effect on
SFDIF.
0No single bit fault detected
1Single bit fault detected and corrected or a Flash array read operation returning invalid data was attempted
while command running
Table26-15. FSTAT Field Descriptions (continued)
FieldDescription
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
932Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.3.2.9P-Flash Protection Register (FPROT)
The FPROT register defines which P-Flash sectors are protected against program and erase operations.
in P-Flash memory as shown inTable26-19. The FPHS bits can only be written to while the FPHDIS bit is set.
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor933
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All possible P-Flash protection scenarios are shown inFigure26-14 . Although the protection scheme is
loaded from the Flash memory at global address 0x3_FF0C during the reset sequence, it can be changed
in P-Flash memory as shown inTable26-20. The FPLS bits can only be written to while the FPLDIS bit is set.
Table26-18. P-Flash Protection Function
FPOPENFPHDISFPLDISFunction1
1For range sizes, refer toTable26-19 andTable26-20.
111No P-Flash Protection
110Protected Low Range
101Protected High Range
100Protected High and Low Ranges
011Full P-Flash Memory Protected
010Unprotected Low Range
001Unprotected High Range
000Unprotected High and Low Ranges
Table26-19. P-Flash Protection Higher Address Range
FPHS[1:0] Global Address RangeProtected Size
000x3_F800–0x3_FFFF2 Kbytes
010x3_F000–0x3_FFFF4 Kbytes
100x3_E000–0x3_FFFF8 Kbytes
110x3_C000–0x3_FFFF16 Kbytes
Table26-20. P-Flash Protection Lower Address Range
FPLS[1:0]Global Address RangeProtected Size
000x3_8000–0x3_83FF1 Kbyte
010x3_8000–0x3_87FF2 Kbytes
100x3_8000–0x3_8FFF4 Kbytes
110x3_8000–0x3_9FFF8 Kbytes
Table26-17. FPROT Field Descriptions (continued)
FieldDescription
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
934Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure26-14. P-Flash Protection Scenarios
7654
FPHS[1:0]FPLS[1:0]
3210
FPHS[1:0]FPLS[1:0]
FPHDIS = 1
FPLDIS = 1
FPHDIS = 1
FPLDIS = 0
FPHDIS = 0
FPLDIS = 1
FPHDIS = 0
FPLDIS = 0
Scenario
Scenario
Unprotected regionProtected region with size
Protected regionProtected region with size
defined by FPLS
defined by FPHSnot defined by FPLS, FPHS
0x3_8000
0x3_FFFF
0x3_8000
0x3_FFFF
FLASH START
FLASH START
FPOPEN = 1FPOPEN = 0
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor935
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1Allowed transitions marked with X, seeFigure26-14 for a definition of the scenarios.
01234567
0XXXX
1XX
2XX
3X
4XX
5XXXX
6XXXX
7XXXXXXXX
OffsetModule Base + 0x0009
76543210
RDPOPENDPS[6:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
Figure26-15. EEPROM Protection Register (DFPROT)
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
936Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
P-Flash memory (seeTable26-4) as indicated by reset condition F inTable26-23. To change the
EEPROM protection that will be loaded during the reset sequence, the P-Flash sector containing the
1Disables EEPROM memory protection from program and erase
6–0
DPS[6:0]
EEPROM Protection Size — The DPS[6:0] bits determine the size of the protected area in the EEPROM
memory, this size increase in step of 32 bytes, as shown inTable26-23 .
Table26-23. EEPROM Protection Address Range
DPS[6:0] Global Address RangeProtected Size
00000000x0_0400 – 0x0_041F32 bytes
00000010x0_0400 – 0x0_043F64 bytes
00000100x0_0400 – 0x0_045F96 bytes
00000110x0_0400 – 0x0_047F128 bytes
00001000x0_0400 – 0x0_049F160 bytes
00001010x0_0400 – 0x0_04BF192 bytes
The Protection Size goes on enlarging in step of 32 bytes, for each DPS value
increasing of one.
.
.
.
11111110x0_0400 – 0x0_13FF4,096 bytes
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor937
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.3.2.11Flash Common Command Object Register (FCCOB)
The FCCOB is an array of six words addressed via the CCOBIX index found in the FCCOBIX register.
Byte wide reads and writes are allowed to the FCCOB register.
26.3.2.11.1FCCOB - NVM Command Mode
NVM command mode uses the indexed FCCOB register to provide a command code and its relevant
parameters to the Memory Controller. The user first sets up all required FCCOB fields and then initiates
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.3.2.12Flash Reserved1 Register (FRSV1)
This Flash register is reserved for factory testing.
All bits in the FRSV1 register read 0 and are not writable.
26.3.2.13Flash Reserved2 Register (FRSV2)
This Flash register is reserved for factory testing.
All bits in the FRSV2 register read 0 and are not writable.
26.3.2.14Flash Reserved3 Register (FRSV3)
This Flash register is reserved for factory testing.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All bits in the FRSV3 register read 0 and are not writable.
26.3.2.15Flash Reserved4 Register (FRSV4)
This Flash register is reserved for factory testing.
All bits in the FRSV4 register read 0 and are not writable.
26.3.2.16Flash Option Register (FOPT)
The FOPT register is the Flash option register.
All bits in the FOPT register are readable but are not writable.
During the reset sequence, the FOPT register is loaded from the Flash nonvolatile byte in the Flash
configuration field at global address 0x3_FF0E located in P-Flash memory (seeTable26-4) as indicated
by reset condition F inFigure26-22. If a double bit fault is detected while reading the P-Flash phrase
containing the Flash nonvolatile byte during the reset sequence, all bits in the FOPT register will be set.
OffsetModule Base + 0x000E
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure26-20. Flash Reserved3 Register (FRSV3)
OffsetModule Base + 0x000F
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure26-21. Flash Reserved4 Register (FRSV4)
OffsetModule Base + 0x0010
76543210
RNV[7:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
= Unimplemented or Reserved
Figure26-22. Flash Option Register (FOPT)
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
940Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.3.2.17Flash Reserved5 Register (FRSV5)
This Flash register is reserved for factory testing.
All bits in the FRSV5 register read 0 and are not writable.
26.3.2.18Flash Reserved6 Register (FRSV6)
This Flash register is reserved for factory testing.
All bits in the FRSV6 register read 0 and are not writable.
26.3.2.19Flash Reserved7 Register (FRSV7)
This Flash register is reserved for factory testing.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All bits in the FRSV7 register read 0 and are not writable.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.4.3Internal NVM resource (NVMRES)
IFR is an internal NVM resource readable by CPU , when NVMRES is active. The IFR fields are shown
inTable26-5.
The NVMRES global address map is shown inTable26-6.
26.4.4Flash Command Operations
Flash command operations are used to modify Flash memory contents.
The next sections describe:
•How to write the FCLKDIV register that is used to generate a time base (FCLK) derived from
BUSCLK for Flash program and erase command operations
•The command write sequence used to set Flash command parameters and launch execution
•Valid Flash commands available for execution, according to MCU functional mode and MCU
security state.
26.4.4.1Writing the FCLKDIV Register
Prior to issuing any Flash program or erase command after a reset, the user is required to write the
sequence. If CCIF is 0, the previous command write sequence is still active, a new command write
sequence cannot be started, and all writes to the FCCOB register are ignored.
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor943
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.4.4.2.1Define FCCOB Contents
The FCCOB parameter fields must be loaded with all required parameters for the Flash command being
executed. Access to the FCCOB parameter fields is controlled via the CCOBIX bits in the FCCOBIX
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.4.4.3Valid Flash Module Commands
Table26-27 present the valid Flash commands, as enabled by the combination of the functional MCU
Table26-28 summarizes the valid P-Flash commands along with the effects of the commands on the
P-Flash block and other resources within the Flash module.
Table26-27. Flash Commands by Mode and Security State
FCMDCommand
UnsecuredSecured
NS1
1Unsecured Normal Single Chip mode
SS2
2Unsecured Special Single Chip mode.
NS3
3Secured Normal Single Chip mode.
SS4
4Secured Special Single Chip mode.
0x01Erase Verify All Blocks∗∗∗∗
0x02Erase Verify Block∗∗∗∗
0x03Erase Verify P-Flash Section∗∗∗
0x04Read Once∗∗∗
0x06Program P-Flash∗∗∗
0x07Program Once∗∗∗
0x08Erase All Blocks∗∗
0x09Erase Flash Block∗∗∗
0x0AErase P-Flash Sector∗∗∗
0x0BUnsecure Flash∗∗
0x0CVerify Backdoor Access Key∗∗
0x0DSet User Margin Level∗∗∗
0x0ESet Field Margin Level∗
0x10Erase Verify EEPROM Section∗∗∗
0x11Program EEPROM∗∗∗
0x12Erase EEPROM Sector∗∗∗
Table26-28. P-Flash Commands
FCMDCommandFunction on P-Flash Memory
0x01Erase Verify All
Blocks
Verify that all P-Flash (and EEPROM) blocks are erased.
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
946Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.4.4.5EEPROM Commands
Table26-29 summarizes the valid EEPROM commands along with the effects of the commands on the
EEPROM block.
0x02Erase Verify BlockVerify that a P-Flash block is erased.
0x03Erase Verify
P-Flash Section
Verify that a given number of words starting at the address provided are erased.
bits in the FPROT register are set prior to launching the command.
0x0AErase P-Flash
Sector
Erase all bytes in a P-Flash sector.
0x0BUnsecure FlashSupports a method of releasing MCU security by erasing all P-Flash (and EEPROM)
blocks and verifying that all P-Flash (and EEPROM) blocks are erased.
0x0CVerify Backdoor
Access Key
Supports a method of releasing MCU security by verifying a set of security keys.
0x0DSet User Margin
Level
Specifies a user margin read level for all P-Flash blocks.
0x0ESet Field Margin
Level
Specifies a field margin read level for all P-Flash blocks (special modes only).
Table26-29. EEPROM Commands
FCMDCommandFunction on EEPROM Memory
0x01Erase Verify All
Blocks
Verify that all EEPROM (and P-Flash) blocks are erased.
0x02Erase Verify BlockVerify that the EEPROM block is erased.
Table26-28. P-Flash Commands
FCMDCommandFunction on P-Flash Memory
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor947
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.4.5Allowed Simultaneous P-Flash and EEPROM Operations
Only the operations marked ‘OK’ inTable26-30 are permitted to be run simultaneously on the Program
2The ‘Mass Erase’ operations are commands ‘Erase All Blocks’ and ‘Erase
Flash Block’
OK
Table26-29. EEPROM Commands
FCMDCommandFunction on EEPROM Memory
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
948Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table26-31. Erase Verify All Blocks Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x01Not required
Table26-32. Erase Verify All Blocks Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERRSet if CCOBIX[2:0] != 000 at command launch
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the reador if blank check failed .
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor949
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.4.6.2Erase Verify Block Command
The Erase Verify Block command allows the user to verify that an entire P-Flash or EEPROM block has
been erased. The FCCOB FlashBlockSelectionCode[1:0] bits determine which block must be verified.
Upon clearing CCIF to launch the Erase Verify Block command, the Memory Controller will verify that
the selected P-Flash or EEPROM block is erased. The CCIF flag will set after the Erase Verify Block
Set if an invalid FlashBlockSelectionCode[1:0] is supplied
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
950Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Erase Verify P-Flash Section command, the Memory Controller will
Set if command not available in current mode (seeTable26-27)
Set if an invalid global address [17:0] is supplied (seeTable26-3)
Set if a misaligned phrase address is supplied (global address [2:0] != 000)
Set if the requested section crosses a the P-Flash address boundary
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
Table26-38. Read Once Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x04Not Required
001Read Once phrase index (0x0000 - 0x0007)
010Read Once word 0 value
011Read Once word 1 value
100Read Once word 2 value
101Read Once word 3 value
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor951
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A P-Flash phrase must be in the erased state before being programmed.
Cumulative programming of bits within a Flash phrase is not allowed.
Upon clearing CCIF to launch the Program P-Flash command, the Memory Controller will program the
data words to the supplied global address and will then proceed to verify the data words read back as
expected. The CCIF flag will set after the Program P-Flash operation has completed.
Table26-39. Read Once Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 001 at command launch
Set if command not available in current mode (seeTable26-27)
Set if an invalid phrase index is supplied
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read
MGSTAT0Set if any non-correctable errors have been encountered during the read
Table26-40. Program P-Flash Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x06Global address [17:16] to
identify P-Flash block
001Global address [15:0] of phrase location to be programmed1
1Global address [2:0] must be 000
010Word 0 program value
011Word 1 program value
100Word 2 program value
101Word 3 program value
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
952Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.4.6.6Program Once Command
The Program Once command restricts programming to a reserved 64 byte field (8 phrases) in the
and any attempt to program one of these phrases a second time will not be allowed. Valid phrase index
values for the Program Once command range from 0x0000 to 0x0007. During execution of the Program
Once command, any attempt to read addresses within P-Flash will return invalid data.
Table26-41. Program P-Flash Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 101 at command launch
Set if command not available in current mode (seeTable26-27)
Set if an invalid global address [17:0] is supplied (seeTable26-3)
Set if a misaligned phrase address is supplied (global address [2:0] != 000)
FPVIOLSet if the global address [17:0] points to a protected area
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
Table26-42. Program Once Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x07Not Required
001Program Once phrase index (0x0000 - 0x0007)
010Program Once word 0 value
011Program Once word 1 value
100Program Once word 2 value
101Program Once word 3 value
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor953
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.4.6.7Erase All Blocks Command
The Erase All Blocks operation will erase the entire P-Flash and EEPROM memory space.
The Erase Flash Block operation will erase all addresses in a P-Flash or EEPROM block.
Table26-43. Program Once Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 101 at command launch
Set if command not available in current mode (seeTable26-27)
Set if an invalid phrase index is supplied
Set if the requested phrase has already been programmed1
1If a Program Once phrase is initially programmed to 0xFFFF_FFFF_FFFF_FFFF, the Program Once command will
be allowed to execute again on that same phrase.
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
Table26-44. Erase All Blocks Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x08Not required
Table26-45. Erase All Blocks Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERRSet if CCOBIX[2:0] != 000 at command launch
Set if command not available in current mode (seeTable26-27)
FPVIOLSet if any area of the P-Flash or EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
954Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Erase Flash Block command, the Memory Controller will erase the
selected Flash block and verify that it is erased. The CCIF flag will set after the Erase Flash Block
operation has completed.
26.4.6.9Erase P-Flash Sector Command
The Erase P-Flash Sector operation will erase all addresses in a P-Flash sector.
Upon clearing CCIF to launch the Erase P-Flash Sector command, the Memory Controller will erase the
selected Flash sector and then verify that it is erased. The CCIF flag will be set after the Erase P-Flash
001Global address [15:0] anywhere within the sector to be erased.
Refer toSection26.1.2.1 for the P-Flash sector size.
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor955
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Set if command not available in current mode (seeTable26-27)
FPVIOLSet if any area of the P-Flash or EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
956Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table26-4). The Verify Backdoor Access Key command must not be executed from the Flash block
containing the backdoor comparison key to avoid code runaway.
Upon clearing CCIF to launch the Verify Backdoor Access Key command, the Memory Controller will
check the FSEC KEYEN bits to verify that this command is enabled. If not enabled, the Memory
Controller sets the ACCERR bit in the FSTAT register and terminates. If the command is enabled, the
Memory Controller compares the key provided in FCCOB to the backdoor comparison key in the Flash
configuration field with Key 0 compared to 0x3_FF00, etc. If the backdoor keys match, security will be
Set if backdoor key access has not been enabled (KEYEN[1:0] != 10, see
Section26.3.2.2)
Set if the backdoor key has mismatched since the last reset
FPVIOLNone
MGSTAT1None
MGSTAT0None
Table26-54. Set User Margin Level Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x0DFlash block selection code [1:0]. See
Table26-34
001Margin level setting.
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor957
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Set User Margin Level command, the Memory Controller will set the
user margin level for the targeted block and then set the CCIF flag.
Table26-56. Set User Margin Level Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 001 at command launch
Set if command not available in current mode (seeTable26-27)
Set if an invalid FlashBlockSelectionCode[1:0] is supplied (SeeTable26-34 )
Set if an invalid margin level setting is supplied
FPVIOLNone
MGSTAT1None
MGSTAT0None
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
958Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.4.6.13Set Field Margin Level Command
The Set Field Margin Level command, valid in special modes only, causes the Memory Controller to set
the margin level specified for future read operations of the P-Flash or EEPROM block.
Upon clearing CCIF to launch the Set Field Margin Level command, the Memory Controller will set the
field margin level for the targeted block and then set the CCIF flag.
Valid margin level settings for the Set Field Margin Level command are defined inTable26-58.
Table26-57. Set Field Margin Level Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x0EFlash block selection code [1:0]. See
Table26-34
001Margin level setting.
Table26-58. Valid Set Field Margin Level Settings
CCOB
(CCOBIX=001)Level Description
0x0000Return to Normal Level
0x0001User Margin-1 Level1
1Read margin to the erased state
0x0002User Margin-0 Level2
2Read margin to the programmed state
0x0003Field Margin-1 Level1
0x0004Field Margin-0 Level2
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor959
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CAUTION
Field margin levels must only be used during verify of the initial factory
programming.
NOTE
Field margin levels can be used to check that Flash memory contents have
001Global address [15:0] of the first word to be verified
010Number of words to be verified
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
960Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.4.6.15Program EEPROM Command
The Program EEPROM operation programs one to four previously erased words in the EEPROM block.
Set if command not available in current mode (seeTable26-27)
Set if an invalid global address [17:0] is supplied
Set if a misaligned word address is supplied (global address [0] != 0)
Set if the requested section breaches the end of the EEPROM block
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
Table26-62. Program EEPROM Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x11Global address [17:16] to
identify the EEPROM block
001Global address [15:0] of word to be programmed
010Word 0 program value
011Word 1 program value, if desired
100Word 2 program value, if desired
101Word 3 program value, if desired
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor961
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.4.6.16Erase EEPROM Sector Command
The Erase EEPROM Sector operation will erase all addresses in a sector of the EEPROM block.
Set if command not available in current mode (seeTable26-27)
Set if an invalid global address [17:0] is supplied (seeTable26-3)
Set if a misaligned word address is supplied (global address [0] != 0)
FPVIOLSet if the selected area of the EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
962Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.4.7Interrupts
The Flash module can generate an interrupt when a Flash command operation has completed or when a
Flash command operation has detected an ECC fault.
NOTE
Vector addresses and their relative interrupt priority are determined at the
MCU level.
26.4.7.1Description of Flash Interrupt Operation
The Flash module uses the CCIF flag in combination with the CCIE interrupt enable bit to generate the
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
26.4.8Wait Mode
The Flash module is not affected if the MCU enters wait mode. The Flash module can recover the MCU
from wait via the CCIF interrupt (seeSection26.4.7, “Interrupts”).
Access Key command match the backdoor keys stored in the Flash memory, the SEC bits in the FSEC
register (seeTable26-11) will be changed to unsecure the MCU. Key values of 0x0000 and 0xFFFF are
not permitted as backdoor keys. While the Verify Backdoor Access Key command is active, P-Flash
memory and EEPROM memory will not be available for read access and will return invalid data.
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
964Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
7.Send BDM commands to execute the Program P-Flash command write sequence to program the
Flash security byte to the unsecured state
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor965
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
8.Reset the MCU
26.5.3Mode and Security Effects on Flash Command Availability
The availability of Flash module commands depends on the MCU operating mode and security state as
state of the word being programmed or the sector/block being erased is not guaranteed.
128 KByte Flash Module (S12FTMRG128K1V1)
MC9S12G Family Reference Manual,Rev.1.06
966Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor967
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter27
192 KByte Flash Module (S12FTMRG192K2V1)
27.1Introduction
The FTMRG192K2 module implements the following:
•192Kbytes of P-Flash (Program Flash) memory
•4Kbytes of EEPROM memory
The Flash memory is ideal for single-supply applications allowing for field reprogramming without
requiring external high voltage sources for program or erase operations. The Flash module includes a
memory controller that executes commands to modify Flash memory contents. The user interface to the
memory controller consists of the indexed Flash Common Command Object (FCCOB) register which is
written to with the command, global address, data, and any required command parameters. The memory
A Flash word or phrase must be in the erased state before being
programmed. Cumulative programming of bits within a Flash word or
phrase is not allowed.
Table27-1. Revision History
Revision
Number
Revision
Date
Sections
AffectedDescription of Changes
V01.0623 Jun 201027.4.6.2/27-100
1
27.4.6.12/27-10
08
27.4.6.13/27-10
09
Updated description of the commands RD1BLK, MLOADU and MLOADF
V01.0720 aug 201027.4.6.2/27-100
1
27.4.6.12/27-10
08
27.4.6.13/27-10
09
Updated description of the commands RD1BLK, MLOADU and MLOADF
Rev.1.0631 Jan 201127.3.2.9/27-984Updated description of protection onSection27.3.2.9
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor968
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The Flash memory may be read as bytes and aligned words. Read access time is one bus cycle for bytes
and aligned words. For misaligned words access, the CPU has to perform twice the byte read access
command. For Flash memory, an erased bit reads 1 and a programmed bit reads 0.
P-Flash Sector— The P-Flash sector is the smallest portion of the P-Flash memory that can be erased.
Each P-Flash sector contains 512 bytes.
Program IFR— Nonvolatile information register located in the P-Flash block that contains the Version
ID, and the Program Once field.
27.1.2Features
27.1.2.1P-Flash Features
•192 Kbytes of P-Flash memory divided into 384 sectors of 512 bytes
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor969
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Single bit fault correction and double bit fault detection within a 32-bit double word during read
operations
•Automated program and erase algorithm with verify and generation of ECC parity bits
•Fast sector erase and phrase program operation
•Ability to read the P-Flash memory while programming a word in the EEPROM memory
•Flexible protection scheme to prevent accidental program or erase of P-Flash memory
•Single bit fault correction and double bit fault detection within a word during read operations
•Automated program and erase algorithm with verify and generation of ECC parity bits
•Fast sector erase and word program operation
•Protection scheme to prevent accidental program or erase of EEPROM memory
•Ability to program up to four words in a burst sequence
27.1.2.3Other Flash Module Features
•No external high-voltage power supply required for Flash memory program and erase operations
•Interrupt generation on Flash command completion and Flash error detection
•Security mechanism to prevent unauthorized access to the Flash memory
27.1.3Block Diagram
The block diagram of the Flash module is shown inFigure27-1.
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
970Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure27-1. FTMRG192K2 Block Diagram
27.2External Signal Description
The Flash module contains no signals that connect off-chip.
Bus
Clock
Divider
Clock
Command
Interrupt
Request
FCLK
Protection
Security
Registers
Flash
Interface
16bit
internal
bus
sector 0
sector 1
sector 383
48Kx39
P-Flash
Error
Interrupt
Request
CPU
sector 0
sector 1
sector 1023
2Kx22
EEPROM
Memory Controller
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor971
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
in the Flash module will be ignored by the Flash module.
CAUTION
Writing to the Flash registers while a Flash command is executing (that is
indicated when the value of flag CCIF reads as ’0’) is not allowed. If such
action is attempted the write operation will not change the register value.
Writing to the Flash registers is allowed when the Flash is not busy
executing commands (CCIF = 1) and during initialization right after reset,
despite the value of flag CCIF in that case (refer toSection27.6 for a
complete description of the reset sequence).
.
27.3.1Module Memory Map
The S12 architecture places the P-Flash memory between global addresses 0x1_0000 and 0x3_FFFF as
shown inTable27-3 .The P-Flash memory map is shown inFigure27-2.
Table27-2. FTMRG Memory Map
Global Address (in Bytes)Size
(Bytes)Description
0x0_0000 - 0x0_03FF1,024Register Space
0x0_0400 – 0x0_13FF4,096EEPROM Memory
0x0_4000 – 0x0_7FFF16,284NVMRES1=1 : NVM Resource area (seeFigure27-3)
1See NVMRES description inSection27.4.3
0x0_4000 – 0x0_FFFF49,152FTMRG reserved area
0x1_0000 – 0x3_FFFF196,608P-Flash Memory
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
972Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure27-2. P-Flash Memory Map
Table27-5. Program IFR Fields
Global AddressSize
(Bytes)Field Description
0x0_4000 – 0x0_40078Reserved
0x0_4008 – 0x0_40B5174Reserved
0x0_40B6 – 0x0_40B72Version ID1
Flash Configuration Field
0x3_C000
Flash Protected/Unprotected Lower Region
1, 2, 4, 8 Kbytes
0x3_8000
0x3_9000
0x3_8400
0x3_8800
0x3_A000
P-Flash END = 0x3_FFFF
0x3_F800
0x3_F000
0x3_E000Flash Protected/Unprotected Higher Region
2, 4, 8, 16 Kbytes
Flash Protected/Unprotected Region
8 Kbytes (up to 29 Kbytes)
16 bytes (0x3_FF00 - 0x3_FF0F)
Flash Protected/Unprotected Region
160 Kbytes
P-Flash START = 0x1_0000
Protection
Protection
Protection
Movable End
Fixed End
Fixed End
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
974Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1NVMRES - SeeSection27.4.3 for NVMRES (NVM Resource) detail.
Global AddressSize
(Bytes)Description
0x0_4000 – 0x040FF256P-Flash IFR (seeTable27-5)
0x0_4100 – 0x0_41FF256Reserved.
0x0_4200 – 0x0_57FFReserved
0x0_5800 – 0x0_5AFF768Reserved
0x0_5B00 – 0x0_5FFF1,280Reserved
0x0_6000 – 0x0_67FF2,048Reserved
0x0_6800 – 0x0_7FFF6,144Reserved
Table27-5. Program IFR Fields
Global AddressSize
(Bytes)Field Description
P-Flash IFR 128 bytes (NVMRES=1)
0x0_4000
Reserved 6144 bytes
Reserved 3328 bytes
0x0_6800
0x0_7FFF
0x0_4100
Reserved 5632 bytes
Reserved 768 bytes
0x0_4200
Reserved 128 bytes
0x0_5800
0x0_5AFF
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor975
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.3.2Register Descriptions
The Flash module contains a set of 20 control and status registers located between Flash module base +
A summary of the Flash module registers is given inFigure27-4 with detailed descriptions in the
following subsections.
Address
& Name76543210
0x0000
FCLKDIV
RFDIVLDFDIVLCKFDIV5FDIV4FDIV3FDIV2FDIV1FDIV0
W
0x0001
FSEC
RKEYEN1KEYEN0RNV5RNV4RNV3RNV2SEC1SEC0
W
0x0002
FCCOBIX
R00000CCOBIX2CCOBIX1CCOBIX0
W
0x0003
FRSV0
R00000000
W
0x0004
FCNFG
RCCIE00
IGNSF00
FDFDFSFD
W
0x0005
FERCNFG
R000000DFDIESFDIE
W
0x0006
FSTAT
RCCIF0ACCERRFPVIOLMGBUSYRSVDMGSTAT1MGSTAT0
W
0x0007
FERSTAT
R000000DFDIFSFDIF
W
0x0008
FPROT
RFPOPENRNV6FPHDISFPHS1FPHS0FPLDISFPLS1FPLS0
W
0x0009
EEPROT
RDPOPENDPS6DPS5DPS4DPS3DPS2DPS1DPS0
W
Figure27-4. FTMRG192K2 Register Summary
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
976Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.3.2.1Flash Clock Divider Register (FCLKDIV)
The FCLKDIV register is used to control timed events in program and erase algorithms.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
BUSCLK frequency. Please refer toSection27.4.4, “Flash Command Operations,” for more information.
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
978Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.3.2.2Flash Security Register (FSEC)
The FSEC register holds all bits associated with the security of the MCU and Flash module.
All bits in the FSEC register are readable but not writable.
During the reset sequence, the FSEC register is loaded with the contents of the Flash security byte in the
Flash configuration field at global address 0x3_FF0F located in P-Flash memory (seeTable27-4) as
Table27-8. FDIV values for various BUSCLK Frequencies
BUSCLK Frequency
(MHz)FDIV[5:0]
BUSCLK Frequency
(MHz)FDIV[5:0]
MIN1
1BUSCLK is Greater Than this value.
MAX2
2BUSCLK is Less Than or Equal to this value.
MIN1MAX2
1.01.60x0016.617.60x10
1.62.60x0117.618.60x11
2.63.60x0218.619.60x12
3.64.60x0319.620.60x13
4.65.60x0420.621.60x14
5.66.60x0521.622.60x15
6.67.60x0622.623.60x16
7.68.60x0723.624.60x17
8.69.60x0824.625.60x18
9.610.60x09
10.611.60x0A
11.612.60x0B
12.613.60x0C
13.614.60x0D
14.615.60x0E
15.616.60x0F
OffsetModule Base + 0x0001
76543210
RKEYEN[1:0]RNV[5:2]SEC[1:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
= Unimplemented or Reserved
Figure27-6. Flash Security Register (FSEC)
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor979
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
indicated by reset condition F inFigure27-6. If a double bit fault is detected while reading the P-Flash
Reserved Nonvolatile Bits— The RNV bits should remain in the erased state for future enhancements.
1–0
SEC[1:0]
Flash Security Bits — The SEC[1:0] bits define the security state of the MCU as shown inTable27-11. If the
Flash module is unsecured using backdoor key access, the SEC bits are forced to 10.
Table27-10. Flash KEYEN States
KEYEN[1:0]Status of Backdoor Key Access
00DISABLED
01DISABLED1
1Preferred KEYEN state to disable backdoor key access.
10ENABLED
11DISABLED
Table27-11. Flash Security States
SEC[1:0]Status of Security
00SECURED
01SECURED1
1Preferred SEC state to set MCU to secured state.
10UNSECURED
11SECURED
OffsetModule Base + 0x0002
76543210
R00000CCOBIX[2:0]
W
Reset00000000
= Unimplemented or Reserved
Figure27-7. FCCOB Index Register (FCCOBIX)
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
980Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CCOBIX bits are readable and writable while remaining bits read 0 and are not writable.
27.3.2.4Flash Reserved0 Register (FRSV0)
This Flash register is reserved for factory testing.
All bits in the FRSV0 register read 0 and are not writable.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.3.2.7Flash Status Register (FSTAT)
The FSTAT register reports the operational status of the Flash module.
CCIF, ACCERR, and FPVIOL bits are readable and writable, MGBUSY and MGSTAT bits are readable
but not writable, while remaining bits read 0 and are not writable.
is set, it is not possible to launch a command or start a command write sequence.
0No protection violation detected
1Protection violation detected
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor983
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.3.2.8Flash Error Status Register (FERSTAT)
The FERSTAT register reflects the error status of internal Flash operations.
All flags in the FERSTAT register are readable and only writable to clear the flag.
3
MGBUSY
Memory Controller Busy Flag— The MGBUSY flag reflects the active state of the Memory Controller.
0Memory Controller is idle
1Memory Controller is busy executing a Flash command (CCIF = 0)
2
RSVD
Reserved Bit— This bit is reserved and always reads 0.
command operation.1 The SFDIF flag is cleared by writing a 1 to SFDIF. Writing a 0 to SFDIF has no effect on
SFDIF.
0No single bit fault detected
1Single bit fault detected and corrected or a Flash array read operation returning invalid data was attempted
while command running
Table27-15. FSTAT Field Descriptions (continued)
FieldDescription
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
984Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.3.2.9P-Flash Protection Register (FPROT)
The FPROT register defines which P-Flash sectors are protected against program and erase operations.
in P-Flash memory as shown inTable27-19. The FPHS bits can only be written to while the FPHDIS bit is set.
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor985
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All possible P-Flash protection scenarios are shown inFigure27-14 . Although the protection scheme is
loaded from the Flash memory at global address 0x3_FF0C during the reset sequence, it can be changed
in P-Flash memory as shown inTable27-20. The FPLS bits can only be written to while the FPLDIS bit is set.
Table27-18. P-Flash Protection Function
FPOPENFPHDISFPLDISFunction1
1For range sizes, refer toTable27-19 andTable27-20.
111No P-Flash Protection
110Protected Low Range
101Protected High Range
100Protected High and Low Ranges
011Full P-Flash Memory Protected
010Unprotected Low Range
001Unprotected High Range
000Unprotected High and Low Ranges
Table27-19. P-Flash Protection Higher Address Range
FPHS[1:0] Global Address RangeProtected Size
000x3_F800–0x3_FFFF2 Kbytes
010x3_F000–0x3_FFFF4 Kbytes
100x3_E000–0x3_FFFF8 Kbytes
110x3_C000–0x3_FFFF16 Kbytes
Table27-20. P-Flash Protection Lower Address Range
FPLS[1:0]Global Address RangeProtected Size
000x3_8000–0x3_83FF1 Kbyte
010x3_8000–0x3_87FF2 Kbytes
100x3_8000–0x3_8FFF4 Kbytes
110x3_8000–0x3_9FFF8 Kbytes
Table27-17. FPROT Field Descriptions (continued)
FieldDescription
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
986Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure27-14. P-Flash Protection Scenarios
7654
FPHS[1:0]FPLS[1:0]
3210
FPHS[1:0]FPLS[1:0]
FPHDIS = 1
FPLDIS = 1
FPHDIS = 1
FPLDIS = 0
FPHDIS = 0
FPLDIS = 1
FPHDIS = 0
FPLDIS = 0
Scenario
Scenario
Unprotected regionProtected region with size
Protected regionProtected region with size
defined by FPLS
defined by FPHSnot defined by FPLS, FPHS
0x3_8000
0x3_FFFF
0x3_8000
0x3_FFFF
FLASH START
FLASH START
FPOPEN = 1FPOPEN = 0
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor987
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1Allowed transitions marked with X, seeFigure27-14 for a definition of the scenarios.
01234567
0XXXX
1XX
2XX
3X
4XX
5XXXX
6XXXX
7XXXXXXXX
OffsetModule Base + 0x0009
76543210
RDPOPENDPS[6:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
Figure27-15. EEPROM Protection Register (EEPROT)
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
988Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
P-Flash memory (seeTable27-4) as indicated by reset condition F inTable27-23. To change the
EEPROM protection that will be loaded during the reset sequence, the P-Flash sector containing the
1Disables EEPROM memory protection from program and erase
6–0
DPS[6:0]
EEPROM Protection Size — The DPS[6:0] bits determine the size of the protected area in the EEPROM
memory, this size increase in step of 32 bytes, as shown inTable27-23 .
Table27-23. EEPROM Protection Address Range
DPS[6:0] Global Address RangeProtected Size
00000000x0_0400 – 0x0_041F32 bytes
00000010x0_0400 – 0x0_043F64 bytes
00000100x0_0400 – 0x0_045F96 bytes
00000110x0_0400 – 0x0_047F128 bytes
00001000x0_0400 – 0x0_049F160 bytes
00001010x0_0400 – 0x0_04BF192 bytes
The Protection Size goes on enlarging in step of 32 bytes, for each DPS value
increasing of one.
.
.
.
11111110x0_0400 – 0x0_13FF4,096 bytes
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor989
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.3.2.11Flash Common Command Object Register (FCCOB)
The FCCOB is an array of six words addressed via the CCOBIX index found in the FCCOBIX register.
Byte wide reads and writes are allowed to the FCCOB register.
27.3.2.11.1FCCOB - NVM Command Mode
NVM command mode uses the indexed FCCOB register to provide a command code and its relevant
parameters to the Memory Controller. The user first sets up all required FCCOB fields and then initiates
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.3.2.12Flash Reserved1 Register (FRSV1)
This Flash register is reserved for factory testing.
All bits in the FRSV1 register read 0 and are not writable.
27.3.2.13Flash Reserved2 Register (FRSV2)
This Flash register is reserved for factory testing.
All bits in the FRSV2 register read 0 and are not writable.
27.3.2.14Flash Reserved3 Register (FRSV3)
This Flash register is reserved for factory testing.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All bits in the FRSV3 register read 0 and are not writable.
27.3.2.15Flash Reserved4 Register (FRSV4)
This Flash register is reserved for factory testing.
All bits in the FRSV4 register read 0 and are not writable.
27.3.2.16Flash Option Register (FOPT)
The FOPT register is the Flash option register.
All bits in the FOPT register are readable but are not writable.
During the reset sequence, the FOPT register is loaded from the Flash nonvolatile byte in the Flash
configuration field at global address 0x3_FF0E located in P-Flash memory (seeTable27-4) as indicated
by reset condition F inFigure27-22. If a double bit fault is detected while reading the P-Flash phrase
containing the Flash nonvolatile byte during the reset sequence, all bits in the FOPT register will be set.
OffsetModule Base + 0x000E
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure27-20. Flash Reserved3 Register (FRSV3)
OffsetModule Base + 0x000F
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure27-21. Flash Reserved4 Register (FRSV4)
OffsetModule Base + 0x0010
76543210
RNV[7:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
= Unimplemented or Reserved
Figure27-22. Flash Option Register (FOPT)
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
992Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.3.2.17Flash Reserved5 Register (FRSV5)
This Flash register is reserved for factory testing.
All bits in the FRSV5 register read 0 and are not writable.
27.3.2.18Flash Reserved6 Register (FRSV6)
This Flash register is reserved for factory testing.
All bits in the FRSV6 register read 0 and are not writable.
27.3.2.19Flash Reserved7 Register (FRSV7)
This Flash register is reserved for factory testing.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All bits in the FRSV7 register read 0 and are not writable.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.4.3Internal NVM resource (NVMRES)
IFR is an internal NVM resource readable by CPU , when NVMRES is active. The IFR fields are shown
inTable27-5.
The NVMRES global address map is shown inTable27-6.
27.4.4Flash Command Operations
Flash command operations are used to modify Flash memory contents.
The next sections describe:
•How to write the FCLKDIV register that is used to generate a time base (FCLK) derived from
BUSCLK for Flash program and erase command operations
•The command write sequence used to set Flash command parameters and launch execution
•Valid Flash commands available for execution, according to MCU functional mode and MCU
security state.
27.4.4.1Writing the FCLKDIV Register
Prior to issuing any Flash program or erase command after a reset, the user is required to write the
sequence. If CCIF is 0, the previous command write sequence is still active, a new command write
sequence cannot be started, and all writes to the FCCOB register are ignored.
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor995
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.4.4.2.1Define FCCOB Contents
The FCCOB parameter fields must be loaded with all required parameters for the Flash command being
executed. Access to the FCCOB parameter fields is controlled via the CCOBIX bits in the FCCOBIX
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.4.4.3Valid Flash Module Commands
Table27-27 present the valid Flash commands, as enabled by the combination of the functional MCU
Table27-28 summarizes the valid P-Flash commands along with the effects of the commands on the
P-Flash block and other resources within the Flash module.
Table27-27. Flash Commands by Mode and Security State
FCMDCommand
UnsecuredSecured
NS1
1Unsecured Normal Single Chip mode
SS2
2Unsecured Special Single Chip mode.
NS3
3Secured Normal Single Chip mode.
SS4
4Secured Special Single Chip mode.
0x01Erase Verify All Blocks∗∗∗∗
0x02Erase Verify Block∗∗∗∗
0x03Erase Verify P-Flash Section∗∗∗
0x04Read Once∗∗∗
0x06Program P-Flash∗∗∗
0x07Program Once∗∗∗
0x08Erase All Blocks∗∗
0x09Erase Flash Block∗∗∗
0x0AErase P-Flash Sector∗∗∗
0x0BUnsecure Flash∗∗
0x0CVerify Backdoor Access Key∗∗
0x0DSet User Margin Level∗∗∗
0x0ESet Field Margin Level∗
0x10Erase Verify EEPROM Section∗∗∗
0x11Program EEPROM∗∗∗
0x12Erase EEPROM Sector∗∗∗
Table27-28. P-Flash Commands
FCMDCommandFunction on P-Flash Memory
0x01Erase Verify All
Blocks
Verify that all P-Flash (and EEPROM) blocks are erased.
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
998Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.4.4.5EEPROM Commands
Table27-29 summarizes the valid EEPROM commands along with the effects of the commands on the
EEPROM block.
0x02Erase Verify BlockVerify that a P-Flash block is erased.
0x03Erase Verify
P-Flash Section
Verify that a given number of words starting at the address provided are erased.
bits in the FPROT register are set prior to launching the command.
0x0AErase P-Flash
Sector
Erase all bytes in a P-Flash sector.
0x0BUnsecure FlashSupports a method of releasing MCU security by erasing all P-Flash (and EEPROM)
blocks and verifying that all P-Flash (and EEPROM) blocks are erased.
0x0CVerify Backdoor
Access Key
Supports a method of releasing MCU security by verifying a set of security keys.
0x0DSet User Margin
Level
Specifies a user margin read level for all P-Flash blocks.
0x0ESet Field Margin
Level
Specifies a field margin read level for all P-Flash blocks (special modes only).
Table27-29. EEPROM Commands
FCMDCommandFunction on EEPROM Memory
0x01Erase Verify All
Blocks
Verify that all EEPROM (and P-Flash) blocks are erased.
0x02Erase Verify BlockVerify that the EEPROM block is erased.
Table27-28. P-Flash Commands
FCMDCommandFunction on P-Flash Memory
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor999
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.4.5Allowed Simultaneous P-Flash and EEPROM Operations
Only the operations marked ‘OK’ inTable27-30 are permitted to be run simultaneously on the Program
2The ‘Mass Erase’ operations are commands ‘Erase All Blocks’ and ‘Erase
Flash Block’
OK
Table27-29. EEPROM Commands
FCMDCommandFunction on EEPROM Memory
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1000Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table27-31. Erase Verify All Blocks Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x01Not required
Table27-32. Erase Verify All Blocks Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERRSet if CCOBIX[2:0] != 000 at command launch
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the reador if blank check failed .
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1001
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.4.6.2Erase Verify Block Command
The Erase Verify Block command allows the user to verify that an entire P-Flash or EEPROM block has
been erased. The FCCOB FlashBlockSelectionCode[1:0]bits determine which block must be verified.
Upon clearing CCIF to launch the Erase Verify Block command, the Memory Controller will verify that
the selected P-Flash or EEPROM block is erased. The CCIF flag will set after the Erase Verify Block
ACCERRSet if CCOBIX[2:0] != 000 at command launch.
FPVIOLNone.
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read1 or if
blank check failed.
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1002Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Erase Verify P-Flash Section command, the Memory Controller will
Set if command not available in current mode (seeTable27-27)
Set if an invalid global address [17:0] is supplied seeTable27-3)
Set if a misaligned phrase address is supplied (global address [2:0] != 000)
Set if the requested section crosses a the P-Flash address boundary
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
Table27-38. Read Once Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x04Not Required
001Read Once phrase index (0x0000 - 0x0007)
010Read Once word 0 value
011Read Once word 1 value
100Read Once word 2 value
101Read Once word 3 value
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1003
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A P-Flash phrase must be in the erased state before being programmed.
Cumulative programming of bits within a Flash phrase is not allowed.
Upon clearing CCIF to launch the Program P-Flash command, the Memory Controller will program the
data words to the supplied global address and will then proceed to verify the data words read back as
expected. The CCIF flag will set after the Program P-Flash operation has completed.
Table27-39. Read Once Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 001 at command launch
Set if command not available in current mode (seeTable27-27)
Set if an invalid phrase index is supplied
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read
MGSTAT0Set if any non-correctable errors have been encountered during the read
Table27-40. Program P-Flash Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x06Global address [17:16] to
identify P-Flash block
001Global address [15:0] of phrase location to be programmed1
1Global address [2:0] must be 000
010Word 0 program value
011Word 1 program value
100Word 2 program value
101Word 3 program value
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1004Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.4.6.6Program Once Command
The Program Once command restricts programming to a reserved 64 byte field (8 phrases) in the
and any attempt to program one of these phrases a second time will not be allowed. Valid phrase index
values for the Program Once command range from 0x0000 to 0x0007. During execution of the Program
Once command, any attempt to read addresses within P-Flash will return invalid data.
Table27-41. Program P-Flash Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 101 at command launch
Set if command not available in current mode (seeTable27-27)
Set if an invalid global address [17:0] is supplied seeTable27-3)
Set if a misaligned phrase address is supplied (global address [2:0] != 000)
FPVIOLSet if the global address [17:0] points to a protected area
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
Table27-42. Program Once Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x07Not Required
001Program Once phrase index (0x0000 - 0x0007)
010Program Once word 0 value
011Program Once word 1 value
100Program Once word 2 value
101Program Once word 3 value
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1005
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.4.6.7Erase All Blocks Command
The Erase All Blocks operation will erase the entire P-Flash and EEPROM memory space.
The Erase Flash Block operation will erase all addresses in a P-Flash or EEPROM block.
Table27-43. Program Once Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 101 at command launch
Set if command not available in current mode (seeTable27-27)
Set if an invalid phrase index is supplied
Set if the requested phrase has already been programmed1
1If a Program Once phrase is initially programmed to 0xFFFF_FFFF_FFFF_FFFF, the Program Once command will
be allowed to execute again on that same phrase.
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
Table27-44. Erase All Blocks Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x08Not required
Table27-45. Erase All Blocks Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERRSet if CCOBIX[2:0] != 000 at command launch
Set if command not available in current mode (seeTable27-27)
FPVIOLSet if any area of the P-Flash or EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1006Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Erase Flash Block command, the Memory Controller will erase the
selected Flash block and verify that it is erased. The CCIF flag will set after the Erase Flash Block
operation has completed.
27.4.6.9Erase P-Flash Sector Command
The Erase P-Flash Sector operation will erase all addresses in a P-Flash sector.
Upon clearing CCIF to launch the Erase P-Flash Sector command, the Memory Controller will erase the
selected Flash sector and then verify that it is erased. The CCIF flag will be set after the Erase P-Flash
001Global address [15:0] anywhere within the sector to be erased.
Refer toSection27.1.2.1 for the P-Flash sector size.
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1007
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Set if command not available in current mode (seeTable27-27)
FPVIOLSet if any area of the P-Flash or EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1008Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table27-4). The Verify Backdoor Access Key command must not be executed from the Flash block
containing the backdoor comparison key to avoid code runaway.
Upon clearing CCIF to launch the Verify Backdoor Access Key command, the Memory Controller will
check the FSEC KEYEN bits to verify that this command is enabled. If not enabled, the Memory
Controller sets the ACCERR bit in the FSTAT register and terminates. If the command is enabled, the
Memory Controller compares the key provided in FCCOB to the backdoor comparison key in the Flash
configuration field with Key 0 compared to 0x3_FF00, etc. If the backdoor keys match, security will be
Set if backdoor key access has not been enabled (KEYEN[1:0] != 10, see
Section27.3.2.2)
Set if the backdoor key has mismatched since the last reset
FPVIOLNone
MGSTAT1None
MGSTAT0None
Table27-54. Set User Margin Level Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x0DFlash block selection code [1:0]. See
Table27-34
001Margin level setting.
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1009
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Set User Margin Level command, the Memory Controller will set the
user margin level for the targeted block and then set the CCIF flag.
The Set Field Margin Level command, valid in special modes only, causes the Memory Controller to set
the margin level specified for future read operations of the P-Flash or EEPROM block.
Table27-55. Valid Set User Margin Level Settings
CCOB
(CCOBIX=001)Level Description
0x0000Return to Normal Level
0x0001User Margin-1 Level1
1Read margin to the erased state
0x0002User Margin-0 Level2
2Read margin to the programmed state
Table27-56. Set User Margin Level Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 001 at command launch.
Set if command not available in current mode (seeTable27-27).
Set if an invalid margin level setting is supplied.
FPVIOLNone
MGSTAT1None
MGSTAT0None
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1010Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Set Field Margin Level command, the Memory Controller will set the
field margin level for the targeted block and then set the CCIF flag.
Valid margin level settings for the Set Field Margin Level command are defined inTable27-58.
Table27-57. Set Field Margin Level Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x0EFlash block selection code [1:0]. See
Table27-34
001Margin level setting.
Table27-58. Valid Set Field Margin Level Settings
CCOB
(CCOBIX=001)Level Description
0x0000Return to Normal Level
0x0001User Margin-1 Level1
1Read margin to the erased state
0x0002User Margin-0 Level2
2Read margin to the programmed state
0x0003Field Margin-1 Level1
0x0004Field Margin-0 Level2
Table27-59. Set Field Margin Level Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 001 at command launch.
Set if command not available in current mode (seeTable27-27).
Set if an invalid margin level setting is supplied.
FPVIOLNone
MGSTAT1None
MGSTAT0None
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1011
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CAUTION
Field margin levels must only be used during verify of the initial factory
programming.
NOTE
Field margin levels can be used to check that Flash memory contents have
Set if command not available in current mode (seeTable27-27)
Set if an invalid global address [17:0] is supplied
Set if a misaligned word address is supplied (global address [0] != 0)
Set if the requested section breaches the end of the EEPROM block
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1012Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.4.6.15Program EEPROM Command
The Program EEPROM operation programs one to four previously erased words in the EEPROM block.
value at Program EEPROM command launch determines how many words will be programmed in the
EEPROM block. The CCIF flag is set when the operation has completed.
27.4.6.16Erase EEPROM Sector Command
The Erase EEPROM Sector operation will erase all addresses in a sector of the EEPROM block.
Table27-62. Program EEPROM Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x11Global address [17:16] to
identify the EEPROM block
001Global address [15:0] of word to be programmed
010Word 0 program value
011Word 1 program value, if desired
100Word 2 program value, if desired
101Word 3 program value, if desired
Table27-63. Program EEPROM Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] < 010 at command launch
Set if CCOBIX[2:0] > 101 at command launch
Set if command not available in current mode (seeTable27-27)
Set if an invalid global address [17:0] is supplied
Set if a misaligned word address is supplied (global address [0] != 0)
Set if the requested group of words breaches the end of the EEPROM block
FPVIOLSet if the selected area of the EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1013
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NOTE
Vector addresses and their relative interrupt priority are determined at the
MCU level.
27.4.7.1Description of Flash Interrupt Operation
The Flash module uses the CCIF flag in combination with the CCIE interrupt enable bit to generate the
will be completed before the MCU is allowed to enter stop mode.
Flash Error Interrupt Request
CCIF
CCIE
DFDIF
DFDIE
SFDIF
SFDIE
Flash Command Interrupt Request
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1015
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
27.5Security
The Flash module provides security information to the MCU. The Flash security state is defined by the
SEC bits of the FSEC register (seeTable27-11). During reset, the Flash module initializes the FSEC
keys stored in addresses 0x3_FF00-0x3_FF07 are unaffected by the Verify Backdoor Access Key
command sequence. The Verify Backdoor Access Key command sequence has no effect on the program
and erase protections defined in the Flash protection register, FPROT.
After the backdoor keys have been correctly matched, the MCU will be unsecured. After the MCU is
unsecured, the sector containing the Flash security byte can be erased and the Flash security byte can be
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1016Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
reprogrammed to the unsecure state, if desired. In the unsecure state, the user has full control of the
initialization sequence is marked by setting CCIF high which enables user commands.
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1017
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
state of the word being programmed or the sector/block being erased is not guaranteed.
192 KByte Flash Module (S12FTMRG192K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1018Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1019
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Chapter28
240 KByte Flash Module (S12FTMRG240K2V1)
28.1Introduction
The FTMRG240K2 module implements the following:
•240Kbytes of P-Flash (Program Flash) memory
•4Kbytes of EEPROM memory
The Flash memory is ideal for single-supply applications allowing for field reprogramming without
requiring external high voltage sources for program or erase operations. The Flash module includes a
memory controller that executes commands to modify Flash memory contents. The user interface to the
memory controller consists of the indexed Flash Common Command Object (FCCOB) register which is
written to with the command, global address, data, and any required command parameters. The memory
A Flash word or phrase must be in the erased state before being
programmed. Cumulative programming of bits within a Flash word or
phrase is not allowed.
Table28-1. Revision History
Revision
Number
Revision
Date
Sections
AffectedDescription of Changes
V01.0623 Jun 201028.4.6.2/28-105
3
28.4.6.12/28-10
60
28.4.6.13/28-10
61
Updated description of the commands RD1BLK, MLOADU and MLOADF
V01.0720 aug 201028.4.6.2/28-105
3
28.4.6.12/28-10
60
28.4.6.13/28-10
61
Updated description of the commands RD1BLK, MLOADU and MLOADF
Rev.1.0631 Jan 201128.3.2.9/28-103
6
Updated description of protection onSection28.3.2.9
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1020
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The Flash memory may be read as bytes and aligned words. Read access time is one bus cycle for bytes
and aligned words. For misaligned words access, the CPU has to perform twice the byte read access
command. For Flash memory, an erased bit reads 1 and a programmed bit reads 0.
P-Flash Sector— The P-Flash sector is the smallest portion of the P-Flash memory that can be erased.
Each P-Flash sector contains 512 bytes.
Program IFR— Nonvolatile information register located in the P-Flash block that contains the Version
ID, and the Program Once field.
28.1.2Features
28.1.2.1P-Flash Features
•240 Kbytes of P-Flash memory divided into 480 sectors of 512 bytes
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1021
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
•Single bit fault correction and double bit fault detection within a 32-bit double word during read
operations
•Automated program and erase algorithm with verify and generation of ECC parity bits
•Fast sector erase and phrase program operation
•Ability to read the P-Flash memory while programming a word in the EEPROM memory
•Flexible protection scheme to prevent accidental program or erase of P-Flash memory
•Single bit fault correction and double bit fault detection within a word during read operations
•Automated program and erase algorithm with verify and generation of ECC parity bits
•Fast sector erase and word program operation
•Protection scheme to prevent accidental program or erase of EEPROM memory
•Ability to program up to four words in a burst sequence
28.1.2.3Other Flash Module Features
•No external high-voltage power supply required for Flash memory program and erase operations
•Interrupt generation on Flash command completion and Flash error detection
•Security mechanism to prevent unauthorized access to the Flash memory
28.1.3Block Diagram
The block diagram of the Flash module is shown inFigure28-1.
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1022Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure28-1. FTMRG240K2 Block Diagram
28.2External Signal Description
The Flash module contains no signals that connect off-chip.
Bus
Clock
Divider
Clock
Command
Interrupt
Request
FCLK
Protection
Security
Registers
Flash
Interface
16bit
internal
bus
sector 0
sector 1
sector 479
60Kx39
P-Flash
Error
Interrupt
Request
CPU
sector 0
sector 1
sector 1023
2Kx22
EEPROM
Memory Controller
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1023
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
in the Flash module will be ignored by the Flash module.
CAUTION
Writing to the Flash registers while a Flash command is executing (that is
indicated when the value of flag CCIF reads as ’0’) is not allowed. If such
action is attempted the write operation will not change the register value.
Writing to the Flash registers is allowed when the Flash is not busy
executing commands (CCIF = 1) and during initialization right after reset,
despite the value of flag CCIF in that case (refer toSection28.6 for a
complete description of the reset sequence).
.
28.3.1Module Memory Map
The S12 architecture places the P-Flash memory between global addresses 0x0_4000 and 0x3_FFFF as
shown inTable28-3 .The P-Flash memory map is shown inFigure28-2.
Table28-2. FTMRG Memory Map
Global Address (in Bytes)Size
(Bytes)Description
0x0_0000 - 0x0_03FF1,024Register Space
0x0_0400 – 0x0_13FF4,096EEPROM Memory
0x0_4000 – 0x0_7FFF16,284NVMRES=0 : P-Flash Memory area active
0x0_4000 – 0x0_7FFF16,284NVMRES1=1 : NVM Resource area (seeFigure28-3)
1See NVMRES description inSection28.4.3
0x0_8000 – 0x3_FFFF229,376P-Flash Memory
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1024Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure28-2. P-Flash Memory Map
Table28-5. Program IFR Fields
Global AddressSize
(Bytes)Field Description
0x0_4000 – 0x0_40078Reserved
0x0_4008 – 0x0_40B5174Reserved
0x0_40B6 – 0x0_40B72Version ID1
Flash Configuration Field
0x3_C000
Flash Protected/Unprotected Lower Region
1, 2, 4, 8 Kbytes
0x3_8000
0x3_9000
0x3_8400
0x3_8800
0x3_A000
P-Flash END = 0x3_FFFF
0x3_F800
0x3_F000
0x3_E000Flash Protected/Unprotected Higher Region
2, 4, 8, 16 Kbytes
Flash Protected/Unprotected Region
8 Kbytes (up to 29 Kbytes)
16 bytes (0x3_FF00 - 0x3_FF0F)
Flash Protected/Unprotected Region
208 Kbytes
P-Flash START = 0x0_4000
Protection
Protection
Protection
Movable End
Fixed End
Fixed End
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1026Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1NVMRES - SeeSection28.4.3 for NVMRES (NVM Resource) detail.
Global AddressSize
(Bytes)Description
0x0_4000 – 0x040FF256P-Flash IFR (seeTable28-5)
0x0_4100 – 0x0_41FF256Reserved.
0x0_4200 – 0x0_57FFReserved
0x0_5800 – 0x0_5AFF768Reserved
0x0_5B00 – 0x0_5FFF1,280Reserved
0x0_6000 – 0x0_67FF2,048Reserved
0x0_6800 – 0x0_7FFF6,144Reserved
Table28-5. Program IFR Fields
Global AddressSize
(Bytes)Field Description
P-Flash IFR 128 bytes (NVMRES=1)
0x0_4000
Reserved 6144 bytes
Reserved 3328 bytes
0x0_6800
0x0_7FFF
0x0_4100
Reserved 5632 bytes
Reserved 768 bytes
0x0_4200
Reserved 128 bytes
0x0_5800
0x0_5AFF
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1027
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.3.2Register Descriptions
The Flash module contains a set of 20 control and status registers located between Flash module base +
A summary of the Flash module registers is given inFigure28-4 with detailed descriptions in the
following subsections.
Address
& Name76543210
0x0000
FCLKDIV
RFDIVLDFDIVLCKFDIV5FDIV4FDIV3FDIV2FDIV1FDIV0
W
0x0001
FSEC
RKEYEN1KEYEN0RNV5RNV4RNV3RNV2SEC1SEC0
W
0x0002
FCCOBIX
R00000CCOBIX2CCOBIX1CCOBIX0
W
0x0003
FRSV0
R00000000
W
0x0004
FCNFG
RCCIE00
IGNSF00
FDFDFSFD
W
0x0005
FERCNFG
R000000DFDIESFDIE
W
0x0006
FSTAT
RCCIF0ACCERRFPVIOLMGBUSYRSVDMGSTAT1MGSTAT0
W
0x0007
FERSTAT
R000000DFDIFSFDIF
W
0x0008
FPROT
RFPOPENRNV6FPHDISFPHS1FPHS0FPLDISFPLS1FPLS0
W
0x0009
EEPROT
RDPOPENDPS6DPS5DPS4DPS3DPS2DPS1DPS0
W
Figure28-4. FTMRG240K2 Register Summary
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1028Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.3.2.1Flash Clock Divider Register (FCLKDIV)
The FCLKDIV register is used to control timed events in program and erase algorithms.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
BUSCLK frequency. Please refer toSection28.4.4, “Flash Command Operations,” for more information.
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1030Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.3.2.2Flash Security Register (FSEC)
The FSEC register holds all bits associated with the security of the MCU and Flash module.
All bits in the FSEC register are readable but not writable.
During the reset sequence, the FSEC register is loaded with the contents of the Flash security byte in the
Flash configuration field at global address 0x3_FF0F located in P-Flash memory (seeTable28-4) as
Table28-8. FDIV values for various BUSCLK Frequencies
BUSCLK Frequency
(MHz)FDIV[5:0]
BUSCLK Frequency
(MHz)FDIV[5:0]
MIN1
1BUSCLK is Greater Than this value.
MAX2
2BUSCLK is Less Than or Equal to this value.
MIN1MAX2
1.01.60x0016.617.60x10
1.62.60x0117.618.60x11
2.63.60x0218.619.60x12
3.64.60x0319.620.60x13
4.65.60x0420.621.60x14
5.66.60x0521.622.60x15
6.67.60x0622.623.60x16
7.68.60x0723.624.60x17
8.69.60x0824.625.60x18
9.610.60x09
10.611.60x0A
11.612.60x0B
12.613.60x0C
13.614.60x0D
14.615.60x0E
15.616.60x0F
OffsetModule Base + 0x0001
76543210
RKEYEN[1:0]RNV[5:2]SEC[1:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
= Unimplemented or Reserved
Figure28-6. Flash Security Register (FSEC)
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1031
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
indicated by reset condition F inFigure28-6. If a double bit fault is detected while reading the P-Flash
Reserved Nonvolatile Bits— The RNV bits should remain in the erased state for future enhancements.
1–0
SEC[1:0]
Flash Security Bits — The SEC[1:0] bits define the security state of the MCU as shown inTable28-11. If the
Flash module is unsecured using backdoor key access, the SEC bits are forced to 10.
Table28-10. Flash KEYEN States
KEYEN[1:0]Status of Backdoor Key Access
00DISABLED
01DISABLED1
1Preferred KEYEN state to disable backdoor key access.
10ENABLED
11DISABLED
Table28-11. Flash Security States
SEC[1:0]Status of Security
00SECURED
01SECURED1
1Preferred SEC state to set MCU to secured state.
10UNSECURED
11SECURED
OffsetModule Base + 0x0002
76543210
R00000CCOBIX[2:0]
W
Reset00000000
= Unimplemented or Reserved
Figure28-7. FCCOB Index Register (FCCOBIX)
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1032Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CCOBIX bits are readable and writable while remaining bits read 0 and are not writable.
28.3.2.4Flash Reserved0 Register (FRSV0)
This Flash register is reserved for factory testing.
All bits in the FRSV0 register read 0 and are not writable.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.3.2.7Flash Status Register (FSTAT)
The FSTAT register reports the operational status of the Flash module.
CCIF, ACCERR, and FPVIOL bits are readable and writable, MGBUSY and MGSTAT bits are readable
but not writable, while remaining bits read 0 and are not writable.
is set, it is not possible to launch a command or start a command write sequence.
0No protection violation detected
1Protection violation detected
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1035
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.3.2.8Flash Error Status Register (FERSTAT)
The FERSTAT register reflects the error status of internal Flash operations.
All flags in the FERSTAT register are readable and only writable to clear the flag.
3
MGBUSY
Memory Controller Busy Flag— The MGBUSY flag reflects the active state of the Memory Controller.
0Memory Controller is idle
1Memory Controller is busy executing a Flash command (CCIF = 0)
2
RSVD
Reserved Bit— This bit is reserved and always reads 0.
command operation.1 The SFDIF flag is cleared by writing a 1 to SFDIF. Writing a 0 to SFDIF has no effect on
SFDIF.
0No single bit fault detected
1Single bit fault detected and corrected or a Flash array read operation returning invalid data was attempted
while command running
Table28-15. FSTAT Field Descriptions (continued)
FieldDescription
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1036Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.3.2.9P-Flash Protection Register (FPROT)
The FPROT register defines which P-Flash sectors are protected against program and erase operations.
in P-Flash memory as shown inTable28-19. The FPHS bits can only be written to while the FPHDIS bit is set.
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1037
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All possible P-Flash protection scenarios are shown inFigure28-14 . Although the protection scheme is
loaded from the Flash memory at global address 0x3_FF0C during the reset sequence, it can be changed
in P-Flash memory as shown inTable28-20. The FPLS bits can only be written to while the FPLDIS bit is set.
Table28-18. P-Flash Protection Function
FPOPENFPHDISFPLDISFunction1
1For range sizes, refer toTable28-19 andTable28-20.
111No P-Flash Protection
110Protected Low Range
101Protected High Range
100Protected High and Low Ranges
011Full P-Flash Memory Protected
010Unprotected Low Range
001Unprotected High Range
000Unprotected High and Low Ranges
Table28-19. P-Flash Protection Higher Address Range
FPHS[1:0] Global Address RangeProtected Size
000x3_F800–0x3_FFFF2 Kbytes
010x3_F000–0x3_FFFF4 Kbytes
100x3_E000–0x3_FFFF8 Kbytes
110x3_C000–0x3_FFFF16 Kbytes
Table28-20. P-Flash Protection Lower Address Range
FPLS[1:0]Global Address RangeProtected Size
000x3_8000–0x3_83FF1 Kbyte
010x3_8000–0x3_87FF2 Kbytes
100x3_8000–0x3_8FFF4 Kbytes
110x3_8000–0x3_9FFF8 Kbytes
Table28-17. FPROT Field Descriptions (continued)
FieldDescription
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1038Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Figure28-14. P-Flash Protection Scenarios
7654
FPHS[1:0]FPLS[1:0]
3210
FPHS[1:0]FPLS[1:0]
FPHDIS = 1
FPLDIS = 1
FPHDIS = 1
FPLDIS = 0
FPHDIS = 0
FPLDIS = 1
FPHDIS = 0
FPLDIS = 0
Scenario
Scenario
Unprotected regionProtected region with size
Protected regionProtected region with size
defined by FPLS
defined by FPHSnot defined by FPLS, FPHS
0x3_8000
0x3_FFFF
0x3_8000
0x3_FFFF
FLASH START
FLASH START
FPOPEN = 1FPOPEN = 0
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1039
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
1Allowed transitions marked with X, seeFigure28-14 for a definition of the scenarios.
01234567
0XXXX
1XX
2XX
3X
4XX
5XXXX
6XXXX
7XXXXXXXX
OffsetModule Base + 0x0009
76543210
RDPOPENDPS[6:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
Figure28-15. EEPROM Protection Register (EEPROT)
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1040Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
P-Flash memory (seeTable28-4) as indicated by reset condition F inTable28-23. To change the
EEPROM protection that will be loaded during the reset sequence, the P-Flash sector containing the
1Disables EEPROM memory protection from program and erase
6–0
DPS[6:0]
EEPROM Protection Size — The DPS[6:0] bits determine the size of the protected area in the EEPROM
memory, this size increase in step of 32 bytes, as shown inTable28-23 .
Table28-23. EEPROM Protection Address Range
DPS[6:0] Global Address RangeProtected Size
00000000x0_0400 – 0x0_041F32 bytes
00000010x0_0400 – 0x0_043F64 bytes
00000100x0_0400 – 0x0_045F96 bytes
00000110x0_0400 – 0x0_047F128 bytes
00001000x0_0400 – 0x0_049F160 bytes
00001010x0_0400 – 0x0_04BF192 bytes
The Protection Size goes on enlarging in step of 32 bytes, for each DPS value
increasing of one.
.
.
.
11111110x0_0400 – 0x0_13FF4,096 bytes
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1041
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.3.2.11Flash Common Command Object Register (FCCOB)
The FCCOB is an array of six words addressed via the CCOBIX index found in the FCCOBIX register.
Byte wide reads and writes are allowed to the FCCOB register.
28.3.2.11.1FCCOB - NVM Command Mode
NVM command mode uses the indexed FCCOB register to provide a command code and its relevant
parameters to the Memory Controller. The user first sets up all required FCCOB fields and then initiates
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.3.2.12Flash Reserved1 Register (FRSV1)
This Flash register is reserved for factory testing.
All bits in the FRSV1 register read 0 and are not writable.
28.3.2.13Flash Reserved2 Register (FRSV2)
This Flash register is reserved for factory testing.
All bits in the FRSV2 register read 0 and are not writable.
28.3.2.14Flash Reserved3 Register (FRSV3)
This Flash register is reserved for factory testing.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All bits in the FRSV3 register read 0 and are not writable.
28.3.2.15Flash Reserved4 Register (FRSV4)
This Flash register is reserved for factory testing.
All bits in the FRSV4 register read 0 and are not writable.
28.3.2.16Flash Option Register (FOPT)
The FOPT register is the Flash option register.
All bits in the FOPT register are readable but are not writable.
During the reset sequence, the FOPT register is loaded from the Flash nonvolatile byte in the Flash
configuration field at global address 0x3_FF0E located in P-Flash memory (seeTable28-4) as indicated
by reset condition F inFigure28-22. If a double bit fault is detected while reading the P-Flash phrase
containing the Flash nonvolatile byte during the reset sequence, all bits in the FOPT register will be set.
OffsetModule Base + 0x000E
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure28-20. Flash Reserved3 Register (FRSV3)
OffsetModule Base + 0x000F
76543210
R00000000
W
Reset00000000
= Unimplemented or Reserved
Figure28-21. Flash Reserved4 Register (FRSV4)
OffsetModule Base + 0x0010
76543210
RNV[7:0]
W
ResetF1
1Loaded from IFR Flash configuration field, during reset sequence.
F1F1F1F1F1F1F1
= Unimplemented or Reserved
Figure28-22. Flash Option Register (FOPT)
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1044Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.3.2.17Flash Reserved5 Register (FRSV5)
This Flash register is reserved for factory testing.
All bits in the FRSV5 register read 0 and are not writable.
28.3.2.18Flash Reserved6 Register (FRSV6)
This Flash register is reserved for factory testing.
All bits in the FRSV6 register read 0 and are not writable.
28.3.2.19Flash Reserved7 Register (FRSV7)
This Flash register is reserved for factory testing.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
All bits in the FRSV7 register read 0 and are not writable.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.4.3Internal NVM resource (NVMRES)
IFR is an internal NVM resource readable by CPU , when NVMRES is active. The IFR fields are shown
inTable28-5.
The NVMRES global address map is shown inTable28-6.
For FTMRG240K2 the NVMRES address area is shared with 16K space of P-Flash area, as shown in
Figure28-2.
28.4.4Flash Command Operations
Flash command operations are used to modify Flash memory contents.
The next sections describe:
•How to write the FCLKDIV register that is used to generate a time base (FCLK) derived from
BUSCLK for Flash program and erase command operations
•The command write sequence used to set Flash command parameters and launch execution
•Valid Flash commands available for execution, according to MCU functional mode and MCU
security state.
28.4.4.1Writing the FCLKDIV Register
Prior to issuing any Flash program or erase command after a reset, the user is required to write the
sequence. If CCIF is 0, the previous command write sequence is still active, a new command write
sequence cannot be started, and all writes to the FCCOB register are ignored.
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1047
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.4.4.2.1Define FCCOB Contents
The FCCOB parameter fields must be loaded with all required parameters for the Flash command being
executed. Access to the FCCOB parameter fields is controlled via the CCOBIX bits in the FCCOBIX
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.4.4.3Valid Flash Module Commands
Table28-27 present the valid Flash commands, as enabled by the combination of the functional MCU
Table28-28 summarizes the valid P-Flash commands along with the effects of the commands on the
P-Flash block and other resources within the Flash module.
Table28-27. Flash Commands by Mode and Security State
FCMDCommand
UnsecuredSecured
NS1
1Unsecured Normal Single Chip mode
SS2
2Unsecured Special Single Chip mode.
NS3
3Secured Normal Single Chip mode.
SS4
4Secured Special Single Chip mode.
0x01Erase Verify All Blocks∗∗∗∗
0x02Erase Verify Block∗∗∗∗
0x03Erase Verify P-Flash Section∗∗∗
0x04Read Once∗∗∗
0x06Program P-Flash∗∗∗
0x07Program Once∗∗∗
0x08Erase All Blocks∗∗
0x09Erase Flash Block∗∗∗
0x0AErase P-Flash Sector∗∗∗
0x0BUnsecure Flash∗∗
0x0CVerify Backdoor Access Key∗∗
0x0DSet User Margin Level∗∗∗
0x0ESet Field Margin Level∗
0x10Erase Verify EEPROM Section∗∗∗
0x11Program EEPROM∗∗∗
0x12Erase EEPROM Sector∗∗∗
Table28-28. P-Flash Commands
FCMDCommandFunction on P-Flash Memory
0x01Erase Verify All
Blocks
Verify that all P-Flash (and EEPROM) blocks are erased.
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1050Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.4.4.5EEPROM Commands
Table28-29 summarizes the valid EEPROM commands along with the effects of the commands on the
EEPROM block.
0x02Erase Verify BlockVerify that a P-Flash block is erased.
0x03Erase Verify
P-Flash Section
Verify that a given number of words starting at the address provided are erased.
bits in the FPROT register are set prior to launching the command.
0x0AErase P-Flash
Sector
Erase all bytes in a P-Flash sector.
0x0BUnsecure FlashSupports a method of releasing MCU security by erasing all P-Flash (and EEPROM)
blocks and verifying that all P-Flash (and EEPROM) blocks are erased.
0x0CVerify Backdoor
Access Key
Supports a method of releasing MCU security by verifying a set of security keys.
0x0DSet User Margin
Level
Specifies a user margin read level for all P-Flash blocks.
0x0ESet Field Margin
Level
Specifies a field margin read level for all P-Flash blocks (special modes only).
Table28-29. EEPROM Commands
FCMDCommandFunction on EEPROM Memory
0x01Erase Verify All
Blocks
Verify that all EEPROM (and P-Flash) blocks are erased.
0x02Erase Verify BlockVerify that the EEPROM block is erased.
Table28-28. P-Flash Commands
FCMDCommandFunction on P-Flash Memory
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1051
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.4.5Allowed Simultaneous P-Flash and EEPROM Operations
Only the operations marked ‘OK’ inTable28-30 are permitted to be run simultaneously on the Program
2The ‘Mass Erase’ operations are commands ‘Erase All Blocks’ and ‘Erase
Flash Block’
OK
Table28-29. EEPROM Commands
FCMDCommandFunction on EEPROM Memory
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1052Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table28-31. Erase Verify All Blocks Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x01Not required
Table28-32. Erase Verify All Blocks Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERRSet if CCOBIX[2:0] != 000 at command launch
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the reador if blank check failed .
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1053
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.4.6.2Erase Verify Block Command
The Erase Verify Block command allows the user to verify that an entire P-Flash or EEPROM block has
been erased. The FCCOB FlashBlockSelectionCode[1:0]bits determine which block must be verified.
Upon clearing CCIF to launch the Erase Verify Block command, the Memory Controller will verify that
the selected P-Flash or EEPROM block is erased. The CCIF flag will set after the Erase Verify Block
ACCERRSet if CCOBIX[2:0] != 000 at command launch.
FPVIOLNone.
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read1 or if
blank check failed.
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1054Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Erase Verify P-Flash Section command, the Memory Controller will
Set if command not available in current mode (seeTable28-27)
Set if an invalid global address [17:0] is supplied seeTable28-3)
Set if a misaligned phrase address is supplied (global address [2:0] != 000)
Set if the requested section crosses a the P-Flash address boundary
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
Table28-38. Read Once Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x04Not Required
001Read Once phrase index (0x0000 - 0x0007)
010Read Once word 0 value
011Read Once word 1 value
100Read Once word 2 value
101Read Once word 3 value
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1055
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A P-Flash phrase must be in the erased state before being programmed.
Cumulative programming of bits within a Flash phrase is not allowed.
Upon clearing CCIF to launch the Program P-Flash command, the Memory Controller will program the
data words to the supplied global address and will then proceed to verify the data words read back as
expected. The CCIF flag will set after the Program P-Flash operation has completed.
Table28-39. Read Once Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 001 at command launch
Set if command not available in current mode (seeTable28-27)
Set if an invalid phrase index is supplied
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read
MGSTAT0Set if any non-correctable errors have been encountered during the read
Table28-40. Program P-Flash Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x06Global address [17:16] to
identify P-Flash block
001Global address [15:0] of phrase location to be programmed1
1Global address [2:0] must be 000
010Word 0 program value
011Word 1 program value
100Word 2 program value
101Word 3 program value
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1056Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.4.6.6Program Once Command
The Program Once command restricts programming to a reserved 64 byte field (8 phrases) in the
and any attempt to program one of these phrases a second time will not be allowed. Valid phrase index
values for the Program Once command range from 0x0000 to 0x0007. During execution of the Program
Once command, any attempt to read addresses within P-Flash will return invalid data.
Table28-41. Program P-Flash Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 101 at command launch
Set if command not available in current mode (seeTable28-27)
Set if an invalid global address [17:0] is supplied seeTable28-3)
Set if a misaligned phrase address is supplied (global address [2:0] != 000)
FPVIOLSet if the global address [17:0] points to a protected area
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
Table28-42. Program Once Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x07Not Required
001Program Once phrase index (0x0000 - 0x0007)
010Program Once word 0 value
011Program Once word 1 value
100Program Once word 2 value
101Program Once word 3 value
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1057
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.4.6.7Erase All Blocks Command
The Erase All Blocks operation will erase the entire P-Flash and EEPROM memory space.
The Erase Flash Block operation will erase all addresses in a P-Flash or EEPROM block.
Table28-43. Program Once Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 101 at command launch
Set if command not available in current mode (seeTable28-27)
Set if an invalid phrase index is supplied
Set if the requested phrase has already been programmed1
1If a Program Once phrase is initially programmed to 0xFFFF_FFFF_FFFF_FFFF, the Program Once command will
be allowed to execute again on that same phrase.
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
Table28-44. Erase All Blocks Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x08Not required
Table28-45. Erase All Blocks Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERRSet if CCOBIX[2:0] != 000 at command launch
Set if command not available in current mode (seeTable28-27)
FPVIOLSet if any area of the P-Flash or EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1058Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Erase Flash Block command, the Memory Controller will erase the
selected Flash block and verify that it is erased. The CCIF flag will set after the Erase Flash Block
operation has completed.
28.4.6.9Erase P-Flash Sector Command
The Erase P-Flash Sector operation will erase all addresses in a P-Flash sector.
Upon clearing CCIF to launch the Erase P-Flash Sector command, the Memory Controller will erase the
selected Flash sector and then verify that it is erased. The CCIF flag will be set after the Erase P-Flash
001Global address [15:0] anywhere within the sector to be erased.
Refer toSection28.1.2.1 for the P-Flash sector size.
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1059
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Set if command not available in current mode (seeTable28-27)
FPVIOLSet if any area of the P-Flash or EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1060Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Table28-4). The Verify Backdoor Access Key command must not be executed from the Flash block
containing the backdoor comparison key to avoid code runaway.
Upon clearing CCIF to launch the Verify Backdoor Access Key command, the Memory Controller will
check the FSEC KEYEN bits to verify that this command is enabled. If not enabled, the Memory
Controller sets the ACCERR bit in the FSTAT register and terminates. If the command is enabled, the
Memory Controller compares the key provided in FCCOB to the backdoor comparison key in the Flash
configuration field with Key 0 compared to 0x3_FF00, etc. If the backdoor keys match, security will be
Set if backdoor key access has not been enabled (KEYEN[1:0] != 10, see
Section28.3.2.2)
Set if the backdoor key has mismatched since the last reset
FPVIOLNone
MGSTAT1None
MGSTAT0None
Table28-54. Set User Margin Level Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x0DFlash block selection code [1:0]. See
Table28-34
001Margin level setting.
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1061
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Set User Margin Level command, the Memory Controller will set the
user margin level for the targeted block and then set the CCIF flag.
The Set Field Margin Level command, valid in special modes only, causes the Memory Controller to set
the margin level specified for future read operations of the P-Flash or EEPROM block.
Table28-55. Valid Set User Margin Level Settings
CCOB
(CCOBIX=001)Level Description
0x0000Return to Normal Level
0x0001User Margin-1 Level1
1Read margin to the erased state
0x0002User Margin-0 Level2
2Read margin to the programmed state
Table28-56. Set User Margin Level Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 001 at command launch.
Set if command not available in current mode (seeTable28-27).
Set if an invalid margin level setting is supplied.
FPVIOLNone
MGSTAT1None
MGSTAT0None
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1062Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Upon clearing CCIF to launch the Set Field Margin Level command, the Memory Controller will set the
field margin level for the targeted block and then set the CCIF flag.
Valid margin level settings for the Set Field Margin Level command are defined inTable28-58.
Table28-57. Set Field Margin Level Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x0EFlash block selection code [1:0]. See
Table28-34
001Margin level setting.
Table28-58. Valid Set Field Margin Level Settings
CCOB
(CCOBIX=001)Level Description
0x0000Return to Normal Level
0x0001User Margin-1 Level1
1Read margin to the erased state
0x0002User Margin-0 Level2
2Read margin to the programmed state
0x0003Field Margin-1 Level1
0x0004Field Margin-0 Level2
Table28-59. Set Field Margin Level Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] != 001 at command launch.
Set if command not available in current mode (seeTable28-27).
Set if an invalid margin level setting is supplied.
FPVIOLNone
MGSTAT1None
MGSTAT0None
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1063
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
CAUTION
Field margin levels must only be used during verify of the initial factory
programming.
NOTE
Field margin levels can be used to check that Flash memory contents have
Set if command not available in current mode (seeTable28-27)
Set if an invalid global address [17:0] is supplied
Set if a misaligned word address is supplied (global address [0] != 0)
Set if the requested section breaches the end of the EEPROM block
FPVIOLNone
MGSTAT1Set if any errors have been encountered during the read or if blank check failed.
MGSTAT0Set if any non-correctable errors have been encountered during the read or if
blank check failed.
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1064Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.4.6.15Program EEPROM Command
The Program EEPROM operation programs one to four previously erased words in the EEPROM block.
value at Program EEPROM command launch determines how many words will be programmed in the
EEPROM block. The CCIF flag is set when the operation has completed.
28.4.6.16Erase EEPROM Sector Command
The Erase EEPROM Sector operation will erase all addresses in a sector of the EEPROM block.
Table28-62. Program EEPROM Command FCCOB Requirements
CCOBIX[2:0]FCCOB Parameters
0000x11Global address [17:16] to
identify the EEPROM block
001Global address [15:0] of word to be programmed
010Word 0 program value
011Word 1 program value, if desired
100Word 2 program value, if desired
101Word 3 program value, if desired
Table28-63. Program EEPROM Command Error Handling
RegisterError BitError Condition
FSTAT
ACCERR
Set if CCOBIX[2:0] < 010 at command launch
Set if CCOBIX[2:0] > 101 at command launch
Set if command not available in current mode (seeTable28-27)
Set if an invalid global address [17:0] is supplied
Set if a misaligned word address is supplied (global address [0] != 0)
Set if the requested group of words breaches the end of the EEPROM block
FPVIOLSet if the selected area of the EEPROM memory is protected
MGSTAT1Set if any errors have been encountered during the verify operation
MGSTAT0Set if any non-correctable errors have been encountered during the verify
operation
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1065
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NOTE
Vector addresses and their relative interrupt priority are determined at the
MCU level.
28.4.7.1Description of Flash Interrupt Operation
The Flash module uses the CCIF flag in combination with the CCIE interrupt enable bit to generate the
will be completed before the MCU is allowed to enter stop mode.
Flash Error Interrupt Request
CCIF
CCIE
DFDIF
DFDIE
SFDIF
SFDIE
Flash Command Interrupt Request
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1067
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
28.5Security
The Flash module provides security information to the MCU. The Flash security state is defined by the
SEC bits of the FSEC register (seeTable28-11). During reset, the Flash module initializes the FSEC
keys stored in addresses 0x3_FF00-0x3_FF07 are unaffected by the Verify Backdoor Access Key
command sequence. The Verify Backdoor Access Key command sequence has no effect on the program
and erase protections defined in the Flash protection register, FPROT.
After the backdoor keys have been correctly matched, the MCU will be unsecured. After the MCU is
unsecured, the sector containing the Flash security byte can be erased and the Flash security byte can be
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1068Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
reprogrammed to the unsecure state, if desired. In the unsecure state, the user has full control of the
initialization sequence is marked by setting CCIF high which enables user commands.
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1069
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
state of the word being programmed or the sector/block being erased is not guaranteed.
240 KByte Flash Module (S12FTMRG240K2V1)
MC9S12G Family Reference Manual,Rev.1.06
1070Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1071
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
AppendixA
Electrical Characteristics
Revision History
A.1General
This supplement contains the most accurate electrical information for the MC9S12G microcontroller
available at the time of publication.
This introduction is intended to give an overview on several common topics like power supply, current
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.1.1Parameter Classification
The electrical parameters shown in this supplement are guaranteed by various methods. To give the
customer a better understanding the following classification is used and the parameters are tagged
accordingly in the tables where appropriate.
NOTE
This classification is shown in the column labeled “C” in the parameter
tables where appropriate.
P:Those parameters are guaranteed during production testing on each individual device.
the analog inputs, BKGD and theRESET pins. Some functionality may be disabled.
Electrical Characteristics
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1073
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.1.3.2Analog Reference
This group consists of the VRH pin.
A.1.3.3Oscillator
The pins EXTAL, XTAL dedicated to the oscillator have a nominal 1.8V level.
A.1.3.4TEST
This pin is used for production testing only. The TEST pin must be tied to ground in all applications.
A.1.4Current Injection
Power supply must maintain regulation within operating VDD35 or VDD range during instantaneous and
operating maximum current conditions. If positive injection current (Vin > VDD35) is greater than IDD35,
the injection current may flow out of VDD35 and could result in external power supply going out of
regulation. Ensure external VDD35 load will shunt current greater than maximum injection current. This
will be the greatest risk when the MCU is not consuming power; e.g., if no system clock is present, or if
clock rate is very low which would reduce overall power consumption.
This device contains circuitry protecting against damage due to high static voltage or electrical fields;
however, it is advised that normal precautions be taken to avoid application of any voltages higher than
maximum-rated voltages to this high-impedance circuit. Reliability of operation is enhanced if unused
inputs are tied to an appropriate logic voltage level (e.g., either VSS35 or VDD35).
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1074Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.1.6ESD Protection and Latch-up Immunity
All ESD testing is in conformity with CDF-AEC-Q100 stress test qualification for automotive grade
integrated circuits. During the device qualification ESD stresses were performed for the Human Body
specification. Complete DC parametric and functional testing is performed per the applicable device
specification at room temperature followed by hot temperature, unless specified otherwise in the device
specification.
TableA-1. Absolute Maximum Ratings1
1Beyond absolute maximum ratings device might be damaged.
NumRatingSymbolMinMaxUnit
1I/O, regulator and analog supply voltageVDD35–0.36.0V
2Voltage difference VDDX to VDDA∆VDDX–6.00.3V
3Voltage difference VSSX to VSSA∆VSSX–0.30.3V
4Digital I/O input voltageVIN–0.36.0V
5Analog referenceVRH–0.36.0V
6EXTAL, XTALVILV–0.32.16V
7Instantaneous maximum current
Single pin limit for all digital I/O pins2
2All digital I/O pins are internally clamped to VSSX and VDDX, or VSSA and VDDA.
ID–25+25mA
8Instantaneous maximum current
Single pin limit for EXTAL, XTAL
IDL–25+25mA
9Storage temperature rangeTstg–65155°C
TableA-2. ESD and Latch-up Test Conditions
ModelDescriptionSymbolValueUnit
Human Body
Series ResistanceR11500Ω
Storage CapacitanceC100pF
Number of Pulse per pin
positive
negative
-
-
3
3
Electrical Characteristics
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1075
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.1.7Operating Conditions
This section describes the operating conditions of the device. Unless otherwise noted those conditions
the ambient temperature TA and the junction temperature TJ. For power
dissipation calculations refer toSectionA.1.8, “Power Dissipation and
Thermal Characteristics”.
NOTE
Operation is guaranteed when powering down until low voltage reset
assertion.
TableA-3. ESD and Latch-Up Protection Characteristics
NumCRatingSymbolMinMaxUnit
1C
Human Body Model (HBM)VHBM2000-V
2C
Charge Device Model (CDM)VCDM500-V
3C
Charge Device Model (CDM) (Corner Pins)VCDM750-V
TableA-4. Operating Conditions
RatingSymbolMinTypMaxUnit
I/O, regulator and analog supply voltageVDD353.1355.5V
Oscillatorfosc4—16MHz
Bus frequencyfbus0.5—25MHz
Temperature Option C
Operating ambient temperature range1
Operating junction temperature range
1Please refer toSectionA.1.8, “Power Dissipation and Thermal Characteristics” for more details about the relation between
ambient temperature TA and device junction temperature TJ.
TA
TJ
–40
–40
27
—
85
105
°C
Temperature Option V
Operating ambient temperature range1
Operating junction temperature range
TA
TJ
–40
–40
27
—
105
125
°C
Temperature Option M
Operating ambient temperature range1
Operating junction temperature range
TA
TJ
–40
–40
27
—
125
150
°C
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1076Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.1.8Power Dissipation and Thermal Characteristics
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1078Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
TableA-5. Thermal Package Characteristics1
NumCRatingSymbolS12GN32,
S12GN16
S12G64,
S12G48,
S12GN48
S12G128,
S12G96
S12G240,
S12GA240,
S12G192,
S12GA192
Unit
20-pin TSSOP
1D
Thermal resistance single sided PCB,
natural convection2θJA91°C/W
2D
Thermal resistance single sided PCB
@ 200 ft/min3θJMA72°C/W
3D
Thermal resistance double sided PCB
with 2 internal planes, natural convection3θJA58°C/W
4D
Thermal resistance double sided PCB
with 2 internal planes @ 200 ft/min3θJMA51°C/W
5DJunction to Board4θJB29°C/W
6DJunction to Case5θJC20°C/W
7DJunction to Package Top6ΨJT4°C/W
32-pin LQFP
8D
Thermal resistance single sided PCB,
natural convection2θJA8184°C/W
9D
Thermal resistance single sided PCB
@ 200 ft/min3θJMA6870°C/W
10DThermal resistance double sided PCB
with 2 internal planes, natural convection3θJA5756°C/W
11DThermal resistance double sided PCB
with 2 internal planes @ 200 ft/min3θJMA5049°C/W
12DJunction to Board4θJB3532°C/W
13DJunction to Case5θJC2523°C/W
14DJunction to Package Top6ΨJT86°C/W
48-pin LQFP
15DThermal resistance single sided PCB,
natural convection2θJA81807975°C/W
16DThermal resistance single sided PCB
@ 200 ft/min3θJMA68676662°C/W
17DThermal resistance double sided PCB
with 2 internal planes, natural convection3θJA57565651°C/W
18DThermal resistance double sided PCB
with 2 internal planes @ 200 ft/min3θJMA50504945°C/W
19DJunction to Board4θJB35343330°C/W
20DJunction to Case5θJC25242119°C/W
21DJunction to Package Top6ΨJT864N/A°C/W
Electrical Characteristics
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1079
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
48-pin QFN
22DThermal resistance single sided PCB,
natural convection2θJA82°C/W
23DThermal resistance single sided PCB
@ 200 ft/min3θJMA67°C/W
24DThermal resistance double sided PCB
with 2 internal planes, natural convection3θJA28°C/W
25DThermal resistance double sided PCB
with 2 internal planes @ 200 ft/min3θJMA23°C/W
26DJunction to Board4θJB11°C/W
27DJunction to Case5θJCN/A°C/W
28DJunction to Package Top6ΨJT4°C/W
64-pin LQFP
29DThermal resistance single sided PCB,
natural convection2θJA707070°C/W
30DThermal resistance single sided PCB
@ 200 ft/min3θJMA595858°C/W
31DThermal resistance double sided PCB
with 2 internal planes, natural convection3θJA525252°C/W
32DThermal resistance double sided PCB
with 2 internal planes @ 200 ft/min3θJMA464645°C/W
33DJunction to Board4θJB343435°C/W
34DJunction to Case5θJC201817°C/W
35DJunction to Package Top6ΨJT54N/A°C/W
100-pin LQFP
36DThermal resistance single sided PCB,
natural convection2θJA6162°C/W
37DThermal resistance single sided PCB
@ 200 ft/min3θJMA5155°C/W
38DThermal resistance double sided PCB
with 2 internal planes, natural convection3θJA4951°C/W
39DThermal resistance double sided PCB
with 2 internal planes @ 200 ft/min3θJMA4347°C/W
40DJunction to Board4θJB3437°C/W
41DJunction to Case5θJC1617°C/W
42DJunction to Package Top6ΨJT3N/A°C/W
1The values for thermal resistance are achieved by package simulations
TableA-5. Thermal Package Characteristics1
NumCRatingSymbolS12GN32,
S12GN16
S12G64,
S12G48,
S12GN48
S12G128,
S12G96
S12G240,
S12GA240,
S12G192,
S12GA192
Unit
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1080Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.2I/O Characteristics
This section describes the characteristics of all I/O pins except EXTAL, XTAL, TEST, and supply pins.
2Per JEDEC JESD51-2 with the single layer board (JESD51-3) horizontal.J
3Per JEDEC JESD51-6 with the board (JESD51-7) horizontal.
per JEDEC JESD51-2.ΨJT is a useful value to use to estimate junction temperature in a steady state customer enviroment.
TableA-6. 3.3-V I/O Characteristics
ALL 3.3V RANGE I/O PARAMETERS ARE SUBJECT TO CHANGE FOLLOWING CHARACTERIZATION
Conditions are 3.15 V < VDD35< 3.6 V junction temperature from –40°C to +150°C, unless otherwise noted
I/O Characteristics for all I/O pins except EXTAL, XTAL,TEST and supply pins.
NumCRatingSymbolMinTypMaxUnit
1PInput high voltageVIH0.65V*VDD35——V
2TInput high voltageVIH——V
DD35+0.3V
3PInput low voltageVIL——0.35*VDD35V
4TInput low voltageVILVSS35 – 0.3——V
5CInput hysteresisVHYS0.06V*VDD35—0.3V*VDD35mV
6
P
Input leakage current (pins in high impedance input
mode)1 Vin= VDD35or VSS35
M temperature range
V temperature range
C temperature range
Iin
-1
-0.5
-0.4
—
—
—
1
0.5
0.4
µA
7POutput high voltage (pins in output mode)
IOH= –1.75 mA
VOHVDD35-0.4——V
8COutput low voltage (pins in output mode)
IOL= +1.75 mA
VOL——
0.4V
9PInternal pull up device current
VIH min > input voltage > VIL max
IPUL-1— –70µA
10PInternal pull down device current
VIH min > input voltage > VIL max
IPDH1—70µA
11DInput capacitanceCin—7—pF
12TInjection current2
Single pin limit
Total device limit, sum of all injected currents
IICS
IICP
–2.5
–25
—
2.5
25
mA
13PPort J, P, AD interrupt input pulse filtered (STOP)3tP_MASK——3µs
14PPort J, P, AD interrupt input pulse passed (STOP)3tP_PASS10——µs
15DPort J, P, AD interrupt input pulse filtered (STOP) in
number of bus clock cycles of period 1/fbus
nP_MASK——3
Electrical Characteristics
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1081
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
16DPort J, P, AD interrupt input pulse passed (STOP) in
8°C to 12C° in the temperature range from 50°C to 125°C.
2Refer toSectionA.1.4, “Current Injection” for more details
3Parameter only applies in stop or pseudo stop mode.
TableA-6. 3.3-V I/O Characteristics
ALL 3.3V RANGE I/O PARAMETERS ARE SUBJECT TO CHANGE FOLLOWING CHARACTERIZATION
Conditions are 3.15 V < VDD35< 3.6 V junction temperature from –40°C to +150°C, unless otherwise noted
I/O Characteristics for all I/O pins except EXTAL, XTAL,TEST and supply pins.
NumCRatingSymbolMinTypMaxUnit
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1082Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.2.1Supply Currents
This section describes the current consumption characteristics of the device as well as the conditions for
the measurements.
TableA-7. 5-V I/O Characteristics
ALL 5V RANGE I/O PARAMETERS ARE SUBJECT TO CHANGE FOLLOWING CHARACTERIZATION
Conditions are 4.5 V < VDD35< 5.5 V junction temperature from –40°C to +150°C, unless otherwise noted
I/O Characteristics for all I/O pins except EXTAL, XTAL,TEST and supply pins.
NumCRatingSymbolMinTypMaxUnit
1PInput high voltageVIH0.65*VDD35——V
2TInput high voltageVIH——V
DD35+0.3V
3PInput low voltageVIL——0.35*VDD35V
4TInput low voltageVILVSSRX–0.3——V
5CInput hysteresisVHYS0.06V*VDD35—0.3V*VDD35mV
6
P
Input leakage current (pins in high impedance input
mode)1 Vin= VDD35or VSS35
M temperature range
V temperature range
C temperature range
Iin
-1
-0.5
-0.4
—
—
—
1
0.5
0.4
µA
7POutput high voltage (pins in output mode)
IOH= –4 mA
VOHVDD35 – 0.8——V
8POutput low voltage (pins in output mode)
IOL= +4mA
VOL——0.8V
9PInternal pull up current
VIH min > input voltage > VIL max
IPUL-10—-130µA
10PInternal pull down current
VIH min > input voltage > VIL max
IPDH10—130µA
11DInput capacitanceCin—7—pF
12TInjection current2
Single pin limit
Total device Limit, sum of all injected currents
IICS
IICP
–2.5
–25
—
2.5
25
mA
13PPort J, P, AD interrupt input pulse filtered (STOP)3tP_MASK——3µs
14PPort J, P, AD interrupt input pulse passed (STOP)3tP_PASS10——µs
15DPort J, P, AD interrupt input pulse filtered (STOP) in
number of bus clock cycles of period 1/fbus
nP_MASK——3
16DPort J, P, AD interrupt input pulse passed (STOP) in
8°C to 12C° in the temperature range from 50°C to 125°C.
2Refer toSectionA.1.4, “Current Injection” for more details
3Parameter only applies in stop or pseudo stop mode.
Electrical Characteristics
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1083
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.2.1.1Measurement Conditions
Run current is measured on VDDR pin. It does not include the current to drive external loads. Unless
to 1MHz. The bus frequency is 25MHz and the CPU frequency is 50MHz. TableA-8., TableA-9. and
TableA-10. show the configuration of the CPMU module and the peripherals for Run, Wait and Stop
current measurement.
TableA-8. CPMU Configuration for Pseudo Stop Current Measurement
CPMU REGISTERBit settings/Conditions
CPMUCLKSPLLSEL=0, PSTP=1,
PRE=PCE=RTIOSCSEL=COPOSCSEL=1
CPMUOSCOSCE=1, External Square wave on EXTAL fEXTAL=4MHz,
VIH= 1.8V, VIL=0V
CPMURTIRTDEC=0, RTR[6:4]=111, RTR[3:0]=1111;
CPMUCOPWCOP=1, CR[2:0]=111
TableA-9. CPMU Configuration for Run/Wait and Full Stop Current Measurement
CPMU REGISTERBit settings/Conditions
CPMUSYNRVCOFRQ[1:0]=01,SYNDIV[5:0] = 24
CPMUPOSTDIVPOSTDIV[4:0]=0
CPMUCLKSPLLSEL=1
CPMUOSCOSCE=0,
Reference clock for PLL is fref=firc1m trimmed to 1MHz
API settings for STOP current measurement
CPMUAPICTLAPIEA=0, APIFE=1, APIE=0
CPMUAPITRtrimmed to 10Khz
CPMUAPIRH/RLset to $FFFF
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1084Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
TableA-10. Peripheral Configurations for Run & Wait Current Measurement
PeripheralConfiguration
MSCANConfigured to loop-back mode using a bit rate of 1Mbit/s
SPIConfigured to master mode, continuously transmit data
(0x55 or 0xAA) at 1Mbit/s
SCIConfigured into loop mode, continuously transmit data
(0x55) at speed of 57600 baud
PWMConfigured to toggle its pins at the rate of 40kHz
ADC
The peripheral is configured to operate at its maximum
1Onlly available on S12GN16, S12GN32, S12GN48, S12G48, and S12G64
The module is enabled with analog output on. The ACMPP
and ACMPM are toggling with 0-1 and 1-0.
DAC2
2Only available on S12G192, S12GA192, S12G340, and S12GA240
DAC0 and DAC1 is buffered at full voltage range
(DACxCTL = $87).
RVA3
3Only available on S12GA192 and S12GA240
ThemoduleisenabledandADCisrunningat6.25MHzwith
maximum bus freq
Electrical Characteristics
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1085
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
TableA-11. Run and Wait Current Characteristics
Conditions are: VDDR=5.5V, TA=125°C, see TableA-9. and TableA-10.
NumCRatingSymbolMinTypMaxUnit
S12GN16, S12GN32
1PIDD Run Current (code execution from RAM)IDDRr12.516mA
2CIDD Run Current (code execution from flash)IDDRf13mA
3PIDD Wait CurrentIDDW7.210mA
S12GN48, S12G48, S12G64
4PIDD Run Current (code execution from RAM)IDDRr1419mA
5CIDD Run Current (code execution from flash)IDDRf15.5mA
6PIDD Wait CurrentIDDW8.711mA
S12G96, S12G128
7PIDD Run Current (code execution from RAM)IDDRr1521mA
8CIDD Run Current (code execution from flash)IDDRf17mA
9PIDD Wait CurrentIDDW911.5mA
S12G192, S12GA192, S12G240, S12GA240
10PIDD Run Current (code execution from RAM)IDDRr1822.5mA
11CIDD Run Current (code execution from flash)IDDRf17mA
12PIDD Wait CurrentIDDW9.512mA
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1086Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
TableA-12. Full Stop Current Characteristics
Conditions are: Typ: VDDX,VDDR,VDDA=5V, Max: VDDX,VDDR,VDDA=5.5V API see TableA-9.
NumCRatingSymbolMinTypMaxUnit
S12GN16, S12GN32
Stop Current API disabled
1P-40°CI
DDS14.424µA
2P25°CI
DDS16.528µA
3P150°CI
DDS120320µA
Stop Current API enabled
4C-40°CI
DDS18.5µA
5C25°CI
DDS21.5µA
6C150°CI
DDS130µA
S12GN48, S12G48, S12G64
Stop Current API disabled
7P-40°CI
DDS1627µA
8P25°CI
DDS18.530µA
9P150°CI
DDS140360µA
Stop Current API enabled
10C-40°CI
DDS20µA
11C25°CI
DDS23.5µA
12C150°CI
DDS150µA
S12G96, S12G128
Stop Current API disabled
13P-40°CI
DDS16.528µA
14P25°CI
DDS1932µA
15P150°CI
DDS150400µA
Stop Current API enabled
16C-40°CI
DDS20.5µA
17C25°CI
DDS24µA
18C150°CI
DDS160µA
S12G192, S12GA192, S12G240, S12GA240
Stop Current API disabled
19P-40°CI
DDS1730µA
20P25°CI
DDS19.534µA
21P150°CI
DDS155420µA
Stop Current API enabled
22C-40°CI
DDS21µA
23C25°CI
DDS24.5µA
24C150°CI
DDS160µA
Electrical Characteristics
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1087
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
TableA-13. Pseudo Stop Current Characteristics
A.3ADC Characteristics
This section describes the characteristics of the analog-to-digital converter.
A.3.1ADC Operating Characteristics
TheTableA-14 andTableA-15 show conditions under which the ADC operates.
The following constraints exist to obtain full-scale, full range results:
VSSA≤VRL ≤VIN ≤VRH ≤VDDA.
Conditions are: VDDX=5V, VDDR=5V, VDDA=5V, RTI and COP and API enabled, see TableA-8.
NumCRatingSymbolMinTypMaxUnit
S12GN16, S12GN32
1C-40°CI
DDPS300µA
2C25°CI
DDPS310µA
3C150°CI
DDPS430µA
S12GN48, S12G48, S12G64
4C-40°CI
DDPS320µA
5C25°CI
DDPS330µA
6C150°CI
DDPS510µA
S12G96, S12G128
7C-40°CI
DDPS340µA
8C25°CI
DDPS350µA
9C150°CI
DDPS520µA
S12G192, S12GA192, S12G240, S12GA240
10C-40°CI
DDPS370µA
11C25°CI
DDPS380µA
12C150°CI
DDPS550µA
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1088Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Supply voltage 3.13 V < VDDA < 5.5 V, -40oC < TJ < 150oC
NumCRatingSymbolMinTypMaxUnit
1DReference potential
Low
High
VRL
VRH
VSSA
VDDA/2
—
—
VDDA/2
VDDA
V
V
2DVoltage difference VDDX to VDDA∆VDDX–2.3500.1V
3DVoltage difference VSSX to VSSA∆VSSX–0.100.1V
4CDifferential reference voltage1
1Full accuracy is not guaranteed when differential voltage is less than 4.50 V
VRH-VRL3.135.05.5V
5CADC Clock Frequency (derived from bus clock via the
prescaler bus)fADCCLk
0.258.0MHz
8D
ADC Conversion Period2
12 bit resolution:
10 bit resolution:
8 bit resolution:
2The minimum time assumes a sample time of 4 ADC clock cycles. The maximum time assumes a sample time of 24 ADC
clock cycles and the discharge feature (SMP_DIS) enabled, which adds 2 ADC clock cycles.
NCONV12
NCONV10
NCONV8
20
19
17
42
41
39
ADC
clock
Cycles
Electrical Characteristics
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1089
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
TableA-16 andTableA-18 specifies the ADC conversion performance excluding any errors due to
current injection, input capacitance and source resistance.
TableA-15. ADC Electrical Characteristics
Supply voltage 3.13 V < VDDA < 5.5 V, -40oC < TJ < 150oC
NumCRatingSymbolMinTypMaxUnit
1CMax input source resistance1
11 Refer toA.3.2.2 for further information concerning source resistance
RS——1KΩ
2DTotal input capacitance Non sampling
Total input capacitance Sampling
CINN
CINS
—
—
—
—
10
16
pF
3DInput internal ResistanceRINA-515kΩ
4CDisruptive analog input currentINA-2.5—2.5mA
5CCoupling ratio positive current injectionKp——1E-4A/A
6CCoupling ratio negative current injectionKn——5E-3A/A
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1090Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.3.3.1ADC Accuracy Definitions
For the following definitions see alsoFigureA-1.
Differential non-linearity (DNL) is defined as the difference between two adjacent switching steps.
The integral non-linearity (INL) is defined as the sum of all DNLs:
DNLi()ViVi1–
–
1LSB
--------------------------1–=
INLn()DNLi()
i1=
n
∑VnV0
–
1LSB
---------------------n–==
Electrical Characteristics
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1091
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
FigureA-1. ADC Accuracy Definitions
NOTE
FigureA-1 shows only definitions, for specification values refer to
TableA-16 andTableA-18.
1
5Vin
mV
101520253035408590951001051101151206570758060
0
3
2
5
4
7
6
45
$3F7
$3F9
$3F8
$3FB
$3FA
$3FD
$3FC
$3FE
$3FF
$3F4
$3F6
$3F5
8
9
1
2
$FF
$FE
$FD
$3F3
10-Bit Resolution
8-Bit Resolution
Ideal Transfer Curve
10-Bit Transfer Curve
8-Bit Transfer Curve
55
10-Bit Absolute Error Boundary
8-Bit Absolute Error Boundary
LSB
Vi-1Vi
DNL
5000 +
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1092Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
TableA-16. ADC Conversion Performance 5V range
S12GA192 and S12GA240
Supply voltage VDDA =5.12 V, -40oC < TJ < 150oC. VREF = VRH - VRL = 5.12V. fADCCLK = 8.0MHz
The values are tested to be valid with no PortAD output drivers switching simultaneous with conversions.
NumCRating1
1The 8-bit and 10-bit mode operation is structurally tested in production test. Absolute values are tested in 12-bit mode.
SymbolMinTypMaxUnit
1PResolution12-BitLSB1.25mV
2PDifferential Nonlinearity12-BitDNL-4±24counts
3PIntegral Nonlinearity12-BitINL-5±2.55counts
4PAbsolute Error2
2These values include the quantization error which is inherently 1/2 count for any A/D converter.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
TableA-19. ADC Conversion Performance 3.3V range
1The 8-bit and 10-bit mode operation is structurally tested in production test. Absolute values are tested in 12-bit mode.
2These values include the quantization error which is inherently 1/2 count for any A/D converter.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
3Please note: although different in value, drift of vrh_int and vrl_int will go in the same direction.
Vvrh_drift-22mV
8CVRL_INT drift vs temperatureVvrl_drift-2.52.5mV
9Crva turn on settling timetsettling_on2.5µs
10Crva turn off settling timetsettling_off1µs
NumCRatingSymbolMinTypMaxUnit
1T Temperature Sensor SlopedVTS-4.0-3.8-3.6mV/°C
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1096Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.4ACMP Characteristics
This section describes the electrical characteristics of the analog comparator.
noted reflect the approximate parameter mean at TA = 25˚C under nominal conditions unless otherwise noted.
NumCRatingsSymbolMinTypMaxUnit
1
D
C
Supply Current of ACMP
module disabled
module enabled∆Vin > 0.1V
Ioff
Irun100
-
180
5
270
µA
µA
2PCommonmodeInputvoltagerangeACMPM,
ACMPP
Vin0-V
DDA-1.5VV
3PInput OffsetVoffset-40040mV
4CInput HysteresisVhyst3720mV
5PSwitchdelayfor-0.1Vto0.1Vinputstep(w/o
synchronize delay)
tdelay-0.30.6µs
OffsetHysteresis
ACMPM
ACMPP
ACMPO
V
t
Electrical Characteristics
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1097
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.5DAC Characteristics
This section describes the electrical characteristics of the digital to analog converter.
6DDAC Range A (FVR bit = 1)Vout0...255/256(VRH-VRL)+VRLV
7DDAC Range B (FVR bit = 0Vout32...287/320(VRH-VRL)+VRLV
8COutput Voltage
unbuffered range A or B (load >= 50MΩ)V
outfull DAC Range A or BV
9POutput Voltage (DRIVE bit = 0)1
buffered range A (load >= 100KΩ to VSSA)
buffered range A (load >= 100KΩto VDDA)
buffered range B (load >= 100KΩ to VSSA)
buffered range B (load >= 100KΩ to VDDA)
1DRIVE bit = 1 is not recomended in this case.
Vout
0
0.15
-
-
VDDA-0.15
VDDAV
full DAC Range B
10POutput Voltage (DRIVE bit = 1)2
bufferedrangeBwith6.4KΩloadintoresistor
divider of 800Ω /6.56KΩ between VDDA and
VSSA.
(equivalent load is >= 65KΩto VSSA) or
(equivalent load is >= 7.5KΩ to VDDA)
2DRIVE bit = 0 is not allowed with this high load.
Voutfull DAC Range BV
11DBuffer Output Capacitive loadCload0-100pF
12PBuffer Output OffsetVoffset-30-+30mV
13PSettling timetdelay-35µs
14DReverence voltage highVrefhVDDA-0.1VVDDAVDDA+0.1VV
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1098Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
at relative address zero. It takes one bus cycle per phrase to verify plus a setup of the command.
tcheck644001
fNVMBUS
---------------------
⋅=
tcheck336001
fNVMBUS
---------------------
⋅=
tcheck180001
fNVMBUS
---------------------
⋅=
tcheck93001
fNVMBUS
---------------------
⋅=
Electrical Characteristics
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1099
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Assuming that no non-blank location is found, then the time to erase verify a P-Flash block is given by:
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
FTMRG32K1, FTMRG16K1:
A.6.1.3Erase Verify P-Flash Section (FCMD=0x03)
The maximum time to erase verify a section of P-Flash depends on the number of phrases being verified
(NVP) and is given by:
A.6.1.4Read Once (FCMD=0x04)
The maximum read once time is given by:
A.6.1.5Program P-Flash (FCMD=0x06)
The programming time for a single phrase of four P-Flash words and the two seven-bit ECC fields is
dependent on the bus frequency, fNVMBUS, as well as on the NVM operating frequency, fNVMOP
.
The typical phrase programming time is given by:
The maximum phrase programming time is given by:
A.6.1.6Program Once (FCMD=0x07)
The maximum time required to program a P-Flash Program Once field is given by:
A.6.1.7Erase All Blocks (FCMD=0x08)
The time required to erase all blocks is given by:
tdcheck26201
fNVMBUS
---------------------
⋅=
t550NVP
+()
1
fNVMBUS
---------------------
⋅≈
t5501
fNVMBUS
---------------------
⋅=
tppgm621
fNVMOP
------------------29001
fNVMBUS
---------------------
⋅+⋅≈
tppgm621
fNVMOP
------------------31001
fNVMBUS
---------------------
⋅+⋅≈
t621
fNVMOP
------------------29001
fNVMBUS
---------------------
⋅+⋅≈
Electrical Characteristics
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1101
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
FTMRG240K2, FTMRG192K2:
FTMRG128K1, FTMRG96K1:
FTMRG64K1, FTMRG48K1:
FTMRG32K1, FTMRG16K1:
A.6.1.8Erase P-Flash Block (FCMD=0x09)
The time required to erase the P-Flash block is given by:
FTMRG240K2, FTMRG192K1:
FTMRG128K1, FTMRG96K1:
FTMRG64K1, FTMRG64K1:
FTMRG32K1, FTMRG16K1:
tmass2001301
fNVMOP
------------------650001
fNVMBUS
---------------------
⋅+⋅≈
tmass1000681
fNVMOP
------------------335001
fNVMBUS
---------------------
⋅+⋅≈
tmass1000681
fNVMOP
------------------183001
fNVMBUS
---------------------
⋅+⋅≈
tmass1000681
fNVMOP
------------------96001
fNVMBUS
---------------------
⋅+⋅≈
tpmass2001241
fNVMOP
------------------627001
fNVMBUS
---------------------
⋅+⋅≈
tpmass1000621
fNVMOP
------------------313001
fNVMBUS
---------------------
⋅+⋅≈
tpmass1000621
fNVMOP
------------------171001
fNVMBUS
---------------------
⋅+⋅≈
tpmass1000621
fNVMOP
------------------90001
fNVMBUS
---------------------
⋅+⋅≈
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1102Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.6.1.9Erase P-Flash Sector (FCMD=0x0A)
The typical time to erase a 512-byte P-Flash sector is given by:
The maximum time to erase a 512-byte P-Flash sector is given by:
A.6.1.10Unsecure Flash (FCMD=0x0B)
The maximum time required to erase and unsecure the Flash is given by:
FTMRG240K2, FTMRG192K2:
FTMRG128K1, FTMRG96K1:
FTMRG64K1, FTMRG48K1:
FTMRG32K1, FTMRG16K1:
A.6.1.11Verify Backdoor Access Key (FCMD=0x0C)
The maximum verify backdoor access key time is given by:
A.6.1.12Set User Margin Level (FCMD=0x0D)
The maximum set user margin level time is given by:
tpera204001
fNVMOP
------------------
⋅7201
fNVMBUS
---------------------
⋅+≈
tpera204001
fNVMOP
------------------
⋅17001
fNVMBUS
---------------------
⋅+≈
tuns2001301
fNVMOP
------------------651001
fNVMBUS
---------------------
⋅+⋅≈
tuns1000701
fNVMOP
------------------335001
fNVMBUS
---------------------
⋅+⋅≈
tuns1000701
fNVMOP
------------------183001
fNVMBUS
---------------------
⋅+⋅≈
tuns1000701
fNVMOP
------------------96001
fNVMBUS
---------------------
⋅+⋅≈
t5201
fNVMBUS
---------------------
⋅=
Electrical Characteristics
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1103
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.6.1.13Set Field Margin Level (FCMD=0x0E)
The maximum set field margin level time is given by:
A.6.1.14Erase Verify EEPROM Section (FCMD=0x10)
The time required to Erase Verify EEPROM for a given number of words NWis given by:
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Maximum EEPROM sector erase times is given by:
The EEPROM sector erase time is ~5ms on a new device and can extend to ~20ms as the flash is cycled.
tdera204001
fNVMOP
------------------7501
fNVMBUS
---------------------
⋅+⋅≈
Electrical Characteristics
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1105
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
TableA-24. NVM Timing Characteristics
NumCRatingSymbolMinTyp1Max2Unit3
1Bus frequencyfNVMBUS1—25MHz
2Operating frequencyfNVMOP0.81.01.05MHz
3DErase all blocks (mass erase) time
(FTMRG240K2, TMRG192K2)
tmass—200260ms
Erase all blocks (mass erase) time
(FTMRG128K1, FTMRG96K1)
tmass—100130ms
Erase all blocks (mass erase) time
(FTMRG128K1, FTMRG96K1)
tmass—100130ms
Erase all blocks (mass erase) time
(FTMRG32K1, FTMRG16K1
tmass—100130ms
4DErase verify all blocks (blank check) time
(FTMRG240K2, TMRG192K2)
tcheck——64400tcyc
Erase verify all blocks (blank check) time
(FTMRG128K1, FTMRG96K1)
tcheck——33600tcyc
Erase verify all blocks (blank check) time
(FTMRG64K1, FTMRG48K1)
tcheck——18000tcyc
Erase verify all blocks (blank check) time
(FTMRG32K1, FTMRG16K1)
tcheck——9300tcyc
5DUnsecure Flash time
(FTMRG240K2, TMRG192K2)
tuns—200260ms
Unsecure Flash time
(FTMRG128K1, FTMRG96K1)
tuns—100130ms
Unsecure Flash time
(FTMRG64K1, FTMRG48K1)
tuns—100130ms
Unsecure Flash time
(FTMRG32K1, FTMRG16K1)
tuns—100130ms
6DP-Flash block erase time
(FTMRG240K2, TMRG192K2)
tpmass—200260ms
P-Flash block erase time
(FTMRG128K1, FTMRG96K1)
tpmass—100130ms
P-Flash block erase time
(FTMRG64K1, FTMRG48K1)
tpmass—100130ms
P-Flash block erase time
(FTMRG32K1, FTMRG16K1)
tpmass—100130ms
7DP-Flash erase verify (blank check) time
(FTMRG240K2, FTMRG192K2)
tpcheck——62200tcyc
P-Flash erase verify (blank check) time
(FTMRG128K1, FTMRG96K1)
tpcheck——33400tcyc
P-Flash erase verify (blank check) time
(FTMRG64K1, FTMRG48K1)
tpcheck——16700tcyc
P-Flash erase verify (blank check) time
(FTMRG32K1, FTMRG16K1)
tpcheck——33400tcyc
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1106Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.6.2NVM Reliability Parameters
The reliability of the NVM blocks is guaranteed by stress test during qualification, constant process
monitors and burn-in to screen early life failures.
The program/erase cycle count on the sector is incremented every time a sector or mass erase event is
executed.
8DP-Flash sector erase timetpera—2026ms
9DP-Flash phrase programming timetppgm—185200µs
10DEEPROM sector erase timetdera—5
426ms
11DEEPROM erase verify (blank check) time
(FTMRG240K2, TMRG192K2)
tdcheck——2620tcyc
EEPROM erase verify (blank check) time
(FTMRG128K1, FTMRG96K1)
tdcheck——2620tcyc
EEPROM erase verify (blank check) time
(FTMRG64K1, FTMRG48K1)
tdcheck——1540tcyc
EEPROM erase verify (blank check) time
(FTMRG32K1, FTMRG16K1)
tdcheck——1030tcyc
12aDEEPROM one word programming timetdpgm1—97106µs
12bDEEPROM two word programming timetdpgm2—140154µs
1Typical program and erase times are based on typical fNVMOP and maximum fNVMBUS
2Maximum program and erase times are based on minimum fNVMOP and maximum fNVMBUS
3tcyc= 1 /fNVMBUS
4Typical value for a new device
NumCRatingSymbolMinTyp1Max2Unit3
Electrical Characteristics
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1107
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.7Phase Locked Loop
A.7.1Jitter Definitions
With each transition of the feedback clock, the deviation from the reference clock is measured and input
voltage to the VCO is adjusted accordingly.The adjustment is done continuously with no abrupt changes
in the VCOCLK frequency. Noise, voltage, temperature and other factors cause slight variations in the
Typical Endurance, please refer to Engineering Bulletin EB619.
—Cycles
EEPROM Array
3CData retention at an average junction temperature of TJavg = 85°C1
after up to 100,000 program/erase cycles
tNVMRET51002—Years
4CData retention at an average junction temperature of TJavg = 85°C1
after up to 10,000 program/erase cycles
tNVMRET101002—Years
5CData retention at an average junction temperature of TJavg = 85°C1
after less than 100 program/erase cycles
tNVMRET201002—Years
6CEEPROM number of program/erase cycles (-40°C≤ Tj≤ 150°C)nFLPE100K500K3—Cycles
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1108Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.7.2Electrical Characteristics for the PLL
A.8Electrical Characteristics for the IRC1M
TableA-26. PLL Characteristics
Conditions are shown inTableA-11 unless otherwise noted
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.9Electrical Characteristics for the Oscillator (XOSCLCP)
A.10Reset Characteristics
TableA-28. XOSCLCP Characteristics
Conditions are shown inTableA-11 unless otherwise noted
NumCRatingSymbolMinTypMaxUnit
1CNominal crystal or resonator frequencyfOSC4.016MHz
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.11Electrical Specification for Voltage Regulator
NOTE
TheLVRmonitorsthevoltagesVDD,V
DDFandVDDX.Assoonasvoltage
drops on these supplies which would prohibit the correct function of the
microcontroller, the LVR is triggering a reset.
TableA-30. Voltage Regulator Characteristics
NumCCharacteristicSymbolMinTypicalMaxUnit
1PInput VoltagesVVDDR,A3.13—5.5V
2PVDDA Low Voltage Interrupt Assert Level1
VDDA Low Voltage Interrupt Deassert Level
1Monitors VDDA, active only in Full Performance Mode. Indicates I/O & ADC performance degradation due to low supply
voltage.
VLVIA
VLVID
4.04
4.19
4.23
4.38
4.40
4.49
V
V
3PVDDX Low Voltage Reset Deassert234
2Device functionality is guaranteed on power down to the LVR assert level
3Monitors VDDX, active only in Full Performance Mode. MCU is monitored by the POR in RPM (seeFigureA-5)
4VLVRXA < VLVRXD. The hysteresis is unspecified and untested.
VLVRXD—3.053.13V
4PVDDX Low Voltage Reset Assert234VLVRXA2.953.02—V
5TCPMU ACLK frequency
(CPMUACLKTR[5:0] = %000000)fACLK—10—KHz
6CTrimmed ACLK internal clock5∆f / fnominal
5The ACLK Trimming CPMUACLKTR[5:0] bits must be set so that fACLK=10KHz.
dfACLK- 5%—+ 5%—
7
D
The first period after enabling the counter
by APIFE might be reduced by ACLK start
up delay
tsdel——100us
8DThe first period after enabling the COP
might be reduced by ACLK start up delaytsdel——100us
9
P
Output Voltage Flash
Full Performance Mode
Reduced Power Mode (MCU STOP mode)
VDDF2.6
1.1
2.82
1.6
2.9
2.98
V
V
10
C
VDDF Voltage Distribution
over input voltage VDDA6
4.5V≤ VDDA≤ 5.5V, TA = 27oC
compared to VDDA = 5.0V
6VDDR≥ 3.13V
∆VDDF-505mV
11
C
VDDF Voltage Distribution
over ambient temperature TA
VDDA= 5V, -40°C≤ TA≤ 125°C
compared to VDDF production test value
(seeA.15, “ADC Conversion Result
Reference”)
∆VDDF-20-+20mV
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1112Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Conditions are shown inTableA-4 unless otherwise noted
NumCRatingSymbolMinTypMaxUnit
1PMSCAN wakeup dominant pulse filteredtWUP——1.5µs
2PMSCAN wakeup dominant pulse passtWUP5——µs
VLVID
VLVIA
VLVRD
VLVRA
VPORD
LVI
POR
LVR
t
VVDDA/VDDX
VDD
LVI enabledLVI disabled due to LVR
Electrical Characteristics
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1113
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
A.14SPI Timing
This section provides electrical parametrics and ratings for the SPI. InTableA-32 the measurement
conditions are listed.
A.14.1Master Mode
InFigureA-6 the timing diagram for master mode with transmission format CPHA = 0 is depicted.
FigureA-6. SPI Master Timing (CPHA = 0)
TableA-32. Measurement Conditions
Conditions are 4.5 V < VDD35< 5.5 V junction temperature from –40°C to +150°C.
DescriptionValueUnit
Drive modeFull drive mode—
Load capacitance CLOAD1,on all outputs
1Timing specified for equal load on all SPI output pins. Avoid asymmetric load.
50pF
Thresholds for delay measurement points(35% / 65%) VDDXV
SCK
(Output)
SCK
(Output)
MISO
(Input)
MOSI
(Output)
SS
(Output)
1
9
56
MSB IN2
Bit MSB-1. . . 1
LSB IN
MSB OUT2LSB OUT
Bit MSB-1. . . 1
11
4
4
2
10
(CPOL = 0)
(CPOL = 1)
3
13
13
1. If configured as an output.
2. LSBF = 0. For LSBF = 1, bit order is LSB, bit 1, bit 2... MSB.
12
12
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1114Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
InFigureA-7 the timing diagram for master mode with transmission format CPHA=1 is depicted.
FigureA-7. SPI Master Timing (CPHA = 1)
SCK
(Output)
SCK
(Output)
MISO
(Input)
MOSI
(Output)
1
56
MSB IN2
Bit MSB-1. . . 1
LSB IN
Master MSB OUT2Master LSB OUT
Bit MSB-1. . . 1
4
4
9
1213
11
Port Data
(CPOL = 0)
(CPOL = 1)
Port Data
SS
(Output)
212133
1.If configured as output
2. LSBF = 0. For LSBF = 1, bit order is LSB, bit 1,bit 2... MSB.
Electrical Characteristics
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1115
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
InTableA-33 the timing characteristics for master mode are listed.
A.14.2Slave Mode
InFigureA-8 the timing diagram for slave mode with transmission format CPHA = 0 is depicted.
FigureA-8. SPI Slave Timing (CPHA = 0)
TableA-33. SPI Master Mode Timing Characteristics
Conditions are 4.5 V < VDD35< 5.5 V junction temperature from –40°C to +150°C.
NumCCharacteristicSymbolMinTypMaxUnit
1DSCK Frequencyfsck1/2048—1/2fbus
1DSCK Periodtsck2—2048tbus
2DEnable Lead TimetL—1/2—tsck
3DEnable Trail TimetT—1/2—tsck
4DClock (SCK) High or Low Timetwsck—1/2—tsck
5DData Setup Time (Inputs)tsu8——ns
6DData Hold Time (Inputs)thi8——ns
9DData Valid after SCK Edgetvsck——15ns
10DData Valid afterSS fall (CPHA=0)tvss——15ns
11DData Hold Time (Outputs)tho0——ns
12DRise and Fall Time Inputstrfi——9ns
13DRise and Fall Time Outputstrfo——9ns
SCK
(Input)
SCK
(Input)
MOSI
(Input)
MISO
(Output)
SS
(Input)
1
9
56
MSB IN
Bit MSB-1 . . . 1
LSB IN
Slave MSBSlave LSB OUT
Bit MSB-1. . . 1
11
4
4
2
7
(CPOL = 0)
(CPOL = 1)
3
13
NOTE: Not defined
12
12
11
See
13
Note
8
10
See
Note
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1116Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
InFigureA-9 the timing diagram for slave mode with transmission format CPHA = 1 is depicted.
FigureA-9. SPI Slave Timing (CPHA = 1)
SCK
(Input)
SCK
(Input)
MOSI
(Input)
MISO
(Output)
1
56
MSB IN
Bit MSB-1 . . . 1
LSB IN
MSB OUTSlave LSB OUT
Bit MSB-1 . . . 1
4
4
9
1213
11
(CPOL = 0)
(CPOL = 1)
SS
(Input)
21213
3
NOTE: Not defined
Slave
7
8
See
Note
Electrical Characteristics
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1117
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
InTableA-34 the timing characteristics for slave mode are listed.
A.15ADC Conversion Result Reference
The reference voltage VDDF is measured under the conditions shown inTableA-35. The value stored in
Conditions are 4.5 V < VDD35< 5.5 V junction temperature from –40°C to +150°C.
NumCCharacteristicSymbolMinTypMaxUnit
1DSCK FrequencyfsckDC—1/4fbus
1DSCK Periodtsck4—tbus
2DEnable Lead TimetL4——tbus
3DEnable Trail TimetT4——tbus
4DClock (SCK) High or Low Timetwsck4——tbus
5DData Setup Time (Inputs)tsu8——ns
6DData Hold Time (Inputs)thi8——ns
7D
Slave Access Time (time to data
active)ta——20ns
8DSlave MISO Disable Timetdis——22ns
9DData Valid after SCK Edgetvsck——1
10.5tbus added due to internal synchronization delay
ns
10DData Valid afterSS falltvss——1ns
11DData Hold Time (Outputs)tho20——ns
12DRise and Fall Time Inputstrfi——9ns
13DRise and Fall Time Outputstrfo——9ns
TableA-35. Measurement Conditions
DescriptionSymbolValueUnit
Regulator supply voltageVDDR5V
I/O supply voltageVDDX5V
Analog supply voltageVDDA5V
ADC reference voltageVRH5V
ADC clockfADCCLK2MHz
ADC sample timetSMP4ADC clock cycles
Bus frequencyfbus24MHz
Junction temperatureTj150 and -40°C
Code executionfrom RAM
∞
280.5tbus
⋅+
280.5tbus
⋅+
Electrical Characteristics
MC9S12G Family Reference Manual,Rev.1.06
1118Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
NVM activitynone
TableA-35. Measurement Conditions
DescriptionSymbolValueUnit
Detailed Register Address Map
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1119
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
AppendixB
Detailed Register Address Map
Revision History
B.1Detailed Register Map
The following tables show the detailed register map of the MC9S12G-Family.
NOTE
This is a summary of all register bits implemented on MC9S12G devices.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
0x001A–0x001B Device ID Register (PARTIDH/PARTIDL)
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
0x007AATDSTAT2HRCCF[15:8]
W
0x007BATDSTAT2LRCCF[7:0]
W
0x007CATDDIENHRIEN[15:8]
W
0x007DATDDIENLRIEN[7:0]
W
0x007EATDCMPHTHRCMPHT[15:8]
W
0x007FATDCMPHTLRCMPHT[7:0]
W
0x0080-
0x0091ATDDR0RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0082-
0x0083ATDDR1RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0084-
0x0085ATDDR2RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0086-
0x0087ATDDR3RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0088-
0x0089ATDDR4RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x008A-
0x008BATDDR5RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x008C-
0x008DATDDR6RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x008E-
0x008FATDDR7RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0090-
0x0091ATDDR8RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0092-
0x0093ATDDR9RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0094-
0x0095ATDDR10RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0096-
0x0097ATDDR11RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x0098-
0x0099ATDDR12RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x009A-
0x009BATDDR13RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x009C-
0x009DATDDR14RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
W
0x009E-
0x009FATDDR15RSeeSection14.3.2.12.1, “Left Justified Result Data (DJM=0)”
andSection14.3.2.12.2, “Right Justified Result Data (DJM=1)”
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
0x00B7PWMPER3RBit 7 6 5 4 3 2 1 Bit 0
W
0x00B8PWMPER4RBit 7 6 5 4 3 2 1 Bit 0
W
0x00B9PWMPER5RBit 7 6 5 4 3 2 1 Bit 0
W
0x00BAPWMPER6RBit 7 6 5 4 3 2 1 Bit 0
W
0x00BBPWMPER7RBit 7 6 5 4 3 2 1 Bit 0
W
0x00BCPWMDTY0RBit 7 6 5 4 3 2 1 Bit 0
W
0x00BDPWMDTY1RBit 7 6 5 4 3 2 1 Bit 0
W
0x00BEPWMDTY2RBit 7 6 5 4 3 2 1 Bit 0
W
0x00BFPWMDTY3RBit 7 6 5 4 3 2 1 Bit 0
W
0x00C0PWMDTY4RBit 7 6 5 4 3 2 1 Bit 0
W
0x00C1PWMDTY5RBit 7 6 5 4 3 2 1 Bit 0
W
0x00C2PWMDTY6RBit 7 6 5 4 3 2 1 Bit 0
W
0x00C3PWMDTY7RBit 7 6 5 4 3 2 1 Bit 0
W
0x00C4-
0x00C7ReservedR00000000
W
0x00C8–0x0CF Serial Communication Interface (SCI0)
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
0x00CCSCI0SR1RTDRETCRDRFIDLEORNFFEPF
W
0x00CDSCI0SR2RAMAP00
TXPOLRXPOLBRK13TXDIRRAF
W
0x00CESCI0DRHRR8T8000000
W
0x00CFSCI0DRLRR7R6R5R4R3R2R1R0
WT7T6T5T4T3T2T1T0
0x00D0–0x0D7 Serial Communication Interface (SCI1)
0x00C8–0x0CF Serial Communication Interface (SCI0)
Detailed Register Address Map
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1129
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
0x016FCANRXFGRSeeSection16.3.3, “Programmer’s Model of Message Storage”
W
0x0170-
0x017FCANTXFGRSeeSection16.3.3, “Programmer’s Model of Message Storage”
W
Detailed Register Address Map
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1133
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
The mask identifier suffix and the Tape & Reel suffix are always both omitted from the
partnumber which is actually marked on the device.
For specific partnumbers to order, please contact your local sales office. The below figure illustrates the
structure of a typical mask-specific ordering number for the MC9S12G devices
Ordering Information
MC9S12G Family Reference Manual,Rev.1.06
1140Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
S9S12G128F0MLLR
Package Option:
Temperature Option:
Device Title
Controller Family
C = -40˚C to85˚C
V = -40˚C to 105˚C
M = -40˚C to 125˚C
TJ = 20 TSSOP
LC = 32 LQFP
LF = 48 LQFP
Status / Partnumber type:
S or SC = Maskset specific partnumber
MC = Generic / mask-independent partnumber
P or PC = prototype status (pre qualification)
Main Memory Type:
9 = Flash
3 = ROM (if available)
Maskset identifier Suffix:
First digit usually references wafer fab
Second digit usually differentiates mask rev
(This suffix is omitted in generic partnumbers)
Tape & Reel:
R = Tape & Reel
No R = No Tape & Reel
LH = 64 LQFP
LL = 100 LQFP
FT = 48 QFN
Package Information
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1141
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
AppendixD
Package Information
Package Information
MC9S12G Family Reference Manual,Rev.1.06
1142Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
D.1100 LQFP
Package Information
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1143
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Package Information
MC9S12G Family Reference Manual,Rev.1.06
1144Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Package Information
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1145
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
D.264 LQFP
Package Information
MC9S12G Family Reference Manual,Rev.1.06
1146Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Package Information
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1147
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Package Information
MC9S12G Family Reference Manual,Rev.1.06
1148Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
D.348 LQFP
Package Information
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1149
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Package Information
MC9S12G Family Reference Manual,Rev.1.06
1150Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
D.448 QFN
Package Information
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1151
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Package Information
MC9S12G Family Reference Manual,Rev.1.06
1152Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Package Information
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1153
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
D.532 LQFP
Package Information
MC9S12G Family Reference Manual,Rev.1.06
1154Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Package Information
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1155
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Package Information
MC9S12G Family Reference Manual,Rev.1.06
1156Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
D.620 TSSOP
Package Information
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1157
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Package Information
MC9S12G Family Reference Manual,Rev.1.06
1158Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
Package Information
MC9S12G Family Reference Manual, Rev.1.06
Freescale Semiconductor1159
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
.
Package Information
MC9S12G Family Reference Manual,Rev.1.06
1160Freescale Semiconductor
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.
This document is valid for S12GN16, S12GN32, S12GN48, S12G96, S12G128, S12G192, S12GA192, S12D240, and S12GA240 devices. All information related to other devices is preliminary.