2.2Kinetis L Series.............................................................................................................................................................31
2.4.5Security and Integrity modules....................................................................................................................37
2.5Orderable part numbers.................................................................................................................................................39
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.3
Page 4
Section numberTitlePage
3.2Module to Module Interconnects..................................................................................................................................41
3.2.1Module to Module Interconnects.................................................................................................................41
3.6Memories and Memory Interfaces................................................................................................................................66
5.5.1Clock divider values after reset....................................................................................................................105
7.4Entering and exiting power modes...............................................................................................................................127
7.5Module Operation in Low Power Modes......................................................................................................................127
8.3Security Interactions with other Modules.....................................................................................................................131
8.3.1Security Interactions with Debug.................................................................................................................132
9.2Debug Port Pin Descriptions.........................................................................................................................................133
9.3SWD status and control registers..................................................................................................................................134
9.3.1MDM-AP Control Register..........................................................................................................................135
9.3.2MDM-AP Status Register............................................................................................................................136
9.6Debug in Low Power Modes........................................................................................................................................139
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
10.4Module Signal Description Tables................................................................................................................................149
11.2.2Modes of operation......................................................................................................................................154
11.3External signal description............................................................................................................................................154
11.4Detailed signal description............................................................................................................................................155
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
8Freescale Semiconductor, Inc.
Page 9
Section numberTitlePage
11.5Memory map and register definition.............................................................................................................................155
11.5.1Pin Control Register n (PORTx_PCRn).......................................................................................................158
11.5.2Global Pin Control Low Register (PORTx_GPCLR)..................................................................................160
11.5.3Global Pin Control High Register (PORTx_GPCHR).................................................................................161
11.5.4Interrupt Status Flag Register (PORTx_ISFR)............................................................................................161
12.2Memory map and register definition.............................................................................................................................165
13.2Modes of operation.......................................................................................................................................................189
13.3Memory map and register descriptions.........................................................................................................................191
13.4.6Debug in low power modes.........................................................................................................................207
14.5Memory map and register descriptions.........................................................................................................................211
14.5.1Low Voltage Detect Status And Control 1 register (PMC_LVDSC1)........................................................212
14.5.2Low Voltage Detect Status And Control 2 register (PMC_LVDSC2)........................................................213
14.5.3Regulator Status And Control register (PMC_REGSC)..............................................................................214
15.1.2Modes of operation......................................................................................................................................218
15.2LLWU signal descriptions............................................................................................................................................220
17.1.3Modes of Operation.....................................................................................................................................241
17.2External Signal Description..........................................................................................................................................241
17.3Memory Map and Register Definition..........................................................................................................................242
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
12Freescale Semiconductor, Inc.
Page 13
Section numberTitlePage
19.1.3Modes of Operation.....................................................................................................................................271
19.2External Signal Description..........................................................................................................................................271
19.3Memory Map and Register Definition..........................................................................................................................272
19.3.3System ROM Memory Map.........................................................................................................................295
22.1.3Modes of operation......................................................................................................................................308
22.2External signal description............................................................................................................................................309
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
22.5.2Enabling and configuring sources................................................................................................................314
23.2DMA Transfer Overview..............................................................................................................................................321
23.3Memory Map and Registers..........................................................................................................................................322
23.4.1Transfer Requests (Cycle-Steal and Continuous Modes)............................................................................331
23.4.2Channel Initialization and Startup................................................................................................................331
23.4.3Dual-Address Data Transfer Mode..............................................................................................................333
23.4.4Advanced Data Transfer Controls: Auto-Alignment...................................................................................334
24.1.2Modes of Operation.....................................................................................................................................339
24.2External Signal Description..........................................................................................................................................340
24.4.1MCG mode state diagram............................................................................................................................348
24.4.2Low Power Bit Usage..................................................................................................................................352
24.4.5MCG Fixed frequency clock .......................................................................................................................353
24.4.6MCG Auto TRIM (ATM)............................................................................................................................353
24.5.2Using a 32.768 kHz reference......................................................................................................................357
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
25.2Features and Modes......................................................................................................................................................365
25.4OSC Signal Descriptions..............................................................................................................................................366
25.10 Low Power Modes Operation.......................................................................................................................................374
26.2Modes of operation.......................................................................................................................................................376
26.3External signal description............................................................................................................................................376
26.4Memory map and register descriptions.........................................................................................................................376
27.2External Signal Description..........................................................................................................................................382
27.3Memory Map and Registers..........................................................................................................................................382
27.3.1Flash Configuration Field Description.........................................................................................................382
27.4.3Flash Operation in Low-Power Modes........................................................................................................394
27.4.4Functional Modes of Operation...................................................................................................................394
27.4.5Flash Reads and Ignored Writes..................................................................................................................394
27.4.6Read While Write (RWW)...........................................................................................................................395
27.4.7Flash Program and Erase..............................................................................................................................395
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.17
Page 18
Section numberTitlePage
28.2ADC Signal Descriptions..............................................................................................................................................419
28.2.1Analog Power (VDDA)...............................................................................................................................420
28.4.1Clock select and divide control....................................................................................................................438
28.4.3Hardware trigger and channel selects..........................................................................................................439
28.6.1External pins and routing.............................................................................................................................456
28.6.2Sources of error............................................................................................................................................458
29.5CMP, DAC and ANMUX diagram...............................................................................................................................465
29.8.3Startup and operation...................................................................................................................................484
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
30.1.3Modes of Operation.....................................................................................................................................492
30.2TPM Signal Descriptions..............................................................................................................................................493
30.3Memory Map and Register Definition..........................................................................................................................494
30.3.1Status and Control (TPMx_SC)...................................................................................................................496
31.5Initialization and application information.....................................................................................................................526
31.6Example configuration for chained timers....................................................................................................................527
31.7Example configuration for the lifetime timer...............................................................................................................528
32.1.2Modes of operation......................................................................................................................................531
32.2LPTMR signal descriptions..........................................................................................................................................532
32.2.1Detailed signal descriptions.........................................................................................................................532
32.3Memory map and register definition.............................................................................................................................532
32.3.1Low Power Timer Control Status Register (LPTMRx_CSR)......................................................................533
32.3.2Low Power Timer Prescale Register (LPTMRx_PSR)................................................................................534
32.3.3Low Power Timer Compare Register (LPTMRx_CMR).............................................................................536
32.3.4Low Power Timer Counter Register (LPTMRx_CNR)...............................................................................536
32.4.1LPTMR power and reset..............................................................................................................................537
33.1.2Modes of operation......................................................................................................................................541
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
22Freescale Semiconductor, Inc.
Page 23
Section numberTitlePage
33.1.3RTC Signal Descriptions.............................................................................................................................541
33.2.1RTC Time Seconds Register (RTC_TSR)...................................................................................................543
33.2.2RTC Time Prescaler Register (RTC_TPR)..................................................................................................543
33.2.3RTC Time Alarm Register (RTC_TAR).....................................................................................................544
33.2.4RTC Time Compensation Register (RTC_TCR).........................................................................................544
33.2.5RTC Control Register (RTC_CR)................................................................................................................545
33.2.6RTC Status Register (RTC_SR)..................................................................................................................547
33.3.1Power, clocking, and reset...........................................................................................................................550
34.1.2Modes of Operation.....................................................................................................................................556
34.2External Signal Description..........................................................................................................................................559
34.2.1SPSCK — SPI Serial Clock.........................................................................................................................559
34.2.2MOSI — Master Data Out, Slave Data In...................................................................................................560
34.2.3MISO — Master Data In, Slave Data Out...................................................................................................560
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.23
Page 24
Section numberTitlePage
34.3Memory Map and Register Descriptions......................................................................................................................561
34.3.1SPI control register 1 (SPIx_C1)..................................................................................................................561
34.3.2SPI control register 2 (SPIx_C2)..................................................................................................................563
34.3.4SPI status register (SPIx_S).........................................................................................................................565
34.3.5SPI data register (SPIx_D)...........................................................................................................................566
34.3.6SPI match register (SPIx_M).......................................................................................................................567
34.4.4SPI Transmission by DMA..........................................................................................................................571
34.4.9Low Power Mode Options...........................................................................................................................579
35.1.2Modes of operation......................................................................................................................................588
35.2I2C signal descriptions..................................................................................................................................................589
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
24Freescale Semiconductor, Inc.
Page 25
Section numberTitlePage
35.3Memory map and register descriptions.........................................................................................................................589
35.3.2I2C Frequency Divider register (I2Cx_F)....................................................................................................591
35.3.3I2C Control Register 1 (I2Cx_C1)...............................................................................................................592
35.3.4I2C Status register (I2Cx_S)........................................................................................................................593
35.3.5I2C Data I/O register (I2Cx_D)...................................................................................................................595
35.3.6I2C Control Register 2 (I2Cx_C2)...............................................................................................................596
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.25
Page 26
Section numberTitlePage
36.1.2Modes of operation......................................................................................................................................620
36.3.5Interrupts and status flags............................................................................................................................643
37.1.2Modes of operation......................................................................................................................................645
37.1.3GPIO signal descriptions.............................................................................................................................646
37.2Memory map and register definition.............................................................................................................................647
37.2.1Port Data Output Register (GPIOx_PDOR).................................................................................................648
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
26Freescale Semiconductor, Inc.
Page 27
Section numberTitlePage
37.2.2Port Set Output Register (GPIOx_PSOR)....................................................................................................649
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.27
Page 28
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
28Freescale Semiconductor, Inc.
Page 29
Chapter 1
About This Document
1.1
Overview
1.1.1Purpose
This document describes the features, architecture, and programming model of the
Freescale KL04 microcontroller.
1.1.2Audience
This document is primarily for system architects and software application developers
who are using or considering using the KL04KL02 microcontroller in a system.
1.2
Conventions
1.2.1Numbering systems
The following suffixes identify different numbering systems:
This suffixIdentifies a
bBinary number. For example, the binary equivalent of the
number 5 is written 101b. In some cases, binary numbers are
shown with the prefix 0b.
dDecimal number. Decimal numbers are followed by this suffix
only when the possibility of confusion exists. In general,
decimal numbers are shown without a suffix.
hHexadecimal number. For example, the hexadecimal
equivalent of the number 60 is written 3Ch. In some cases,
hexadecimal numbers are shown with the prefix 0x.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.29
Page 30
Conventions
1.2.2Typographic notation
The following typographic notation is used throughout this document:
ExampleDescription
placeholder, xItems in italics are placeholders for information that you provide. Italicized text is also used for
the titles of publications and for emphasis. Plain lowercase letters are also used as
placeholders for single letters and numbers.
code
SR[SCM]A mnemonic in brackets represents a named field in a register. This example refers to the
REVNO[6:4], XAD[7:0]Numbers in brackets and separated by a colon represent either:
Fixed-width type indicates text that must be typed exactly as shown. It is used for instruction
mnemonics, directives, symbols, subcommands, parameters, and operators. Fixed-width type
is also used for example code. Instruction mnemonics and directives in text and tables are
shown in all caps; for example, BSR.
Scaling Mode (SCM) field in the Status Register (SR).
• A subset of a register's named field
For example, REVNO[6:4] refers to bits 6–4 that are part of the COREREV field that
occupies bits 6–0 of the REVNO register.
• A continuous range of individual signals of a bus
For example, XAD[7:0] refers to signals 7–0 of the XAD bus.
1.2.3Special terms
The following terms have special meanings:
TermMeaning
assertedRefers to the state of a signal as follows:
• An active-high signal is asserted when high (1).
• An active-low signal is asserted when low (0).
deassertedRefers to the state of a signal as follows:
• An active-high signal is deasserted when low (0).
• An active-low signal is deasserted when high (1).
In some cases, deasserted signals are described as negated.
reservedRefers to a memory space, register, or field that is either
reserved for future use or for which, when written to, the
module or chip behavior is unpredictable.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
30Freescale Semiconductor, Inc.
Page 31
Chapter 2
Introduction
2.1Overview
This chapter provides an overview of the Kinetis L series of ARM® Cortex™-M0+
MCUs and KL04 product family. It also presents high-level descriptions of the modules
available on the devices covered by this document.
2.2Kinetis L Series
The Kinetis L series is the most scalable portfolio of ultra low-power, mixed-signal ARM
Cortex-M0+ MCUs in the industry. The portfolio includes 5 MCU families that offer a
broad range of memory, peripheral and package options. Kinetis L Series families share
common peripherals and pin-counts allowing developers to migrate easily within an
MCU family or between MCU families to take advantage of more memory or feature
integration. This scalability allows developers to standardize on the Kinetis L Series for
their end product platforms, maximising hardware and software reuse and reducing timeto-market.
Features common to all Kinetis L series families include:
• 12-bit digital-to-analog converters for all series except for KLx4/KLx2 family
• High-speed analog comparators
• Low-power touch sensing with wake-up on touch from reduced power states for all
series except for KLx4/KLx2 family
• Powerful timers for a broad range of applications including motor control
• Low power focused serial communication interfaces such as low power UART, SPI,
I2C etc.
• Single power supply: 1.71V - 3.6V with multiple low-power modes support single
operation temperature: -40 ~ 105 °C (exclude CSP package)
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.31
Page 32
KL2x Family
KL1x Family
KL0x Family
KL3x Family
Family
Program
Flash
Packages Key Features
Low powerMixed signalUSBSegment LCD
KL4x Family
8-32KB
32-256KB
32-256KB
64-256KB
128-256KB
16-48pin
32-80pin
32-121pin
64-121pin
64-121pin
Kinetis L Series
Kinetis L series MCU families combine the latest low-power innovations with precision
mixed-signal capability and a broad range of communication, connectivity, and humanmachine interface peripherals. Each MCU family is supported by a market-leading
enablement bundle from Freescale and numerous ARM 3rd party ecosystem partners.
The KL0x family is the entry-point to the Kinetis L series and is pin compatible with the
8-bit S08PT family. The KL1x/2x/3x/4x families are compatible with each other and
their equivalent ARM Cortex-M4 Kinetis K series families - K10/20/30/40.
All Kinetis L series families include a powerful array of analog, communication and
timing and control peripherals with the level of feature integration increasing with flash
memory size and the pin count. Features within the Kinetis L series families include:
Figure 2-1. Kinetis L series families of MCU portfolio
• Core and Architecture:
• ARM Cortex-M0+ Core running up to 48 MHz with zero wait state execution
from memories
• Single-cycle access to I/O: Up to 50 percent faster than standard I/O,
improves reaction time to external events allowing bit banging and software
protocol emulation
• Two-stage pipeline: Reduced number of cycles per instruction (CPI),
enabling faster branch instruction and ISR entry, and reducing power
consumption
• Excellent code density vs. 8-bit and 16-bit MCUs - reduces flash size,
system cost and power consumption
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
32Freescale Semiconductor, Inc.
Page 33
Chapter 2 Introduction
• Optimized access to program memory: Accesses on alternate cycles reduces
power consumption
• 100 percent compatible with ARM Cortex-M0 and a subset ARM CortexM3/M4: Reuse existing compilers and debug tools
• Simplified architecture: 56 instructions and 17 registers enables easy
programming and efficient packaging of 8/16/32-bit data in memory
• Linear 4 GB address space removes the need for paging/banking, reducing
software complexity
• ARM third-party ecosystem support: Software and tools to help minimize
development time/cost
• Micro Trace Buffer: Lightweight trace solution allows fast bug identification and
correction
• BME: Bit manipulation engine reduces code size and cycles for bit oriented
operations to peripheral registers eliminating traditional methods where the core
would need to perform read-modify-write operations.
• Up to 4-channel DMA for peripheral and memory servicing with minimal CPU
intervention (feature not available on KL02 family)
• Ultra low-power:
• Extreme dynamic efficiency: 32-bit ARM Cortex-M0+ core combined with
Freescale 90 nm thin film storage flash technology delivers 50% energy savings
per Coremark versus the closest 8/16-bit competitive solution
• Multiple flexible low-power modes, including new operation clocking option
which reduces dynamic power by shutting off bus and system clocks for lowest
power core processing. Peripherals with an alternate asynchronous clock source
can continue operation.
• UART, SPI, I2C, ADC, DAC, TPM, LPT, and DMA support low-power mode
operation without waking up the core
• Memory:
• Scalable memory footprints from 8 KB flash / 1 KB SRAM to 256 KB flash / 32
KB SRAM
• Embedded 64 B cache memory for optimizing bus bandwidth and flash
execution performance (32 B cache on KL02 family)
• Mixed-signal analog:
• Fast, high precision 16-, or 12-bit ADC with optional differential pairs, 12-bit
DAC, high speed comparators. Powerful signal conditioning, conversion and
analysis capability with reduced system cost (12-bit DAC not available on KL02
family)
• Human Machine Interface (HMI):
• Optional capacitive Touch Sensing Interface with full low-power support and
minimal current adder when enabled
• Segment LCD controller
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.33
Page 34
KL04 Sub-Family Introduction
• Connectivity and Communications:
• Up to three UARTs, all UARTs support DMA transfers, and can trigger when
data on bus is detected, UART0 supports 4x to 32x over sampling ratio.
Asynchronous transmit and receive operation for operating in STOP/VLPS
modes.
• Up to two SPIs
• Up to two I2Cs
• Full-speed USB OTG controller with on-chip transceiver
• 5 V to 3.3 V USB on-chip regulator
• Up to one I2S
• Reliability, Safety and Security:
• Internal watchdog with independent clock source
• Timing and Control:
• Powerful timer modules which support general purpose, PWM, and motor
control functions
• Periodic Interrupt Timer for RTOS task scheduler time base or trigger source for
ADC conversion and timer modules
• System:
• GPIO with pin interrupt functionality
• Wide operating voltage range from 1.71 V to 3.6 V with flash programmable
down to 1.71 V with fully functional flash and analog peripherals
• Ambient operating temperature ranges from -40 °C to 105 °C
2.3KL04 Sub-Family Introduction
The device is highly-integrated, market leading ultra low power 32-bit microcontroller
based on the enhanced Cortex-M0+ (CM0+) core platform. The family derivatives
feature:
• Core platform clock up to 48 MHz, bus clock up to 24 MHz
• Memory option is up to 32 KB Flash and 4 KB RAM
• Wide operating voltage ranges from 1.71V to 3.6V with full functional Flash
program/erase/read operations
• Multiple package options from 24-pin to 48-pin
• Ambient operating temperature ranges from –40 °C to 105 °C
The family acts as an ultra low power, cost effective microcontroller to provide
developers an appropriate entry-level 32-bit solution. The family is next generation MCU
solution for low cost, low power, high performance devices applications. It’s valuable for
cost-sensitive, portable applications requiring long battery life-time.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
34Freescale Semiconductor, Inc.
Page 35
Chapter 2 Introduction
2.4Module functional categories
The modules on this device are grouped into functional categories. The following
sections describe the modules assigned to each category in more detail.
Table 2-1. Module functional categories
Module categoryDescription
ARM Cortex-M0+ core• 32-bit MCU core from ARM’s Cortex-M class, 1.77 CoreMark®/MHz from
single-cycle access memories, 48 MHz CPU frequency
System• System integration module
• Power management and mode controllers
• Multiple power modes available based on run, wait, stop, and powerdown modes
• Miscellaneous control module
• Low-leakage wakeup unit
• Peripheral bridge
• Direct memory access (DMA) controller with multiplexer to increase available
DMA requests
• COP watchdog
Memories• Internal memories include:
• Up to 32 KB flash memory
• up to 4 KB SRAM
Clocks• Multiple clock generation options available from internally- and externally-
generated clocks
• MCG module with FLL for systems and CPU clock sources
• Low power 1 kHz RC oscillator for RTC and COP watchdog
• System oscillator to provide clock source for the MCU
• Comparator (CMP) with internal 6-bit digital-to-analog converter (DAC)
Timers• One 6-channel TPM
• One 2-channel TPM
• 2-channel periodic interrupt timer
• Real time clock
• Low-power timer
• System tick timer
Communications• One8-bit serial peripheral interface
• One inter-integrated circuit (I2C) module
• One low power UART module
Human-Machine Interfaces (HMI)• General purpose input/output controller
2.4.1ARM® Cortex™-M0+ Core Modules
The following core modules are available on this device.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.35
Page 36
Module functional categories
Table 2-2. Core modules
ModuleDescription
ARM® Cortex™-M0+The ARM® Cortex™-M0+ is the newest member of the Cortex M Series of
processors targeting microcontroller applications focused on very cost sensitive,
deterministic, interrupt driven environments. The Cortex M0+ processor is based
on the ARMv6 Architecture and Thumb®-2 ISA and is 100% instruction set
compatible with its predecessor, the Cortex-M0 core, and upward compatible to
Cortex-M3 and M4 cores.
NVICThe ARMv6-M exception model and nested-vectored interrupt controller (NVIC)
implement a relocatable vector table supporting many external interrupts, a single
non-maskable interrupt (NMI), and priority levels.
The NVIC replaces shadow registers with equivalent system and simplified
programmability. The NVIC contains the address of the function to execute for a
particular handler. The address is fetched via the instruction port allowing parallel
register stacking and look-up. The first sixteen entries are allocated to ARM
internal sources with the others mapping to MCU-defined interrupts.
AWICThe primary function of the Asynchronous Wake-up Interrupt Controller (AWIC) is
to detect asynchronous wake-up events in stop modes and signal to clock control
logic to resume system clocking. After clock restart, the NVIC observes the
pending interrupt and performs the normal interrupt or event processing.
Single-cycle I/O PortFor high-speed, single-cycle access to peripherals, the Cortex-M0+ processor
implements a dedicated single-cycle I/O port.
Debug interfacesMost of this device's debug is based on the ARM CoreSight™ architecture. One
debug interface is supported:
• Serial Wire Debug (SWD)
2.4.2System Modules
The following system modules are available on this device.
Table 2-3. System modules
ModuleDescription
System integration module (SIM)The SIM includes integration logic and several module configuration settings.
System mode controllerThe SMC provides control and protection on entry and exit to each power mode,
control for the Power management controller (PMC), and reset entry and exit for
the complete MCU.
Power management controller (PMC)The PMC provides the user with multiple power options. Multiple modes are
supported that allow the user to optimize power consumption for the level of
functionality needed. Includes power-on-reset (POR) and integrated low voltage
detect (LVD) with reset (brownout) capability and selectable LVD trip points.
Miscellaneous control module (MCM)The MCM includes integration logic and details.
Crossbar switch (XBS)The XBS connects bus masters and bus slaves, allowing all bus masters to access
different bus slaves simultaneously and providing arbitration among the bus
masters when they access the same slave.
Low-leakage wakeup unit (LLWU)The LLWU module allows the device to wake from low leakage power modes (LLS
and VLLS) through various internal peripheral and external pin sources.
Table continues on the next page...
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
36Freescale Semiconductor, Inc.
Page 37
Chapter 2 Introduction
Table 2-3. System modules (continued)
ModuleDescription
Peripheral bridgeThe peripheral bridge converts the crossbar switch interface to an interface to
access a majority of peripherals on the device.
DMA multiplexer (DMAMUX)The DMA multiplexer selects from many DMA requests down to 4 for the DMA
controller.
Direct memory access (DMA) controllerThe DMA controller provides programmable channels with transfer control
descriptors for data movement via dual-address transfers for 8-, 16- and 32-bit
data values.
Computer operating properly watchdog
(WDOG)
The WDOG monitors internal system operation and forces a reset in case of
failure. It can run from an independent 1 kHz low power oscillator with a
programmable refresh window to detect deviations in program flow or system
frequency.
2.4.3Memories and Memory Interfaces
The following memories and memory interfaces are available on this device.
Table 2-4. Memories and memory interfaces
ModuleDescription
Flash memoryProgram flash memory — up to 32 KB of the non-volatile flash memory that can
execute program code
Flash memory controllerManages the interface between the device and the on-chip flash memory.
SRAMUp to 4 KB internal system RAM.
2.4.4Clocks
The following clock modules are available on this device.
Table 2-5. Clock modules
ModuleDescription
Multipurpose Clock Generator (MCG)MCG module containing a frequency-locked-loop (FLL) controlled by internal or
external reference oscillator.
System oscillatorThe system oscillator, in conjunction with an external crystal or resonator,
generates a reference clock for the MCU.
2.4.5Security and Integrity modules
The following security and integrity modules are available on this device:
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.37
Page 38
Module functional categories
Table 2-6. Security and integrity modules
ModuleDescription
Watchdog Timer (WDOG)Watchdog Timer keeps a watch on the system functioning and resets it in case of
its failure.
2.4.6Analog modules
The following analog modules are available on this device:
Table 2-7. Analog modules
ModuleDescription
Analog-to-digital converters (ADC)12-bit successive-approximation ADC module.
Analog comparatorsOne comparator that compares two analog input voltages across the full range of
the supply voltage and can trigger an ADC acquisition, TPM update, or CPU
interrupt.
6-bit digital-to-analog converters (DAC)64-tap resistor ladder network which provides a selectable voltage reference for
comparator.
2.4.7Timer modules
The following timer modules are available on this device:
• 16-bit free-running counter or modulo counter with counting be up or updown
• Six configurable channels for input capture, output compare, or edge-aligned
PWM mode
• Support the generation of an interrupt and/or DMA request per channel
• Support the generation of an interrupt and/or DMA request when the counter
overflows
• Support selectable trigger input to optionally reset or cause the counter to
start incrementing.
• Support the generation of hardware triggers when the counter overflows and
per channel
Periodic interrupt timers (PIT)• One general purpose interrupt timer
• Interrupt timers for triggering ADC conversions
• 32-bit counter resolution
• Clocked by bus clock frequency
• DMA support
Table continues on the next page...
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
38Freescale Semiconductor, Inc.
Page 39
Table 2-8. Timer modules (continued)
ModuleDescription
Low power timer (LPTMR)• 16-bit time counter or pulse counter with compare
• Configurable clock source for prescaler/glitch filter
• Configurable input source for pulse counter
Real-time counter (RTC)• 16-bit up-counter
• 16-bit modulo match limit
• Software controllable periodic interrupt on match
• Software selectable clock sources for input to prescaler with programmable
16-bit prescaler
• XOSC 32.678 kHz nominal
• LPO (~1 kHz)
• External RTC_CLKIN
2.4.8Communication interfaces
The following communication interfaces are available on this device:
Chapter 2 Introduction
Table 2-9. Communication modules
ModuleDescription
Serial peripheral interface (SPI)Synchronous serial bus for communication to an external device
Inter-integrated circuit (I2C)Allows communication between a number of devices. Also supports the System
Several analog blocks have selectable reference voltages as shown in the below table.
These options allow analog peripherals to share or have separate analog references. Care
should be taken when selecting analog references to avoid cross talk noise.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.43
Selected by ADCx_SC2[REFSEL] bits
Selected by CMPx_DACCR[VRSEL] bit
Page 44
ARM Cortex-M0+
Core
DebugInterrupts
Crossbar
switch
Core Modules
3.3
Core Modules
3.3.1ARM Cortex-M0+ Core Configuration
This section summarizes how the module has been configured in the chip. Full
documentation for this module is provided by ARM and can be found at www.arm.com.
Figure 3-1. Core configuration
Table 3-3. Reference links to related information
TopicRelated moduleReference
Full descriptionARM Cortex-M0+ core,
r0p0
System memory mapSystem memory map
ClockingClock distribution
Power managementPower management
System/instruction/data
bus module
DebugSerial Wire Debug
InterruptsNested Vectored
Crossbar switchCrossbar switch
(SWD)
Interrupt Controller
(NVIC)
Miscellaneous Control
Module (MCM)
ARM Cortex-M0+ Technical Reference Manual, r0p0
Debug
NVIC
MCM
3.3.1.1ARM Cortex M0+ Core
The ARM Cortex M0+ parameter settings are as follows:
44Freescale Semiconductor, Inc.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Vector Table Offset RegisterVTOR1 = PresentImplements relocation of exception vector
table
WIC SupportWIC1 = PresentImplements WIC interface
WIC RequestsWICLINES34Exact number of wakeup IRQs is 34
WatchpointsWPT2Implements 2 watchpoints
For details on the ARM Cortex-M0+ processor core, see the ARM website:
www.arm.com.
3.3.1.2Buses, Interconnects, and Interfaces
The ARM Cortex-M0+ core has two bus interfaces:
• single 32-bit AMBA-3 AHB-Lite system interface that provides connections to
peripherals and all system memory, which includes flash and RAM.
• single 32-bit I/O port bus interfacing to the GPIO with 1-cycle loads and stores.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.45
Page 46
Nested Vectored
Interrupt Controller
(NVIC)
ARM Cortex-M0+
core
Interrupts
Module
Module
Module
PPB
Core Modules
3.3.1.3System Tick Timer
The CLKSOURCE bit in SysTick Control and Status register selects either the core clock
(when CLKSOURCE = 1) or a divide-by-16 of the core clock (when CLKSOURCE = 0).
Because the timing reference is a variable frequency, the TENMS bit in the SysTick
Calibration Value Register is always zero.
3.3.1.4Debug Facilities
This device supports standard ARM 2-pin SWD debug port.
3.3.1.5Core Privilege Levels
The Core on this device is implemented with both Privileged and Unprivileged levels.
The ARM documentation uses different terms than this document to distinguish between
privilege levels.
This section summarizes how the module has been configured in the chip. Full
documentation for this module is provided by ARM and can be found at www.arm.com.
Figure 3-2. NVIC configuration
Table 3-5. Reference links to related information
TopicRelated moduleReference
Full descriptionNested Vectored
Interrupt Controller
(NVIC)
System memory mapSystem memory map
ClockingClock distribution
ARM Cortex-M0+ Technical Reference Manual
46Freescale Semiconductor, Inc.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Table continues on the next page...
Page 47
Chapter 3 Chip Configuration
Table 3-5. Reference links to related information (continued)
TopicRelated moduleReference
Power managementPower management
Private Peripheral Bus
(PPB)
ARM Cortex-M0+ coreARM Cortex-M0+ core
3.3.2.1Interrupt priority levels
This device supports 4 priority levels for interrupts. Therefore, in the NVIC each source
in the IPR registers contains 2 bits. For example, IPR0 is shown below:
The non-maskable interrupt request to the NVIC is controlled by the external NMI signal.
The pin the NMI signal is multiplexed on, must be configured for the NMI function to
generate the non-maskable interrupt request.
3.3.2.3Interrupt channel assignments
The interrupt vector assignments are defined in the following table.
• Vector number — the value stored on the stack when an interrupt is serviced.
• IRQ number — non-core interrupt source count, which is the vector number minus
16.
The IRQ number is used within ARM's NVIC documentation.
Table 3-7. Interrupt vector assignments
AddressVectorIRQ
ARM Core System Handler Vectors
0x0000_00000——ARM coreInitial Stack Pointer
0x0000_00041——ARM coreInitial Program Counter
1
NVIC
IPR
register
number
Source moduleSource description
2
Table continues on the next page...
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
0x0000_009838225PITSingle interrupt vector for all channels
0x0000_009C39235——
0x0000_00A040246—
0x0000_00A441256—
0x0000_00A842266—
0x0000_00AC43276MCG
0x0000_00B044287LPTMR0
0x0000_00B445297—
0x0000_00B846307Port control modulePin detect (Port A)
0x0000_00BC47317Port control modulePin detect (Port B )
1. Indicates the NVIC's interrupt source number.
2. Indicates the NVIC's IPR register number used for this IRQ. The equation to calculate this value is: IRQ div 4
1
NVIC
IPR
register
number
Source moduleSource description
2
3.3.2.3.1Determining the bitfield and register location for configuring a
particular interrupt
Suppose you need to configure the SPI0 interrupt. The following table is an excerpt of the
SPI0 row from Interrupt priority levels.
Table 3-8. Interrupt vector assignments
AddressVectorIRQ
0x0000_006826102SPI0Single interrupt vector for all sources
1. Indicates the NVIC's interrupt source number.
2. Indicates the NVIC's IPR register number used for this IRQ. The equation to calculate this value is: IRQ div 4.
1
NVIC IPR
register
number
Source moduleSource description
2
• The NVIC registers you would use to configure the interrupt are:
• NVICIPR2
• To determine the particular IRQ's bitfield location within these particular registers:
This section summarizes how the module has been configured in the chip. Full
documentation for this module is provided by ARM and can be found at www.arm.com.
The device uses the following internal and external inputs to the AWIC module.
Table 3-10. AWIC stop wake-up sources
Wake-up sourceDescription
Available system resetsRESET pin when LPO is its clock source
Low-voltage detectPower management controller - functional in Stop mode
Low-voltage warningPower management controller - functional in Stop mode
Pin interruptsPort control module - any enabled pin interrupt is capable of waking the system
ADCThe ADC is functional when using internal clock source
CMP0Interrupt in normal or trigger mode
50Freescale Semiconductor, Inc.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
Figure 3-4. SIM configuration
Table 3-11. Reference links to related information
TopicRelated moduleReference
Full descriptionSIMSIM
System memory mapSystem memory map
ClockingClock distribution
Power managementPower management
Freescale Semiconductor, Inc.51
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 52
Power Management
Controller (PMC)
Register
access
Peripheral
bridge
System Mode
Controller (SMC)
Resets
System Modules
3.4.2System Mode Controller (SMC) Configuration
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
Figure 3-5. System Mode Controller configuration
Table 3-12. Reference links to related information
TopicRelated moduleReference
Full descriptionSystem Mode
Controller (SMC)
System memory mapSystem memory map
Power managementPower management
Power management
controller (PMC)
Low-Leakage Wakeup
Unit (LLWU)
Reset Control Module
(RCM)
SMC
PMC
LLWU
Reset
3.4.2.1VLLS2 not supported
VLLS2 power mode is not supported on this device.
3.4.3PMC Configuration
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
52Freescale Semiconductor, Inc.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 53
Register access
Power Management
Controller (PMC)
Module
signals
Peripheral
bridge
Module
signals
System Mode
Controller (SMC)
Low-Leakage
Wakeup Unit
Chapter 3 Chip Configuration
Figure 3-6. PMC configuration
Table 3-13. Reference links to related information
TopicRelated moduleReference
Full descriptionPMCPMC
System memory mapSystem memory map
Power managementPower management
Full descriptionSystem Mode
Controller (SMC)
Low-Leakage Wakeup
Unit (LLWU)
Reset Control Module
(RCM)
System Mode Controller
LLWU
Reset
3.4.4Low-Leakage Wake-up Unit (LLWU) Configuration
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
Freescale Semiconductor, Inc.53
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 54
Low-Leakage Wake-up
Unit (LLWU)
Power Management
Controller (PMC)
Peripheral
bridge 0
Register
access
Wake-up
requests
Module
Module
System Modules
Figure 3-7. Low-Leakage Wake-up Unit configuration
Table 3-14. Reference links to related information
TopicRelated moduleReference
Full descriptionLLWULLWU
System memory mapSystem memory map
ClockingClock distribution
Power managementPower management chapter
Power Management
Controller (PMC)
System Mode
Controller (SMC)
Wake-up requestsLLWU wake-up sources
Power Management Controller (PMC)
System Mode Controller
3.4.4.1LLWU interrupt
3.4.4.2Wake-up Sources
The device uses the following internal peripheral and external pin inputs as wakeup
sources to the LLWU module. LLWU_Px are external pin inputs, and LLWU_M0IFM7IF are connections to the internal peripheral interrupt flags.
54Freescale Semiconductor, Inc.
Do not mask the LLWU interrupt when in LLS mode. Masking
the interrupt prevents the device from exiting stop mode when a
wakeup is detected.
In addition to the LLWU wakeup sources, the device also
wakes from low power modes when NMI or RESET pins are
enabled and the respective pin is asserted.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
Figure 3-8. MCM configuration
Table 3-16. Reference links to related information
TopicRelated moduleReference
Full descriptionMiscellaneous control
module (MCM)
System memory mapSystem memory map
ClockingClock distribution
Power managementPower management
Private Peripheral Bus
(PPB)
ARM Cortex-M0+ coreARM Cortex-M0+ core
MCM
Freescale Semiconductor, Inc.55
Table continues on the next page...
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 56
Crossbar Switch
Slave Modules
Master Modules
M2
M0
S0
S2
ARM core
unified bus
DMA
Flash
controller
S1
SRAML
BME
Peripheral
bridge 0
GPIO
controller
SRAMU
Peripherals
System Modules
Table 3-16. Reference links to related information (continued)
TopicRelated moduleReference
TransferFlash memory
Flash memory controller
controller
3.4.6Crossbar-Light Switch Configuration
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
56Freescale Semiconductor, Inc.
Figure 3-9. Crossbar-Light switch integration
Table 3-17. Reference links to related information
TopicRelated moduleReference
Full descriptionCrossbar switchCrossbar Switch
System memory mapSystem memory map
ClockingClock Distribution
Crossbar switch master ARM Cortex-M0+ coreARM Cortex-M0+ core
Crossbar switch masterDMA controllerDMA controller
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
Figure 3-10. Peripheral bridge configuration
Table 3-18. Reference links to related information
TopicRelated moduleReference
Full descriptionPeripheral bridge
(AIPS-Lite)
System memory mapSystem memory map
ClockingClock Distribution
Crossbar switchCrossbar switchCrossbar switch
Peripheral bridge (AIPS-Lite)
Freescale Semiconductor, Inc.57
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 58
DMA Request
Multiplexer
DMA controller
Requests
Module
Module
Module
Peripheral
bridge 0
Register
access
Channel
request
System Modules
3.4.7.1Number of peripheral bridges
This device contains one peripheral bridge.
3.4.7.2Memory maps
The peripheral bridges are used to access the registers of most of the modules on this
device. See AIPS0 Memory Map for the memory slot assignment for each module.
3.4.8DMA request multiplexer configuration
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
Table 3-19. Reference links to related information
TopicRelated moduleReference
Full descriptionDMA request
multiplexer
System memory mapSystem memory map
ClockingClock distribution
Power managementPower management
Channel requestDMA controllerDMA Controller
RequestsDMA request sources
58Freescale Semiconductor, Inc.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
DMA Mux
Page 59
Chapter 3 Chip Configuration
3.4.8.1DMA MUX Request Sources
This device includes a DMA request mux that allows up to 63 DMA request signals to be
mapped to any of the 4 DMA channels. Because of the mux there is no hard correlation
between any of the DMA request sources and a specific DMA channel. Some of the
modules support Asynchronous DMA operation as indicated by the last column in the
following DMA source assignment table.
1. Configuring a DMA channel to select source 0 or any of the reserved sources disables that DMA channel.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
60Freescale Semiconductor, Inc.
Page 61
DMA Controller
Crossbar switch
Requests
Peripheral
bridge 0
Register
access
Transfers
DMA Multiplexer
Chapter 3 Chip Configuration
3.4.8.2DMA transfers via PIT trigger
The PIT module can trigger a DMA transfer on the first two DMA channels. The
assignments are detailed at PIT/DMA Periodic Trigger Assignments .
3.4.9DMA Controller Configuration
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
Figure 3-12. DMA Controller configuration
Table 3-21. Reference links to related information
This section summarizes how the module has been configured in the chip.
Freescale Semiconductor, Inc.61
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 62
WDOG
Mode Controller
Peripheral
bridge 0
Register
access
System Modules
Figure 3-13. COP watchdog configuration
Table 3-22. Reference links to related information
TopicRelated moduleReference
ClockingClock distribution
Power managementPower management
Programming modelSystem Integration
Module (SIM)
SIM
3.4.10.1COP clocks
The two clock inputs for the COP are the 1 kHz clock and the bus clock.
3.4.10.2COP watchdog operation
The COP watchdog is intended to force a system reset when the application software fails
to execute as expected. To prevent a system reset from the COP timer (when it is
enabled), application software must reset the COP counter periodically. If the application
program gets lost and fails to reset the COP counter before it times out, a system reset is
generated to force the system back to a known starting point.
After any reset, the COP watchdog is enabled. If the COP watchdog is not used in an
application, it can be disabled by clearing COPCTRL[COPT] in the SIM.
The COP counter is reset by writing 0x55 and 0xAA (in that order) to the address of the
SIM's Service COP (SRVCOP) register during the selected timeout period. Writes do not
affect the data in the SRVCOP register. As soon as the write sequence is complete, the
COP timeout period is restarted. If the program fails to perform this restart during the
timeout period, the microcontroller resets. Also, if any value other than 0x55 or 0xAA is
written to the SRVCOP register, the microcontroller immediately resets.
62Freescale Semiconductor, Inc.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 63
Chapter 3 Chip Configuration
The SIM's COPCTRL[COPCLKS] field selects the clock source used for the COP timer.
The clock source options are either the bus clock or an internal 1 kHz clock source. With
each clock source, there are three associated timeouts controlled by COPCTRL[COPT].
The following table summarizes the control functions of the COPCLKS and COPT bits.
The COP watchdog defaults to operation from the 1 kHz clock source and the longest
timeout for that clock source (210 cycles).
After the bus clock source is selected, windowed COP operation is available by setting
COPCTRL[COPW] in the SIM. In this mode, writes to the SRVCOP register to clear the
COP timer must occur in the last 25% of the selected timeout period. A premature write
immediately resets the chip. When the 1 kHz clock source is selected, windowed COP
operation is not available.
The COP counter is initialized by the first writes to the SIM's COPCTRL register and
after any system reset. Subsequent writes to the SIM's COPCTRL register have no effect
on COP operation. Even if an application uses the reset default settings of the COPT,
COPCLKS, and COPW bits, the user should write to the write-once COPCTRL register
during reset initialization to lock in the settings. This approach prevents accidental
changes if the application program becomes lost.
The write to the SRVCOP register that services (clears) the COP counter should not be
placed in an interrupt service routine (ISR) because the ISR could continue to be
executed periodically even if the main application program fails.
If the bus clock source is selected, the COP counter does not increment while the
microcontroller is in debug mode or while the system is in stop (including VLPS or LLS)
mode. The COP counter resumes when the microcontroller exits debug mode or stop
mode.
If the 1 kHz clock source is selected, the COP counter is re-initialized to zero upon entry
to either debug mode or stop (including VLPS or LLS) mode. The counter begins from
zero upon exit from debug mode or stop mode.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.63
Page 64
Register
access
Peripheral
bridge
Multipurpose Clock
Generator (MCG)
System
oscillator
System integration
module (SIM)
Clock Modules
Regardless of the clock selected, the COP is disabled when the chip enters a VLLSx
mode. Upon a reset that wakes the chip from the VLLSx mode, the COP is re-initialized
and enabled as for any reset.
3.4.10.3Clock Gating
This family of devices includes clock gating control for each peripheral, that is, the clock
to each peripheral can explicitly be gated on or off, using clock-gate control bits in the
SIM module.
3.5
Clock Modules
3.5.1MCG Configuration
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
Figure 3-14. MCG configuration
Table 3-24. Reference links to related information
TopicRelated moduleReference
Full descriptionMCGMCG
System memory mapSystem memory map
ClockingClock distribution
Power managementPower management
Signal multiplexingPort controlSignal multiplexing
64Freescale Semiconductor, Inc.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 65
Signal multiplexing
Register
access
Peripheral
bridge
System oscillator
MCG
Module signals
RTC
Chapter 3 Chip Configuration
3.5.1.1MCG FLL modes
On L-series devices the MCGFLLCLK frequency is limited to 48 MHz max. The DCO is
limited to the two lowest range settings (MCG_C4[DRST_DRS] must be set to either
0b00 or 0b01).
3.5.2OSC Configuration
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
Figure 3-15. OSC configuration
Table 3-25. Reference links to related information
TopicRelated moduleReference
Full descriptionOSCOSC
System memory mapSystem memory map
ClockingClock distribution
Power managementPower management
Signal multiplexingPort controlSignal multiplexing
Full descriptionMCGMCG
3.5.2.1OSC modes of operation with MCG and RTC
The most common method of controlling the OSC block is through MCG clock source
selection MCG_C1[CLKS] and the MCG_C2 register bits to configure the oscillator
frequency range, gain-mode, and for crystal or external clock operation. The OSC_CR
also provides control for enabling the OSC and configuring internal load capacitors for
the EXTAL and XTAL pins. See the OSC and MCG chapters for more details.
Freescale Semiconductor, Inc.65
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 66
Register
access
Flash memory
Transfers
Flash memory
controller
Peripheral bus
controller 0
Memories and Memory Interfaces
The RTC_CR[OSCE] bit has overriding control over the MCG and OSC_CR enable
functions. When RTC_CR[OSCE] is set, the OSC is configured for low frequency, low
power and the RTC_CR[SCxP] bits override the OSC_CR[SCxP] bits to control the
internal capacitance configuration. See the RTC chapter for more details.
3.6
Memories and Memory Interfaces
3.6.1Flash Memory Configuration
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
Figure 3-16. Flash memory configuration
Table 3-26. Reference links to related information
TopicRelated moduleReference
Full descriptionFlash memoryFlash memory
System memory mapSystem memory map
ClockingClock Distribution
TransfersFlash memory
controller
Register accessPeripheral bridgePeripheral bridge
Flash memory controller
3.6.1.1Flash Memory Sizes
The devices covered in this document contain 1 program flash block consisting of 1 KB
sectors.
The amounts of flash memory for the devices covered in this document are:
66Freescale Semiconductor, Inc.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 67
Program flash
Flash configuration field
Program flash base address
Flash memory base address
Registers
Chapter 3 Chip Configuration
Table 3-27. KL04 flash memory size
DeviceProgram flash (KB)Block 0 (P-Flash) address range
The flash memory and the flash registers are located at different base addresses as shown
in the following figure. The base address for each is specified in System memory map.
Figure 3-17. Flash memory map
The on-chip Flash is implemented in a portion of the allocated Flash range to form a
contiguous block in the memory map beginning at address 0x0000_0000. See Flash
Memory Sizes for details of supported ranges.
Accesses to the flash memory ranges outside the amount of Flash on the device causes
the bus cycle to be terminated with an error followed by the appropriate response in the
requesting bus master. Read collision events in which flash memory is accessed while a
flash memory resource is being manipulated by a flash command also generates a bus
error response.
Freescale Semiconductor, Inc.67
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 68
Memories and Memory Interfaces
3.6.1.3Flash Security
How flash security is implemented on this device is described in Chip Security.
3.6.1.4Flash Modes
The flash memory chapter defines two modes of operation - NVM normal and NVM
special modes. On this device, The flash memory only operates in NVM normal mode.
All references to NVM special mode should be ignored.
3.6.1.5Erase All Flash Contents
In addition to software, the entire flash memory may be erased external to the flash
memory via the SW-DP debug port by setting MDM-AP CONTROL[0]. MDM-AP
STATUS[0] is set to indicate the mass erase command has been accepted. MDM-AP
STATUS[0] is cleared when the mass erase completes.
3.6.1.6FTFA_FOPT Register
The flash memory's FTFA_FOPT register allows the user to customize the operation of
the MCU at boot time. See FOPT boot options for details of its definition.
3.6.2Flash Memory Controller Configuration
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
See MCM_PLACR register description for details on the reset configuration of the FMC.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Table 3-28. Reference links to related information
TopicRelated moduleReference
Full descriptionFlash memory
controller
System memory mapSystem memory map
ClockingClock Distribution
TransfersFlash memoryFlash memory
TransfersCrossbar switchCrossbar Switch
Register accessMCMMCM
Flash memory controller
3.6.3SRAM Configuration
This section summarizes how the module has been configured in the chip.
Figure 3-19. SRAM configuration
Table 3-29. Reference links to related information
TopicRelated moduleReference
Full descriptionSRAMSRAM
System memory mapSystem memory map
ClockingClock Distribution
ARM Cortex-M0+ coreARM Cortex-M0+ core
Freescale Semiconductor, Inc.69
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 70
Memories and Memory Interfaces
3.6.3.1SRAM Sizes
This device contains SRAM which could be accessed by bus masters through the crossbar switch. The amount of SRAM for the devices covered in this document is shown in
the following table.
Table 3-30. KL04 SRAM memory size
DeviceSRAM (KB)
MKL04Z8VFK41
MKL04Z16VFK42
MKL04Z32VFK44
MKL04Z8VLC41
MKL04Z16VLC42
MKL04Z32VLC44
MKL04Z8VFM41
MKL04Z16VFM42
MKL04Z32VFM44
MKL04Z16VLF42
MKL04Z32VLF44
3.6.3.2SRAM Ranges
The on-chip SRAM is split into two ranges, 1/4 is allocated SRAM_L and 3/4 is allocated
to SRAM_U.
The on-chip RAM is implemented such that the SRAM_L and SRAM_U ranges form a
contiguous block in the memory map. As such:
• SRAM_L is anchored to 0x1FFF_FFFF and occupies the space before this ending
address.
• SRAM_U is anchored to 0x2000_0000 and occupies the space after this beginning
address.
Valid address ranges for SRAM_L and SRAM_U are then defined as:
• SRAM_L = [0x2000_0000–(SRAM_size/4)] to 0x1FFF_FFFF
• SRAM_U = 0x2000_0000 to [0x2000_0000+(SRAM_size*(3/4))-1]
This is illustrated in the following figure.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
70Freescale Semiconductor, Inc.
Page 71
SRAM_U
0x2000_0000
SRAM size *(1/4)
SRAM_L
0x1FFF_FFFF
SRAM size * (3/4)
0x2000_0000 – SRAM_size/4
0x2000_0000 + SRAM_size(3/4) - 1
Chapter 3 Chip Configuration
For example, for a device containing 16 KB of SRAM the ranges are:
• SRAM_L: 0x1FFF_F000 – 0x1FFF_FFFF
• SRAM_U: 0x2000_0000 – 0x2000_2FFF
3.6.3.3SRAM retention in low power modes
The SRAM is retained down to VLLS3 mode. In VLLS1 and VLLS0 no SRAM is
retained.
3.7
Analog
3.7.112-bit SAR ADC Configuration
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
Figure 3-20. SRAM blocks memory map
Freescale Semiconductor, Inc.71
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 72
Signal multiplexing
Module signals
Register
access
12-bit SAR ADC
Peripheral bus
controller 0
Other peripherals
Analog
Figure 3-21. 12-bit SAR ADC configuration
Table 3-31. Reference links to related information
TopicRelated moduleReference
Full description12-bit SAR ADC12-bit SAR ADC
System memory mapSystem memory map
ClockingClock distribution
Power managementPower management
Signal multiplexingPort controlSignal multiplexing
3.7.1.1ADC Instantiation Information
This device contains one 12-bit successive approximation ADC with up to 14-channels.
The ADC supports both software and hardware triggers. The hardware trigger sources are
listed in the Module-to-Module section.
The number of ADC channels present on the device is determined by the pinout of the
specific device package and is shown in the following table.
Table 3-32. Number of KL04 ADC channels
DeviceNumber of ADC channels
MKL04Z8VFK412
MKL04Z16VFK412
MKL04Z32VFK412
MKL04Z8VLC414
MKL04Z16VLC414
MKL04Z32VLC414
MKL04Z8VFM414
MKL04Z16VFM414
MKL04Z32VFM414
MKL04Z16VLF414
Table continues on the next page...
72Freescale Semiconductor, Inc.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 73
Chapter 3 Chip Configuration
Table 3-32. Number of KL04 ADC channels (continued)
DeviceNumber of ADC channels
MKL04Z32VLF414
3.7.1.2DMA Support on ADC
Applications may require continuous sampling of the ADC that may have considerable
load on the CPU. The ADC supports DMA request functionality for higher performance
when the ADC is sampled at a very high rate. The ADC can trigger the DMA (via DMA
req) on conversion completion.
1. This is the PMC bandgap 1V reference voltage. Prior to reading from this ADC channel, ensure that you enable the
bandgap buffer by setting the PMC_REGSC[BGBE] bit. Refer to the device data sheet for the bandgap voltage (VBG)
specification.
ChannelInput signal
(SC1n[DIFF]= 1)
1
Input signal
(SC1n[DIFF]= 0)
Bandgap (S.E)
1
3.7.1.4ADC Analog Supply and Reference Connections
This device internally connects VDDA to VDD and VSSA to VSS.
This device contains separate VREFH and VREFL pins on 32-pin and higher devices.
These pins are internally connected to VDD and VSS respectively, on packages less than
32-pin.
3.7.1.5ADC Reference Options
The ADC supports the following references:
• VREFH/VREFL - connected as the primary reference option
• VDDA - connected as the V
reference option
ALT
3.7.1.6Alternate clock
For this device, the alternate clock is connected to OSCERCLK.
NOTE
This clock option is only usable when OSCERCLK is in the
MHz range. A system with OSCERCLK in the kHz range has
the optional clock source below minimum ADC clock operating
frequency.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
74Freescale Semiconductor, Inc.
Page 75
Signal multiplexing
Module signals
Register
access
CMP
Peripheral
bridge 0
Other peripherals
Chapter 3 Chip Configuration
3.7.2CMP Configuration
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
Figure 3-22. CMP configuration
Table 3-33. Reference links to related information
TopicRelated moduleReference
Full descriptionComparator (CMP)Comparator
System memory mapSystem memory map
ClockingClock distribution
Power managementPower management
Signal multiplexingPort controlSignal multiplexing
3.7.2.1CMP Instantiation Information
The device includes one high speed comparator and two 8-input multiplexors for both the
inverting and non-inverting inputs of the comparator. Each CMP input channel connects
to both muxes. Two of the channels are connected to internal sources, leaving resources
to support up to 6 input pins. See the channel assignment table for a summary of CMP
input connections for this device.
The CMP also includes one 6-bit DAC with a 64-tap resistor ladder network, which
provides a selectable voltage reference for applications where voltage reference is needed
for internal connection to the CMP.
The CMP can be optionally on in all modes except VLLS0.
The CMP has several module to module interconnects in order to facilitate ADC
triggering, TPM triggering and UART IR interfaces. For complete details on the CMP
module interconnects please refer to the Module-to-Module section.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.75
Page 76
Analog
The CMP does not support window compare function and CMP_CR1[WE] must always
be written to 0. The sample function has limited functionality since the SAMPLE input to
the block is not connected to a valid input. Usage of sample operation is limited to a
divided version of the bus clock (CMP_CR1[SE] = 0).
Due to the pin number limitation, the CMP pass through mode is not supported by this
device, so the CMPx_MUXCR[PSTM] must be left as 0.
3.7.2.2CMP input connections
The following table shows the fixed internal connections to the CMP.
1. This is the PMC bandgap 1V reference voltage. Prior to using as CMP input, ensure that you enable the bandgap buffer by
setting the PMC_REGSC[BGBE] bit. Refer to the device data sheet for the bandgap voltage (VBG) specification.
3.7.2.3CMP external references
The 6-bit DAC sub-block supports selection of two references. For this device, the
references are connected as follows:
• VREFH - V
input. When using VREFH, any ADC conversion using this same
in1
reference at the same time is negatively impacted.
• VDD - V
in2
input
3.7.2.4CMP trigger mode
The CMP and 6-bit DAC sub-block supports trigger mode operation when the
CMP_CR1[TRIGM] is set. When trigger mode is enabled, the trigger event will initiate a
compare sequence that must first enable the CMP and DAC prior to performing a CMP
operation and capturing the output. In this device, control for this two staged sequencing
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
76Freescale Semiconductor, Inc.
Page 77
Signal multiplexing
Module signals
Register
access
TPM
Peripheral bus
controller 0
Other peripherals
Chapter 3 Chip Configuration
is provided from the LPTMR. The LPTMR triggering output is always enabled when the
LPTMR is enabled. The first signal is supplied to enable the CMP and DAC and is
asserted at the same time as the TCF flag is set. The delay to the second signal that
triggers the CMP to capture the result of the compare operation is dependent on the
LPTMR configuration. In Time Counter mode with prescaler enabled, the delay is 1/2
Prescaler output period. In Time Counter mode with prescaler bypassed, the delay is 1/2
Prescaler clock period.
The delay between the first signal from LPTMR and the second signal from LPTMR
must be greater than the Analog comparator initialization delay as defined in the device
datasheet.
3.8
Timers
3.8.1Timer/PWM Module Configuration
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
Figure 3-23. TPM configuration
Table 3-35. Reference links to related information
TopicRelated moduleReference
Full descriptionTimer/PWM ModuleTimer/PWM Module
System memory mapSystem memory map
ClockingClock distribution
Power managementPower management
Signal multiplexingPort controlSignal multiplexing
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.77
Page 78
Timers
3.8.1.1TPM Instantiation Information
This device contains two Low Power TPM modules (TPM). All TPM modules in the
device only are configured as basic TPM function, and no quadrature decoder function
and all can be functional in Stop/VLPS mode. The clock source is either external or
internal in Stop/VLPS mode.
The following table shows how these modules are configured.
Table 3-36. TPM configuration
TPM instanceNumber of channelsFeatures/usage
TPM06Basic TPM,functional in Stop/VLPS mode
TPM12Basic TPM,functional in Stop/VLPS mode
There are several connections to and from the TPMs in order to facilitate customer use
cases. For complete details on the TPM module interconnects please refer to the Module-
to-Module section.
3.8.1.2Clock Options
The TPM blocks are clocked from a single TPM clock that can be selected from
OSCERCLK, MCGIRCLK, or MCGFLLCLK. The selected source is controlled by
SIM_SOPT2[TPMSRC] control registers.
Each TPM also supports an external clock mode (TPM_SC[CMOD]=1x) in which the
counter increments after a synchronized (to the selected TPM clock source) rising edge
detect of an external clock input. The available external clock (either TPM_CLKIN0 or
TPM_CLKIN1) is selected by SIM_SOPT4[TPMxCLKSEL] control register. To
guarantee valid operation the selected external clock must be less than half the frequency
of the selected TPM clock source.
3.8.1.3Trigger Options
Each TPM has a selectable trigger input source controlled by the
TPMx_CONF[TRGSEL] field to use for starting the counter and/or reloading the
counter. The options available are shown in the following table.
Table 3-37. TPM trigger options
TPMx_CONF[TRGSEL]Selected source
0000External trigger pin input (EXTRG_IN)
Table continues on the next page...
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Each TPM has a global timebase feature controlled by the TPMx_CONF[GTBEEN] bit.
TPM1 is configured as the global time when this option is enabled.
3.8.1.5TPM Interrupts
The TPM has multiple sources of interrupt. However, these sources are OR'd together to
generate a single interrupt request to the interrupt controller. When an TPM interrupt
occurs, read the TPM status registers to determine the exact interrupt source.
3.8.2PIT Configuration
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.79
Page 80
Register
access
Peripheral
bridge
Periodic interrupt
timer
Timers
Figure 3-24. PIT configuration
Table 3-38. Reference links to related information
TopicRelated moduleReference
Full descriptionPITPIT
System memory mapSystem memory map
ClockingClock Distribution
Power managementPower management
3.8.2.1PIT/DMA Periodic Trigger Assignments
The PIT generates periodic trigger events to the DMA channel mux as shown in the table
below.
Table 3-39. PIT channel assignments for periodic DMA triggering
PIT triggers are selected as ADCx trigger sources using the SOPT7[ADCxTRGSEL] bits
in the SIM module. For more details, refer to SIM chapter.
3.8.2.3PIT/TPM Triggers
PIT triggers are selected as TPMx trigger sources using the TPMx_CONF[TRGSEL] bits
in the TPM module. For more details, refer to TPM chapter.
80Freescale Semiconductor, Inc.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 81
Signal multiplexing
Register
access
Peripheral
bridge
Module signals
Low-power timer
Chapter 3 Chip Configuration
3.8.2.4PIT/DAC Triggers
PIT Channel 0 is configured as the DAC hardware trigger source. For more details, refer
to DAC chapter.
3.8.3Low-power timer configuration
Figure 3-25. LPT configuration
Table 3-40. Reference links to related information
TopicRelated moduleReference
Full descriptionLow-power timerLow-power timer
System memory mapSystem memory map
ClockingClock Distribution
Power managementPower management
Signal MultiplexingPort controlSignal Multiplexing
3.8.3.1LPTMR Instantiation Information
The low-power timer (LPTMR) allows operation during all power modes. The LPTMR
can operate as a real-time interrupt or pulse accumulator. It includes a 15-bit prescaler
(real-time interrupt mode) or glitch filter (pulse accumulator mode).
The LPTMR can be clocked from the internal reference clock, the internal 1 kHz LPO,
OSCERCLK, or an external 32.768 kHz crystal. In VLLS0 mode, the clocking option is
limited to an external pin with the OSC configured for bypass (external clock) operation.
An interrupt is generated (and the counter may reset) when the counter equals the value
in the 16-bit compare register.
Freescale Semiconductor, Inc.81
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 82
Timers
3.8.3.2LPTMR pulse counter input options
The LPTMR_CSR[TPS] bitfield configures the input source used in pulse counter mode.
The following table shows the chip-specific input assignments for this bitfield.
The prescaler and glitch filter of the LPTMR module can be clocked from one of four
sources determined by the LPTMR0_PSR[PCS] bitfield. The following table shows the
chip-specific clock assignments for this bitfield.
NOTE
The chosen clock must remain enabled if the LPTMR is to
continue operating in all required low-power modes.
LPTMR0_PSR[PCS]Prescaler/glitch filter clock
number
000MCGIRCLK — internal reference clock
011LPO — 1 kHz clock (not available in
102ERCLK32K (not available in VLLS0
113OSCERCLK — external reference clock
Chip clock
(not available in LLS and VLLS modes)
VLLS0 mode)
mode when using 32 kHz oscillator)
(not available in VLLS0 mode)
See Clock Distribution for more details on these clocks.
3.8.4RTC configuration
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
82Freescale Semiconductor, Inc.
Page 83
Signal multiplexing
Register
access
Peripheral
bridge
Module signals
Real-time clock
Chapter 3 Chip Configuration
Figure 3-26. RTC configuration
Table 3-41. Reference links to related information
TopicRelated moduleReference
Full descriptionRTCRTC
System memory mapSystem memory map
ClockingClock Distribution
Power managementPower management
3.8.4.1RTC Instantiation Information
RTC prescaler is clocked by ERCLK32K.
RTC is reset on POR Only.
RTC_CR[OSCE] can override the configuration of the System OSC, configuring the
OSC for 32 kHz crystal operation in all power modes except VLLS0, and through any
System Reset. When OSCE is enabled, the RTC also overrides the capacitor
configurations.
3.8.4.2RTC_CLKOUT options
RTC_CLKOUT pin can be driven either with the RTC 1 Hz output or with the
OSCERCLK on-chip clock source. Control for this option is through
SIM_SOPT2[RTCCLKOUTSEL] bit.
When RTCCLKOUTSEL = 0, the RTC 1 Hz clock is output is selected on the
RTC_CLKOUT pin. When RTCCLKOUTSEL = 1, OSCERCLK clock is output on the
RTC_CLKOUT pin.
Freescale Semiconductor, Inc.83
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 84
Signal multiplexing
Register
access
SPI
Peripheral
bridge
Module signals
Communication interfaces
3.9
Communication interfaces
3.9.1SPI configuration
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
Figure 3-27. SPI configuration
Table 3-42. Reference links to related information
TopicRelated moduleReference
Full descriptionSPISPI
System memory mapSystem memory map
ClockingClock Distribution
Signal MultiplexingPort controlSignal Multiplexing
3.9.1.1SPI Instantiation Information
This device contains one SPI module that supports 8-bit data length.
SPI0 is clocked on the bus clock.
The SPI supports DMA request and can operate in VLPS mode. When the SPI is
operating in VLPS mode, it will operate as a slave.
SPI can wakeup MCU from VLPS mode upon reception of SPI data in slave mode.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
84Freescale Semiconductor, Inc.
Page 85
Signal multiplexing
Register
access
Peripheral
bridge
Module signals
2
I C
Chapter 3 Chip Configuration
3.9.2I2C Configuration
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
Figure 3-28. I2C configuration
Table 3-43. Reference links to related information
TopicRelated moduleReference
Full descriptionI2CI2C
System memory mapSystem memory map
ClockingClock Distribution
Power managementPower management
Signal MultiplexingPort controlSignal Multiplexing
3.9.2.1IIC Instantiation Information
This device has one IIC module.
When the package pins associated with IIC have their mux select configured for IIC
operation, the pins (SCL and SDA) are driven in a pseudo open drain configuration.
The digital glitch filter implemented in the IIC0 module, controlled by the
I2C0_FLT[FLT] registers, is clocked from the bus clock and thus has filter granularity in
bus clock cycle counts.
3.9.3UART Configuration
This section summarizes how the module has been configured in the chip. For a
comprehensive description of the module itself, see the module’s dedicated chapter.
Freescale Semiconductor, Inc.85
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 86
Signal multiplexing
Register
access
Peripheral
bridge
Module signals
UART
Communication interfaces
Figure 3-29. UART configuration
Table 3-44. Reference links to related information
TopicRelated moduleReference
Full descriptionUART0UART
System memory mapSystem memory map
ClockingClock Distribution
Power managementPower management
Signal MultiplexingPort controlSignal Multiplexing
3.9.3.1UART0 overview
The UART0 module supports basic UART with DMA interface function, x4 to x32
oversampling of baud-rate.
This module supports LIN slave operation.
The module can remain functional in VLPS mode provided the clock it is using remains
enabled.
ISO7816 protocol is intended to be handled in software for this product. To support smart
card reading, TxD pin can be configured as pseudo open drain for 1-wire half-duplex like
ISO7816 communication via the SIM_SOPT5[UART0ODE] bit.
3.9.3.2UART1 and UART2 Overview
This device contains two basic universal asynchronous receiver/transmitter (UART)
modules with DMA function support. Generally, these modules are used in RS-232,
RS-485, and other communications. This module supports LIN Slave operation.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
86Freescale Semiconductor, Inc.
Page 87
Signal multiplexing
Register
access
Peripheral
bridge
Module signals
GPIO controller
ARM Cortex -M0+
Core
Register access
Chapter 3 Chip Configuration
3.10
Human-machine interfaces (HMI)
3.10.1GPIO Configuration
Figure 3-30. GPIO configuration
Table 3-45. Reference links to related information
TopicRelated moduleReference
Full descriptionGPIOGPIO
System memory mapSystem memory map
ClockingClock Distribution
Power managementPower management
Crossbar switchCrossbar switchCrossbar switch
Signal MultiplexingPort controlSignal Multiplexing
3.10.1.1GPIO Instantiation Information
The device includes four pins, PTB0, PTB1, PTA12, and PTA13, with high current drive
capability. These pins can be used to drive LED or power MOSFET directly. The high
drive capability applies to all functions which are multiplexed on these pins (UART,
TPM, SPI...etc)
3.10.1.1.1Pull Devices and Directions
The pull devices are enabled out of POR only on RESET_B, NMI_b and respective SWD
signals. Other pins can be enabled by writing to PORTx_PCRn[PE] field.
Freescale Semiconductor, Inc.87
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 88
Human-machine interfaces (HMI)
All the pins are hard wired to be pullup except for SWD_CLK. The state will be reflected
in the PORTx_PCRn[PS] field.
3.10.1.2Port Control and Interrupt Summary
The following table provides more information regarding the Port Control and Interrupt
configurations .
Table 3-46. Ports Summary
FeaturePort APort B
Pull Select controlNoNo
Pull Select at resetPTA0=Pull down, Others=Pull upPull up
Pull Enable controlYesYes
Pull Enable at resetPTA0/PTA2/RESET_b=Enabled;
Others=Disabled
Slew Rate Enable controlNoNo
Slew Rate Enable at resetPTA2/PTA6/PTA7/PTA15=Disabled;
Others=Enabled
Passive Filter Enable controlRESET_b onlyPTB5 only
Passive Filter Enable at resetRESET_b=Enabled; Others=DisabledDisabled
Open Drain Enable control
Open Drain Enable at resetDisabledDisabled
Drive Strength Enable controlPTA12/PTA13 onlyPTB0/PTB1 only
Drive Strength Enable at resetDisabledDisabled
Pin Mux controlYesYes
Pin Mux at resetPTA0/PTA2=ALT3; Others=ALT0PTB5=ALT3; Others=ALT0
Lock BitNoNo
Interrupt and DMA RequestPTA0/PTA1/PTA7/PTA10/PTA11/
Digital Glitch FilterNoNo
1
NoNo
PTA12/PTA16/PTA17/PTA18 only
PTB5=Enabled; Others=Disabled
PTB0/PTB15/PTB16/PTB17= Disabled;
Others=Enabled
PTB0/PTB1/PTB2/PTB3/PTB4/PTB5/
PTB6/PTB7/PTB14 only
1. UART signals can be configured for open-drain using SIM_SOPT5 register. IIC signals are automatically enabled for open
drain when selected.
3.10.1.3GPIO accessibility in the memory map
The GPIO is multi-ported and can be accessed directly by the core with zero wait states at
base address 0xF800_0000. It can also be accessed by the core and DMA masters
through the cross bar/AIPS interface at 0x400F_F000 and at an aliased slot (15) at
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
88Freescale Semiconductor, Inc.
Page 89
Chapter 3 Chip Configuration
address 0x4000_F000. All BME operations to the GPIO space can be accomplished
referencing the aliased slot (15) at address 0x4000_F000. Only some of the BME
operations can be accomplished referencing GPIO at address 0x400F_F000.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.89
Page 90
Human-machine interfaces (HMI)
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
90Freescale Semiconductor, Inc.
Page 91
Chapter 4
Memory Map
4.1Introduction
This device contains various memories and memory-mapped peripherals which are
located in a 4 GB memory space. This chapter describes the memory and peripheral
locations within that memory space.
4.2System memory map
The following table shows the high-level device memory map.
Table 4-1. System memory map
System 32-bit Address RangeDestination SlaveAccess
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.91
Page 92
Program flash
Flash configuration field
Program flash base address
Flash memory base address
Registers
Flash Memory Map
Table 4-1. System memory map (continued)
System 32-bit Address RangeDestination SlaveAccess
0xF000_1000–0xF000_1FFFMTB Data Watchpoint and Trace (MTBDWT) registersCortex-M0+ core
0xF000_2000–0xF000_2FFFROM tableCortex-M0+ core
0xF000_3000–0xF000_3FFFMiscellaneous Control Module (MCM)Cortex-M0+ core
0xF000_4000–0xF7FF_FFFFReserved–
0xF800_0000–0xFFFF_FFFFIOPORT: GPIO (single cycle)Cortex-M0+ core
1. The program flash always begins at 0x0000_0000 but the end of implemented flash varies depending on the amount of
flash implemented for a particular device. See Flash Memory Sizes for details.
2. This range varies depending on SRAM sizes. See SRAM Ranges for details.
3. Includes BME operations to GPIO at slot 15 (based at 0x4000_F000).
4.3Flash Memory Map
The flash memory and the flash registers are located at different base addresses as shown
in the following figure. The base address for each is specified in System memory map.
The on-chip Flash is implemented in a portion of the allocated Flash range to form a
contiguous block in the memory map beginning at address 0x0000_0000. See Flash
Memory Sizes for details of supported ranges.
Accesses to the flash memory ranges outside the amount of Flash on the device causes
the bus cycle to be terminated with an error followed by the appropriate response in the
requesting bus master. Read collision events in which flash memory is accessed while a
flash memory resource is being manipulated by a flash command also generates a bus
error response.
92Freescale Semiconductor, Inc.
Figure 4-1. Flash memory map
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Page 93
Chapter 4 Memory Map
4.3.1Alternate Non-Volatile IRC User Trim Description
The following non-volatile locations (4 bytes) are reserved for custom IRC user trim
supported by some development tools. An alternate IRC trim to the factory loaded trim
can be stored at this location. To override the factory trim, user software must load new
values into the MCG trim registers.
The on-chip RAM is split between SRAM_L and SRAM_U. The RAM is also
implemented such that the SRAM_L and SRAM_U ranges form a contiguous block in
the memory map. See SRAM Ranges for details.
Accesses to the SRAM_L and SRAM_U memory ranges outside the amount of RAM on
the device causes the bus cycle to be terminated with an error followed by the appropriate
response in the requesting bus master.
4.5Bit Manipulation Engine
The Bit Manipulation Engine (BME) provides hardware support for atomic read-modifywrite memory operations to the peripheral address space. By combining the basic load
and store instruction support in the Cortex-M instruction set architecture with the concept
of decorated storage provided by the BME, the resulting implementation provides a
robust and efficient read-modify-write capability to this class of ultra low-end
microcontrollers. See the Bit Manipulation Engine Block Guide (BME) for a detailed
description of BME functionality.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.93
Page 94
Peripheral bridge (AIPS-Lite) memory map
4.6Peripheral bridge (AIPS-Lite) memory map
The peripheral memory map is accessible via one slave port on the crossbar in the
0x4000_0000–0x400F_FFFF region. The device implements one peripheral bridge that
defines a 1024 KB address space.
The three regions associated with this space are:
• A 128 KB region, partitioned as 32 spaces, each 4 KB in size and reserved for onplatform peripheral devices. The AIPS controller generates unique module enables
for all 32 spaces.
• A 384 KB region, partitioned as 96 spaces, each 4 KB in size and reserved for offplatform modules. The AIPS controller generates unique module enables for all 96
spaces.
• The last slot is a 4 KB region beginning at 0x400F_F000 for accessing the GPIO
module. The GPIO slot (slot 128) is an alias of slot 15. This block is also directly
interfaced to the core and provides direct access without incurring wait states
associated with accesses via the AIPS controller.
Modules that are disabled via their clock gate control bits in the SIM registers disable the
associated AIPS slots. Access to any address within an unimplemented or disabled
peripheral bridge slot results in a transfer error termination.
For programming model accesses via the peripheral bridges, there is generally only a
small range within the 4 KB slots that is implemented. Accessing an address that is not
implemented in the peripheral results in a transfer error termination.
4.6.1Read-after-write sequence and required serialization of
memory operations
In some situations, a write to a peripheral must be completed fully before a subsequent
action can occur. Examples of such situations include:
• Exiting an interrupt service routine (ISR)
• Changing a mode
• Configuring a function
In these situations, application software must perform a read-after-write sequence to
guarantee the required serialization of the memory operations:
1. Write the peripheral register.
2. Read the written peripheral register to verify the write.
3. Continue with subsequent operations.
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
In user mode, for MCG, RCM, SIM (slot 71 and 72), SMC, LLWU, and PMC, reads are
allowed, but writes are blocked and generate bus error.
4.7Private Peripheral Bus (PPB) memory map
The PPB is part of the defined ARM bus architecture and provides access to select
processor-local modules. These resources are only accessible from the core; other system
masters do not have access to them.
Table 4-3. PPB memory map
System 32-bit Address RangeResourceAdditional Range DetailResource
0xE000_0000–0xE000_DFFFReserved
Table continues on the next page...
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
98Freescale Semiconductor, Inc.
Page 99
Chapter 4 Memory Map
Table 4-3. PPB memory map (continued)
System 32-bit Address RangeResourceAdditional Range DetailResource
0xE000_E000–0xE000_EFFFSystem Control Space
(SCS)
0xE000_F000–0xE00F_EFFFReserved
0xE00F_F000–0xE00F_FFFFCore ROM Space (CRS)
0xE000_E000–0xE000_E00FReserved
0xE000_E010–0xE000_E0FFSysTick
0xE000_E100–0xE000_ECFFNVIC
0xE000_ED00–0xE000_ED8FSystem Control Block
0xE000_ED90–0xE000_EDEFReserved
0xE000_EDF0–0xE000_EEFFDebug
0xE000_EF00–0xE000_EFFFReserved
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
Freescale Semiconductor, Inc.99
Page 100
Private Peripheral Bus (PPB) memory map
KL04 Sub-Family Reference Manual, Rev. 3.1, November 2012
100Freescale Semiconductor, Inc.
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.