MKE02Z64M20SF0RM
MKE02Z64M20SF0RM
MKE02Z64M20SF0RM
Chapter 1
About This Document
1.1 Overview.........................................................................................................................................................................33
1.1.1 Purpose.............................................................................................................................................................33
1.1.2 Audience..........................................................................................................................................................33
1.2 Conventions....................................................................................................................................................................33
Chapter 2
Introduction
2.1 Overview.........................................................................................................................................................................35
2.2.4 Clocks...............................................................................................................................................................38
Chapter 3
Chip Configuration
3.1 Introduction.....................................................................................................................................................................41
3.3.1.5 Caches..........................................................................................................................................48
3.8 Analog.............................................................................................................................................................................67
3.9 Timers.............................................................................................................................................................................72
Chapter 4
Memory Map
4.1 Introduction.....................................................................................................................................................................85
Chapter 5
Clock Distribution
5.1 Introduction.....................................................................................................................................................................93
Chapter 6
Reset and Boot
6.1 Introduction.....................................................................................................................................................................101
6.2 Reset................................................................................................................................................................................101
6.3 Boot.................................................................................................................................................................................105
Chapter 7
Power Management
7.1 Introduction.....................................................................................................................................................................107
Chapter 8
Security
8.1 Introduction.....................................................................................................................................................................111
Chapter 9
Debug
9.1 Introduction.....................................................................................................................................................................113
Chapter 10
Signal Multiplexing and Signal Descriptions
10.1 Introduction.....................................................................................................................................................................119
10.2 Pinout..............................................................................................................................................................................119
10.3.5 Analog..............................................................................................................................................................125
Chapter 11
Port Control (PORT)
11.1 Introduction.....................................................................................................................................................................129
Chapter 12
System Integration Module (SIM)
12.1 Introduction.....................................................................................................................................................................149
12.1.1 Features............................................................................................................................................................149
Chapter 13
Power Management Controller (PMC)
13.1 Introduction.....................................................................................................................................................................165
Chapter 14
Miscellaneous Control Module (MCM)
14.1 Introduction.....................................................................................................................................................................171
14.1.1 Features............................................................................................................................................................171
Chapter 15
Peripheral Bridge (AIPS-Lite)
15.1 Introduction.....................................................................................................................................................................177
15.1.1 Features............................................................................................................................................................177
Chapter 16
Watchdog Timer (WDOG)
16.1 Introduction.....................................................................................................................................................................179
16.1.1 Features............................................................................................................................................................179
Chapter 17
Bit Manipulation Engine (BME)
17.1 Introduction.....................................................................................................................................................................195
17.1.1 Overview..........................................................................................................................................................196
17.1.2 Features............................................................................................................................................................196
Chapter 18
Flash Memory Module (FTMRH)
18.1 Introduction.....................................................................................................................................................................215
18.2 Feature.............................................................................................................................................................................215
18.3.6 Protection.........................................................................................................................................................224
18.3.7 Security............................................................................................................................................................229
18.3.7.3 Mode and security effects on flash and EEPROM command availability...................................231
Chapter 19
Flash Memory Controller (FMC)
19.1 Introduction.....................................................................................................................................................................259
19.1.1 Overview..........................................................................................................................................................259
19.1.2 Features............................................................................................................................................................259
Chapter 20
Internal Clock Source (ICS)
20.1 Introduction.....................................................................................................................................................................263
20.1.1 Features............................................................................................................................................................263
20.4.1.7 Stop..............................................................................................................................................273
Chapter 21
Oscillator (OSC)
21.1 Introduction.....................................................................................................................................................................279
21.1.1 Overview..........................................................................................................................................................279
21.6.1.1 Off................................................................................................................................................285
21.6.3 Counter.............................................................................................................................................................288
Chapter 22
Cyclic Redundancy Check (CRC)
22.1 Introduction.....................................................................................................................................................................289
22.1.1 Features............................................................................................................................................................289
Chapter 23
Interrupt (IRQ)
23.1 Introduction.....................................................................................................................................................................299
23.2 Features...........................................................................................................................................................................299
Chapter 24
Analog-to-digital converter (ADC)
24.1 Introduction.....................................................................................................................................................................303
24.1.1 Features............................................................................................................................................................303
Chapter 25
Analog comparator (ACMP)
25.1 Introduction.....................................................................................................................................................................335
25.1.1 Features............................................................................................................................................................335
25.6 Resets..............................................................................................................................................................................342
25.7 Interrupts.........................................................................................................................................................................342
Chapter 26
FlexTimer Module (FTM)
26.1 Introduction.....................................................................................................................................................................343
26.1.2 Features............................................................................................................................................................344
26.4.2 Prescaler...........................................................................................................................................................394
26.4.3 Counter.............................................................................................................................................................394
26.4.3.1 Up counting..................................................................................................................................394
26.4.12 Inverting...........................................................................................................................................................433
26.4.18 Initialization.....................................................................................................................................................445
Chapter 27
Periodic Interrupt Timer (PIT)
27.1 Introduction.....................................................................................................................................................................465
27.1.2 Features............................................................................................................................................................466
27.4.1.1 Timers..........................................................................................................................................471
27.4.2 Interrupts..........................................................................................................................................................472
Chapter 28
Real-Time Counter (RTC)
28.1 Introduction.....................................................................................................................................................................477
28.2 Features...........................................................................................................................................................................477
Chapter 29
Serial Peripheral Interface (SPI)
29.1 Introduction.....................................................................................................................................................................485
29.1.1 Features............................................................................................................................................................485
29.4.1 General.............................................................................................................................................................497
29.4.6.1 SS Output.....................................................................................................................................504
29.4.9 Reset.................................................................................................................................................................508
29.4.10 Interrupts..........................................................................................................................................................508
29.4.10.1 MODF..........................................................................................................................................509
29.4.10.2 SPRF............................................................................................................................................509
29.4.10.3 SPTEF..........................................................................................................................................509
29.4.10.4 SPMF...........................................................................................................................................509
Chapter 30
Inter-Integrated Circuit (I2C)
30.1 Introduction.....................................................................................................................................................................515
30.1.1 Features............................................................................................................................................................515
30.4.1.8 Handshaking.................................................................................................................................533
30.4.4.1 Timeouts.......................................................................................................................................537
30.4.5 Resets...............................................................................................................................................................539
30.4.6 Interrupts..........................................................................................................................................................539
Chapter 31
Universal Asynchronous Receiver/Transmitter (UART)
31.1 Introduction.....................................................................................................................................................................547
31.1.1 Features............................................................................................................................................................547
Chapter 32
General-Purpose Input/Output (GPIO)
32.1 Introduction.....................................................................................................................................................................573
32.1.1 Features............................................................................................................................................................573
32.4.3 IOPORT...........................................................................................................................................................586
Chapter 33
Keyboard Interrupts (KBI)
33.1 Introduction.....................................................................................................................................................................587
33.1.1 Features............................................................................................................................................................587
1.1 Overview
1.1.1 Purpose
This document describes the features, architecture, and programming model of the
Freescale KE02 microcontroller.
1.1.2 Audience
This document is primarily for system architects and software application developers
who are using or considering using the KE02 microcontroller in a system.
1.2 Conventions
2.1 Overview
This chapter provides an overview of the Kinetis KE02 product family of ARM®
Cortex®-M0+ MCUs. It also presents high-level descriptions of the modules available on
the devices covered by this document.
2.2.4 Clocks
The following clock modules are available on this device.
Table 2-5. Clock modules
Module Description
Internal Clock Source (ICS) ICS module containing an internal reference clock (ICSIRCLK) and a frequency-
locked-loop (FLL).
System oscillator (OSC) The system oscillator, in conjunction with an external crystal or resonator,
generates a reference clock for the MCU.
Low-Power Oscillator (LPO) The PMC module contains a 1 kHz low-power oscillator which acts as a standalone
low-frequency clock source in all modes.
3.1 Introduction
This chapter provides details on the individual modules of the microcontroller. It
includes:
• Module block diagrams showing immediate connections within the device
• Specific module-to-module interactions not necessarily discussed in the individual
module chapters
• Links for more information
ch0
FTM1 +
ch1 ACMP0
ovf RTC 1
-
0 UART0_RX
rxd
00 UART0
txd
01 ovf PITch0 0
ADC trg UART0_TX
10 1
ch0
11 FTM0
ch1 1
0 FTM0_CH1
0 inittrg fault0
FTM2_FLT1
ovf DELAY 1 matchtrg fault1
fault2 FTM2_FLT2
FTM2 fault3
BUS CLK 1 trigger0
2N trigger1
trigger2
BUSOUT
CLKOE
TX
UART0 0 UART0_TX
FTM0_CH0 1
PORT LOGIC
TXDME
RX
UART0 UART0_RX
1
FTM0_CH1
FTM0_CH1
0
RXDCE
0 UART0_RX
RX
UART0
1 ACMP0
+
To UART0_RX
Capture Function
RXDFE From Internal or External
Reference Voltage
When ADC hardware trigger selects the output of FTM2 triggers, an 8-bit delay block
will be enabled. This logic delays any trigger from FTM2 with an 8-bit counter whose
value is specified by SIM_SOPT[DELAY]. The reference clock to this module is the bus
clock with selectable predivider specified by SIM_SOPT[BUSREF].
Debug Interrupts
For details on the ARM Cortex-M0+ processor core see the ARM website: arm.com.
3.3.1.5 Caches
This device does not have processor related cache memories, but the flash controller has
an internal 32-byte cache for flash access.
Interrupts
ARM Cortex-M0+
Module
PPB Nested Vectored
Module
core
Interrupt Controller
(NVIC)
Module
R 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
IRQ3 IRQ2 IRQ1 IRQ0
W
• 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-8. Interrupt vector assignments
Address Vector IRQ1 NVIC Source module Source description
IPR
register
number2
ARM Core System Handler Vectors
0x0000_0000 0 — — ARM core Initial Stack Pointer
0x0000_0004 1 — — ARM core Initial Program Counter
0x0000_0008 2 — — ARM core Non-maskable Interrupt (NMI)
0x0000_000C 3 — — ARM core Hard Fault
0x0000_0010 4 — — — —
0x0000_0014 5 — — — —
0x0000_0018 6 — — — —
0x0000_001C 7 — — — —
0x0000_0020 8 — — — —
0x0000_0024 9 — — — —
0x0000_0028 10 — — — —
0x0000_002C 11 — — ARM core Supervisor call (SVCall)
0x0000_0030 12 — — — —
0x0000_0034 13 — — — —
0x0000_0038 14 — — ARM core Pendable request for system service
(PendableSrvReq)
0x0000_003C 15 — — ARM core System tick timer (SysTick)
Non-Core Vectors
0x0000_0040 16 0 0 — —
0x0000_0044 17 1 0 — —
0x0000_0048 18 2 0 — —
0x0000_004C 19 3 0 — —
0x0000_0050 20 4 1 — —
0x0000_0054 21 5 1 FTMRH Command complete and error interrupt
0x0000_0058 22 6 1 PMC Low-voltage warning
0x0000_005C 23 7 1 IRQ External interrupt
0x0000_0060 24 8 2 I2C0 Single interrupt vector for all sources
0x0000_0064 25 9 2 — —
0x0000_0068 26 10 2 SPI0 Single interrupt vector for all sources
0x0000_006C 27 11 2 SPI1 Single interrupt vector for all sources
0x0000_0070 28 12 3 UART0 Status and error
• The NVIC registers you would use to configure the interrupt are:
• NVICIPR2
• To determine the particular IRQ's field location within these particular registers:
• NVICIPR2 field starting location = 8 * (IRQ mod 4) + 6 = 22
Since the NVICIPR fields are 2-bit wide (4 priority levels), the NVICIPR2 field
range is bits 22–23.
Therefore, the field locations NVICIPR2[23:22] are used to configure the SPI0 interrupts.
Clock logic
Wake-up
requests
interrupt controller
Nested vectored
Asynchronous
(NVIC)
Module
Wake-up Interrupt
Controller (AWIC)
Module
Register
access
System integration
module (SIM)
Register access
Power Management
Controller (PMC)
ARM Cortex-M0+
Miscellaneous
core
Control Module
Transfers
(MCM)
GPIO
controller
Crossbar Switch
Flash
S0
controller
M0
IOPORT
SRAML
S1
SRAMU
BME
Peripheral
S2
Peripherals
bridge
Peripherals
Transfers Transfers
AIPS-Lite
peripheral bridge
Register
access
CRC
Peripheral
bridge
Register
access
System integration
module
WDOG
The watchdog counter has four clock source options selected by programming
WDOG_CS2[CLK]. The clock source options are the bus clock, internal 1 kHz clock,
external clock, or an internal 32 kHz clock source.
The refresh timeout time is defined by WDOG_TOVALH:L. In addition, if window
mode is used, software must not start the refresh sequence until after the time value set in
the WDOG_WINH:L registers.
An optional fixed prescaler for all clock sources allows for longer timeout periods. When
WDOG_CS2[PRES] is set, the clock source is prescaled by 256 before clocking the
watchdog counter.
The watchdog counter registers CNTH:L provide access to the value of the free-running
watchdog counter. The software can read the counter registers at any time but cannot
write directly to the watchdog counter. The refresh sequence resets the watchdog counter
to 0x0000. Write to the WDOG_CNTH:L registers of 0xC520 followed by 0xD928
within 16 bus clocks start the unlock sequence. On completing the unlock sequence, the
user must reconfigure the watchdog within 128 bus clocks; otherwise, the watchdog
forces a reset to the MCU.
By default, the watchdog is not functional in Debug mode, Wait mode, or Stop mode.
Setting WDOG_CS1[DBG], WDOG_CS1[WAIT] or WDOG_CS1[STOP] can activate
the watchdog in Debug, Wait or Stop modes.
Peripheral
bridge
Register
access
System integration
module (SIM)
oscillator
System
ICS
Peripheral
bridge
Register
access
Signal multiplexing
Module signals
ICS
System oscillator
Peripheral bus
controller 0
Register
access
Flash memory
controller
Transfers
Flash memory
The on-chip flash memory 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 and EEPROM memory sizes for details of supported ranges.
Access 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.
See Platform Control Register (MCM_PLACR) register description for details on the
reset configuration of the FMC.
MCM
Crossbar switch
Flash memory
Transfers Transfers
Flash memory
controller
Transfers
crossbar SRAM upper
Cortex-M0+ SRAM
core switch controller
SRAM lower
0x2000_0000 – SRAM_size/4
SRAM_L
0x1FFF_FFFF
0x2000_0000
SRAM size * (3/4)
SRAM_U
0x2000_0000 + SRAM_size(3/4) - 1
3.8 Analog
Peripheral
bridge
Register
access
Signal multiplexing
Transfers Module signals
Other peripherals SAR ADC
Peripheral
bridge 0
Register
access
Signal multiplexing
Module signals
Other peripherals ACMP
3.9 Timers
Peripheral bus
controller 0
Register
access
Signal multiplexing
Transfers Module signals
Other peripherals FlexTimer
1. The global time base (GTB) feature allows the synchronization of multiple FTM modules on a chip. It requires the GTB
function supported by all the related FTM modules. On this device, only one FTM module (FTM2) supports the GTB
function, so the GTB function is actually not usable.
Peripheral
bridge
Register
access
Periodic interrupt
timer
Peripheral
bridge
Register
access
Signal multiplexing
Module signals
Real-time clock
Register
access
Module signals
Signal
SPI
multiplexing
Register
access
Signal multiplexing
Module signals
I2 C
Peripheral
bridge
Register
access
Signal multiplexing
Module signals
UART
Register
access
Signal multiplexing
ARM Cortex -M0+
GPIO controller
Register
access
Signal multiplexing
ARM Cortex -M0+
KBI
Register
access
Signal multiplexing
ARM Cortex -M0+
IRQ
4.1 Introduction
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.
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 and EEPROM memory sizes for details.
2. The EEPROM supports only byte access.
3. This range varies depending on SRAM sizes. See SRAM sizes for details.
4. Includes BME operations to GPIO at slot 15 (based at 0x4000_F000).
• A 384 KB region, partitioned as 96 spaces, each 4 KB in size and reserved for off-
platform 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.
5.1 Introduction
This chapter presents the clock architecture for the device, the overview of the clocks and
includes a terminology section.
The Cortex M0+ resides within a synchronous core platform, where the processor and
bus masters, Flash and peripherals clocks can be configured independently.
The ICS module will be used for main system clock generation. The ICS module controls
which clock sources (internal references, external crystals or external clock signals)
generate the source of the system clocks.
• System Oscillator (OSC) module: The system oscillator providing reference clock to
internal clock source (ICS), the real-time clock counter clock module (RTC), and
other MCU sub-systems
• Low-Power Oscillator (LPO) module: The on-chip low-power oscillator providing 1
kHz reference clock to RTC and Watchdog (WDOG)
Figure 5-1 shows how clocks from the ICS and OSC modules are distributed to the
microcontroller’s other function units. Some modules in the microcontroller have
selectable clock input.
The following registers of the system oscillator, ICS, and SIM modules control the
multiplexers, dividers, and clock gates shown in the figure:
Table 5-1. Registers controlling multiplexers, dividers, and clock gate
OSC ICS SIM
Multiplexers OSC_CR ICS_C1 SIM_SOPT
Dividers — ICS_C2 SIM_BUSDIV
Clock gates OSC_CR ICS_C1 SIM_SCGC
ICS SIM
ICSIRCLK
CG CG RTC / WDOG
ICSFFCLK
1/2 CG FTM
32 kHz IRC
FLL
IREFS
Core clock
CG Plat clock
ICSFLLCLK ICSOUTCLK System clock
BDIV
RDIV
CLKS
BUSDIV CG
Bus clock
Flash clock
CLK_GEN
System oscillator
EXTAL OSCCLK OSCERCLK
CG RTC / WDOG / ADC
XTAL_CLK
OSC
XTAL logic OSCOS
PMC
LPOCLK
1 kHz LPO RTC / WDOG
CG — Clock gate
Note: See subsequent sections for details on where these clocks are used.
It's the free-running FCLK which clocks the crossbar switch and NVIC.
System clock ICSOUTCLK divided by BDIV.
ICSFFCLK can be selected as clock source for the FTM modules. The frequency of
the ICSFFCLK is determined by the setting of the ICS.
OSCCLK (OSC_OUT) System oscillator output of the internal oscillator or sourced directly from EXTAL. Used as
ICS external reference clock
OSCERCLK System oscillator output sourced from OSCCLK that can be selected as the clock source of
RTC, WDOG or ADC modules
LPOCLK PMC 1 kHz output.
The LPOCLK can be selected as the clock source to the RTC or WDOG modules.
1-kHz LPOCLK
LPO
EXTAL OSCCLK
OSC
XTAL
ICSIRCLK
UART0
ACMP0 SPI0
WDG RTC ADC UART1
ACMP1 SPI1
UART2
BUS_CLK
32 kHz
IRC FTM0 FTM1 FTM2 PIT CRC IIC
ICSFFCLK
1/2
SYS_CLK
FLASH_CLK
NOTE
Clock divide and gating are not shown in clock distribution
diagram.
6.1 Introduction
The following reset sources are supported in this MCU:
Table 6-1. Reset sources
Reset sources Description
POR reset • Power-on reset (POR)
System resets • External pin reset (PIN)
• Low-voltage detect (LVD)
• Watchdog (WDOG) timer
• ICS loss of clock (LOC) reset
• Stop mode acknowledge error (SACKERR)
• Software reset (SW)
• Lockup reset (LOCKUP)
• MDM DAP system reset
Each of the system reset sources has an associated bit in the System Reset Status and ID
Register (SIM_SRSID).
The MCU can exit and reset in functional mode where the CPU is executing code
(default) or the CPU is in a debug halted state. There are several boot options that can be
configured. See Boot for more details.
6.2 Reset
This section discusses basic reset mechanisms and sources. Some modules that cause
resets can be configured to cause interrupts instead. Consult the individual peripheral
chapters for more information.
The glitch width threshold can be adjusted easily by setting Port Filter Register
(PORT_IOFLT) between 1~4096 BUSCLKs (or 1~128 LPOCLKs). This configurable
glitch filter can replace an on-board external analog filter, and greatly improve the EMC
performance. Setting Port Filter Register (PORT_IOFLT) can configure the filter of the
whole port.
6.3 Boot
This section describes the boot sequence, including sources and options.
Some configuration information such as clock trim values stored in factory programmed
flash locations is auto-loaded.
1. VTOR: refer to Vector Table Offset Register in the ARMv6-M Architecture Reference Manual.
This device supports booting from internal flash with the reset vectors located at
addresses 0x0 (initial SP_main), 0x4 (initial PC), and RAM with relocating the exception
vector table to RAM.
7.1 Introduction
This chapter describes the various chip power modes and functionality of the individual
modules in these modes.
1. SRAM memory enable signal disables internal clock signal and masks the address and data inputs when held low, RAM
clock at SoC can be active in Wait mode.
2. Supports wake-up on edge in Stop mode
3. Supports slave mode receive and wake-up in Stop mode
4. Supports address match wake-up in Stop mode
5. Supports pin interrupt wake-up in Stop mode
8.1 Introduction
This device implements security based on the mode selected from the flash module. The
following sections provide an overview of flash security and details of the effects of
security on non-flash modules.
9.1 Introduction
This device's debug is based on the ARM CoreSight architecture and is configured to
provide the maximum flexibility as allowed by the restrictions of the pinout and other
available resources.
It provides register and memory accessibility from the external debugger interface, basic
run/halt control plus 2 breakpoints and 2 watchpoints.
This device supports only one debug interface, Serial Wire Debug (SWD).
1. The pad library of this device does not support on-chip pull down; it supports only pullup controlled by
PORT_PUEL[PTCPE4] bit, external pulldown resistor is required to fully support SWD protocol.
DPACC APACC
Data[31:0] A[3:2] RnW Data[31:0] A[3:2] RnW
0x0C
0x00
0x04
0x08
Debug Port ID Register (IDCODE)
Debug Port
SW-DP
Control/Status (CTRL/STAT)
DP Registers
Generic
Debug Port
(DP)
Internal Bus
Decode
SELECT[31:24] (APSEL) selects the AP
SELECT[7:4] (APBANKSEL) selects the bank
A[3:2] from the APACC selects the register
within the bank
AHB-AP
0x3F
0x00
0x01
1 Flash Ready Indicates that flash memory has been initialized and debugger can be
configured even if system is continuing to be held in reset via the
debugger.
0 Flash is under initialization.
Table continues on the next page...
1 Debug Disable N Set to disable debug. Clear to allow debug operation. When set, it
overrides the C_DEBUGEN field within the DHCSR2 and forces to
disable Debug logic.
2 Debug Request N Set to force the core to halt.
If the core is in Stop or Wait mode, this field can be used to wake the
core and transition to a halted state.
3 System Reset Request Y Set to force a system reset. The system remains held in reset until
this field is cleared. When this bit is set, RESET pin did not reflect the
status of system reset and did not keep low.
4 Core Hold N Configuration field to control core operation at the end of system
reset sequencing.
0 Normal operation—release the core from reset along with the rest
of the system at the end of system reset sequencing.
Table continues on the next page...
10.1 Introduction
To optimize functionality in small packages, pins have several functions available via
signal multiplexing. This chapter illustrates which of this device's signals are multiplexed
on which external pin.
The Pin Selection Register (SIM_PINSEL) controls which signal is present on the
external pin. Refer to that register to find the detailed control operation of a specific
multiplexed pin.
10.2 Pinout
Note
When an alternative function is first enabled, it is possible to
get a spurious edge to the module. User software must clear any
associated flags before interrupts are enabled. Table 10-1
illustrates the priority if multiple modules are enabled. The
highest priority module will have control over the pin. Selecting
a higher priority pin function with a lower priority function
PTE11
PTE01
PTG1
PTG2
PTG3
PTG0
PTC5
PTA0
PTC6
PTA5
PTC4
PTE3
PTC7
PTA4
PTE2
PTA1
55
58
49
62
63
60
59
56
54
52
51
50
64
61
57
53
PTD1 1 1 48 PTA22
PTD0 1 2 47 PTA32
PTH7 3 46 PTD2
PTH6 4 45 PTD3
PTE7 5 44 PTD4
PTH2 6 43 PTF0
VDD 7 42 PTF1
VDDA/VREFH 8 41 VDD
VREFL 9 40 VSS
VSSA/VSS 10 39 PTE4
PTB7 11 38 PTA6
PTB6 12 37 PTA7
VSS 13 36 PTF2
PTH11 14 35 PTF3
PTH01 15 34 PTB0
PTE6 16 33 PTB1
19
17
20
24
26
31
18
21
22
23
25
27
28
29
30
32
PTC1
PTB5 1
PTB4 1
PTC2
PTB2
PTC0
PTC3
PTD7
PTD6
PTF7
PTB3
PTD5
PTF6
PTF5
PTF4
PTE5
PTE01
PTE11
PTC5
PTA5
PTA0
PTC4
PTC6
PTA4
PTC7
PTE2
PTA1
44
43
42
41
40
39
38
37
36
34
35
PTD1 1 1 33 PTA22
PTD0 1 2 32 PTA32
PTE7 3 31 PTD2
PTH2 4 30 PTD3
VDD 5 29 PTD4
VDDA/VREFH 6 28 VDD
VREFL 7 27 VSS
VSSA/VSS 8 26 PTA6
PTB7 9 25 PTA7
PTB6 10 24 PTB0
VSS 11 23 PTB1
19
17
20
18
21
22
16
13
12
14
15
PTC1
PTB5 1
PTB4 1
PTB2
PTC2
PTC0
PTC3
PTD7
PTB3
PTD6
PTD5
Pins in bold are not available on less pi n-count packages.
1. High source/sink current pins
2. True open drain pins
PTC6
PTA4
PTA0
PTC7
PTA5
PTA1
32
29
28
31
27
26
25
30
PTD1 1 1 24 PTA22
PTD0 1 2 23 PTA32
VDD 3 22 PTD2
VDDA/VREFH 4 21 PTD3
VREFL 5 20 PTA6
VSSA/VSS 6 19 PTA7
PTB7 7 18 PTB0
PTB6 8 17 PTB1
11
9
10
16
13
12
14
15
PTB5 1
PTB4 1
PTC3
PTC2
PTC1
PTC0
PTB2
PTB3
1. The pad library of this device does not support on-chip pull down; it supports only pullup controlled by
PORT_PUEL[PTCPE4] bit, external pulldown resistor is required to fully support SWD protocol.
10.3.5 Analog
Table 10-5. ADC0 signal descriptions
Chip signal name Module signal Description I/O
name
ADC0_SEn AD15-AD0 Analog channel inputs I
VDDA/VREFH VDDA/VREFH Analog power supply / voltage reference high I
VREFL VREFL Voltage reference low I
1. The available GPIO pins depends on the specific package. See the signal multiplexing section for which exact GPIO
signals are available.
11.1 Introduction
This device has eight sets of I/O ports, which include up to 57 general-purpose I/O pins.
Not all pins are available on all devices.
Many of the I/O pins are shared with on-chip peripheral functions. The peripheral
modules have priority over the I/O, so when a peripheral is enabled, the associated I/O
functions are disabled.
After reset, the shared peripheral functions are disabled so that the pins are controlled by
the parallel I/O except PTA4, PTA5, PTB4 and PTC4 that are default to SWD_DIO,
SWD_CLK, NMI and RESET function. All of the parallel I/O are configured as high-
impedance (Hi-Z). The pin control functions for each pin are configured as follows:
• input disabled (GPIOx_PIDR[PID] = 1),
• output disabled ( GPIOx_PDDR[PDD] = 0), and
• internal pullups disabled (PORT_PUE(L/H)[PTxPEn] = 0).
Additionally, the parallel I/O that support high drive capability are disabled (HDRVE =
0x00) after reset.
The following three figures show the structures of each I/O pin.
PORT_PUE(L/H)[PTxPEn]
GPIOx_PDDR[PDD]
GPIOx_PDOR[PDO]
GPIOx_PIDR[PID]
1 0 (except RESET/NMI)
CPU read GPIOx_PDIR[PDI]
0 Glitch filter
PORT_IOFLT
PORT_PUE(L/H)[PTxPEn]
GPIOx_PDDR[PDD]
GPIOx_PDOR[PDO]
GPIOx_PIDR[PID]
1 0 (except RESET/NMI)
CPU read GPIOx_PDIR[PDI]
0 Glitch filter
PORT_IOFLT
PORT_PUE(L/H)[PTxPEn]
GPIOx_PDDR[PDD]
GPIOx_PDOR[PDO]
GPIOx_PIDR[PID]
HDRVE
1 0 (except RESET/NMI)
CPU read GPIOx_PDIR[PDI]
0 Glitch filter
PORT_IOFLT
When a shared analog function is enabled for a pin, all digital pin functions are disabled.
A read of the port data register returns a value of 0 for any bits that have shared analog
functions enabled. In general, whenever a pin is shared with both an alternate digital
function and an analog function, the analog function has priority such that if both of the
digital and analog functions are enabled, the analog function controls the pin.
A write of valid data to a port data register must occur before setting the output enable bit
of an associated port pin. This ensures that the pin will not be driven with an incorrect
data value.
Glitches that are shorter than the selected clock period will be filtered out; Glitches that
are more than twice the selected clock period will not be filtered out. It will pass to
internal circuitry.
Pass to
internal rate
100%
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R
W
FLTDIV3 FLTDIV2 FLTDIV1 FLTNMI FLTKBI1 FLTKBI0 FLTRST
Reset 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R
W
FLTH FLTG FLTF FLTE FLTD FLTC FLTB FLTA
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
000 LPOCLK
001 LPOCLK/2
010 LPOCLK/4
011 LPOCLK/8
100 LPOCLK/16
101 LPOCLK/32
110 LPOCLK/64
111 LPOCLK/128
000 BUSCLK/32
001 BUSCLK/64
010 BUSCLK/128
011 BUSCLK/256
100 BUSCLK/512
101 BUSCLK/1024
110 BUSCLK/2048
111 BUSCLK/4096
25–24 Filter Division Set 1
FLTDIV1
Port Filter Division Set 1
00 BUSCLK/2
01 BUSCLK/4
10 BUSCLK/8
11 BUSCLK/16
23–22 Filter Selection for Input from NMI
FLTNMI
00 No filter.
01 Selects FLTDIV1, and will switch to FLTDIV3 in Stop mode automatically.
10 Selects FLTDIV2, and will switch to FLTDIV3 in Stop mode automatically.
11 FLTDIV3
21–20 Filter Selection for Input from KBI1
FLTKBI1
00 No filter
01 Selects FLTDIV1, and will switch to FLTDIV3 in Stop mode automatically.
10 Selects FLTDIV2, and will switch to FLTDIV3 in Stop mode automatically.
11 FLTDIV3
19–18 Filter selection for Input from KBI0
FLTKBI0
00 No filter.
01 Selects FLTDIV1, and will switch to FLTDIV3 in Stop mode automatically.
10 Selects FLTDIV2, and will switch to FLTDIV3 in Stop mode automatically.
11 FLTDIV3
17–16 Filter Selection for Input from RESET/IRQ
FLTRST
00 No filter.
01 Selects FLTDIV1, and will switch to FLTDIV3 in Stop mode automatically.
10 Selects FLTDIV2, and will switch to FLTDIV3 in Stop mode automatically.
11 FLTDIV3
15–14 Filter Selection for Input from PTH
FLTH
00 BUSCLK
01 FLTDIV1
Table continues on the next page...
00 BUSCLK
01 FLTDIV1
10 FLTDIV2
11 FLTDIV3
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R
PTDPE7
PTDPE6
PTDPE5
PTDPE4
PTDPE3
PTDPE2
PTDPE1
PTDPE0
PTCPE7
PTCPE6
PTCPE5
PTCPE4
PTCPE3
PTCPE2
PTCPE1
PTCPE0
W
Reset 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R
PTBPE7
PTBPE6
PTBPE5
PTBPE4
PTBPE3
PTBPE2
PTBPE1
PTBPE0
PTAPE7
PTAPE6
PTAPE5
PTAPE4
PTAPE3
PTAPE2
PTAPE1
PTAPE0
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
NOTE: When configuring to use this pin as output high for IIC, the internal pullup device remains active
when PTAPE3 is set. It is automatically disabled to save power when output low.
NOTE: When configuring to use this pin as output high for IIC, the internal pullup device remains active
when PTAPE2 is set. It is automatically disabled to save power when output low.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 0
PTGPE3
PTGPE2
PTGPE1
PTGPE0
PTHPE7
PTHPE6
PTHPE2
PTHPE1
PTHPE0
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PTEPE7
PTEPE6
PTEPE5
PTEPE4
PTEPE3
PTEPE2
PTEPE1
PTEPE0
PTFPE7
PTFPE6
PTFPE5
PTFPE4
PTFPE3
PTFPE2
PTFPE1
PTFPE0
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 PTH1 PTH0 PTE1 PTE0 PTD1 PTD0 PTB5 PTB4
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
12.1 Introduction
The system integration module (SIM) provides system control and chip configuration
registers.
12.1.1 Features
The features of the SIM module are listed below.
• Reset status and device ID infomation
• System interconnection configuration and special pin enable
• Pin re-map control
• System clock gating control and bus clock divide
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reset 0 0 0 0 0 0 1 0 0 0 0 0 * * * *
LVD 0 0 0 0 0 0 1 0 0 0 0 0 * * * *
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SACKERR
LOCKUP
MDMAP
WDOG
POR
LOC
LVD
R 0 0 SW 0 PIN 0 0
Reset 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0
LVD 0 0 0 0 0 0 0 0 u* 0 0 0 0 0 1 0
* Notes:
• PINID field: Decided by device pin number.
• u = Unaffected by reset.
0 Reset is not caused by peripheral failure to acknowledge attempt to enter Stop mode.
1 Reset is caused by peripheral failure to acknowledge attempt to enter Stop mode.
12 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
11 MDM-AP System Reset Request
MDMAP
Indicates a reset has been caused by the host debugger system setting of the System Reset Request field
in the MDM-AP Control Register.
0 Reset is not caused by host debugger system setting of the System Reset Request bit.
1 Reset is caused by host debugger system setting of the System Reset Request bit.
10 Software
SW
Indicates a reset has been caused by software setting of SYSRESETREQ bit in Application Interrupt and
Reset Control Register in the ARM core.
NOTE: This bit POR to 1, LVR to uncertain value and reset to 0 at any other conditions.
NOTE: This field is reset to 1 on POR and LVR, and reset to 0 on other reset.
NOTE
RSTPE and NMIE are write-only on each reset.
Address: 4004_8000h base + 4h offset = 4004_8004h
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
DLYACT
R 0
CLKOE
DELAY BUSREF
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
POR/ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
LVD
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 0 0
TXDME
RXDCE
RXDFE
RSTPE
SWDE
RTCC
Reset 0 0 0 0 0 0 0 0 0 0 0 0 1 u* u* 0
POR/ 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0
LVD
* Notes:
• u = Unaffected by reset.
000 Bus
001 Bus divided by 2
010 Bus divided by 4
011 Bus divided by 8
100 Bus divided by 16
101 Bus divided by 32
110 Bus divided by 64
111 Bus divided by 128
15 UART0_TX Modulation Select
TXDME
Enables the UART0_TX output modulated by FTM0 channel 0.
0 No synchronization triggered.
1 Generates a PWM synchronization trigger to the FTM2 modules.
13 UART0_RX Filter Select
RXDFE
Enables the UART0_RX input to be filtered by ACMP. When this function is enabled, any signal tagged
with ACMP inputs can be regarded UART0.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0
UART0PS
R
FTM2PS3
FTM2PS2
FTM2PS1
FTM2PS0
FTM1PS1
FTM1PS0
FTM0PS1
FTM0PS0
SPI0PS
I2C0PS
RTCPS
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 SPI0_SCK, SPI0_MOSI, SPI0_MISO, and SPI0_PCS0 are mapped on PTB2, PTB3, PTB4, and
PTB5.
1 SPI0_SCK, SPI0_MOSI, SPI0_MISO, and SPI0_PCS0 are mapped on PTE0, PTE1, PTE2, and
PTE3.
5 I2C0 Port Pin Select
I2C0PS
Selects the I2C0 port pins.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 0 0 0
ACMP1
ACMP0
UART2
UART1
UART0
ADC IRQ KBI1 KBI0 SPI1 SPI0 I2C
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 0 0 0
FLASH
FTM2
FTM1
FTM0
SWD CRC PIT RTC
W
Reset 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R ID[31:0]
W
Reset x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
The read-only SIM_UUIDH register contains a series of number to identify the unique
device in the family.
Address: 4004_8000h base + 14h offset = 4004_8014h
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R ID[63:32]
W
Reset x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
POR 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0
BUSDIV
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 u*
POR 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
* Notes:
• u = Unaffected by reset.
13.1 Introduction
This chapter describes the functionality of the individual modules in the chip’s low-
power modes and the operation of Power Management Controller module.
LVD1
LVD
+
LVW0
LVW1
LVW2
LVW3 LVW
+
vBG
R7 Bandgap
vss
Bit 7 6 5 4 3 2 1 0
Read LVWF 0
LVWIE LVDRE LVDSE LVDE BGBE
Write LVWACK 0
Reset 0 0 0 1 1 1 0 0
NOTE: LVWF will be set in the case when VSupply transitions below the trip point or after reset and VSupply
is already below VLVW. LVWF may be 1 after power-on-reset, therefore, to use LVW interrupt
function, before enabling LVWIE, LVWF must be cleared by writing LVWACK first.
NOTE: This field can be written only one time after reset. Additional writes are ignored.
If LVDRE = 0, use LVW to monitor status because no flag was assert.
NOTE: This field can be written only one time after reset. Additional writes are ignored.
Bit 7 6 5 4 3 2 1 0
Read 0 0
LVDV LVWV
Write
Reset 0 0 0 0 0 0 0 0
14.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances, see the chip configuration information.
The Miscellaneous Control Module (MCM) provides a myriad of miscellaneous control
functions.
14.1.1 Features
The MCM includes the following features:
• Program-visible information on the platform configuration
• Flash controller speculation buffer and cache configurations
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Read 0 ASC
Write
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Read 0 AMC
Write
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
The cache in flash controller is enabled and caching both instruction and data type fetches
after reset. It is possible to have these states for the cache:
DFCC DFCIC DFCDA Description
0 0 0 Cache is on for both
instruction and data.
0 0 1 Cache is on for instruction
and off for data.
0 1 0 Cache is off for instruction
and on for data.
0 1 1 Cache is off for both
instruction and data.
1 X X Cache is off.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0
ESFC
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 0
DFCDA
DFCIC
DFCC
DFCS
EFDS
CFCC
Reset 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
15.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances, see the chip configuration information.
The peripheral bridge converts the crossbar switch interface to an interface that can
access most of the slave peripherals on this chip.
The peripheral bridge occupies 64 MB of the address space, which is divided into
peripheral slots of 4 KB . (It might be possible that all the peripheral slots are not used.
See Memory map for details on slot assignments.) The bridge includes separate clock
enable inputs for each of the slots to accommodate slower peripherals.
15.1.1 Features
Key features of the peripheral bridge are:
• Supports peripheral slots with 8-, 16-, and 32-bit datapath width
• Transfer attributes
• Byte enables
• Write data
The peripheral bridge selects and captures read data from the peripheral interface and
returns it to the crossbar switch.
The register maps of the peripherals are located on 4-KB boundaries. Each peripheral is
allocated one or more 4-KB block(s) of the memory map.
The AIPS-Lite module uses the data width of accessed peripheral to perform proper data
byte lane routing; bus decomposition (bus sizing) is performed when the access size is
larger than the peripheral's data width.
16.1 Introduction
The Watchdog Timer (WDOG) module is an independent timer that is available for
system use. It provides a safety feature to ensure that software is executing as planned
and that the CPU is not stuck in an infinite loop or executing unintended code. If the
WDOG module is not serviced (refreshed) within a certain period, it resets the MCU.
16.1.1 Features
Features of the WDOG module include:
• Configurable clock source inputs independent from the bus clock
• Internal 32 kHz RC oscillator
• Internal 1 kHz RC oscillator
• External clock source
• Programmable timeout period
• Programmable 16-bit timeout value
• Optional fixed 256 clock prescaler when longer timeout periods are needed
• Robust write sequence for counter refresh
• Refresh sequence of writing 0x02A6 and then 0x80B4 within 16 bus clocks
• Window mode option for the refresh mechanism
• Programmable 16-bit window value
Backup Reset
BUS CLK
Counter
1K CLK Compare Logic Overflow
MUX
32K CLK
MUX
Bit 7 6 5 4 3 2 1 0
Read EN INT UPDATE TST DBG WAIT STOP
Write
Reset 1 0 0 0 0 0 0 0
0 Watchdog disabled.
1 Watchdog enabled.
0 Updates not allowed. After the initial configuration, the watchdog cannot be later modified without
forcing a reset.
1 Updates allowed. Software can modify the watchdog configuration registers within 128 bus clocks
after performing the unlock write sequence.
4–3 Watchdog Test
TST
Enables the fast test mode. The test mode allows software to exercise all bits of the counter to
demonstrate that the watchdog is functioning properly. See the Fast testing of the watchdog section.
This write-once field is cleared (0:0) on POR only. Any other reset does not affect the value of this field.
Bit 7 6 5 4 3 2 1 0
Read FLG 0 0
WIN PRES CLK
Write w1c
Reset 0 0 0 0 0 0 0 1
0 No interrupt occurred.
1 An interrupt occurred.
5 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
4 Watchdog Prescalar
PRES
This write-once bit enables a fixed 256 pre-scaling of watchdog counter reference clock. (The block
diagram shows this clock divider option.)
This write-once field indicates the clock source that feeds the watchdog counter. See the Clock source
section.
00 Bus clock.
01 1 kHz internal low-power oscillator (LPOCLK).
10 32 kHz internal oscillator (ICSIRCLK).
11 External clock source.
Bit 7 6 5 4 3 2 1 0
Read CNTHIGH
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read CNTLOW
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read TOVALHIGH
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read TOVALLOW
Write
Reset 0 0 0 0 0 1 0 0
Bit 7 6 5 4 3 2 1 0
Read WINHIGH
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read WINLOW
Write
Reset 0 0 0 0 0 0 0 0
WDOG counter
WDOG_TOVALH and
WDOG_TOVALL
WDOG_WINH and
WDOG_WINL Refresh opportunity
in window mode
0 Time
Refresh opportunity (not in window mode)
Note
Before starting the refresh sequence, disable global interrupts.
Otherwise, an interrupt could effectively invalidate the refresh
sequence if writing the four bytes takes more than 16 bus
clocks. Re-enable interrupts when the sequence is finished.
/* Refresh watchdog */
...
}
once after reset. Otherwise, the WDOG uses the reset values by default. If window mode
is not used (CS2[WIN] is 0), writing to WDOG_WINH:L is not required to make the new
configuration take effect.
NOTE
When the programmer switches clock sources during
reconfiguration, the watchdog hardware holds the counter at
zero for 2.5 periods of the previous clock source and 2.5
periods of the new clock source after the configuration time
period (128 bus clocks) ends. This delay ensures a smooth
KE02 Sub-Family Reference Manual, Rev. 3, July 2013
Freescale Semiconductor, Inc. 191
Functional description
5. Confirm the WDOG flag in the system reset register is set, indicating that the
watchdog caused the reset. (The POR flag remains clear.)
6. Confirm that WDOG_CS1[TST] shows a test (10b or 11b) was performed.
If confirmed, the count and compare functions work for the selected byte. Repeat the
procedure, selecting the other byte in step 2.
NOTE
WDOG_CS1[TST] is cleared by a POR only and not affected
by other resets.
17.1 Introduction
The Bit Manipulation Engine (BME) provides hardware support for atomic read-modify-
write memory operations to the peripheral address space in Cortex-M0+ based
microcontrollers. This architectural capability is also known as "decorated storage" as it
defines a mechanism for providing additional semantics for load and store operations to
memory-mapped peripherals beyond just the reading and writing of data values to the
addressed memory locations. In the BME definition, the "decoration", that is, the
additional semantic information, is encoded into the peripheral address used to reference
the memory.
By combining the basic load and store instructions of the Cortex-M instruction set
architecture (v6M, v7M) 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. The resulting architectural capability defined
by this core platform function is targeted at the manipulation of n-bit fields in peripheral
registers and is consistent with I/O hardware addressing in the Embedded C standard. For
most BME commands, a single core read or write bus cycle is converted into an atomic
read-modify-write, that is, an indivisible "read followed by a write" bus sequence.
BME decorated references are only available on system bus transactions generated by the
processor core and targeted at the standard 512 KB peripheral address space based at
0x4000_00001. The decoration semantic is embedded into address bits[28:19], creating a
448 MB space at addresses 0x4400_0000 - 0x5FFF_FFFF for AIPS; these bits are
stripped out of the actual address sent to the peripheral bus controller and used by the
BME to define and control its operation.
1. To be perfectly accurate, the peripheral address space occupies a 516 KB region: 512 KB based at 0x4000_0000 plus a 4
KB space based at 0x400F_F000 for GPIO accesses. This organization provides compatibility with the Kinetis K Family.
Attempted accesses to the memory space located between 0x4008_0000 - 0x400E_FFFF are error terminated due to an
illegal address.
17.1.1 Overview
The following figure is a generic block diagram of the processor core and platform for
this class of ultra low-end microcontrollers.
Cortex-M0+ Core
Dbg Fetch CM0+ Core Platform
AGU Dec Rn
NVIC
SHFT
LD/ST MUL
ALU
IO Port
32
RAM
PRAM Array
GPIO
m0 s1
AXBS Slave
-Lite 32 Peripherals
s2 BME PBRIDGE
s0
32
NVM
FMC Array
As shown in the block diagram, the BME module interfaces to a switch AHB slave port
as its primary input and sources an AHB bus output to the Peripheral Bridge (PBRIDGE)
controller. The BME hardware microarchitecture is a 2-stage pipeline design matching
the protocol of the AMBA-AHB system bus interfaces. The PBRIDGE module converts
the AHB system bus protocol into the IPS/APB protocol used by the attached slave
peripherals.
17.1.2 Features
The key features of the BME include:
• Lightweight implementation of decorated storage for peripheral address space
• Additional access semantics encoded into the reference address
• Resides between a switch slave port and a peripheral bridge bus controller
• Two-stage pipeline design matching the AHB system bus protocol
• Combinationally passes non-decorated accesses to peripheral bridge bus controller
• Conversion of decorated loads and stores from processor core into atomic read-
modify-writes
• Decorated loads support unsigned bit field extracts, load-and-{set,clear} 1-bit
operations
• Decorated stores support bit field inserts, logical AND, OR, and XOR operations
• Support for byte, halfword and word-sized decorated operations
• Supports minimum signal toggling on AHB output bus to reduce power dissipation
mx_hattr next
mx_hwrite next
mx_hwdata wdata
mx_hrdata
mx_hready
BME AHB Output Bus
sx_haddr 400v_wxyz 400v_wxyz next
sx_hattr next
sx_hwrite next
sx_hrdata rdata
sx_hready
BME States + Datapath
control_state_dp1
control_state_dp2
reg_addr_data_dp 5..v_wxyz wdata bfi rdata
All the decorated store operations follow the same execution template shown in Figure
17-2, a two-cycle read-modify-write operation:
1. Cycle x, 1st AHB address phase: Write from input bus (mx_h<signal>) is translated
into a read operation on the output bus (sx_h<signal>) using the actual memory
address (with the decoration removed) and then captured in a register
(reg_addr_data_dp).
2. Cycle x+1, 2nd AHB address phase: Write access with the registered (but actual)
memory address is output (sx_h<signal>)
3. Cycle x+1, 1st AHB data phase: Memory read data (sx_hrdata) is modified using the
input bus write data (mx_hwdata) and the function defined by the decoration and
captured in a data register. (reg_addr_data_dp); the input bus cycle is stalled
(mx_hready = 0).
4. Cycle x+2, 2nd AHB data phase: Registered write data is sourced onto the output
write data bus (sx_hwdata).
NOTE
Any wait states inserted by the peripheral slave device
(sx_hready = 0) are simply passed through the BME back to the
master input bus, stalling the AHB transaction cycle for cycle.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ioandb 0 1 0 0 0 1 - - - - - - mem_addr
ioandh 0 1 0 0 0 1 - - - - - - mem_addr 0
ioandw 0 1 0 0 0 1 - - - - - - mem_addr 0 0
See Figure 17-3 where addr[28:26] = 001 specifies the AND operation, and
mem_addr[19:0] specifies the address offset into the peripheral space based at
0x4000_0000. The "-" indicates an address bit "don't care".
The decorated AND write operation is defined in the following pseudo-code as:
ioand<sz>(accessAddress, wdata) // decorated store AND
tmp = mem[accessAddress & 0xE00FFFFF, size] // memory read
tmp = tmp & wdata // modify
mem[accessAddress & 0xE00FFFFF, size] = tmp // memory write
where the operand size <sz> is defined as b(yte, 8-bit), h(alfword, 16-bit) and w(ord, 32-
bit). This notation is used throughout the document.
In the cycle definition tables, the notations AHB_ap and AHB_dp refer to the address and
data phases of the BME AHB transaction. The cycle-by-cycle BME operations are
detailed in the following table.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ioorb 0 1 0 0 1 0 - - - - - - mem_addr
ioorh 0 1 0 0 1 0 - - - - - - mem_addr 0
ioorw 0 1 0 0 1 0 - - - - - - mem_addr 0 0
See Figure 17-4, where addr[28:26] = 010 specifies the OR operation, and
mem_addr[19:0] specifies the address offset into the peripheral space based at
0x4000_0000. The "-" indicates an address bit "don't care".
The decorated OR write operation is defined in the following pseudo-code as:
ioor<sz>(accessAddress, wdata) // decorated store OR
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ioxorb 0 1 0 0 1 1 - - - - - - mem_addr
ioxorh 0 1 0 0 1 1 - - - - - - mem_addr 0
ioxorw 0 1 0 0 1 1 - - - - - - mem_addr 0 0
See Figure 17-5, where addr[28:26] = 011 specifies the XOR operation, and
mem_addr[19:0] specifies the address offset into the peripheral space based at
0x4000_0000. The "-" indicates an address bit "don't care".
The decorated XOR write operation is defined in the following pseudo-code as:
ioxor<sz>(accessAddress, wdata) // decorated store XOR
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
iobfib 0 1 0 1 - - b b b - w w w mem_addr
iobfih 0 1 0 1 - b b b b w w w w mem_addr 0
iobfiw 0 1 0 1 b b b b b w w w w mem_addr 0 0
where addr[28] = 1 signals a BFI operation, addr[27:23] is "b", the LSB identifier,
addr[22:19] is "w", the bit field width minus 1 identifier, and addr[18:0] specifies the
address offset into the peripheral space based at 0x4000_0000. The "-" indicates an
address bit "don't care". Note, unlike the other decorated store operations, BFI uses
addr[19] as the least significant bit in the "w" specifier and not as an address bit.
The decorated BFI write operation is defined in the following pseudo-code as:
The write data operand (wdata) associated with the store instruction contains the bit field
to be inserted. It must be properly aligned within a right-aligned container, that is, within
the lower 8 bits for a byte operation, the lower 16 bits for a halfword, or the entire 32 bits
for a word operation.
To illustrate, consider the following example of the insertion of the 3-bit field "xyz" into
an 8-bit memory container, initially set to "abcd_efgh". For all cases, w is 2, signaling a
bit field width of 3.
if b = 0 and the decorated store (strb) Rt register[7:0] = ----_-xyz,
then destination is "abcd_exyz"
if b = 1 and the decorated store (strb) Rt register[7:0] = ----_xyz-,
then destination is "abcd_xyzh"
if b = 2 and the decorated store (strb) Rt register[7:0] = ---x_yz--,
then destination is "abcx_yzgh"
if b = 3 and the decorated store (strb) Rt register[7:0] = --xy_z---,
then destination is "abxy_zfgh"
if b = 4 and the decorated store (strb) Rt register[7:0] = -xyz_----,
then destination is "axyz_efgh"
if b = 5 and the decorated store (strb) Rt register[7:0] = xyz-_----,
then destination is "xyzd_efgh"
if b = 6 and the decorated store (strb) Rt register[7:0] = yz--_----,
then destination is "yzcd_efgh"
if b = 7 and the decorated store (strb) Rt register[7:0] = z---_----,
then destination is "zbcd_efgh"
Note from the example, when the starting bit position plus the field width exceeds the
container size, only part of the source bit field is inserted into the destination memory
location. Stated differently, if (b + w+1) > container_width, only the low-order
"container_width - b" bits are actually inserted.
The cycle-by-cycle BME operations are detailed in the following table.
Table 17-4. Cycle definitions of decorated store: bit field insert
Pipeline stage Cycle
x x+1 x+2
BME AHB_ap Forward addr to memory; Recirculate captured addr + <next>
Decode decoration; Convert attr to memory as slave_wt
master_wt to slave_rd;
Capture address, attributes
BME AHB_dp <previous> Perform memory read; Form Perform write sending
bit mask; Form bitwise registered data to memory
((mask) ? wdata : rdata)) and
capture destination data in
register
mx_hattr next
mx_hwrite next
mx_hwdata
mx_hrdata orig_1bit
mx_hready
BME AHB Output Bus
sx_haddr 400v_wxyz 400v_wxyz next
sx_hattr next
sx_hwrite next
sx_hrdata rdata
sx_hready
BME States + Datapath
control_state_dp1
control_state_dp2
reg_addr_data_dp 4c.v_wxyz rdata + 1bit
Figure 17-7. Decorated load: load-and-set 1-bit field insert timing diagram
Decorated load-and-{set, clear} 1-bit operations follow the execution template shown in
the above figure: a 2-cycle read-modify-write operation:
1. Cycle x, first AHB address phase: Read from input bus is translated into a read
operation on the output bus with the actual memory address (with the decoration
removed) and then captured in a register
2. Cycle x+1, second AHB address phase: Write access with the registered (but actual)
memory address is output
3. Cycle x+1, first AHB data phase: The "original" 1-bit memory read data is captured
in a register, while the 1-bit field is set or clear based on the function defined by the
decoration with the modified data captured in a register; the input bus cycle is stalled
4. Cycle x+2, second AHB data phase: The selected original 1-bit is right-justified,
zero-filled and then driven onto the input read data bus, while the registered write
data is sourced onto the output write data bus
NOTE
Any wait states inserted by the peripheral slave device
(sx_hready = 0) are simply passed through the BME back to the
master input bus, stalling the AHB transaction cycle for cycle.
A generic timing diagram of a decorated load showing an unsigned bit field operation is
shown in the following figure.
CYCLE RULER 1 2 3 4
hclk
BME AHB Input Bus
mx_haddr 5..v_wxyz next
mx_hattr next
mx_hwrite next
mx_hwdata
mx_hrdata ubfx
mx_hready
BME AHB Output Bus
sx_haddr 400v_wxyz next
sx_hattr next
sx_hwrite next
sx_hwdata
sx_hrdata rdata
sx_hready
BME States + Datapath
control_state_dp1
control_state_dp2
reg_addr_data_dp 5..v_wxyz rdata
Figure 17-8. Decorated load: unsigned bit field insert timing diagram
The decorated unsigned bit field extract follows the same execution template shown in
the above figure, a 2-cycle read operation:
• Cycle x, 1st AHB address phase: Read from input bus is translated into a read
operation on the output bus with the actual memory address (with the decoration
removed) and then captured in a register
• Cycle x+1, 2nd AHB address phase: Idle cycle
• Cycle x+1, 1st AHB data phase: A bit mask is generated based on the starting bit
position and the field width; the mask is AND'ed with the memory read data to
isolate the bit field; the resulting data is captured in a data register; the input bus
cycle is stalled
• Cycle x+2, 2nd AHB data phase: Registered data is logically right-aligned for proper
alignment and driven onto the input read data bus
NOTE
Any wait states inserted by the peripheral slave device
(sx_hready = 0) are simply passed through the BME back to the
master input bus, stalling the AHB transaction cycle for cycle.
See Figure 17-9 where addr[28:26] = 010 specifies the load-and-clear 1 bit operation,
addr[25:21] is "b", the bit identifier, and mem_addr[19:0] specifies the address offset into
the peripheral space based at 0x4000_0000. The "-" indicates an address bit "don't care".
The decorated load-and-clear 1-bit read operation is defined in the following pseudo-code
as:
rdata = iolac1<sz>(accessAddress) // decorated load-and-clear 1
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
iolas1b 0 1 0 0 1 1 - - b b b - mem_addr
iolas1h 0 1 0 0 1 1 - b b b b - mem_addr 0
iolas1w 0 1 0 0 1 1 b b b b b - mem_addr 0 0
where addr[28:26] = 011 specifies the load-and-set 1 bit operation, addr[25:21] is "b", the
bit identifier, and mem_addr[19:0] specifies the address offset into the peripheral space
based at 0x4000_0000. The "-" indicates an address bit "don't care".
The decorated Load-and-Set 1 Bit read operation is defined in the following pseudo-code
as:
rdata = iolas1<sz>(accessAddress) // decorated load-and-set 1
See Figure 17-11, where addr[28] = 1 specifies the unsigned bit field extract operation,
addr[27:23] is "b", the LSB identifier, addr[22:19] is "w", the bit field width minus 1
identifier, and mem_addr[18:0] specifies the address offset into the peripheral space
based at 0x4000_0000. The "-" indicates an address bit "don't care". Note, unlike the
other decorated load operations, UBFX uses addr[19] as the least significant bit in the
"w" specifier and not as an address bit.
The decorated unsigned bit field extract read operation is defined in the following
pseudo-code as:
rdata = ioubfx<sz>(accessAddress) // unsigned bit field extract
Like the BFI operation, when the starting bit position plus the field width exceeds the
container size, only part of the source bit field is extracted from the destination memory
location. Stated differently, if (b + w+1) > container_width, only the low-order
"container_width - b" bits are actually extracted. The cycle-by-cycle BME operations are
detailed in the following table.
Table 17-7. Cycle definitions of decorated load: unsigned bit field extract
Pipeline Stage Cycle
x x+1 x+2
BME AHB_ap Forward addr to memory; Idle AHB address phase <next>
Decode decoration; Capture
address, attributes
BME AHB_dp <previous> Perform memory read; Form Logically right shift registered
bit mask; Form (rdata & mask) data; Return justified rdata to
and capture destination data master
in register
#define IOANDH(ADDR,WDATA) \
__asm("ldr r3, =(1<<26);" \
"orr r3, %[addr];" \
"mov r2, %[wdata];" \
"strh r2, [r3];" \
:: [addr] "r" (ADDR), [wdata] "r" (WDATA) : "r2", "r3");
#define IOANDB(ADDR,WDATA) \
__asm("ldr r3, =(1<<26);" \
"orr r3, %[addr];" \
"mov r2, %[wdata];" \
"strb r2, [r3];" \
:: [addr] "r" (ADDR), [wdata] "r" (WDATA) : "r2", "r3");
#define IOORW(ADDR,WDATA) \
__asm("ldr r3, =(1<<27);" \
"orr r3, %[addr];" \
"mov r2, %[wdata];" \
"str r2, [r3];" \
:: [addr] "r" (ADDR), [wdata] "r" (WDATA) : "r2", "r3");
#define IOORH(ADDR,WDATA) \
__asm("ldr r3, =(1<<27);" \
"orr r3, %[addr];" \
"mov r2, %[wdata];" \
"strh r2, [r3];" \
:: [addr] "r" (ADDR), [wdata] "r" (WDATA) : "r2", "r3");
#define IOORB(ADDR,WDATA) \
__asm("ldr r3, =(1<<27);" \
"orr r3, %[addr];" \
"mov r2, %[wdata];" \
"strb r2, [r3];" \
#define IOXORW(ADDR,WDATA) \
__asm("ldr r3, =(3<<26);" \
"orr r3, %[addr];" \
"mov r2, %[wdata];" \
"str r2, [r3];" \
:: [addr] "r" (ADDR), [wdata] "r" (WDATA) : "r2", "r3");
#define IOXORH(ADDR,WDATA) \
__asm("ldr r3, =(3<<26);" \
"orr r3, %[addr];" \
"mov r2, %[wdata];" \
"strh r2, [r3];" \
:: [addr] "r" (ADDR), [wdata] "r" (WDATA) : "r2", "r3");
#define IOXORB(ADDR,WDATA) \
__asm("ldr r3, =(3<<26);" \
"orr r3, %[addr];" \
"mov r2, %[wdata];" \
"strb r2, [r3];" \
:: [addr] "r" (ADDR), [wdata] "r" (WDATA) : "r2", "r3");
18.1 Introduction
The FTMRH module implements the following:
• Program flash (flash) memory
• EEPROM memory
The flash memory is ideal for single-supply applications allowing for field
reprogramming without requiring external high voltage sources for program or erase
operations. The flash module includes a memory controller that executes commands to
modify flash memory contents. The user interface to the memory controller consists of
the indexed Flash Common Command Object (FCCOB) register which is written to with
the command, global address, data, and any required command parameters. The memory
controller must complete the execution of a command before the FCCOB register can be
written to with a new command.
CAUTION
A flash byte or longword must be in the erased state before
being programmed. Cumulative programming of bits within a
flash byte or longword is not allowed.
The flash memory is read as bytes. Read access time is one bus cycle for bytes. For flash
memory, an erased bit reads 1 and a programmed bit reads 0.
It is possible to read from flash memory while some commands are executing on
EEPROM memory. It is not possible to read from EEPROM memory while a command
is executing on flash memory.
EEPROM memory is implemented with Error Correction Codes (ECC) that can resolve
single bit faults and detect double bit faults.
18.2 Feature
MKE02Z32VLC2(R)
MKE02Z32VLD2(R) Flash block contains flash
0x0000–0x7FFF 32 KB
MKE02Z32VQH2(R) configuration field.
MKE02Z32VLH2(R)
MKE02Z64VLC2(R)
MKE02Z64VLD2(R) Flash block contains flash
0x0000–0xFFFF 64 KB
MKE02Z64VQH2(R) configuration field.
MKE02Z64VLH2(R)
The figure below shows a general flowchart of the flash or EEPROM command write
sequence.
START
Read: FCLKDIV
register
Yes
ACCERR No
Access Error and
or FPVIOL Set?
Protection Violation Check Results from previous Command
Yes
More No
Parameters? Write: FSTAT register
(to launch command)
Yes
Clear CCIF 0x80
No
Bit Polling for CCIF Set?
Command Completion Check
Yes
END
Figure 18-1. Generic flash and EEPROM command write sequence flowchart
CAUTION
Programming or erasing the flash and EEPROM memory
cannot be performed if the bus clock runs at less than 0.8 MHz.
Setting FCLKDIV[FDIV] too high can destroy the flash and
EEPROM memory due to overstress. Setting FCLKDIV[FDIV]
too low can result in incomplete programming or erasure of the
flash and EEPROM memory cells.
Table 18-3. FCCOB – flash and EEPROM command mode typical usage
CCOBIX[2:0] Byte FCCOB parameter fields in flash and EEPROM command mode
HI FCMD[7:0] defining flash command
000
LO Global address [23:16]
HI Global address [15:8]
001
LO Global address [7:0]
HI Data 0 [15:8]
010
LO Data 0 [7:0]
HI Data 1 [15:8]
011
LO Data 1 [7:0]
HI Data 2 [15:8]
100
LO Data 2 [7:0]
HI Data 3 [15:8]
101
LO Data 3 [7:0]
The contents of the FCCOB parameter fields are transferred to the memory controller
when the user clears the FSTAT[CCIF] command completion flag by writing 1. The
CCIF flag will remain clear until the flash and EEPROM command has completed. Upon
completion, the memory controller will return FSTAT[CCIF] to 1 and the FCCOB
register will be used to communicate any results.
The following table presents the valid flash and EEPROM commands, as enabled by the
combination of the functional MCU mode with the MCU security state of unsecured or
secured.
MCU secured state is selected by FSEC[SEC].
Table 18-4. Flash and EEPROM commands by mode and security state
Unsecured Secured
FCMD Command
U1 U2
0x01 Erase verify all blocks * *
0x02 Erase verify block * *
0x03 Erase verify flash section * *
0x04 Read once * *
0x06 Program flash * *
0x07 Program once * *
0x08 Erase all block * *
0x09 Erase flash block * *
0x0A Erase flash sector * *
0x0B Unsecure flash * *
0x0C Verify backdoor access key * *
Table 18-4. Flash and EEPROM commands by mode and security state (continued)
Unsecured Secured
FCMD Command
U1 U2
0x0D Set user margin level * *
0x0E Set factory margin level * *
0x10 Erase verify EEPROM section * *
0x11 Program EEPROM * *
0x12 Erase EEPROM sector * *
18.3.6 Protection
The FPROT register can be set to protect regions in the flash memory from accidental
programing or erasing. Three separate memory regions, one growing upward from global
address 0x0000 in the flash memory, called the lower region; one growing downward
from global address 0x7FFF in the flash memory, called the higher region; and the
remaining addresses in the flash memory, can be activated for protection. The flash
memory addresses covered by these protectable regions are shown in the flash memory
map.
0x0_1000
2, 4, 8, 16 KB
0x0_2000
flash protected/unprotected lower region
0x0_4000
8 KB (up to 29 KB)
flash protected/unprotected region
Protection
fixed end
0x0_6000
1, 2, 4, 8 KB
Protection 0x0_7000 flash protected/unprotected upper region
movable end 0x0_7800
0x0_7400
0x0_8000
Protection
fixed end
32 KB
flash protected/unprotected region
Default protection settings as well as security information that allows the MCU to restrict
access to the flash module are stored in the flash configuration field as described in the
table below.
Table 18-6. Flash configuration field
Global address Size (Bytes) Description
Backdoor comparison key. See Verify backdoor access key command and
0x0400–0x0407 8
Unsecuring the MCU using backdoor key access.
0x0408–0x040B
4 Reserved
1
1. 0x040C–0x040F must be programmed at once. Each byte in the 0x0408–0x040B reserved field must be programmed to
0xFF.
The flash and EEPROM module provides protection to the MCU. During the reset
sequence, the FPROT register is loaded with the contents of the flash protection byte in
the flash configuration field at global address 0x040D in flash memory. The protection
functions depend on the configuration of bit settings in FPROT register.
Table 18-7. Flash protection function
FPOPEN FPHDIS FPLDIS Function1
1 1 1 No flash protection
1 1 0 Protected low range
1 0 1 Protected high range
1 0 0 Protected high and low ranges
0 1 1 Full flash memory protected
0 1 0 Unprotected low range
0 0 1 Unprotected high range
0 0 0 Unprotected high and low ranges
FPLS[1:0]
0x0_0000
FPOPEN = 1
FPHS[1:0]
0x0_7FFF
FLASH END
Scenario 3 2 1 0
FPLS[1:0]
0x0_0000
FPOPEN = 0
FPHS[1:0]
0x0_7FFF
FLASH END
The general guideline is that flash protection can only be added and not removed. The
following table specifies all valid transitions between flash protection scenarios. Any
attempt to write an invalid scenario to the FPROT register will be ignored. The contents
of the FPROT register reflect the active protection scenario. See the FPROT[FPHS] and
FPROT[FPLS] field descriptions for additional restrictions.
Table 18-8. Flash protection scenario transitions
From protection To protection scenario1
scenario 0 1 2 3 4 5 6 7
0 × × × ×
1 × ×
2 × ×
3 ×
4 × ×
5 × × × ×
6 × × × ×
7 × × × × × × × ×
The flash protection address range is listed in the following two tables regarding the
scenarios in the table above.
Table 18-9. Flash protection higher address range
FPHS[1:0] Global address range Protected size
00 0x7C00–0x7FFF 1 KB
01 0x7800–0x7FFF 2 KB
10 0x7000–0x7FFF 4 KB
11 0x6000–0x7FFF 8 KB
During the reset sequence, fields EEPROT[DPOPEN] and EEPROT[DPS] are loaded
with the contents of the EEPROM protection byte in the flash configuration field at
global address 0x040C located in flash memory. EEPROM protection address range is
specified by the EEPROT[DPS].
All possible flash protection scenarios are shown in Figure 18-4. Although the protection
scheme is loaded from the flash memory at global address 0x040D during the reset
sequence, it can be changed by the user.
18.3.7 Security
The flash and EEPROM module provides security information to the MCU. The flash
security state is defined by FSEC[SEC]. During reset, the flash module initializes the
FSEC register using data read from the security byte of the flash and EEPROM
configuration field. The security state out of reset can be permanently changed by
programming the security byte, assuming that the MCU is starting from a mode where
the necessary flash and EEPROM erase and program commands are available and that
the upper region of the flash is unprotected. If the flash security byte is successfully
programmed, its new value will take effect after the next MCU reset.
The following subsections describe these security-related subjects:
• Unsecuring the MCU using backdoor key access
• Unsecuring the MCU using SWD
• Mode and security effects on flash and EEPROM command availability
allows the user to present four prospective keys for comparison to the keys stored in the
flash and EEPROM memory via the memory controller. If the keys presented in the
verify backdoor access key command match the backdoor keys stored in the flash and
EEPROM memory, FSEC[SEC] will be changed to unsecure the MCU. Key values of
0x0000 and 0xFFFF are not permitted as backdoor keys. While the Verify Backdoor
Access Key command is active, flash and EEPROM memory will not be available for
read access and will return invalid data.
The user code stored in the flash memory must have a method of receiving the backdoor
keys from an external stimulus. This external stimulus would typically be through one of
the on-chip serial ports.
If the KEYEN[1:0] bits are in the enabled state, the MCU can be unsecured by the
backdoor key access sequence described below:
1. Follow the command sequence for the verify backdoor access key command as
explained in Verify backdoor access key command.
2. If the verify backdoor access key command is successful, the MCU is unsecured and
FSEC[SEC] is forced to the unsecure state of 10.
The verify backdoor access key command is monitored by the memory controller and an
illegal key will prohibit future use of the verify backdoor access key command. A reset of
the MCU is the only method to re-enable the verify backdoor access key command. The
security as defined in the flash and EEPROM security byte is not changed by using the
verify backdoor access key command sequence. The backdoor keys stored in addresses
0x400–0x407 are unaffected by the verify backdoor access key command sequence. The
verify backdoor access key command sequence has no effect on the program and erase
protections defined in the flash and EEPROM protection register, FPROT.
After the backdoor keys have been correctly matched, the MCU will be unsecured. After
the MCU is unsecured, the sector containing the flash and EEPROM security byte can be
erased and the flash and EEPROM security byte can be reprogrammed to the unsecure
state, if desired. In the unsecure state, the user has full control of the contents of the
backdoor keys by programming addresses 0x400–0x407 in the flash configuration field.
0x08 Erase All Block An erase of all flash blocks is possible only when the EEPROT[DPOPEN],
FPROT[FPHDIS], FPROT[FPLDIS] and FPROT[FPOEN] and the bit are set prior
to launching the command
Erases a flash or EEPROM block
0x09 Erase Flash Block An erase of the full flash block is possible only when FPROT[FPLDIS],
FPROT[FPHDIS], and FPROT[FPOEN] are set prior to launching the command.
0x0A Erase Flash Sector Erases all bytes in a flash sector
Supports a method of releasing MCU security by erasing all flash and EEPROM
0x0B Unsecure Flash
blocks and verifying that all flash and EEPROM blocks are erased
0x08 Erase All Block An erase of all EEPROM blocks is possible only when the FPROT[FPLDIS],
FPROT[FPHDIS], FPROT[FPOEN] and EEPORT[DPOPEN] fields are set prior
to launching the command.
Erases a EEPROM and flash block
0x09 Erase EEPROM Block An erase of the full flash block is possible only when FPROT[FPLDIS],
FPROT[FPHDIS] and FPROT[FPOPEN] bits are set prior to launching the
command.
Supports a method of releasing MCU security by erasing all EEPROM and flash
0x0B Unsecure EEPROM
blocks and verifying that all EEPROM and flash blocks are erased.
0x0D Set User Margin Level Specifies a user margin read level for all flash blocks.
Erase Verify EEPROM
0x10 Verifies that a given number of bytes starting at the address provided are erased.
Section
0x11 Program EEPROM Programs up to four bytes in the EEPROM block.
0x12 Erase EEPROM Sector Erases all bytes in a sector of the EEPROM block.
Read OK OK OK
Margin Read2
Program
Sector Erase
Mass Erase1 OK
2. The 'Mass erase' operations are commands 'Erase all blocks' and 'Erase flash block'
2. A 'Margin read' is any read after executing the margin setting commands 'Set user margin level' or 'Set field margin level'
with anything but the 'normal' level specified. See the Note on margin settings in Set user margin level command.
Upon clearing FSTAT[CCIF] to launch the Erase Verify All Blocks command, the
memory controller will verify that the entire flash memory space is erased. The
FSTAT[CCIF] flag will set after the erase verify all blocks operation has completed. If all
blocks are not erased, it means blank check failed and both FSTAT[MGSTAT] bits will
be set.
Table 18-16. Erase verify all blocks command error handling
Register Error bit Error condition
ACCERR Set if CCOBIX[2:0] != 000 at command launch
FPVIOL None
FSTAT Set if any errors have been encountered during the read1 or if blank check
MGSTAT1
failed
Set if any non-correctable errors have been encountered during the read
MGSTAT0
or if blank check failed
1. Global address [23] selects between flash (0) or EEPROM (1) block.
Upon clearing FSTAT[CCIF] to launch the erase verify block command, the memory
controller will verify that the selected flash and EEPROM block is erased. The
FSTAT[CCIF] flag will set after the erase verify block operation has completed. If the
block is not erased, it means blank check failed and both FSTAT[MGSTAT] bits will be
set.
Table 18-18. Erase Verify Block command error handling
Register Error bit Error condition
Set if CCOBIX[2:0] != 000 at command launch
ACCERR
Set if an invalid global address [23:0] is supplied1
FPVIOL None
FSTAT Set if any errors have been encountered during the read or if blank check
MGSTAT1
failed
Set if any non-correctable errors have been encountered during the read
MGSTAT0
or if blank check failed
Upon clearing FSTAT[CCIF] to launch the erase verify flash section command, the
memory controller will verify that the selected section of flash memory is erased. The
FSTAT[CCIF] flag will set after the erase verify flash section operation has completed. If
the section is not erased, it means blank check failed and both FSTAT[MGSTAT] bits
will be set.
Table 18-20. Erase Verify Flash Section command error handling
Register Error bit Error condition
Set if CCOBIX[2:0] != 010 at command launch
FSTAT ACCERR Set if command not available in current mode (see Table 18-4)
Set if an invalid global address [23:0] is supplied (see Table 18-1)1
Table 18-20. Erase Verify Flash Section command error handling (continued)
Register Error bit Error condition
Set if a misaligned long words address is supplied (global address[1:0] !=
00)
Set if the requested section crosses flash address boundary
FPVIOL None
Set if any errors have been encountered during the read2 or if blank check
MGSTAT1
failed
Set if any non-correctable errors have been encountered during the read2
MGSTAT0
or if blank check failed
Upon clearing FSTAT[CCIF] to launch the read once command, a read once phrase is
fetched and stored in the FCCOB indexed register. The FSTAT[CCIF] flag will set after
the read once operation has completed. Valid phrase index values for the read once
command range from 0x0000 to 0x0007. During execution of the read once command,
any attempt to read addresses within flash block will return invalid data.
Upon clearing FSTAT[CCIF] to launch the Program Flash command, the memory
controller will program the data words to the supplied global address and will then
proceed to verify the data words read back as expected. The FSTAT[CCIF] flag will set
after the program flash operation has completed.
Table 18-24. Program Flash command error handling
Register Error bit Error condition
Set if CCOBIX[2:0] ≠ 011 or 101 at command launch
FSTAT ACCERR Set if command not available in current mode (see Table 18-4)
Set if an invalid global address [23:0] is supplied (see Table 18-11
Upon clearing FSTAT[CCIF] to launch the program once command, the memory
controller first verifies that the selected phrase is erased. If erased, then the selected
phrase will be programmed and then verified with read back. The FSTAT[CCIF] flag will
remain clear, setting only after the program once operation has completed.
The reserved nonvolatile information register accessed by the Program Once command
cannot be erased, and any attempt to program one of these phrases a second time will not
be allowed. Valid phrase index values for the program once command range from 0x0000
to 0x0007. During execution of the program once command, any attempt to read
addresses within flash will return invalid data.
1. If a program once phrase is initially programmed to 0xFFFF_FFFF_FFFF_FFFF, the program once command will be
allowed to execute again on that same phrase.
Upon clearing FSTAT[CCIF] to launch the Erase All Blocks command, the memory
controller will erase the entire NVM memory space and verify that it is erased. If the
memory controller verifies that the entire NVM memory space was properly erased,
security will be released. Therefore, the device is in unsecured state. During the execution
of this command (FSTAT[CCIF] = 0) the user must not write to any NVM module
register. The FSTAT[CCIF] flag will set after the erase all blocks operation has
completed.
Table 18-28. Erase All Blocks command error handling
Register Error bit Error condition
Set if CCOBIX[2:0] ≠ 000 at command launch
ACCERR
Set if command not available in current mode (see Table 18-4)
FPVIOL Set if any area of the flash memory is protected
FSTAT
MGSTAT1 Set if any errors have been encountered during the verify operation1
Set if any non-correctable errors have been encountered during the verify
MGSTAT0
operation1
1. Global address [23] selects between flash (0) or EEPROM (1) block.
Upon clearing FSTAT[CCIF] to launch the erase flash block command, the memory
controller will erase the selected flash block and verify that it is erased. The
FSTAT[CCIF] flag will set after the erase flash block operation has completed.
Table 18-30. Erase flash block command error handling
Register Error Bit Error Condition
Set if CCOBIX[2:0] != 001 at command launch
ACCERR Set if command not available in current mode (see Table 18-4)
Set if an invalid global address [23:16] is supplied1
FSTAT FPVIOL Set if an area of the selected flash block is protected
MGSTAT1 Set if any errors have been encountered during the verify operation2
Set if any non-correctable errors have been encountered during the verify
MGSTAT0
operation2
Upon clearing FSTAT[CCIF] to launch the erase flash sector command, the memory
controller will erase the selected flash sector and then verify that it is erased. The
FSTAT[CCIF] flag will be set after the erase flash sector operation has completed.
Upon clearing FSTAT[CCIF] to launch the unsecure flash command, the memory
controller will erase the entire flash and EEPROM memory space and verify that it is
erased. If the memory controller verifies that the entire flash and EEPROM memory
space was properly erased, security will be released. If the erase verify is not successful,
the unsecure flash operation sets FSTAT[MGSTAT1] and terminates without changing
the security state. During the execution of this command (FSTAT[CCIF] = 0), the user
must not write to any flash and EEPROM module register. The FSTAT[CCIF] flag is set
after the unsecure flash operation has completed.
Table 18-34. Unsecure flash command error handling
Register Error bit Error condition
Set if CCOBIX[2:0] != 000 at command launch
ACCERR
Set if command is not available in current mode (see Table 18-4)
FSTAT
FPVIOL Set if any area of the flash or EEPROM memory is protected
MGSTAT1 Set if any errors have been encountered during the verify operation1
Set if any non-correctable errors have been encountered during the verify
MGSTAT0
operation1
Upon clearing FSTAT[CCIF] to launch the verify backdoor access key command, the
memory controller will check the FSEC[KEYEN] bits to verify that this command is
enabled. If not enabled, the memory controller sets the FSTAT[ACCERR] bit. If the
command is enabled, the memory controller compares the key provided in FCCOB to the
backdoor comparison key in the flash configuration field with Key 0 compared to
0x0400, and so on. If the backdoor keys match, security will be released. If the backdoor
keys do not match, security is not released and all future attempts to execute the verify
backdoor access key command are aborted (set FSTAT[ACCERR]) until a reset occurs.
The FSTAT[CCIF] flag is set after the verify backdoor access key operation has
completed.
Table 18-36. Verify backdoor access key command error handling
Register Error bit Error condition
Set if CCOBIX[2:0] ≠ 100 at command launch
Set if an incorrect backdoor key is supplied
ACCERR
Set if backdoor key access has not been enabled (KEYEN[1:0] ≠ 10
FSTAT Set if the backdoor key has mismatched since the last reset
FPVIOL None
MGSTAT1 None
MGSTAT0 None
1. Global Address [23] selects between flash (0) or EEPROM (1) block.
Upon clearing FSTAT[CCIF] to launch the set user margin level command, the memory
controller will set the user margin level for the targeted block and then set the
FSTAT[CCIF] flag.
Note
When the EEPROM block is targeted, the EEPROM user
margin levels are applied only to the EEPROM reads. However,
when the Flash block is targeted, the flash user margin levels
are applied to both Flash and EEPROM reads. It is not possible
to apply user margin levels to the flash block only.
Valid margin level settings for the set user margin level command are defined in the
following tables.
Table 18-38. Valid set user margin level settings
CCOB
Level description
(CCOBIX = 010)
0x0000 Return to normal level
0x0001 User margin-1 level1
0x0002 User margin-0 level2
Note
User margin levels can be used to check that NVM memory
contents have adequate margin for normal level read operations.
If unexpected results are encountered when checking NVM
memory contents at user margin levels, a potential loss of
information has been detected.
1. Global Address [23] selects between flash (0) or EEPROM (1) block, that can otherwise eventually share the same
address on the MCU global memory map.
Upon clearing FSTAT[CCIF] to launch the set factory margin level command, the
memory controller will set the factory margin level for the targeted block and then set the
FSTAT[CCIF] flag.
Note
When the EEPROM block is targeted, the EEPROM factory
margin levels are applied only to the EEPROM reads. However,
when the flash block is targeted, the flash factory margin levels
are applied to both flash and EEPROM reads. It is not possible
to apply factory margin levels to the flash block only.
KE02 Sub-Family Reference Manual, Rev. 3, July 2013
244 Freescale Semiconductor, Inc.
Chapter 18 Flash Memory Module (FTMRH)
Valid margin level settings for the set factory margin level command are defined in the
following tables.
Table 18-41. Valid set factory margin level settings
CCOB
Level description
(CCOBIX = 010)
0x0000 Return to normal level
0x0001 User margin-1 level1
0x0002 User margin-0 level2
0x0003 Factory margin-1 level1
0x0004 Factory margin-0 level2
CAUTION
Factory margin levels must only be used during verify of the
initial factory programming.
Note
Factory margin levels can be used to check that Flash memory
contents have adequate margin for data retention at the normal
level setting. If unexpected results are encountered when
checking flash memory contents at factory margin levels, the
fash memory contents must be erased and reprogrammed.
Upon clearing FSTAT[CCIF] to launch the erase verify that EEPROM section command,
the memory controller will verify the selected section of EEPROM memory is erased.
The FSTAT[CCIF] flag will set after the erase verify EEPROM section operation has
completed. If the section is not erased, which means that blank check failed, both
FSTAT[MGSTAT] bits will be set.
Table 18-44. Erase verify EEPROM section command error handling
Register Error bit Error condition
Set if CCOBIX[2:0] ≠ 010 at command launch
Set if command is not available in current mode (see Table 18-4)
ACCERR
Set if an invalid global address [23:0] is supplied
Set if the requested section breaches the end of the EEPROM block
FSTAT FPVIOL None
Set if any errors have been encountered during the read or if blank check
MGSTAT1
failed
Set if any non-correctable errors have been encountered during the read
MGSTAT0
or it blank check failed.
Upon clearing FSTAT[CCIF] to launch the program EEPROM command, the user-
supplied words will be transferred to the memory controller and be programmed if the
area is unprotected. The CCOBIX index value at program EEPROM command launch
determines how many bytes will be programmed in the EEPROM block. The
FSTAT[CCIF] flag is set when the operation has completed.
Table 18-46. Program EEPROM command error handling
Register Error Bit Error condition
Set if CCOBIX[2:0] < 010 at command launch
Set if CCOBIX[2:0] >101 at command launch
Set if command is not available in current mode (see Table 18-4)
ACCERR
Set if an invalid global address [23:0] is supplied
FSTAT Set if the requested group of words breaches the end of the EEPROM
block
FPVIOL Set if the selected area of the EEPROM memory is protected
MGSTAT1 Set if any errors have been encountered during the verify operation
Set if any non-correctable errors have been encountered during the verify
MGSTAT0
operation
Upon clearing FSTAT[CCIF] to launch the erase EEPROM sector command, the
memory controller will erase the selected EEPROM sector and verify that it is erased.
The FSTAT[CCIF] flag will set after the erase EEPROM sector operation has completed.
KE02 Sub-Family Reference Manual, Rev. 3, July 2013
Freescale Semiconductor, Inc. 247
Memory map and register definition
NOTE
The FCLKDIV register must not be written while a flash
command is executing (FSTAT[CCIF] = 0)
Address: 4002_0000h base + 0h offset = 4002_0000h
Bit 7 6 5 4 3 2 1 0
Read FDIVLD
FDIVLCK FDIV
Write
Reset 0 0 0 0 0 0 0 0
FDIV[5:0] must be set to effectively divide BUSCLK down to 1MHz to control timed events during flash
program and erase algorithms. Refer to the table in the Writing the FCLKDIV register for the
recommended values of FDIV based on the BUSCLK frequency.
Bit 7 6 5 4 3 2 1 0
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
00 Disabled
01 Disabled
10 Enabled
11 Disabled
5–2 This field is reserved.
Reserved
SEC Flash Security Bits
Defines the security state of the MCU. If the flash module is unsecured using backdoor key access, the
SEC field is forced to 10.
00 Secured
01 Secured
10 Unsecured
11 Secured
Bit 7 6 5 4 3 2 1 0
Read 0 CCOBIX
Write
Reset 0 0 0 0 0 0 0 0
Selects which word of the FCCOB register array is being read or written to.
Bit 7 6 5 4 3 2 1 0
Read 0 0
CCIE IGNSF FDFD FSFD
Write
Reset 0 0 0 0 0 0 0 0
0 Flash array read operations will set the FERSTAT[DFDIF] flag only if a double bit fault is detected.
1 Any flash array read operation will force the FERSTAT[DFDIF] flag to be set and an interrupt will be
generated as long as FERCNFG[DFDIE] is set.
0 Force Single Bit Fault Detect
FSFD
The FSFD bit allows the user to simulate a single bit fault during flash array read operations and check the
associated interrupt routine. This field is cleared by writing a 0 to FSFD.
0 Flash array read operations will set the SFDIF flag in the FERSTAT register only if a single bit fault is
detected.
1 Flash array read operation will force the SFDIF flag in the FERSTAT register to be set and an interrupt
will be generated as long as FERCNFG[SFDIE] is set.
Bit 7 6 5 4 3 2 1 0
The FSTAT register reports the operational status of the flash and EEPROM module.
Address: 4002_0000h base + 6h offset = 4002_0006h
Bit 7 6 5 4 3 2 1 0
One or more MGSTAT flag bits are set if an error is detected during execution of a flash command or
during the flash reset sequence.
NOTE: Reset value can deviate from the value shown if a double bit fault is detected during the reset
sequence.
Bit 7 6 5 4 3 2 1 0
NOTE: The single bit fault and double bit fault flags are mutually exclusive for parity errors, meaning that
an ECC fault occurrence can be either single fault or double fault but never both. A simultaneous
access collision, when the flash array read operation is returning invalid data attempted while a
command is running, is indicated when both SFDIF and DFDIF flags are high.
NOTE: There is a one cycle delay in storing the ECC DFDIF and SFDIF fault flags in the register. At least
one NOP is required after a flash memory read before checking FERSTAT for the occurrence of
EEC errors.
Trying to alter data in any protected area in the flash memory will result in a protection
violation error and the FPVIOL bit will be set in the FSTAT register. The block erase of a
flash block is not possible if any of the flash sectors contained in the same flash block are
protected.
Address: 4002_0000h base + 8h offset = 4002_0008h
Bit 7 6 5 4 3 2 1 0
Read RNV6
FPOPEN FPHDIS FPHS FPLDIS FPLS
Write
Reset * * * * * * * *
* Notes:
• Loaded from Flash configuration field, during reset sequence.
0 When FPOPEN is clear, the FPHDIS and FPLDIS fields define unprotected address ranges as
specified by the corresponding FPHS and FPLS fields.
1 When FPOPEN is set, the FPHDIS and FPLDIS fields enable protection for the address range
specified by the corresponding FPHS and FPLS fields.
6 Reserved Nonvolatile Bit
RNV6
The RNV bit must remain in the erased state.
5 Flash Protection Higher Address Range Disable
FPHDIS
The FPHDIS bit determines whether there is a protected/unprotected area in a specific region of the flash
memory ending with global address 0x7FFF.
0 Protection/Unprotection enabled.
1 Protection/Unprotection disabled.
4–3 Flash Protection Higher Address Size
FPHS
The FPHS bits determine the size of the protected/unprotected area in flash memory. The FPHS bits can
be written to only while the FPHDIS bit is set.
2 Flash Protection Lower Address Range Disable
FPLDIS
The FPLDIS bit determines whether there is a protected/unprotected area in a specific region of the flash
memory beginning with global address 0x0_0000.
0 Protection/Unprotection enabled.
1 Protection/Unprotection disabled.
FPLS Flash Protection Lower Address Size
The FPLS bits determine the size of the protected/unprotected area in flash memory. The FPLS bits can
only be written to while the FPLDIS bit is set.
Bit 7 6 5 4 3 2 1 0
Read 0
DPOPEN DPS
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
Bit 7 6 5 4 3 2 1 0
Read CCOB
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read CCOB
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read NV
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
The NV[7:0] bits are available as nonvolatile bits. During the reset sequence, the FOPT register is loaded
from the flash nonvolatile byte in the flash configuration field at global address 0x40F located in flash
memory.
19.1 Introduction
The Flash Memory Controller (FMC) is a memory acceleration unit that provides:
• an interface between bus masters and the 32-bit program flash memory.
• a buffer and a cache that can accelerate program flash memory data transfers.
19.1.1 Overview
The Flash Memory Controller manages the interface between bus masters and the 32-bit
program flash memory. The FMC receives status information detailing the configuration
of the flash memory and uses this information to ensure a proper interface. The FMC
supports 8-bit, 16-bit, and 32-bit read operations from the program flash memory. A write
operation to program flash memory results in a bus error.
In addition, the FMC provides two separate mechanisms for accelerating the interface
between bus masters and program flash memory. A 32-bit speculation buffer can prefetch
the next 32-bit flash memory location, and a 4-way, 2-set program flash memory cache
can store previously accessed program flash memory data for quick access times.
19.1.2 Features
The features of FMC module include:
• Interface between bus masters and the 32-bit program flash memory:
• 8-bit, 16-bit, and 32-bit read operations to nonvolatile flash memory.
• Acceleration of data transfer from the program flash memory to the device:
• 32-bit prefetch speculation buffer for program flash accesses with controls for
instruction/data access
• 4-way, 2-set, 32-bit line size program flash memory cache for a total of eight 32-
bit entries with invalidation control
20.1 Introduction
The internal clock source (ICS) module provides clock source choices for the MCU. The
module contains a frequency-locked loop (FLL) as a clock source that is controllable by
either an internal or an external reference clock. The module can provide this FLL clock
or either of the internal or external reference clocks as a source for the MCU system
clock. There are also signals provided to control a low-power oscillator (OSC) module.
These signals configure and enable the OSC module to generate its external crystal/
resonator clock (OSC_OUT) used by peripheral modules and as the ICS external
reference clock source. The ICS external reference clock can be the external crystal/
resonator (OSC_OUT) supplied by an OSC, or it can be another external clock source.
The ICS clock source chosen is passed through a reduced bus divider (BDIV) which
allows a lower final output clock frequency to be derived.
20.1.1 Features
The key features of the ICS module are given below:
• Frequency-locked loop (FLL) is trimmable for accuracy
• Internal or external reference clocks can be used to control the FLL.
• Reference divider is provided for external clock.
• Internal reference clock has 9 trim bits available.
• Internal or external reference clocks can be selected as the clock source for the MCU.
• Whichever clock is selected as the source can be divided down.
• 3-bit select for clock divider is provided
• Allowable dividers are: 1, 2, 4, 8, 16, 32, 64, 128 if OSC_CR[RANGE] = 0; 32,
64, 128, 256, 512, 1024 if OSC_CR[RANGE] = 1.
• FLL Engaged Internal mode is automatically selected out of reset.
• Selectable digitally-controlled oscillators (DCO) optimized frequency ranges
• FLL lock detector and external clock monitor
IREFSTEN BDIV
Internal / 2n
Reference ICSOUT
Clock n=0-7
LP
/ 2n Filter DCO
n=0-7
IREFS
RDIV
ICSFFCLK
IREFST CLKST LOLIE LOLS LOCK CME
Bit 7 6 5 4 3 2 1 0
Read CLKS RDIV IREFS IRCLKEN IREFSTEN
Write
Reset 0 0 0 0 0 1 0 0
1. Reset default
2 Internal Reference Select
IREFS
Selects the reference clock source for the FLL.
0 ICSIRCLK is inactive.
1 ICSIRCLK is active.
0 Internal Reference Stop Enable
IREFSTEN
Controls whether or not the internal reference clock remains enabled when the ICS enters Stop mode.
1. Reset default
Bit 7 6 5 4 3 2 1 0
Read 0
BDIV LP
Write
Reset 0 0 1 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read SCTRIM
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
Controls the slow internal reference clock frequency by controlling the internal reference clock period. The
bits are binary weighted. In other words, bit 1 adjusts twice as much as bit 0. Increasing the binary value in
SCTRIM will increase the period, and decreasing the value will decrease the period. An additional fine trim
bit is available as the ICS_C4[SCFTRIM]. SCTRIM is loaded during reset from a factory programmed
location if the device is not in any debug mode.
Bit 7 6 5 4 3 2 1 0
Read 0 0
LOLIE CME SCFTRIM
Write
Reset 0 0 0 0 0 0 0 x*
* Notes:
• x = Undefined at reset.
NOTE: SCFTRIM is loaded during reset from a factory programmed location when not in any debug
mode.
Bit 7 6 5 4 3 2 1 0
Write
Reset 0 0 0 1 0 0 0 0
0 FLL has not lost lock since LOLS was last cleared.
1 FLL has lost lock since LOLS was last cleared.
6 Lock Status
LOCK
Indicates whether the FLL has acquired lock. Lock detection is disabled when FLL is disabled. If the lock
status bit is set then changing the value of any of the following fields IREFS, RDIV[2:0], or, if in FEI or FBI
modes, TRIM[7:0] will cause the lock status bit to clear and stay cleared until the FLL has reacquired lock.
Stop mode entry will also cause the lock status bit to clear and stay cleared until the FLL has reacquired
lock.
FLL Engaged
IREFS=0 Internal (FEI) IREFS=1
CLKS=10 CLKS=01
Debug Enabled Debug Enabled
or LP =0 or LP=0
IREFS=0 IREFS=1
CLKS=10 CLKS=01
Debug Disabled Debug Disabled
and LP=1 FLL Engaged and LP=1
External (FEE)
IREFS=0
CLKS=00
In FLL engaged external mode, the ICSOUT clock is derived from the FLL clock which
is controlled by the external reference clock source.The FLL loop locks the frequency to
1024 times the external reference frequency, as selected by ICS_C1[RDIV] and
OSC_CR[RANGE ]. The external reference clock is enabled.
20.4.1.7 Stop
NOTE
The DCO frequency changes from the pre-stop value to its reset
value and the FLL need to re-acquire the lock before the
frequency is stable. Timing sensitive operations must wait for
the FLL acquisition time, tAcquire, before executing.
Stop mode is entered whenever the MCU enters a STOP state. In this mode, all ICS clock
signals are static except in the following cases:
ICSIRCLK will be active in Stop mode when all the following conditions occur:
• 1b is written to ICS_C1[IRCLKEN].
• 1b is written to ICS_C1[IREFSTEN].
21.1 Introduction
21.1.1 Overview
The OSC module provides the clock source for the MCU. The OSC module, in
conjunction with an external crystal or resonator, generates a clock for the MCU that can
be used as reference clock or bus clock.
EXTAL XTAL
Digital Wrapper
Mux
HGO OSC_OUT
High Gain
RANGE 32K/4-20MHz
Oscillator
OSCOS XTL_CLK
EN
Low Power
ICS_OSC_EN 4-20MHz
Oscillator
4096
EN Counter
Low Power
STOP
32KHz
OSCEN Oscillator
OSCSTEN
CNT_DONE_4096
OSC_INIT HARD BLOCK
Crystal or Resonator
RS
Cx Cy
RF
Crystal or Resonator
Bit 7 6 5 4 3 2 1 0
Read 0 0 OSCINIT
OSCEN OSCSTEN OSCOS RANGE HGO
Write
Reset 0 0 0 0 0 0 0 0
0 Low-power mode
1 High-gain mode
0 OSC Initialization
OSCINIT
This field is set after the initialization cycles of oscillator are completed.
Off
• Oscillator OFF
EN
• OSC_OUT = Static
EN EN
&& OSCOS && OSCOS
Start-Up Start-Up
• Oscillator On, not yet stable • Oscillator On
• OSC_OUT = Static • OSC_OUT = EXTAL
CNT_DONE_4096
Stable
• Oscillator On, Stable
• OSC_OUT = XTL_CLK
21.6.1.1 Off
The off state is entered whenever the EN signal is negated. Upon entering this state,
XTL_CLK and OSC_OUT is static. The EXTAL and XTAL pins are also decoupled
from all other oscillator circuitry in this state. The OSC module circuitry is configured to
draw minimal current.
The oscillator input buffer in this mode is single-ended. It provides low pass frequency
filtering as well as hysteresis for voltage filtering and converts the output to logic levels.
21.6.3 Counter
The oscillator output clock (OSC_OUT) is gated off until the counter has detected 4096
cycles of its input clock (XTL_CLK). Once 4096 cycles are complete, the counter passes
XTL_CLK onto OSC_OUT. This counting timeout is used to guarantee output clock
stability.
22.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances, see the chip configuration information.
The cyclic redundancy check (CRC) module generates 16/32-bit CRC code for error
detection.
The CRC module provides a programmable polynomial, WAS, and other parameters
required to implement a 16-bit or 32-bit CRC standard.
The 16/32-bit code is calculated for 32 bits of data at a time.
22.1.1 Features
Features of the CRC module include:
• Hardware CRC generator circuit using a 16-bit or 32-bit programmable shift register
• Programmable initial seed value and polynomial
• Option to transpose input data or output data (the CRC result) bitwise or bytewise.
This option is required for certain CRC standards. A bytewise transpose operation is
not possible when accessing the CRC data register via 8-bit accesses. In this case, the
user's software must perform the bytewise transpose function.
• Option for inversion of final CRC result
• 32-bit CPU register programming interface
MUX
CRC Data [23:16]
[7:0] Logic Logic [15:8]
[7:0]
Checksum
CRC Polynomial CRC Engine
Register
Data
[31:24]
[23:16] Combine
Polynomial
[15:8] Logic
[7:0]
16-/32-bit Select
TCRC
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R
W
HU HL LU LL
Reset 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
When CTRL[WAS] is 1, values written to this field are part of the seed value. When CTRL[WAS] is 0, data
written to this field is used for CRC checksum generation.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R
W
HIGH LOW
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 0
TCRC
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
00 No transposition.
01 Bits in bytes are transposed; bytes are not transposed.
10 Both bits in bytes and bytes are transposed.
11 Only bytes are transposed; no bits in a byte are transposed.
29–28 Type Of Transpose For Read
TOTR
Identifies the transpose configuration of the value read from the CRC Data register. See the description of
the transpose feature for the available transpose options.
00 No transposition.
01 Bits in bytes are transposed; bytes are not transposed.
10 Both bits in bytes and bytes are transposed.
11 Only bytes are transposed; no bits in a byte are transposed.
27 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
26 Complement Read Of CRC Data Register
FXOR
Some CRC protocols require the final checksum to be XORed with 0xFFFFFFFF or 0xFFFF. Asserting
this bit enables on the fly complementing of read data.
0 No XOR on reading.
1 Invert or complement the read value of the CRC Data register.
25 Write CRC Data Register As Seed
WAS
When asserted, a value written to the CRC data register is considered a seed value. When deasserted, a
value written to the CRC data register is taken as data for CRC computation.
No transposition occurs.
2. CTRL[TOT] or CTRL[TOTR] is 01
Bits in a byte are transposed, while bytes are not transposed.
reg[31:0] becomes {reg[24:31], reg[16:23], reg[8:15], reg[0:7]}
31 24 23 16 15 8 7 0
24 31 16 23 8 15 0 7
31 0
0 31
31 24 23 16 15 8 7 0
7 0 15 8 23 16 31 24
NOTE
For 8-bit and 16-bit write accesses to the CRC data register, the
data is transposed with zeros on the unused byte or bytes
(taking 32 bits as a whole), but the CRC is calculated on the
valid byte(s) only. When reading the CRC data register for a
16-bit CRC result and using transpose options 10 and 11, the
resulting value after transposition resides in the CRC[HU:HL]
fields. The user software must account for this situation when
reading the 16-bit CRC result, so reading 32 bits is preferred.
23.1 Introduction
The external interrupt (IRQ) module provides a maskable interrupt input.
23.2 Features
Features of the IRQ module include:
• A dedicated external interrupt pin IRQ
• IRQ Interrupt Control bits
• Programmable edge-only or edge and level interrupt sensitivity
• Automatic interrupt acknowledge
• Internal pullup device
A low level applied to the external interrupt request (IRQ) pin can latch a CPU interrupt
request. The following figure shows the structure of the IRQ module:
IRQACK
RESET
SYNCHRO- TO CPU
NIZER
BUSCLK
VDD
IRQF
CLR
1 D Q SYNCHRO-
NIZER
IRQ 0 CK
S IRQPE
STOP
STOP BYPASS
IRQEDG
External interrupts are managed by the IRQSC status and control register. When the IRQ
function is enabled, synchronous logic monitors the pin for edge-only or edge-and-level
events. When the MCU is in Stop mode and system clocks are shut down, a separate
asynchronous path is used so that the IRQ, if enabled, can wake the MCU.
When enabling the IRQ pin for use, IRQSC[IRQF] will be set,
and must be cleared prior to enabling the interrupt. When
configuring the pin for falling edge and level sensitivity in a 3
V system, it is necessary to wait at least cycles between
clearing the flag and enabling the interrupt.
Bit 7 6 5 4 3 2 1 0
Read 0 IRQF 0
IRQPDD IRQEDG IRQPE IRQIE IRQMOD
Write IRQACK
Reset 0 0 0 0 0 0 0 0
0 No IRQ request
1 IRQ event is detected.
2 IRQ Acknowledge
IRQACK
This write-only field is used to acknowledge interrupt request events (write 1 to clear IRQF). Writing 0 has
no meaning or effect. Reads always return 0. If edge-and-level detection is selected (IRQMOD = 1), IRQF
cannot be cleared while the IRQ pin remains at its asserted level.
1 IRQ Interrupt Enable
IRQIE
This read/write control field determines whether IRQ events generate an interrupt request.
24.1 Introduction
The 12-bit analog-to-digital converter (ADC) is a successive approximation ADC
designed for operation within an integrated microcontroller system-on-chip.
24.1.1 Features
Features of the ADC module include:
• Linear Successive Approximation algorithm with 8-, 10-, or 12-bit resolution
• Up to 16 external analog inputs, external pin inputs, and 5 internal analog inputs
including internal bandgap, temperature sensor, and references
• Output formatted in 8-, 10-, or 12-bit right-justified unsigned format
• Single or Continuous Conversion (automatic return to idle after single conversion)
• Support up to eight result FIFO with selectable FIFO depth
• Configurable sample time and conversion speed/power
• Conversion complete flag and interrupt
• Input clock selectable from up to four sources
• Operation in Wait or Stop modes for lower noise operation
• Asynchronous clock source for lower noise operation
• Selectable asynchronous hardware conversion trigger
• Automatic compare with interrupt for less-than, or greater-than or equal-to,
programmable value
AD CHANNEL FIFO
AD RESULT FIFO
5 5-bit ch 2 12-bit AD result
4 5-bit ch 3 12-bit AD result
3 5-bit ch 4 12-bit AD result
2 5-bit ch 5 12-bit AD result
1 5-bit ch 6 12-bit AD result
0 5-bit ch 7 12-bit AD result
AD14
ANALOG MUX
ASYNC
CLOCK
GENERATOR
ADICLK ADIV
• The bus clock divided by two. For higher bus clock rates, this allows a maximum
divide by 16 of the bus clock.
Whichever clock is selected, its frequency must fall within the specified frequency range
for ADCK. If the available clocks are too slow, the ADC do not perform according to
specifications. If the available clocks are too fast, the clock must be divided to the
appropriate frequency. This divider is specified by the ADC_SC3[ADIV] bits and can be
divide-by 1, 2, 4, or 8.
When the ADC_SC4[ASCANE] = 0 in FIFO mode, the bus clock must be not slower
than ADC conversion clock (ADCK) divided by 2 . When the ADC_SC2[ACFE] = 1 in
FIFO mode, the bus clock must be not slower than ADC conversion clock (ADCK)
divided by 2.
continuous convert configuration, only the initial rising edge to launch continuous
conversions is observed. The hardware trigger function operates in conjunction with any
of the conversion modes and configurations.
When a conversion is aborted, the contents of the data register, ADC_R, are not altered.
However, they continue to be the values transferred after the completion of the last
successful conversion. If the conversion was aborted by a reset, ADC_R returns to their
reset states.
If the bus frequency is less than the fADCK frequency, precise sample time for continuous
conversions cannot be guaranteed when short sample is enabled (ADC_SC3[ADLSMP]
= 0). If the bus frequency is less than 1/11th of the fADCK frequency, precise sample time
for continuous conversions cannot be guaranteed when long sample is enabled
(ADC_SC3[ADLSMP] = 1).
The maximum total conversion time for different conditions is summarized in the table
below.
Table 24-2. Total conversion time vs. control conditions
Conversion type ADICLK ADLSMP Max total conversion time
Single or first continuous 8-bit 0x, 10 0 20 ADCK cycles + 5 bus clock cycles
Single or first continuous 10-bit or 12-bit 0x, 10 0 23 ADCK cycles + 5 bus clock cycles
Single or first continuous 8-bit 0x, 10 1 40 ADCK cycles + 5 bus clock cycles
Single or first continuous 10-bit or 12-bit 0x, 10 1 43 ADCK cycles + 5 bus clock cycles
Single or first continuous 8-bit 11 0 5 µs + 20 ADCK + 5 bus clock cycles
Single or first continuous 10-bit or 12-bit 11 0 5 µs + 23 ADCK + 5 bus clock cycles
Single or first continuous 8-bit 11 1 5 µs + 40 ADCK + 5 bus clock cycles
Single or first continuous 10-bit or 12-bit 11 1 5 µs + 43 ADCK + 5 bus clock cycles
Subsequent continuous 8-bit; xx 0 17 ADCK cycles
fBUS > fADCK
Subsequent continuous 10-bit or 12-bit; xx 0 20 ADCK cycles
fBUS > fADCK
Subsequent continuous 8-bit; xx 1 37 ADCK cycles
fBUS > fADCK/11
Subsequent continuous 10-bit or 12-bit; xx 1 40 ADCK cycles
fBUS > fADCK/11
The maximum total conversion time is determined by the selected clock source and the
divide ratio. The clock source is selectable by the ADC_SC3[ADICLK] bits, and the
divide ratio is specified by the ADC_SC3[ADIV] bits. For example, in 10-bit mode, with
the bus clock selected as the input clock source, the input clock divide-by-1 ratio
selected, and a bus frequency of 8 MHz, then the conversion time for a single conversion
as given below:
Note
The ADCK frequency must be between fADCK minimum and
fADCK maximum to meet ADC specifications.
The FIFO function is enabled when the ADC_SC4[AFDEP] bits are set non-zero. The
FIFO depth is indicated by these bits. The FIFO supports up to eight level buffer.
The analog input channel FIFO is accessed by ADC_SC1[ADCH] bits, when FIFO
function is enabled. The analog channel must be written to this FIFO in order. The ADC
will not start the conversion if the channel FIFO is fulfilled below the level indicated by
the ADC_SC4[AFDEP] bits, no matter whether software or hardware trigger is set. Read
ADC_SC1[ADCH] will read the current active channel value. Write to
ADC_SC1[ADCH] will re-fill channel FIFO to initial new conversion. It will abort
current conversion and any other conversions that did not start. Write to the ADC_SC1
after all the conversions are completed or ADC is in idle state.
The result of the FIFO is accessed by ADC_R register, when FIFO function is enabled.
The result must be read via these two registers by the same order of analog input channel
FIFO to get the proper results. Don't read ADC_R until all of the conversions are
completed in FIFO mode. The ADC_SC1[COCO] bit will be set only when all
conversions indicated by the analog input channel FIFO complete whatever software or
hardware trigger is set. An interrupt request will be submitted to CPU if the
ADC_SC1[AIEN] is set when the FIFO conversion completes and the
ADC_SC1[COCO] bit is set.
AFDEP
ADC_R read
ADC_R
ADCH write 0 12-bit AD result
ADCH
1 12-bit AD result
5-bit ch 7
2 12-bit AD result
5-bit ch 6
AD CHANNEL FIFO
AD RESULT FIFO
3 12-bit AD result
5-bit ch 5
4 12-bit AD result
5-bit ch 4
5 12-bit AD result
5-bit ch 3
6 12-bit AD result
5-bit ch 2
7 12-bit AD result
5-bit ch 1
8 12-bit AD result
5-bit ch 0
9 12-bit AD result
10 12-bit AD result
FIFO Read/Write Logic reset
11 12-bit AD result
BUS CLK
If software trigger is enabled, the next analog channel is fetched from analog input
channel FIFO as soon as a conversion completes and its result is stored in the result
FIFO. When all conversions set in the analog input channel FIFO completes, the
ADC_SC1[COCO] bit is set and an interrupt request will be submitted to CPU if the
ADC_SC1[AIEN] bit is set.
If hardware trigger mode is enabled, the next analog is fetched from analog input channel
FIFO only when this conversion completes, its result is stored in the result FIFO, and the
next hardware trigger is fed to ADC module. When all conversions set in the analog input
channel FIFO completes, the ADC_SC1[COCO] bit is set and an interrupt request will be
submitted to CPU if the ADC_SC1[AIEN] bit is set.
In single conversion in which ADC_SC1[ADCO] bit is clear, the ADC stops conversions
when ADC_SC1[COCO] bit is set until the channel FIFO is fulfilled again or new
hardware trigger occur.
The FIFO also provides scan mode to simplify the dummy work of input channel FIFO.
When the ADC_SC4[ASCANE] bit is set in FIFO mode, the FIFO will always use the
first dummied channel in spite of the value in the input channel FIFO. The ADC
conversion start to work in FIFO mode as soon as the first channel is dummied. The
following write operation to the input channel FIFO will cover the first channel element
in this FIFO. In scan FIFO mode, the ADC_SC1[COCO] bit is set when the result FIFO
is fulfilled according to the depth indicated by the ADC_SC4[AFDEP] bits.
In continuous conversion in which the ADC_SC1[ADCO] bit is set, the ADC starts next
conversion immediately when all conversions are completed. ADC module will fetch the
analog input channel from the beginning of analog input channel FIFO.
0 n max
The nth AD
channel fetch max = AFDEP
The nth AD
channel fetch
when n hardware trigger occurs max = AFDEP
when last hardware trigger occurs
Channel FIFO fulfilled
Start FIFOed Conversion
when 1st hardware trigger occurs
0 n max If new trigger occurs, the new set conversions will be generated
The nth AD
channel fetch max = AFDEP
0 n max 0 n
A conversion complete event sets the ADC_SC1[COCO] and generates an ADC interrupt
to wake the MCU from Stop mode if the ADC interrupt is enabled (ADC_SC1[AIEN] =
1). In fifo mode, ADC cannot complete the conversion operation fully or wake the MCU
from Stop mode.
Note
The ADC module can wake the system from low-power stop
and cause the MCU to begin consuming run-level currents
without generating a system level interrupt. To prevent this
scenario, the data transfer blocking mechanism must be cleared
when entering Stop and continuing ADC conversions.
3. Update status and control register 1 (ADC_SC1) to select whether conversions will
be continuous or completed only once, and to enable or disable conversion complete
interrupts. The input channel on which conversions will be performed is also selected
here.
//4-Level FIFO
ADC_SC4 = ADC_SC4_AFDEP1_MASK | ADC_SC4_AFDEP0_MASK;
When available on a separate pin, VREFH may be connected to the same potential as
VDDA, or may be driven by an external source between the minimum VDDA spec and the
VDDA potential (VREFH must never exceed VDDA). When available on a separate pin,
VREFL must be connected to the same voltage potential as VSSA. VREFH and VREFL must
be routed carefully for maximum noise immunity and bypass capacitors placed as near as
possible to the package.
AC current in the form of current spikes required to supply charge to the capacitor array
at each successive approximation step is drawn through the VREFH and VREFL loop. The
best external component to meet this current demand is a 0.1 µF capacitor with good high
frequency characteristics. This capacitor is connected between VREFH and VREFL and
must be placed as near as possible to the package pins. Resistance in the path is not
recommended because the current causes a voltage drop that could result in conversion
errors. Inductance in this path must be minimum (parasitic only).
For minimal loss of accuracy due to current injection, pins adjacent to the analog input
pins should not be transitioning during conversions.
There are some situations where external system activity causes radiated or conducted
noise emissions or excessive VDD noise is coupled into the ADC. In these situations, or
when the MCU cannot be placed in wait or Stop or I/O activity cannot be halted, these
recommended actions may reduce the effect of noise on the accuracy:
• Place a 0.01 µF capacitor (CAS) on the selected input channel to VREFL or VSSA (this
improves noise issues, but affects the sample rate based on the external analog source
resistance).
• Average the result by converting the analog input many times in succession and
dividing the sum of the results. Four samples are required to eliminate the effect of a
1LSB, one-time error.
• Reduce the effect of synchronous noise by operating off the asynchronous clock
(ADACK) and averaging. Noise that is synchronous to ADCK cannot be averaged
out.
There is an inherent quantization error due to the digitization of the result. For 8-bit or
10-bit conversions the code transitions when the voltage is at the midpoint between the
points where the straight line transfer function is exactly represented by the actual
transfer function. Therefore, the quantization error will be ± 1/2 lsb in 8- or 10-bit mode.
As a consequence, however, the code width of the first (0x000) conversion is only 1/2 lsb
and the code width of the last (0xFF or 0x3FF) is 1.5 lsb.
For 12-bit conversions the code transitions only after the full code width is present, so the
quantization error is -1 lsb to 0 lsb and the code width of each step is 1 lsb.
When FIFO is enabled, the analog input channel FIFO is written via ADCH. The analog
input channel queue must be written to ADCH continuously. The resulting FIFO follows
the order in which the analog input channel is written. The ADC will start conversion
when the input channel FIFO is fulfilled at the depth indicated by the
ADC_SC4[AFDEP]. Any write 0x1F to these bits will reset the FIFO and stop the
conversion if it is active.
Address: 4003_B000h base + 0h offset = 4003_B000h
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
COCO
R 0 ADCO
AIEN ADCH
Reset 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1
0 One conversion following a write to the ADC_SC1 when software triggered operation is selected, or
one conversion following assertion of ADHWT when hardware triggered operation is selected. When
the FIFO function is enabled (AFDEP > 0), a set of conversions are triggered.
1 Continuous conversions are initiated following a write to ADC_SC1 when software triggered operation
is selected. Continuous conversions are initiated by an ADHWT event when hardware triggered
operation is selected. When the FIFO function is enabled (AFDEP > 0), a set of conversions are loop
triggered.
ADCH Input Channel Select
The ADCH bits form a 5-bit field that selects one of the input channels.
00000-01111 AD0-AD15
10000-10011 VSS
10100-10101 Reserved
10110 Temperature Sensor
10111 Bandgap
11000-11100 Reserved
11101 VREFH
11110 VREFL
11111 Module disabled
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FEMPTY
ADACT
FFULL
R 0
ADTRG
ACFGT
ACFE
REFSEL
Reset 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0
ADLSMP
ADLPC
ADIV MODE ADICLK
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
00 8-bit conversion (N = 8)
01 10-bit conversion (N = 10)
10 12-bit conversion (N = 12)
11 Reserved
ADICLK Input Clock Select
ADICLK bits select the input clock source to generate the internal clock ADCK.
00 Bus clock
01 Bus clock divided by 2
10 Alternate clock (ALTCLK)
11 Asynchronous clock (ADACK)
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 0
ASCANE
ACFSEL
AFDEP
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
If the MODE bits are changed, any data in ADC_R becomes invalid.
Address: 4003_B000h base + 10h offset = 4003_B010h
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 ADR
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
This register holds the compare value. Bits ADCV11:ADCV0 are compared to the 12 bits
of the result following a conversion in 12-bit mode.
Address: 4003_B000h base + 14h offset = 4003_B014h
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 CV
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 ADPC
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
25.1 Introduction
The analog comparator module (ACMP) provides a circuit for comparing two analog
input voltages. The comparator circuit is designed to operate across the full range of the
supply voltage (rail-to-rail operation).
The analog mux provides a circuit for selecting an analog input signal from four
channels. One signal provided by the 6-bit DAC. The mux circuit is designed to operate
across the full range of the supply voltage. The 6-bit DAC is 64-tap resistor ladder
network which provides a selectable voltage reference for applications where voltage
reference is needed. The 64-tap resistor ladder network divides the supply reference Vin
into 64 voltage level. A 6-bit digital signal input selects output voltage level, which varies
from Vin to Vin/64. Vin can be selected from two voltage sources.
25.1.1 Features
ACMP features include:
• Operational over the whole supply range of 2.7 V to 5.5 V
• On-chip 6-bit resolution DAC with selectable reference voltage from VDD or internal
bandgap
• Configurable hysteresis
• Selectable interrupt on rising edge, falling edge, or both rising or falling edges of
comparator output
• Selectable inversion on comparator output
• Up to four selectable comparator inputs
• Operational in Stop mode
DACREF
VDDA
MUX
Bandgap
ACPSEL
DACVAL
MUX
DACEN ACNSEL
+
External Output
–
ACMP0
MUX
Edge Control Interrupt
ACMP1
ACMP2 HYST Logic
Read ACO
ACE HYST ACF ACIE ACOPE ACMOD
Write
Reset 0 0 0 0 0 0 0 0
0 20 mV.
1 30 mV.
5 ACMP Interrupt Flag Bit
ACF
Synchronously set by hardware when ACMP output has a valid edge defined by ACMOD. The setting of
this bit lags the ACMPO to bus clocks. Clear ACF bit by writing a 0 to this bit. Writing a 1 to this bit has no
effect.
4 ACMP Interrupt Enable
ACIE
Enables an ACMP CPU interrupt.
Read 0 0
ACPSEL ACNSEL
Write
Reset 0 0 0 0 0 0 0 0
00 External reference 0
01 External reference 1
10 External reference 2
11 DAC output
Selects the output voltage using the given formula: Voutput= (Vin/64)x(DACVAL[5:0]+1) The Voutput range is
from Vin/64 to Vin, the step is Vin/64
Read 0 ACIPE
Write
Reset 0 0 0 0 0 0 0 0
This 3-bit field controls if the corresponding ACMP external pin can be driven by an analog input.
reference inputs and one internal reference input from the DAC output. The positive input
of ACMP is selected by ACMP_C0[ACPSEL] and the negative input is selected by
ACMP_C0[ACNSEL]. Any pair of the eight inputs can be compared by configuring the
ACMPC0 with the appropriate value.
After the ACMP is enabled by setting ACMP_CS[ACE], the comparison result appears
as a digital output. Whenever a valid edge defined in ACMP_CS[ACMOD] occurs,
ACMP_CS[ACF] is asserted. If ACMP_CS[ACIE] is set, a ACMP CPU interrupt occurs.
The valid edge is defined by ACMP_CS[ACMOD]. When ACMP_CS[ACMOD] = 00b
or 10b, only the falling-edge on ACMP output is valid. When ACMP_CS[ACMOD] =
01b, only rising-edge on ACMP output is valid. When ACMP_CS[ACMOD] = 11b, both
the rising-edge and falling-edge on the ACMP output are valid.
The ACMP output is synchronized by the bus clock to generate ACMP_CS[ACO] so that
the CPU can read the comparison. In stop3 mode, if the output of ACMP is changed,
ACMPO cannot be updated in time. The output can be synchronized and
ACMP_CS[ACO] can be updated upon the waking up of the CPU because of the
availability of the bus clock. ACMP_CS[ACO] changes following the comparison result,
so it can serve as a tracking flag that continuously indicates the voltage delta on the
inputs.
If a reference input external to the chip is selected as an input of ACMP, the
corresponding ACMP_C2[ACIPE] bit must be set to enable the input from pad interface.
If the output of the ACMP needs to be put onto the external pin, the ACMP_CS[ACOPE]
bit must enable the ACMP pin function of pad logic.
25.6 Resets
During a reset the ACMP is configured in the default mode. Both CMP and DAC are
disabled.
25.7 Interrupts
If the bus clock is available when a valid edge defined in ACMP_CS[ACMOD] occurs,
the ACMP_CS[ACF] is asserted. If ACMP_CS[ACIE] is set, a ACMP interrupt event
occurs. The ACMP_CS[ACF] bit remains asserted until the ACMP interrupt is cleared by
software. When in stop mode, a valid edge on ACMP output generates an asynchronous
interrupt that can wake the MCU from stop. The interrupt can be cleared by writing a 0 to
the ACMP_CS[ACF] bit.
26.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances, see the chip configuration information.
The FlexTimer module (FTM) is a two-to-eight channel timer that supports input capture,
output compare, and the generation of PWM signals to control electric motor and power
management applications. The FTM time reference is a 16-bit counter that can be used as
an unsigned or signed counter.
Motor control and power conversion features have been added through a dedicated set of
registers and defaults turn off all new features. The new features, such as hardware
deadtime insertion, polarity, fault control, and output forcing and masking, greatly reduce
loading on the execution software and are usually each controlled by a group of registers.
FlexTimer input triggers can be from comparators, ADC, or other submodules to initiate
timer functions automatically. These triggers can be linked in a variety of ways during
integration of the sub modules so please note the options available for used FlexTimer
configuration.
Several FlexTimers may be synchronized to provide a larger timer with their counters
incrementing in unison, assuming the initialization, the input clocks, the initial and final
counting values are the same in each FlexTimer.
All main user access registers are buffered to ease the load on the executing software. A
number of trigger options exist to determine which registers are updated with this user
defined data.
26.1.2 Features
The FTM features include:
• FTM source clock is selectable
• Source clock can be the system clock, the fixed frequency clock, or an external
clock
• Fixed frequency clock is an additional clock input to allow the selection of an on
chip clock source other than the system clock
• Selecting external clock connects FTM clock to a chip level input pin therefore
allowing to synchronize the FTM counter with an off chip clock source
• Prescaler divide-by 1, 2, 4, 8, 16, 32, 64, or 128
• 16-bit counter
• It can be a free-running counter or a counter with initial and final value
• The counting can be up or up-down
• Each channel can be configured for input capture, output compare, or edge-aligned
PWM mode
• In Input Capture mode:
• The capture can occur on rising edges, falling edges or both edges
• An input filter can be selected for some channels
• In Output Compare mode the output signal can be set, cleared, or toggled on match
• All channels can be configured for center-aligned PWM mode
• Each pair of channels can be combined to generate a PWM signal with independent
control of both edges of PWM signal
• The FTM channels can operate as pairs with equal outputs, pairs with
complementary outputs, or independent channels with independent outputs
• The deadtime insertion is available for each complementary pair
• Generation of match triggers
• Software control of PWM outputs
• Up to 4 fault inputs for global fault control
• The polarity of each channel is configurable
• The generation of an interrupt per channel
• The generation of an interrupt when the counter overflows
• The generation of an interrupt when the fault condition is detected
• Synchronized loading of write buffered FTM registers
• Write protection for critical registers
• Backwards compatible with TPM
• Testing of input captures for a stuck at zero and one conditions
• Dual edge capture for pulse and period width measurement
real time reference or provide the interrupt sources needed to wake the MCU from Wait
mode, the power can then be saved by disabling FTM functions before entering Wait
mode.
CLKS
FTMEN
no clock selected
(FTM counter disable) PS
system clock
fixed frequency clock
external clock prescaler
synchronizer
(1, 2, 4, 8, 16, 32, 64 or 128)
CPWMS
CAPTEST INITTRIGEN initialization
CNTIN trigger
FAULTM[1:0]
FTM counter TOIE timer overflow
MOD TOF interrupt
FFVAL[3:0]
FAULTIE
FAULTIN
FAULTnEN*
FAULTF
FFLTRnEN*
FAULTFn*
fault control fault interrupt
fault input n* *where n = 3, 2, 1, 0
fault condition
channel 0
input input capture output modes logic
mode logic C0V channel 0
(generation of channels 0 and 1 outputs signals in output
compare, EPWM, CPWM and combine modes according to output signal
initialization, complementary mode, inverting, software output channel 1
input capture C1V control, deadtime insertion, output mask, fault control output signal
channel 1 mode logic and polarity control)
input
DECAPEN
COMBINE0 CH1F channel 1
interrupt channel 1
CPWMS CH1IE CH1TRIG match trigger
MS1B:MS1A
ELS1B:ELS1A
channel 6
input input capture output modes logic
mode logic C6V channel 6
(generation of channels 6 and 7 outputs signals in output
compare, EPWM, CPWM and combine modes according to output signal
initialization, complementary mode, inverting, software output channel 7
input capture C7V control, deadtime insertion, output mask, fault control output signal
channel 7 mode logic and polarity control)
input
DECAPEN
COMBINE3 CH7F channel 7 channel 7
CPWMS CH7IE
interrupt CH7TRIG match trigger
MS7B:MS7A
ELS7B:ELS7A
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TOF
R 0
CPWMS
TOIE CLKS PS
W 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Selects one of 8 division factors for the clock source selected by CLKS. The new prescaler factor affects
the clock source on the next system clock cycle after the new value is updated into the register bits.
This field is write protected. It can be written only when MODE[WPDIS] = 1.
000 Divide by 1
001 Divide by 2
010 Divide by 4
011 Divide by 8
100 Divide by 16
101 Divide by 32
110 Divide by 64
111 Divide by 128
R 0
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 CHF 0 0
CHIE MSB MSA ELSB ELSA
W 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
If FTMEN = 0, this write coherency mechanism may be manually reset by writing to the
CnSC register whether Debug mode is active or not.
Address: Base address + 10h offset + (8d × i), where i=0d to 7d
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 VAL
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Captured FTM counter value of the input modes or the match value for the output modes
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
CH7F
CH6F
CH5F
CH4F
CH3F
CH2F
CH1F
CH0F
R 0
W 0 0 0 0 0 0 0 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PWMSYNC
0
CAPTEST
R
FAULTIE
FTMEN
WPDIS
FAULTM INIT
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
0 No restrictions. Software and hardware triggers can be used by MOD, CnV, OUTMASK, and FTM
counter synchronization.
1 Software trigger can only be used by MOD and CnV synchronization, and hardware triggers can only
be used by OUTMASK and FTM counter synchronization.
2 Write Protection Disable
WPDIS
When write protection is enabled (WPDIS = 0), write protected bits cannot be written. When write
protection is disabled (WPDIS = 1), write protected bits can be written. The WPDIS bit is the negation of
the WPEN bit. WPDIS is cleared when 1 is written to WPEN. WPDIS is set when WPEN bit is read as a 1
and then 1 is written to WPDIS. Writing 0 to WPDIS has no effect.
0 Only the TPM-compatible registers (first set of registers) can be used without any restriction. Do not
use the FTM-specific registers.
1 All registers including the FTM-specific registers (second set of registers) are available for use with no
restrictions.
NOTE
The software trigger, SWSYNC bit, and hardware triggers
TRIG0, TRIG1, and TRIG2 bits have a potential conflict if
used together when SYNCMODE = 0. Use only hardware or
software triggers but not both at the same time, otherwise
unpredictable behavior is likely to happen.
The selection of the loading point, CNTMAX and CNTMIN
bits, is intended to provide the update of MOD, CNTIN, and
CnV registers across all enabled channels simultaneously. The
use of the loading point selection together with SYNCMODE =
0 and hardware trigger selection, TRIG0, TRIG1, or TRIG2
bits, is likely to result in unpredictable behavior.
The synchronization event selection also depends on the
PWMSYNC (MODE register) and SYNCMODE (SYNCONF
register) bits. See PWM synchronization.
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SYNCHOM
R 0
SWSYNC
CNTMAX
CNTMIN
REINIT
TRIG2
TRIG1
TRIG0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 Trigger is disabled.
1 Trigger is enabled.
5 PWM Synchronization Hardware Trigger 1
TRIG1
Enables hardware trigger 1 to the PWM synchronization. Hardware trigger 1 happens when a rising edge
is detected at the trigger 1 input signal.
0 Trigger is disabled.
1 Trigger is enabled.
4 PWM Synchronization Hardware Trigger 0
TRIG0
Enables hardware trigger 0 to the PWM synchronization. Hardware trigger 0 happens when a rising edge
is detected at the trigger 0 input signal.
0 Trigger is disabled.
1 Trigger is enabled.
3 Output Mask Synchronization
SYNCHOM
Selects when the OUTMASK register is updated with the value of its buffer.
0 OUTMASK register is updated with the value of its buffer in all rising edges of the system clock.
1 OUTMASK register is updated with the value of its buffer only by the PWM synchronization.
2 FTM Counter Reinitialization By Synchronization (FTM counter synchronization)
REINIT
Determines if the FTM counter is reinitialized when the selected trigger for the synchronization is detected.
The REINIT bit configures the synchronization when SYNCMODE is zero.
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0
CH7OI
CH6OI
CH5OI
CH4OI
CH3OI
CH2OI
CH1OI
CH0OI
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0
CH7OM
CH6OM
CH5OM
CH4OM
CH3OM
CH2OM
CH1OM
CH0OM
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DECAPEN3
DECAPEN2
0 0
COMBINE3
COMBINE2
FAULTEN3
FAULTEN2
R
SYNCEN3
SYNCEN2
DECAP3
DECAP2
COMP3
COMP2
DTEN3
DTEN2
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
DECAPEN1
DECAPEN0
0 COMBINE1 0
COMBINE0
FAULTEN1
FAULTEN0
R
SYNCEN1
SYNCEN0
DECAP1
DECAP0
COMP1
COMP0
DTEN1
DTEN0
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 The channel (n+1) output is the same as the channel (n) output.
1 The channel (n+1) output is the complement of the channel (n) output.
24 Combine Channels For n = 6
COMBINE3
Enables the combine feature for channels (n) and (n+1).
This field is write protected. It can be written only when MODE[WPDIS] = 1.
0 The channel (n+1) output is the same as the channel (n) output.
1 The channel (n+1) output is the complement of the channel (n) output.
16 Combine Channels For n = 4
COMBINE2
Enables the combine feature for channels (n) and (n+1).
This field is write protected. It can be written only when MODE[WPDIS] = 1.
0 The channel (n+1) output is the same as the channel (n) output.
1 The channel (n+1) output is the complement of the channel (n) output.
8 Combine Channels For n = 2
COMBINE1
Enables the combine feature for channels (n) and (n+1).
This field is write protected. It can be written only when MODE[WPDIS] = 1.
0 The channel (n+1) output is the same as the channel (n) output.
1 The channel (n+1) output is the complement of the channel (n) output.
Selects the deadtime insertion value for the deadtime counter. The deadtime counter is clocked by a
scaled version of the system clock. See the description of DTPS.
Deadtime insert value = (DTPS × DTVAL).
DTVAL selects the number of deadtime counts inserted as follows:
When DTVAL is 0, no counts are inserted.
When DTVAL is 1, 1 count is inserted.
When DTVAL is 2, 2 counts are inserted.
This pattern continues up to a possible 63 counts.
This field is write protected. It can be written only when MODE[WPDIS] = 1.
Reserved
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TRIGF
R
INITTRIGEN
CH1TRIG
CH0TRIG
CH5TRIG
CH4TRIG
CH3TRIG
CH2TRIG
Reserved
W 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R
W
Reserved POL7 POL6 POL5 POL4 POL3 POL2 POL1 POL0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FAULTF3
FAULTF2
FAULTF1
FAULTF0
FAULTIN
FAULTF
R 0 0
WPEN
W 0 0 0 0 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
This register selects the filter value for the fault inputs, enables the fault inputs and the
fault inputs filter.
Address: Base address + 7Ch offset
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
FAULT3EN
FAULT2EN
FAULT1EN
FAULT0EN
FFLTR3EN
FFLTR2EN
FFLTR1EN
FFLTR0EN
R 0
FFVAL
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
This register selects the number of times that the FTM counter overflow should occur
before the TOF bit to be set, the FTM behavior in Debug modes, the use of an external
global time base, and the global time base signal generation.
Address: Base address + 84h offset
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0
GTBEOUT
R
GTBEEN
BDMMODE NUMTOF
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Selects the ratio between the number of counter overflows to the number of times the TOF bit is set.
NUMTOF = 0: The TOF bit is set for each counter overflow.
NUMTOF = 1: The TOF bit is set for the first counter overflow but not for the next overflow.
NUMTOF = 2: The TOF bit is set for the first counter overflow but not for the next 2 overflows.
NUMTOF = 3: The TOF bit is set for the first counter overflow but not for the next 3 overflows.
This pattern continues up to a maximum of 31.
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0
FLT3POL
FLT2POL
FLT1POL
FLT0POL
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 The fault input polarity is active high. A one at the fault input indicates a fault.
1 The fault input polarity is active low. A zero at the fault input indicates a fault.
2 Fault Input 2 Polarity
FLT2POL
Defines the polarity of the fault input.
This field is write protected. It can be written only when MODE[WPDIS] = 1.
0 The fault input polarity is active high. A one at the fault input indicates a fault.
1 The fault input polarity is active low. A zero at the fault input indicates a fault.
1 Fault Input 1 Polarity
FLT1POL
Defines the polarity of the fault input.
This field is write protected. It can be written only when MODE[WPDIS] = 1.
0 The fault input polarity is active high. A one at the fault input indicates a fault.
1 The fault input polarity is active low. A zero at the fault input indicates a fault.
0 Fault Input 0 Polarity
FLT0POL
Defines the polarity of the fault input.
This field is write protected. It can be written only when MODE[WPDIS] = 1.
0 The fault input polarity is active high. A one at the fault input indicates a fault.
1 The fault input polarity is active low. A zero at the fault input indicates a fault.
HWRSTCNT
0
HWWRBUF
R
HWINVC
HWSOC
HWOM
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
HWTRIGMOD
SYNCMODE
0 SWRSTCNT 0 0 0
SWWRBUF
R
SWINVC
SWSOC
CNTINC
SWOM
SWOC
INVC
E
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0
INV3EN
INV2EN
INV1EN
INV0EN
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R
CH7OCV
CH6OCV
CH5OCV
CH4OCV
CH3OCV
CH2OCV
CH1OCV
CH0OCV
CH7OC
CH6OC
CH5OC
CH4OC
CH3OC
CH2OC
CH1OC
CH0OC
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 0
CH7SEL
CH6SEL
CH5SEL
CH4SEL
CH3SEL
CH2SEL
CH1SEL
CH0SEL
LDOK
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
prescaler counter 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
FTM counter 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2
The external clock passes through a synchronizer clocked by the system clock to assure
that counter transitions are properly aligned to system clock transitions.Therefore, to
meet Nyquist criteria considering also jitter, the frequency of the external clock source
must not exceed 1/4 of the system clock frequency.
26.4.2 Prescaler
The selected counter clock source passes through a prescaler that is a 7-bit counter. The
value of the prescaler is selected by the PS[2:0] bits. The following figure shows an
example of the prescaler counter and FTM counter.
FTM counting is up.
PS[2:0] = 001
CNTIN = 0x0000
MOD = 0x0003
prescaler counter 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
FTM counter 0 1 2 3 0 1 2 3 0 1
26.4.3 Counter
The FTM has a 16-bit counter that is used by the channels either for input or output
modes. The FTM counter clock is the selected clock divided by the prescaler.
The FTM counter has these modes of operation:
• Up counting
• Up-down counting
26.4.3.1 Up counting
Up counting is selected when:
• CPWMS = 0
CNTIN defines the starting value of the count and MOD defines the final value of the
count, see the following figure. The value of CNTIN is loaded into the FTM counter, and
the counter increments until the value of MOD is reached, at which point the counter is
reloaded with the value of CNTIN.
The FTM period when using up counting is (MOD – CNTIN + 0x0001) × period of the
FTM counter clock.
The TOF bit is set when the FTM counter changes from MOD to CNTIN.
FTM counting is up.
CNTIN = 0xFFFC (in two's complement is equal to -4)
MOD = 0x0004
TOF bit
FTM counter 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2
TOF bit
Note
• FTM operation is only valid when the value of the CNTIN
register is less than the value of the MOD register, either in
the unsigned counting or signed counting. It is the
responsibility of the software to ensure that the values in
the CNTIN and MOD registers meet this requirement. Any
values of CNTIN and MOD that do not satisfy this criteria
can result in unpredictable behavior.
• MOD = CNTIN is a redundant condition. In this case, the
FTM counter is always equal to MOD and the TOF bit is
set in each rising edge of the FTM counter clock.
• When MOD = 0x0000, CNTIN = 0x0000, for example
after reset, and FTMEN = 1, the FTM counter remains
stopped at 0x0000 until a non-zero value is written into the
MOD or CNTIN registers.
• Setting CNTIN to be greater than the value of MOD is not
recommended as this unusual setting may make the FTM
operation difficult to comprehend. However, there is no
restriction on this configuration, and an example is shown
in the following figure.
FTM counter 0x0005 0x0015 0x0016 ... 0xFFFE 0xFFFF 0x0000 0x0001 0x0002 0x0003 0x0004 0x0005 0x0015 0x0016 ...
TOF bit
Figure 26-166. Example of up counting when the value of CNTIN is greater than the
value of MOD
FTM counter 0 1 2 3 4 3 2 1 0 1 2 3 4 3 2 1 0 1 2 3 4
TOF bit
Note
It is expected that the up-down counting be used only with
CNTIN = 0x0000.
FTM counter ... 0x0003 0x0004 ... 0xFFFE 0xFFFF 0x0000 0x0001 0x0002 0x0003 0x0004 0x0005 0x0006 ...
TOF bit
FTM counter
NUMTOF[4:0] 0x02
TOF counter 0x01 0x02 0x00 0x01 0x02 0x00 0x01 0x02
FTM counter
NUMTOF[4:0] 0x00
was rising
edge selected?
is filter
enabled?
0 0 CHnIE channel (n) interrupt
CHnF
synchronizer rising edge
0 1
channel (n) input D Q D Q edge
detector CnV
Filter* 1
system clock CLK CLK 1
falling edge
0 0
was falling
edge selected?
* Filtering function is only available in the inputs of channel 0, 1, 2, and 3 FTM counter
If the channel input does not have a filter enabled, then the input signal is always delayed
3 rising edges of the system clock, that is, two rising edges to the synchronizer plus one
more rising edge to the edge detector. In other words, the CHnF bit is set on the third
rising edge of the system clock after a valid edge occurs on the channel input.
Note
The Input Capture mode must be used only with CNTIN =
0x0000.
CHnFVAL[3:0]
Logic to control
channel (n) input after the filter counter
the synchronizer filter output
S Q
filter counter Logic to define
C
the filter output
divided by 4
CLK
system clock
When there is a state change in the input signal, the counter is reset and starts counting
up. As long as the new state is stable on the input, the counter continues to increment.
When the counter is equal to CHnFVAL[3:0], the state change of the input signal is
validated. It is then transmitted as a pulse edge to the edge detector.
If the opposite edge appears on the input signal before it can be validated, the counter is
reset. At the next input transition, the counter starts counting again. Any pulse that is
shorter than the minimum value selected by CHnFVAL[3:0] (× 4 system clocks) is
regarded as a glitch and is not passed on to the edge detector. A timing diagram of the
input filter is shown in the following figure.
The filter function is disabled when CHnFVAL[3:0] bits are zero. In this case, the input
signal is delayed 3 rising edges of the system clock. If (CHnFVAL[3:0] ≠ 0000), then the
input signal is delayed by the minimum pulse width (CHnFVAL[3:0] × 4 system clocks)
plus a further 4 rising edges of the system clock: two rising edges to the synchronizer,
one rising edge to the filter output, plus one more to the edge detector. In other words,
CHnF is set (4 + 4 × CHnFVAL[3:0]) system clock periods after a valid edge occurs on
the channel input.
The clock for the counter in the channel input filter is the system clock divided by 4.
counter
CHnFVAL[3:0] = 0010
(binary value)
Time
filter output
TOF bit
Figure 26-174. Example of the Output Compare mode when the match toggles the
channel output
TOF bit
Figure 26-175. Example of the Output Compare mode when the match clears the
channel output
MOD = 0x0005
CnV = 0x0003
counter channel (n) counter channel (n) counter
overflow match overflow match overflow
TOF bit
Figure 26-176. Example of the Output Compare mode when the match sets the channel
output
If (ELSnB:ELSnA = 0:0) when the counter reaches the value in the CnV register, the
CHnF bit is set and the channel (n) interrupt is generated if CHnIE = 1, however the
channel (n) output is not modified and controlled by FTM.
Note
The Output Compare mode must be used only with CNTIN =
0x0000.
The CHnF bit is set and the channel (n) interrupt is generated if CHnIE = 1 at the channel
(n) match (FTM counter = CnV), that is, at the end of the pulse width.
This type of PWM signal is called edge-aligned because the leading edges of all PWM
signals are aligned with the beginning of the period, which is the same for all channels
within an FTM.
counter overflow counter overflow counter overflow
period
pulse
width
Figure 26-177. EPWM period and pulse width with ELSnB:ELSnA = 1:0
If (ELSnB:ELSnA = 0:0) when the counter reaches the value in the CnV register, the
CHnF bit is set and the channel (n) interrupt is generated if CHnIE = 1, however the
channel (n) output is not controlled by FTM.
If (ELSnB:ELSnA = 1:0), then the channel (n) output is forced high at the counter
overflow when the CNTIN register value is loaded into the FTM counter, and it is forced
low at the channel (n) match (FTM counter = CnV). See the following figure.
MOD = 0x0008
CnV = 0x0005
counter channel (n) counter
overflow match overflow
TOF bit
If (ELSnB:ELSnA = X:1), then the channel (n) output is forced low at the counter
overflow when the CNTIN register value is loaded into the FTM counter, and it is forced
high at the channel (n) match (FTM counter = CnV). See the following figure.
TOF bit
If (CnV = 0x0000), then the channel (n) output is a 0% duty cycle EPWM signal and
CHnF bit is not set even when there is the channel (n) match. If (CnV > MOD), then the
channel (n) output is a 100% duty cycle EPWM signal and CHnF bit is not set even when
there is the channel (n) match. Therefore, MOD must be less than 0xFFFF in order to get
a 100% duty cycle EPWM signal.
Note
The EPWM mode must be used only with CNTIN = 0x0000.
counter overflow channel (n) match channel (n) match counter overflow
FTM counter = (FTM counting (FTM counting FTM counter =
MOD is down) is up) MOD
Figure 26-180. CPWM period and pulse width with ELSnB:ELSnA = 1:0
If (ELSnB:ELSnA = 0:0) when the FTM counter reaches the value in the CnV register,
the CHnF bit is set and the channel (n) interrupt is generated (if CHnIE = 1), however the
channel (n) output is not controlled by FTM.
If (ELSnB:ELSnA = 1:0), then the channel (n) output is forced high at the channel (n)
match (FTM counter = CnV) when counting down, and it is forced low at the channel (n)
match when counting up. See the following figure.
MOD = 0x0008 counter counter
CnV = 0x0005 overflow overflow
channel (n) match in channel (n) match in channel (n) match in
down counting up counting down counting
TOF bit
If (ELSnB:ELSnA = X:1), then the channel (n) output is forced low at the channel (n)
match (FTM counter = CnV) when counting down, and it is forced high at the channel (n)
match when counting up. See the following figure.
MOD = 0x0008 counter counter
CnV = 0x0005 overflow overflow
channel (n) match in channel (n) match in channel (n) match in
down counting up counting down counting
TOF bit
If (CnV = 0x0000) or CnV is a negative value, that is (CnV[15] = 1), then the channel (n)
output is a 0% duty cycle CPWM signal and CHnF bit is not set even when there is the
channel (n) match.
If CnV is a positive value, that is (CnV[15] = 0), (CnV ≥ MOD), and (MOD ≠ 0x0000),
then the channel (n) output is a 100% duty cycle CPWM signal and CHnF bit is not set
even when there is the channel (n) match. This implies that the usable range of periods
set by MOD is 0x0001 through 0x7FFE, 0x7FFF if you do not need to generate a 100%
duty cycle CPWM signal. This is not a significant limitation because the resulting period
is much longer than required for normal applications.
The CPWM mode must not be used when the FTM counter is a free running counter.
Note
The CPWM mode must be used only with CNTIN = 0x0000.
If (ELSnB:ELSnA = X:1), then the channel (n) output is forced high at the beginning of
the period (FTM counter = CNTIN) and at the channel (n+1) match (FTM counter = C(n
+1)V). It is forced low at the channel (n) match (FTM counter = C(n)V). See the
following figure.
In Combine mode, the ELS(n+1)B and ELS(n+1)A bits are not used in the generation of
the channels (n) and (n+1) output. However, if (ELSnB:ELSnA = 0:0) then the channel
(n) output is not controlled by FTM, and if (ELS(n+1)B:ELS(n+1)A = 0:0) then the
channel (n+1) output is not controlled by FTM.
channel (n+1) match
FTM counter
channel (n) match
The following figures illustrate the PWM signals generation using Combine mode.
FTM counter
MOD
C(n+1)V
C(n)V
CNTIN
Figure 26-184. Channel (n) output if (CNTIN < C(n)V < MOD) and (CNTIN < C(n+1)V <
MOD) and (C(n)V < C(n+1)V)
C(n)V
CNTIN
Figure 26-185. Channel (n) output if (CNTIN < C(n)V < MOD) and (C(n+1)V = MOD)
FTM counter
MOD
C(n+1)V
C(n)V = CNTIN
Figure 26-186. Channel (n) output if (C(n)V = CNTIN) and (CNTIN < C(n+1)V < MOD)
FTM counter
MOD = C(n+1)V
C(n)V
CNTIN
Figure 26-187. Channel (n) output if (CNTIN < C(n)V < MOD) and (C(n)V is Almost Equal
to CNTIN) and (C(n+1)V = MOD)
C(n+1)V
C(n)V = CNTIN
Figure 26-188. Channel (n) output if (C(n)V = CNTIN) and (CNTIN < C(n+1)V < MOD) and
(C(n+1)V is Almost Equal to MOD)
FTM counter
C(n+1)V
MOD
CNTIN
C(n)V
Figure 26-189. Channel (n) output if C(n)V and C(n+1)V are not between CNTIN and MOD
MOD
C(n+1)V = C(n)V
CNTIN
Figure 26-190. Channel (n) output if (CNTIN < C(n)V < MOD) and (CNTIN < C(n+1)V <
MOD) and (C(n)V = C(n+1)V)
FTM counter
MOD
C(n)V =
C(n+1)V = CNTIN
CNTIN
C(n)V
C(n+1)V
CNTIN
Figure 26-193. Channel (n) output if (CNTIN < C(n)V < MOD) and (CNTIN < C(n+1)V <
MOD) and (C(n)V > C(n+1)V)
FTM counter
MOD
C(n+1)V
CNTIN
C(n)V
Figure 26-194. Channel (n) output if (C(n)V < CNTIN) and (CNTIN < C(n+1)V < MOD)
C(n)V
CNTIN
C(n+1)V
Figure 26-195. Channel (n) output if (C(n+1)V < CNTIN) and (CNTIN < C(n)V < MOD)
FTM counter
C(n)V
MOD
C(n+1)V
CNTIN
Figure 26-196. Channel (n) output if (C(n)V > MOD) and (CNTIN < C(n+1)V < MOD)
C(n+1)V
MOD
C(n)V
CNTIN
Figure 26-197. Channel (n) output if (C(n+1)V > MOD) and (CNTIN < C(n)V < MOD)
FTM counter
C(n+1)V
MOD = C(n)V
CNTIN
Figure 26-198. Channel (n) output if (C(n+1)V > MOD) and (CNTIN < C(n)V = MOD)
• FTMEN = 1
• DECAPEN = 0
• COMBINE = 1
• CPWMS = 0, and
• COMP = 1
In Complementary mode, the channel (n+1) output is the inverse of the channel (n)
output.
So, the channel (n+1) output is the same as the channel (n) output when:
• FTMEN = 1
• DECAPEN = 0
• COMBINE = 1
• CPWMS = 0, and
• COMP = 0
channel (n+1) match
FTM counter
channel (n) match
Figure 26-199. Channel (n+1) output in Complementary mode with (ELSnB:ELSnA = 1:0)
FTM counter
channel (n) match
Figure 26-200. Channel (n+1) output in Complementary mode with (ELSnB:ELSnA = X:1)
If (HWTRIGMODE = 0) then the TRIGn bit is cleared when 0 is written to it or when the
trigger n event is detected.
In this case, if two or more hardware triggers are enabled (for example, TRIG0 and
TRIG1 = 1) and only trigger 1 event occurs, then only TRIG1 bit is cleared. If a trigger n
event occurs together with a write setting TRIGn bit, then the synchronization is initiated,
but TRIGn bit remains set due to the write operation.
system clock
TRIG0 bit
trigger_0 input
synchronized trigger_0
by system clock
trigger 0 event
Note
All hardware trigger inputs have the same behavior.
If HWTRIGMODE = 1, then the TRIGn bit is only cleared when 0 is written to it.
NOTE
The HWTRIGMODE bit must be 1 only with enhanced PWM
synchronization (SYNCMODE = 1).
software trigger event occurred; see Boundary cycle and loading points and the following
figure. If (PWMSYNC = 0) and (REINIT = 1) then SWSYNC bit is cleared when the
software trigger event occurs.
If SYNCMODE = 1 then the SWSYNC bit is also cleared by FTM according to the
SWRSTCNT bit. If SWRSTCNT = 0 then SWSYNC bit is cleared at the next selected
loading point after that the software trigger event occurred; see the following figure. If
SWRSTCNT = 1 then SWSYNC bit is cleared when the software trigger event occurs.
system clock
SWSYNC bit
PWM synchronization
selected loading point
up counting mode
begin
legacy =0
PWM synchronization SYNCMODE
bit ?
=1
enhanced PWM synchronization
software hardware
trigger trigger
0= TRIGn
=0
SWSYNC
bit ? bit ?
=1
=1
FTM counter is reset by
software trigger
=0
=1 wait hardware trigger n
SWRSTCNT
bit ?
end end
In the case of legacy PWM synchronization, the MOD register synchronization depends
on PWMSYNC and REINIT bits according to the following description.
If (SYNCMODE = 0), (PWMSYNC = 0), and (REINIT = 0), then this synchronization is
made on the next selected loading point after an enabled trigger event takes place. If the
trigger event was a software trigger, then the SWSYNC bit is cleared on the next selected
loading point. If the trigger event was a hardware trigger, then the trigger enable bit
(TRIGn) is cleared according to Hardware trigger. Examples with software and hardware
triggers follow.
system clock
SWSYNC bit
Figure 26-205. MOD synchronization with (SYNCMODE = 0), (PWMSYNC = 0), (REINIT =
0), and software trigger was used
system clock
TRIG0 bit
trigger 0 event
If (SYNCMODE = 0), (PWMSYNC = 0), and (REINIT = 1), then this synchronization is
made on the next enabled trigger event. If the trigger event was a software trigger, then
the SWSYNC bit is cleared according to the following example. If the trigger event was a
hardware trigger, then the TRIGn bit is cleared according to Hardware trigger. Examples
with software and hardware triggers follow.
system clock
SWSYNC bit
Figure 26-207. MOD synchronization with (SYNCMODE = 0), (PWMSYNC = 0), (REINIT =
1), and software trigger was used
system clock
TRIG0 bit
trigger 0 event
system clock
SWSYNC bit
begin
1= =0
SYNCMODE
no = rising edge bit ?
of system
clock ?
legacy
= yes PWM synchronization
update OUTMASK
with its buffer value
end
update OUTMASK
end with its buffer value
=1
HWTRIGMODE
bit ?
=0
end
system clock
SWSYNC bit
system clock
TRIG0 bit
trigger 0 event
system clock
TRIG0 bit
trigger 0 event
begin
update INVCTRL register at
each rising edge of system clock update INVCTRL register by
PWM synchronization
0= INVC =1
bit ?
1= =0
SYNCMODE
bit ?
no = rising edge
of system end
clock ?
= yes
update INVCTRL
with its buffer value
end
update INVCTRL
wait hardware trigger n
with its buffer value
update INVCTRL
end with its buffer value
=1
HWTRIGMODE
bit ?
=0
end
The SWOCTRL register can be updated at each rising edge of system clock (SWOC = 0)
or by the enhanced PWM synchronization (SWOC = 1 and SYNCMODE = 1) according
to the following flowchart.
In the case of enhanced PWM synchronization, the SWOCTRL register synchronization
depends on SWSOC and HWSOC bits.
begin
update SWOCTRL register at
each rising edge of system clock update SWOCTRL register by
0= =1 PWM synchronization
SWOC
bit ?
1= =0
SYNCMODE
bit ?
no = rising edge
of system end
clock ?
= yes
update SWOCTRL
with its buffer value
end
update SWOCTRL
wait hardware trigger n
with its buffer value
update SWOCTRL
end with its buffer value
=1
HWTRIGMODE
bit ?
=0
end
FTM counter
channel (n) match
synchronization event
The FTM counter synchronization can be done by either the enhanced PWM
synchronization (SYNCMODE = 1) or the legacy PWM synchronization (SYNCMODE
= 0). However, the FTM counter must be synchronized only by the enhanced PWM
synchronization.
In the case of enhanced PWM synchronization, the FTM counter synchronization
depends on SWRSTCNT and HWRSTCNT bits according to the following flowchart.
begin
legacy =0
PWM synchronization SYNCMODE
bit ?
=1
enhanced PWM synchronization
end
=1
HWTRIGMODE
bit ?
=0
end
In the case of legacy PWM synchronization, the FTM counter synchronization depends
on REINIT and PWMSYNC bits according to the following description.
If (SYNCMODE = 0), (REINIT = 1), and (PWMSYNC = 0) then this synchronization is
made on the next enabled trigger event. If the trigger event was a software trigger then
the SWSYNC bit is cleared according to the following example. If the trigger event was a
hardware trigger then the TRIGn bit is cleared according to Hardware trigger. Examples
with software and hardware triggers follow.
system clock
SWSYNC bit
Figure 26-218. FTM counter synchronization with (SYNCMODE = 0), (REINIT = 1),
(PWMSYNC = 0), and software trigger was used
system clock
TRIG0 bit
trigger 0 event
Figure 26-219. FTM counter synchronization with (SYNCMODE = 0), (HWTRIGMODE = 0),
(REINIT = 1), (PWMSYNC = 0), and a hardware trigger was used
system clock
TRIG0 bit
trigger 0 event
Figure 26-220. FTM counter synchronization with (SYNCMODE = 0), (HWTRIGMODE = 0),
(REINIT = 1), (PWMSYNC = 1), and a hardware trigger was used
26.4.12 Inverting
The invert functionality swaps the signals between channel (n) and channel (n+1)
outputs. The inverting operation is selected when:
• FTMEN = 1
• DECAPEN = 0
• COMBINE = 1
• COMP = 1
• CPWMS = 0, and
• INVm = 1 (where m represents a channel pair)
The INVm bit in INVCTRL register is updated with its buffer value according to
INVCTRL register synchronization
In High-True (ELSnB:ELSnA = 1:0) Combine mode, the channel (n) output is forced low
at the beginning of the period (FTM counter = CNTIN), forced high at the channel (n)
match and forced low at the channel (n+1) match. If the inverting is selected, the channel
(n) output behavior is changed to force high at the beginning of the PWM period, force
low at the channel (n) match and force high at the channel (n+1) match. See the following
figure.
FTM counter
channel (n) match
INVCTRL register
synchronization
INV(m) bit
NOTE
INV(m) bit selects the inverting to the pair channels (n) and (n+1).
Figure 26-221. Channels (n) and (n+1) outputs after the inverting in High-True
(ELSnB:ELSnA = 1:0) Combine mode
Note that the ELSnB:ELSnA bits value should be considered because they define the
active state of the channels outputs. In Low-True (ELSnB:ELSnA = X:1) Combine mode,
the channel (n) output is forced high at the beginning of the period, forced low at the
channel (n) match and forced high at the channel (n+1) match. When inverting is
selected, the channels (n) and (n+1) present waveforms as shown in the following figure.
FTM counter
channel (n) match
INVCTRL register
synchronization
INV(m) bit
NOTE
INV(m) bit selects the inverting to the pair channels (n) and (n+1).
Figure 26-222. Channels (n) and (n+1) outputs after the inverting in Low-True
(ELSnB:ELSnA = X:1) Combine mode
Note
The inverting feature must be used only in Combine mode.
The following figure shows the channels (n) and (n+1) outputs signals when the software
output control is used. In this case the channels (n) and (n+1) are set to Combine and
Complementary mode.
channel (n+1) match
FTM counter
channel (n) match
CH(n)OC buffer
CH(n+1)OC buffer
CH(n)OC bit
CH(n+1)OC bit
NOTE
CH(n)OCV = 1 and CH(n+1)OCV = 0.
Software output control forces the following values on channels (n) and (n+1) when the
COMP bit is zero.
Table 26-242. Software ouput control behavior when (COMP = 0)
CH(n)OC CH(n+1)OC CH(n)OCV CH(n+1)OCV Channel (n) Output Channel (n+1) Output
0 0 X X is not modified by SWOC is not modified by SWOC
1 1 0 0 is forced to zero is forced to zero
1 1 0 1 is forced to zero is forced to one
1 1 1 0 is forced to one is forced to zero
1 1 1 1 is forced to one is forced to one
Software output control forces the following values on channels (n) and (n+1) when the
COMP bit is one.
Table 26-243. Software ouput control behavior when (COMP = 1)
CH(n)OC CH(n+1)OC CH(n)OCV CH(n+1)OCV Channel (n) Output Channel (n+1) Output
0 0 X X is not modified by SWOC is not modified by SWOC
1 1 0 0 is forced to zero is forced to zero
1 1 0 1 is forced to zero is forced to one
Note
• The software output control feature must be used only in
Combine mode.
• The CH(n)OC and CH(n+1)OC bits should be equal.
• The COMP bit must not be modified when software output
control is enabled, that is, CH(n)OC = 1 and/or CH(n
+1)OC = 1.
• Software output control has the same behavior with
disabled or enabled FTM counter (see the CLKS field
description in the Status and Control register).
when the channel (n+1) match (FTM counter = C(n+1)V) occurs, the channel (n+1)
output remains at the high value until the end of the deadtime delay when the channel (n
+1) output is cleared.
channel (n+1) match
FTM counter
channel (n) match
Figure 26-224. Deadtime insertion with ELSnB:ELSnA = 1:0, POL(n) = 0, and POL(n+1) =
0
FTM counter
channel (n) match
Figure 26-225. Deadtime insertion with ELSnB:ELSnA = X:1, POL(n) = 0, and POL(n+1) =
0
NOTE
The deadtime feature must be used only in Combine and
Complementary modes.
• and the deadtime delay is greater than or equal to the channel (n) duty cycle ((C(n
+1)V – C(n)V) × system clock), then the channel (n) output is always the inactive
value (POL(n) bit value).
• and the deadtime delay is greater than or equal to the channel (n+1) duty cycle
((MOD – CNTIN + 1 – (C(n+1)V – C(n)V) ) × system clock), then the channel (n+1)
output is always the inactive value (POL(n+1) bit value).
Although, in most cases the deadtime delay is not comparable to channels (n) and (n+1)
duty cycle, the following figures show examples where the deadtime delay is comparable
to the duty cycle.
channel (n+1) match
FTM counter
channel (n) match
Figure 26-226. Example of the deadtime insertion (ELSnB:ELSnA = 1:0, POL(n) = 0, and
POL(n+1) = 0) when the deadtime delay is comparable to channel (n+1) duty cycle
FTM counter
channel (n) match
Figure 26-227. Example of the deadtime insertion (ELSnB:ELSnA = 1:0, POL(n) = 0, and
POL(n+1) = 0) when the deadtime delay is comparable to channels (n) and (n+1) duty
cycle
FTM counter
CHnOM bit
The following table shows the output mask result before the polarity control.
Table 26-244. Output mask result for channel (n) before the polarity
control
CHnOM Output Mask Input Output Mask Result
0 inactive state inactive state
active state active state
1 inactive state inactive state
active state
Note
The output mask feature must be used only in Combine mode.
(FFVAL[3:0] 0000)
and (FFLTRnEN*)
FLTnPOL
synchronizer fault input n* value
0
fault input n* D Q D Q fault input
polarity rising edge
control FAULTFn*
Fault filter detector
(5-bit counter) 1
system clock CLK CLK
* where n = 3, 2, 1, 0
If the fault control and fault input n are enabled and a rising edge at the fault input n
signal is detected, a fault condition has occurred and the FAULTFn bit is set. The
FAULTF bit is the logic OR of FAULTFn[3:0] bits. See the following figure.
fault input 0 value
fault input 1 value
FAULTIN
fault input 2 value
fault input 3 value
If the fault control is enabled (FAULTM[1:0] ≠ 0:0), a fault condition has occurred and
(FAULTEN = 1), then outputs are forced to their safe values:
• Channel (n) output takes the value of POL(n)
• Channel (n+1) takes the value of POL(n+1)
The fault interrupt is generated when (FAULTF = 1) and (FAULTIE = 1). This interrupt
request remains set until:
• Software clears the FAULTF bit by reading FAULTF bit as 1 and writing 0 to it
• Software clears the FAULTIE bit
• A reset occurs
Note
The fault control must be used only in Combine mode.
FTM counter
FAULTIN bit
FAULTF bit
FTM counter
FAULTIN bit
FAULTF bit
Note
The polarity control must be used only in Combine mode.
26.4.18 Initialization
The initialization forces the CHnOI bit value to the channel (n) output when a one is
written to the INIT bit.
The initialization depends on COMP and DTEN bits. The following table shows the
values that channels (n) and (n+1) are forced by initialization when the COMP and
DTEN bits are zero.
Table 26-245. Initialization behavior when (COMP = 0 and DTEN = 0)
CH(n)OI CH(n+1)OI Channel (n) Output Channel (n+1) Output
0 0 is forced to zero is forced to zero
0 1 is forced to zero is forced to one
1 0 is forced to one is forced to zero
1 1 is forced to one is forced to one
The following table shows the values that channels (n) and (n+1) are forced by
initialization when (COMP = 1) or (DTEN = 1).
Table 26-246. Initialization behavior when (COMP = 1 or DTEN = 1)
CH(n)OI CH(n+1)OI Channel (n) Output Channel (n+1) Output
0 X is forced to zero is forced to one
1 X is forced to one is forced to zero
Note
The initialization feature must be used only in Combine mode
and with disabled FTM counter. See the description of the
CLKS field in the Status and Control register.
FTM counter
DECAPEN
COMBINE(m)
CPWMS
C(n)V
MS(n)B CH(n)OC
generation of channel
channel (n) (n)
output
output signal signal
software deadtime polarity
complementary output fault
initialization inverting output insertion control
mode mask control
control
generation of channel
(n+1)
channel (n+1)
output
output signal signal
C(n+1)V
MS(n+1)B
MS(n+1)A
ELS(n+1)B
ELS(n+1)A
NOTE
The channels (n) and (n+1) are in output compare, EPWM, CPWM or combine modes.
Figure 26-233. Priority of the features used at the generation of channels (n) and (n+1)
outputs signals
Note
The Initialization feature must not be used with Inverting and
Software output control features.
The FTM is able to generate multiple triggers in one PWM period. Because each trigger
is generated for a specific channel, several channels are required to implement this
functionality. This behavior is described in the following figure.
the beginning of new PWM cycles
MOD
(a)
(b)
(c)
(d)
NOTE
(a) CH0TRIG = 0, CH1TRIG = 0, CH2TRIG = 0, CH3TRIG = 0, CH4TRIG = 0, CH5TRIG = 0
(b) CH0TRIG = 1, CH1TRIG = 0, CH2TRIG = 0, CH3TRIG = 0, CH4TRIG = 0, CH5TRIG = 0
(c) CH0TRIG = 0, CH1TRIG = 0, CH2TRIG = 0, CH3TRIG = 1, CH4TRIG = 1, CH5TRIG = 1
(d) CH0TRIG = 1, CH1TRIG = 1, CH2TRIG = 1, CH3TRIG = 1, CH4TRIG = 1, CH5TRIG = 1
Note
The channel match trigger must be used only in Combine mode.
system clock
FTM counter 0x0C 0x0D 0x0E 0x0F 0x00 0x01 0x02 0x03 0x04 0x05
initialization trigger
Figure 26-235. Initialization trigger is generated when the FTM counting achieves the
CNTIN register value
CNTIN = 0x0000
MOD = 0x000F
CPWMS = 0
system clock
FTM counter 0x04 0x05 0x06 0x00 0x01 0x02 0x03 0x04 0x05 0x06
write to CNT
initialization trigger
Figure 26-236. Initialization trigger is generated when there is a write to CNT register
CNTIN = 0x0000
MOD = 0x000F
CPWMS = 0
system clock
FTM counter 0x04 0x05 0x06 0x07 0x00 0x01 0x02 0x03 0x04 0x05
FTM counter
synchronization
initialization trigger
Figure 26-237. Initialization trigger is generated when there is the FTM counter
synchronization
system clock
CLKS[1:0] bits 00 01
initialization trigger
Figure 26-238. Initialization trigger is generated if (CNT = CNTIN), (CLKS[1:0] = 0:0), and
a value different from zero is written to CLKS[1:0] bits
The initialization trigger output provides a trigger signal that is used for on-chip modules.
Note
The initialization trigger must be used only in Combine mode.
CAPTEST bit
FTM counter 0x1053 0x1054 0x1055 0x1056 0x78AC 0x78AD 0x78AE0x78AF 0x78B0
write 0x78AC
write to CNT
CHnF bit
0x0300 0x78AC
CnV
NOTE
- FTM counter configuration: (FTMEN = 1), (CAPTEST = 1), (CPWMS = 0), (CNTIN = 0x0000), and (MOD = 0xFFFF)
- FTM channel n configuration: input capture mode - (DECAPEN = 0), (COMBINE = 0), and (MSnB:MSnA = 0:0)
FTMEN
DECAPEN
is filter DECAP
enabled? channel (n)
MS(n)A CH(n)IE interrupt
ELS(n)B:ELS(n)A
CH(n)F
synchronizer ELS(n+1)B:ELS(n+1)A
0 C(n)V[15:0]
channel (n) input D Q D Q Dual edge capture
mode logic
channel (n+1)
Filter* 1 CH(n+1)IE interrupt
system clock CLK CLK
CH(n+1)F
C(n+1)V[15:0]
FTM counter
* Filtering function for dual edge capture mode is only available in the channels 0 and 2
The MS(n)A bit defines if the Dual Edge Capture mode is one-shot or continuous.
The ELS(n)B:ELS(n)A bits select the edge that is captured by channel (n), and ELS(n
+1)B:ELS(n+1)A bits select the edge that is captured by channel (n+1). If both
ELS(n)B:ELS(n)A and ELS(n+1)B:ELS(n+1)A bits select the same edge, then it is the
period measurement. If these bits select different edges, then it is a pulse width
measurement.
In the Dual Edge Capture mode, only channel (n) input is used and channel (n+1) input is
ignored.
If the selected edge by channel (n) bits is detected at channel (n) input, then CH(n)F bit is
set and the channel (n) interrupt is generated (if CH(n)IE = 1). If the selected edge by
channel (n+1) bits is detected at channel (n) input and (CH(n)F = 1), then CH(n+1)F bit is
set and the channel (n+1) interrupt is generated (if CH(n+1)IE = 1).
The C(n)V register stores the value of FTM counter when the selected edge by channel
(n) is detected at channel (n) input. The C(n+1)V register stores the value of FTM
counter when the selected edge by channel (n+1) is detected at channel (n) input.
In this mode, a coherency mechanism ensures coherent data when the C(n)V and C(n
+1)V registers are read. The only requirement is that C(n)V must be read before C(n
+1)V.
Note
• The CH(n)F, CH(n)IE, MS(n)A, ELS(n)B, and ELS(n)A
bits are channel (n) bits.
• The CH(n+1)F, CH(n+1)IE, MS(n+1)A, ELS(n+1)B, and
ELS(n+1)A bits are channel (n+1) bits.
• The Dual Edge Capture mode must be used with
ELS(n)B:ELS(n)A = 0:1 or 1:0, ELS(n+1)B:ELS(n+1)A =
0:1 or 1:0 and the FTM counter in Free running counter.
In this mode, the DECAP bit is automatically cleared by FTM when the edge selected by
channel (n+1) is captured. Therefore, while DECAP bit is set, the one-shot capture is in
process. When this bit is cleared, both edges were captured and the captured values are
ready for reading in the C(n)V and C(n+1)V registers.
Similarly, when the CH(n+1)F bit is set, both edges were captured and the captured
values are ready for reading in the C(n)V and C(n+1)V registers.
positive polarity pulse width. The CH(n)F bit is set when the first edge of this pulse is
detected, that is, the edge selected by ELS(n)B:ELS(n)A bits. The CH(n+1)F bit is set
and DECAP bit is cleared when the second edge of this pulse is detected, that is, the edge
selected by ELS(n+1)B:ELS(n+1)A bits. Both DECAP and CH(n+1)F bits indicate when
two edges of the pulse were captured and the C(n)V and C(n+1)V registers are ready for
reading.
4 8 12 16 20 24
3 28
7 11 15 19
FTM counter 23 27
2 6 10 14 18 22 26
1 5 9 13 17 21 25
DECAPEN bit
set DECAPEN
DECAP bit
set DECAP
C(n)V 1 3 5 7 9 15 19
CH(n)F bit
clear CH(n)F
C(n+1)V 2 4 6 8 10 16 20 22 24
CH(n+1)F bit
clear CH(n+1)F
problem 1 problem 2
Note
- The commands set DECAPEN, set DECAP, clear CH(n)F, and clear CH(n+1)F are made by the user.
- Problem 1: channel (n) input = 1, set DECAP, not clear CH(n)F, and clear CH(n+1)F.
- Problem 2: channel (n) input = 1, set DECAP, not clear CH(n)F, and not clear CH(n+1)F.
Figure 26-241. Dual Edge Capture – One-Shot mode for positive polarity pulse width
measurement
The following figure shows an example of the Dual Edge Capture – Continuous mode
used to measure the positive polarity pulse width. The DECAPEN bit selects the Dual
Edge Capture mode, so it remains set. While the DECAP bit is set the configured
measurements are made. The CH(n)F bit is set when the first edge of the positive polarity
pulse is detected, that is, the edge selected by ELS(n)B:ELS(n)A bits. The CH(n+1)F bit
is set when the second edge of this pulse is detected, that is, the edge selected by ELS(n
+1)B:ELS(n+1)A bits. The CH(n+1)F bit indicates when two edges of the pulse were
captured and the C(n)V and C(n+1)V registers are ready for reading.
4 8 12 16 20 24 28
3 7 11 15 19 23
FTM counter 2 6 10 14
27
18 22 26
1 5 9 13 17 21 25
DECAPEN bit
set DECAPEN
DECAP bit
set DECAP
C(n)V 1 3 5 7 9 11 15 19 21 23
CH(n)F bit
clear CH(n)F
C(n+1)V 2 4 6 8 10 12 16 20 22 24
CH(n+1)F bit
clear CH(n+1)F
Note
- The commands set DECAPEN, set DECAP, clear CH(n)F, and clear CH(n+1)F are made by the user.
Figure 26-242. Dual Edge Capture – Continuous mode for positive polarity pulse width
measurement
The period measurement can be made in One-Shot Capture mode or Continuous Capture
mode.
The following figure shows an example of the Dual Edge Capture – One-Shot mode used
to measure the period between two consecutive rising edges. The DECAPEN bit selects
the Dual Edge Capture mode, so it remains set. The DECAP bit is set to enable the
measurement of next period. The CH(n)F bit is set when the first rising edge is detected,
that is, the edge selected by ELS(n)B:ELS(n)A bits. The CH(n+1)F bit is set and DECAP
bit is cleared when the second rising edge is detected, that is, the edge selected by ELS(n
+1)B:ELS(n+1)A bits. Both DECAP and CH(n+1)F bits indicate when two selected
edges were captured and the C(n)V and C(n+1)V registers are ready for reading.
4 8 12 16 20 24
3 28
7 11 15 19 23
FTM counter 2 6 27
10 14 18
1 22 26
5 9 13 17 21 25
DECAPEN bit
set DECAPEN
DECAP bit
set DECAP
C(n)V 1 3 5 6 7 14 17 18 20 27
CH(n)F bit
clear CH(n)F
C(n+1)V 2 4 6 7 9 15 18 20 23 26
CH(n+1)F bit
clear CH(n+1)F
Note
- The commands set DECAPEN, set DECAP, clear CH(n)F, and clear CH(n+1)F are made by the user.
- Problem 1: channel (n) input = 0, set DECAP, not clear CH(n)F, and not clear CH(n+1)F.
- Problem 2: channel (n) input = 1, set DECAP, not clear CH(n)F, and clear CH(n+1)F.
- Problem 3: channel (n) input = 1, set DECAP, not clear CH(n)F, and not clear CH(n+1)F.
Figure 26-243. Dual Edge Capture – One-Shot mode to measure of the period between
two consecutive rising edges
The following figure shows an example of the Dual Edge Capture – Continuous mode
used to measure the period between two consecutive rising edges. The DECAPEN bit
selects the Dual Edge Capture mode, so it remains set. While the DECAP bit is set the
configured measurements are made. The CH(n)F bit is set when the first rising edge is
detected, that is, the edge selected by ELS(n)B:ELS(n)A bits. The CH(n+1)F bit is set
when the second rising edge is detected, that is, the edge selected by ELS(n+1)B:ELS(n
+1)A bits. The CH(n+1)F bit indicates when two edges of the period were captured and
the C(n)V and C(n+1)V registers are ready for reading.
4 8 12 16 20 24 28
3 7 11 15 19 23
FTM counter 2 6 10 14
27
18 22 26
1 5 9 13 17 21 25
DECAPEN bit
set DECAPEN
DECAP bit
set DECAP
C(n)V 1 3 5 6 7 8 9 10 11 12 14 15 16 18 19 20 21 22 23 24 26
CH(n)F bit
clear CH(n)F
C(n+1)V 2 4 6 7 8 9 10 11 12 13 15 16 17 19 20 21 22 23 24 25 27
CH(n+1)F bit
clear CH(n+1)F
Note
- The commands set DECAPEN, set DECAP, clear CH(n)F, and clear CH(n+1)F are made by the user.
Figure 26-244. Dual Edge Capture – Continuous mode to measure of the period between
two consecutive rising edges
+1) are in Dual Edge Capture – Continuous mode for positive polarity pulse width
measurement. Thus, the channel (n) is configured to capture the FTM counter value when
there is a rising edge at channel (n) input signal, and channel (n+1) to capture the FTM
counter value when there is a falling edge at channel (n) input signal.
When a rising edge occurs in the channel (n) input signal, the FTM counter value is
captured into channel (n) capture buffer. The channel (n) capture buffer value is
transferred to C(n)V register when a falling edge occurs in the channel (n) input signal.
C(n)V register has the FTM counter value when the previous rising edge occurred, and
the channel (n) capture buffer has the FTM counter value when the last rising edge
occurred.
When a falling edge occurs in the channel (n) input signal, the FTM counter value is
captured into channel (n+1) capture buffer. The channel (n+1) capture buffer value is
transferred to C(n+1)V register when the C(n)V register is read.
In the following figure, the read of C(n)V returns the FTM counter value when the event
1 occurred and the read of C(n+1)V returns the FTM counter value when the event 2
occurred.
event 1 event 2 event 3 event 4 event 5 event 6 event 7 event 8 event 9
FTM counter 1 2 3 4 5 6 7 8 9
channel (n) 1 3 5 7 9
capture buffer
C(n)V 1 3 5 7
channel (n+1) 2 4 6 8
capture buffer
C(n+1)V 2
C(n)V register must be read prior to C(n+1)V register in dual edge capture one-shot and
continuous modes for the read coherency mechanism works properly.
Note that if BDMMODE[1:0] = 2’b00 then the channels outputs remain at the value
when the chip enters in Debug mode, because the FTM counter is stopped. However, the
following situations modify the channels outputs in this Debug mode.
• Write any value to CNT register; see Counter reset. In this case, the FTM counter is
updated with the CNTIN register value and the channels outputs are updated to the
initial value – except for those channels set to Output Compare mode.
• FTM counter is reset by PWM Synchronization mode; see FTM counter
synchronization. In this case, the FTM counter is updated with the CNTIN register
value and the channels outputs are updated to the initial value – except for channels
in Output Compare mode.
• In the channels outputs initialization, the channel (n) output is forced to the CH(n)OI
bit value when the value 1 is written to INIT bit. See Initialization.
Note
The BDMMODE[1:0] = 2’b00 must not be used with the Fault
control. Even if the fault control is enabled and a fault condition
exists, the channels outputs values are updated as above.
(a)
(b)
(c)
(d)
(e)
(f)
NOTE
(a) LDOK = 0, CH0SEL = 0, CH1SEL = 0, CH2SEL = 0, CH3SEL = 0, CH4SEL = 0, CH5SEL = 0, CH6SEL = 0, CH7SEL = 0
(b) LDOK = 1, CH0SEL = 0, CH1SEL = 0, CH2SEL = 0, CH3SEL = 0, CH4SEL = 0, CH5SEL = 0, CH6SEL = 0, CH7SEL = 0
(c) LDOK = 0, CH0SEL = 0, CH1SEL = 0, CH2SEL = 0, CH3SEL = 1, CH4SEL = 0, CH5SEL = 0, CH6SEL = 0, CH7SEL = 0
(d) LDOK = 1, CH0SEL = 0, CH1SEL = 0, CH2SEL = 0, CH3SEL = 0, CH4SEL = 0, CH5SEL = 0, CH6SEL = 1, CH7SEL = 0
(e) LDOK = 1, CH0SEL = 1, CH1SEL = 0, CH2SEL = 1, CH3SEL = 0, CH4SEL = 1, CH5SEL = 0, CH6SEL = 1, CH7SEL = 0
(f) LDOK = 1, CH0SEL = 1, CH1SEL = 1, CH2SEL = 1, CH3SEL = 1, CH4SEL = 1, CH5SEL = 1, CH6SEL = 1, CH7SEL = 1
After enabling the loading points, the LDOK bit must be set for the load to occur. In this
case, the load occurs at the next enabled loading point according to the following
conditions:
Table 26-249. Conditions for loads occurring at the next enabled loading point
When a new value was written Then
To the MOD register The MOD register is updated with its write buffer value.
Table 26-249. Conditions for loads occurring at the next enabled loading point (continued)
When a new value was written Then
To the CNTIN register and CNTINC = 1 The CNTIN register is updated with its write buffer value.
To the C(n)V register and SYNCENm = 1 – where m indicates The C(n)V register is updated with its write buffer value.
the pair channels (n) and (n+1)
To the C(n+1)V register and SYNCENm = 1 – where m The C(n+1)V register is updated with its write buffer value.
indicates the pair channels (n) and (n+1)
NOTE
• If ELSjB and ELSjA bits are different from zero, then the
channel (j) output signal is generated according to the
configured output mode. If ELSjB and ELSjA bits are zero,
then the generated signal is not available on channel (j)
output.
• If CHjIE = 1, then the channel (j) interrupt is generated
when the channel (j) match occurs.
• At the intermediate load neither the channels outputs nor
the FTM counter are changed. Software must set the
intermediate load at a safe point in time.
• The intermediate load feature must be used only in
Combine mode.
gtb_in
gtb_in
gtb_out
The GTB functionality is implemented by the GTBEEN and GTBEOUT bits in the
CONF register, the input signal gtb_in, and the output signal gtb_out. The GTBEEN bit
enables gtb_in to control the FTM counter enable signal:
• If GTBEEN = 0, each one of FTM modules works independently according to their
configured mode.
• If GTBEEN = 1, the FTM counter update is enabled only when gtb_in is 1.
In the configuration described in the preceding figure, FTM modules A and B have their
FTM counters enabled if at least one of the gtb_out signals from one of the FTM modules
is 1. There are several possible configurations for the interconnection of the gtb_in and
gtb_out signals, represented by the example glue logic shown in the figure. Note that
these configurations are chip-dependent and implemented outside of the FTM modules.
See the chip configuration details for the chip's specific implementation.
NOTE
• In order to use the GTB signals to synchronize the FTM
counter of different FTM modules, the configuration of
each FTM module should guarantee that its FTM counter
starts counting as soon as the gtb_in signal is 1.
• The GTB feature does not provide continuous
synchronization of FTM counters, meaning that the FTM
counters may lose synchronization during FTM operation.
The GTB feature only allows the FTM counters to start
their operation synchronously.
FTM counter XXXX 0x0000 0x0010 0x0011 0x0012 0x0013 0x0014 0x0015 0x0016 0x0017 0x0018 . . .
CLKS[1:0] XX 00 01
NOTES:
– CNTIN = 0x0010
– Channel (n) is in low-true combine mode with CNTIN < C(n)V < C(n+1)V < MOD
– C(n)V = 0x0015
Figure 26-248. FTM behavior after reset when the channel (n) is in Combine mode
The following figure shows an example when the channel (n) is in Output Compare mode
and the channel (n) output is toggled when there is a match. In the Output Compare
mode, the channel output is not updated to its initial value when there is a write to CNT
register (item 3). In this case, use the software output control (Software output control) or
the initialization (Initialization) to update the channel output to the selected value (item
4).
(4) use of software output control or initialization
to update the channel output to the zero
(3) write any value
(1) FTM reset to CNT register (5) write 1 to SC[CLKS]
FTM counter XXXX 0x0000 0x0010 0x0011 0x0012 0x0013 0x0014 0x0015 0x0016 0x0017 . . .
CLKS[1:0] XX 00 01
NOTES:
– CNTIN = 0x0010
– Channel (n) is in output compare and the channel (n) output is toggled when there is a match
– C(n)V = 0x0014
Figure 26-249. FTM behavior after reset when the channel (n) is in Output Compare
mode
27.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances, see the chip configuration information.
The PIT module is an array of timers that can be used to raise interrupts and triggers.
PIT
Peripheral
bus PIT
registers
load_value
Timer 1
Iinterrupts
Triggers
Timer n
Peripheral
bus clock
NOTE
See the chip configuration details for the number of PIT
channels used in this MCU.
27.1.2 Features
The main features of this block are:
• Ability of timers to generate trigger pulses
• Ability of timers to generate interrupts
• Maskable interrupts
• Independent timeout periods for each timer
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reserved
R 0
MDIS FRZ
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0
R TVL
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
NOTE: • If the timer is disabled, do not use this field as its value is unreliable.
• The timer uses a downcounter. The timer values are frozen in Debug mode if MCR[FRZ] is
set.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 CHN TIE TEN
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 Timer n is disabled.
1 Timer n is enabled.
R 0
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 TIF
W w1c
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
27.4.1.1 Timers
The timers generate triggers at periodic intervals, when enabled. The timers load the start
values as specified in their LDVAL registers, count down to 0 and then load the
respective start value again. Each time a timer reaches 0, it will generate a trigger pulse
and set the interrupt flag.
All interrupts can be enabled or masked by setting TCTRLn[TIE]. A new interrupt can be
generated only after the previous one is cleared.
If desired, the current counter value of the timer can be read via the CVAL registers.
The counter period can be restarted, by first disabling, and then enabling the timer with
TCTRLn[TEN]. See the following figure.
Trigger
event
p1 p1 p1 p1
The counter period of a running timer can be modified, by first disabling the timer,
setting a new load value, and then enabling the timer again. See the following figure.
Timer enabled Disable timer, Re-enable
Start value = p1 Set new load value timer
Trigger
event p2 p2 p2
p1
p1
It is also possible to change the counter period without restarting the timer by writing
LDVAL with the new load value. This value will then be loaded after the next trigger
event. See the following figure.
Timer enabled New start
Start value = p1 Value p2 set
Trigger
event
p1 p1 p1 p2 p2
27.4.2 Interrupts
All the timers support interrupt generation. See the MCU specification for related vector
addresses and priorities.
Timer interrupts can be enabled by setting TCTRLn[TIE]. TFLGn[TIF] are set to 1 when
a timeout occurs on the associated timer, and are cleared to 0 by writing a 1 to the
corresponding TFLGn[TIF].
// turn on PIT
PIT_MCR = 0x00;
// Timer 1
PIT_LDVAL1 = 0x0003E7FF; // setup timer 1 for 256000 cycles
PIT_TCTRL1 = TIE; // enable Timer 1 interrupts
PIT_TCTRL1 |= TEN; // start Timer 1
// Timer 3
PIT_LDVAL3 = 0x0016E35F; // setup timer 3 for 1500000 cycles
PIT_TCTRL3 |= TEN; // start Timer 3
// turn on PIT
PIT_MCR = 0x00;
// Timer 2
PIT_LDVAL2 = 0x00000009; // setup Timer 2 for 10 counts
PIT_TCTRL2 = TIE; // enable Timer 2 interrupt
PIT_TCTRL2 |= CHN; // chain Timer 2 to Timer 1
PIT_TCTRL2 |= TEN; // start Timer 2
// Timer 1
PIT_LDVAL1 = 0x23C345FF; // setup Timer 1 for 600 000 000 cycles
PIT_TCTRL1 = TEN; // start Timer 1
28.1 Introduction
The real-time counter (RTC) consists of one 16-bit counter, one 16-bit comparator,
several binary-based and decimal-based prescaler dividers, three clock sources, one
programmable periodic interrupt, and one programmable external toggle pulse output.
This module can be used for time-of-day, calendar or any task scheduling functions. It
can also serve as a cyclic wake-up from low-power modes, Stop and Wait without the
need of external components.
28.2 Features
Features of the RTC module include:
• 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
• OSC 32.768KHz nominal.
• LPO (~1 kHz)
• Bus clock
• Internal reference clock (32 kHz)
16-bit modulo
16-bit latch
16-bit modulo
1
D Q RTIF
16-bit comparator RTC
EXT CLK R
INTERRUPT
LPO CLK CLOCK REQUEST
16-bit counter
BUS CLK DIVIDER
IRC CLK
RTIE
D Q
OUTPUT
Q
TOGLE
RTCCNT RTCO
RTCLKS RTCPS
Write 1 to RTIF
RTC_SC contains the real-time interrupt status flag (RTIF), and the toggle output enable
bit (RTCO).
Address: 4003_D000h base + 0h offset = 4003_D000h
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 0 0
RTCO
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
000 Off
001 If RTCLKS = x0, it is 1; if RTCLKS = x1, it is 128.
010 If RTCLKS = x0, it is 2; if RTCLKS = x1, it is 256.
011 If RTCLKS = x0, it is 4; if RTCLKS = x1, it is 512.
100 If RTCLKS = x0, it is 8; if RTCLKS = x1, it is 1024.
101 If RTCLKS = x0, it is 16; if RTCLKS = x1, it is 2048.
110 If RTCLKS = x0, it is 32; if RTCLKS = x1, it is 100.
111 If RTCLKS = x0, it is 64; if RTCLKS = x1, it is 1000.
7 Real-Time Interrupt Flag
RTIF
This status bit indicates the RTC counter register reached the value in the RTC modulo register. Writing a
logic 0 has no effect. Writing a logic 1 clears the bit and the real-time interrupt request. Reset clears RTIF
to 0.
0 RTC counter has not reached the value in the RTC modulo register.
1 RTC counter has reached the value in the RTC modulo register.
6 Real-Time Interrupt Enable
RTIE
This read/write bit enables real-time interrupts. If RTIE is set, then an interrupt is generated when RTIF is
set. Reset clears RTIE to 0.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 MOD
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
This read/write field contains the modulo value used to reset the count to 0x0000 upon a compare match
and set SC[RTIF] status field. A value of 0x0000 sets SC[RTIF] on each rising-edge of the prescaler
output. Reset sets the modulo to 0x0000.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 CNT
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
This read-only field contains the current value of the 16-bit counter, read CNT[7:0] first and, then
CNT[15:8]. Writes have no effect to this register. Reset or writing different values to SC[RTCLKS] and
SC[RTCPS] clear the count to 0x0000.
The RTC Modulo register (RTC_MOD) allows the compare value to be set to any value
from 0x0000 to 0xFFFF. When the counter is active, the counter increments at the
selected rate until the count matches the modulo value. When these values match, the
counter resets to 0x0000 and continues counting. The Real-Time Interrupt Flag
(RTC_SC[RTIF]) is set whenever a match occurs. The flag sets on the transition from the
modulo value to 0x0000. The modulo value written to RTC_MOD is latched until the
RTC counter overflows or RTC_SC[RTCPS] is selected nonzero.
The RTC allows for an interrupt to be generated whenever RTC_SC[RTIF] is set. To
enable the real-time interrupt, set the Real-Time Interrupt Enable field (RTC_SC[RTIE]).
RTC_SC[RTIF] is cleared by writing a 1 to RTC_SC[RTIF].
The RTC also allows an output to external pinout by toggling the level. RTC_SC[RTCO]
must be set to enable toggling external pinout. The level depends on the previous state of
the pinout when the counter overflows if this function is active.
OSC (32768Hz)
RTCLKS = 00b
RTC Clock
RTCPS = 001b
RTCCNT
32765 32766 32767 0 1 2 3 4
RTCPS = 001b
RTIF
16-bit modulo 32767 32767 32767 32766 32766 32766 32766 32766
RTCO
In the above example, the external clock source is selected. The prescaler is set to
RTC_SC[RTCPS] = 001b or passthrough. The actual modulo value used by 16-bit
comparator is 32767, when the modulo value in the RTC_MOD register is set to 32766.
When the counter, RTC_CNT, reaches the modulo value of 32767, the counter overflows
to 0x00 and continues counting. The modulo value is updated by fetching from
RTC_MOD register. The real-time interrupt flag, RTC_SC[RTIF], sets when the counter
value changes from 0x7FFF to 0x0000. The RTC_SC[RTCO] toggles as well when the
RTC_SC[RTIF] is set.
/* Configure RTC to interrupt every 1 second from OSC (32.768KHz) clock source */
RTC_MOD = 511; // overflow every 32 times
RTC_SC = RTC_SC_RTCPS_MASK; // external 32768 clock selected with 1/64 predivider.
RTC_SC = RTC_SC_RTIF_MASK | RTC_SC_RTIE_MASK; // interrupt cleared and enabled
/**********************************************************************
Function Name : RTC_ISR
Notes : Interrupt service routine for RTC module.
**********************************************************************/
void RTC_ISR(void)
{
/* Clears the interrupt flag, RTIF, and interrupt request */
RTC_SC |= RTC_SC_RTIF_MASK;
/* 60 seconds in a minute */
if (Seconds > 59)
{
Minutes++;
Seconds = 0;
}
/* 60 minutes in an hour */
if (Minutes > 59)
{
Hours++;
Minutes = 0;
}
/* 24 hours in a day */
if (Hours > 23)
{
Days ++;
Hours = 0;
}
29.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances, see the chip configuration information.
The serial peripheral interface (SPI) module provides for full-duplex, synchronous, serial
communication between the MCU and peripheral devices. These peripheral devices can
include other microcontrollers, analog-to-digital converters, shift registers, sensors, and
memories, among others.
The SPI runs at a baud rate up to the bus clock divided by two in master mode and up to
the bus clock divided by four in slave mode. Software can poll the status flags, or SPI
operation can be interrupt driven.
NOTE
For the actual maximum SPI baud rate, refer to the Chip
Configuration details and to the device’s Data Sheet.
The SPI also includes a hardware match feature for the receive data buffer.
29.1.1 Features
The SPI includes these distinctive features:
• Master mode or slave mode operation
• Full-duplex or single-wire bidirectional mode
• Programmable transmit bit rate
• Double-buffered transmit and receive data register
MOSI MOSI
MISO MISO
8 BITS 8 BITS
SPSCK SPSCK
CLOCK
GENERATOR
SS SS
When the SPI is configured as a master, the clock output is routed to the SPSCK pin, the
shifter output is routed to MOSI, and the shifter input is routed from the MISO pin.
When the SPI is configured as a slave, the SPSCK pin is routed to the clock input of the
SPI, the shifter output is routed to MISO, and the shifter input is routed from the MOSI
pin.
In the external SPI system, simply connect all SPSCK pins to each other, all MISO pins
together, and all MOSI pins together. Peripheral devices often use slightly different
names for these pins.
PIN CONTROL
M
MOSI
SPE S (MOMI)
BIDIROE
SHIFT SHIFT Rx BUFFER Tx BUFFER
LSBFE
DIRECTION CLOCK FULL EMPTY
MASTER CLOCK
M
BUS RATE SPIBR CLOCK
CLOCK SPSCK
CLOCK GENERATOR LOGIC SLAVE CLOCK
S
MASTER/SLAVE MASTER/
MSTR
MODE SELECT SLAVE
MOD-
SSOE
MODE FAULT
SS
DETECTION
SPRF
8-BIT COMPARATOR
SPMF
SPIxM SPMIE
SPTEF
SPTIE
INTERRUPT
MODF
REQUEST
SPIE
The SPI has 8-bit registers to select SPI options, to control baud rate, to report SPI status,
to hold an SPI data match value, and for transmit/receive data.
SPI memory map
Absolute
Address Width Section/
address Register name Access Reset value
offset (hex) (in bits) page
(hex)
0 4007_6000 SPI Control Register 1 (SPI0_C1) 8 R/W 04h 29.3.1/491
1 4007_6001 SPI Control Register 2 (SPI0_C2) 8 R/W 00h 29.3.2/492
2 4007_6002 SPI Baud Rate Register (SPI0_BR) 8 R/W 00h 29.3.3/494
3 4007_6003 SPI Status Register (SPI0_S) 8 R 20h 29.3.4/495
5 4007_6005 SPI Data Register (SPI0_D) 8 R/W 00h 29.3.5/496
7 4007_6007 SPI Match Register (SPI0_M) 8 R/W 00h 29.3.6/497
0 4007_7000 SPI Control Register 1 (SPI1_C1) 8 R/W 04h 29.3.1/491
1 4007_7001 SPI Control Register 2 (SPI1_C2) 8 R/W 00h 29.3.2/492
2 4007_7002 SPI Baud Rate Register (SPI1_BR) 8 R/W 00h 29.3.3/494
3 4007_7003 SPI Status Register (SPI1_S) 8 R 20h 29.3.4/495
5 4007_7005 SPI Data Register (SPI1_D) 8 R/W 00h 29.3.5/496
7 4007_7007 SPI Match Register (SPI1_M) 8 R/W 00h 29.3.6/497
This read/write register includes the SPI enable control, interrupt enables, and
configuration options.
Address: 4007_6000h base + 0h offset = 4007_6000h
Bit 7 6 5 4 3 2 1 0
Read SPIE SPE SPTIE MSTR CPOL CPHA SSOE LSBFE
Write
Reset 0 0 0 0 0 1 0 0
0 First edge on SPSCK occurs at the middle of the first cycle of a data transfer.
1 First edge on SPSCK occurs at the start of the first cycle of a data transfer.
1 Slave Select Output Enable
SSOE
This bit is used in combination with the Mode Fault Enable (MODFEN) field in the C2 register and the
Master/Slave (MSTR) control bit to determine the function of the SS pin.
0 When C2[MODFEN] is 0: In master mode, SS pin function is general-purpose I/O (not SPI). In slave
mode, SS pin function is slave select input.
When C2[MODFEN] is 1: In master mode, SS pin function is SS input for mode fault. In slave mode,
SS pin function is slave select input.
1 When C2[MODFEN] is 0: In master mode, SS pin function is general-purpose I/O (not SPI). In slave
mode, SS pin function is slave select input.
When C2[MODFEN] is 1: In master mode, SS pin function is automatic SS output. In slave mode: SS
pin function is slave select input.
0 LSB First (shifter direction)
LSBFE
This bit does not affect the position of the MSB and LSB in the data register. Reads and writes of the data
register always have the MSB in bit 7.
0 SPI serial data transfers start with the most significant bit.
1 SPI serial data transfers start with the least significant bit.
This read/write register is used to control optional features of the SPI system. Bit 6 is not
implemented and always reads 0.
Address: 4007_6000h base + 1h offset = 4007_6001h
Bit 7 6 5 4 3 2 1 0
Read SPMIE Reserved Reserved MODFEN BIDIROE Reserved SPISWAI SPC0
Write
Reset 0 0 0 0 0 0 0 0
0 Mode fault function disabled, master SS pin reverts to general-purpose I/O not controlled by SPI
1 Mode fault function enabled, master SS pin acts as the mode fault input or the slave select output
3 Bidirectional Mode Output Enable
BIDIROE
When bidirectional mode is enabled because SPI pin control 0 (SPC0) is set to 1, BIDIROE determines
whether the SPI data output driver is enabled to the single bidirectional SPI I/O pin. Depending on whether
the SPI is configured as a master or a slave, it uses the MOSI (MOMI) or MISO (SISO) pin, respectively,
as the single SPI data I/O pin. When SPC0 is 0, BIDIROE has no meaning or effect.
0 SPI uses separate pins for data input and data output (pin mode is normal).
In master mode of operation: MISO is master in and MOSI is master out.
In slave mode of operation: MISO is slave out and MOSI is slave in.
1 SPI configured for single-wire bidirectional operation (pin mode is bidirectional).
In master mode of operation: MISO is not used by SPI; MOSI is master in when BIDIROE is 0 or
master I/O when BIDIROE is 1.
In slave mode of operation: MISO is slave in when BIDIROE is 0 or slave I/O when BIDIROE is 1;
MOSI is not used by SPI.
Use this register to set the prescaler and bit rate divisor for an SPI master. This register
may be read or written at any time.
Address: 4007_6000h base + 2h offset = 4007_6002h
Bit 7 6 5 4 3 2 1 0
This 4-bit field selects one of nine divisors for the SPI baud rate divider. The input to this divider comes
from the SPI baud rate prescaler. Refer to the description of “SPI Baud Rate Generation” for details.
Bit 7 6 5 4 3 2 1 0
Write
Reset 0 0 1 0 0 0 0 0
0 Value in the receive data buffer does not match the value in the M register
1 Value in the receive data buffer matches the value in the M register
5 SPI Transmit Buffer Empty Flag
SPTEF
This bit is set when the transmit data buffer is empty. SPTEF is cleared by reading the S register with
SPTEF set and then writing a data value to the transmit buffer at D. The S register must be read with
SPTEF set to 1 before writing data to the D register; otherwise, the D write is ignored. SPTEF is
automatically set when all data from the transmit buffer transfers into the transmit shift register. For an idle
SPI, data written to D is transferred to the shifter almost immediately so that SPTEF is set within two bus
cycles, allowing a second set of data to be queued into the transmit buffer. After completion of the transfer
of the data in the shift register, the queued data from the transmit buffer automatically moves to the shifter,
and SPTEF is set to indicate that room exists for new data in the transmit buffer. If no new data is waiting
in the transmit buffer, SPTEF simply remains set and no data moves from the buffer to the shifter.
If a transfer does not stop, the last data that was transmitted is sent out again.
Bit 7 6 5 4 3 2 1 0
Read Bits[7:0]
Write
Reset 0 0 0 0 0 0 0 0
This register contains the hardware compare value. When the value received in the SPI
receive data buffer equals this hardware compare value, the SPI Match Flag in the S
register (S[SPMF]) sets.
Address: 4007_6000h base + 7h offset = 4007_6007h
Bit 7 6 5 4 3 2 1 0
Read Bits[7:0]
Write
Reset 0 0 0 0 0 0 0 0
29.4.1 General
The SPI system is enabled by setting the SPI enable (SPE) bit in SPI Control Register 1.
While C1[SPE] is set, the four associated SPI port pins are dedicated to the SPI function
as:
• Slave select (SS)
• Serial clock (SPSCK)
• Master out/slave in (MOSI)
• Master in/slave out (MISO)
An SPI transfer is initiated in the master SPI device by reading the SPI status register
(SPIx_S) when S[SPTEF] = 1 and then writing data to the transmit data buffer (write to
SPIxD ). When a transfer is complete, received data is moved into the receive data buffer.
The SPIxD register acts as the SPI receive data buffer for reads and as the SPI transmit
data buffer for writes.
The Clock Phase Control (CPHA) and Clock Polarity Control (CPOL) bits in the SPI
Control Register 1 (SPIx_C1) select one of four possible clock formats to be used by the
SPI system. The CPOL bit simply selects a non-inverted or inverted clock. C1[CPHA] is
used to accommodate two fundamentally different protocols by sampling data on odd
numbered SPSCK edges or on even numbered SPSCK edges.
The SPI can be configured to operate as a master or as a slave. When the MSTR bit in
SPI Control Register 1 is set, master mode is selected; when C1[MSTR] is clear, slave
mode is selected.
mode fault error also sets the Mode Fault (MODF) flag in the SPI Status Register
(SPIx_S). If the SPI Interrupt Enable bit (SPIE) is set when S[ MODF] gets set,
then an SPI interrupt sequence is also requested. When a write to the SPI Data
Register in the master occurs, there is a half SPSCK-cycle delay. After the delay,
SPSCK is started within the master. The rest of the transfer operation differs
slightly, depending on the clock format specified by the SPI clock phase bit,
CPHA, in SPI Control Register 1 (see SPI clock formats).
Note
A change of C1[CPOL], C1[CPHA], C1[SSOE], C1[LSBFE],
C2[MODFEN], C2[SPC0], C2[BIDIROE] with C2[SPC0] set,
SPPR2-SPPR0 and SPR3-SPR0 in master mode abort a
transmission in progress and force the SPI into idle state. The
remote slave cannot detect this, therefore the master has to
ensure that the remote slave is set back to idle state.
Although the SPI is capable of duplex operation, some SPI peripherals are capable of
only receiving SPI data in a slave mode. For these simpler devices, there is no serial
data out pin.
Note
When peripherals with duplex capability are used, take care not
to simultaneously enable two receivers whose serial outputs
drive the same system slave's serial data output line.
As long as no more than one slave device drives the system slave's serial data output line,
it is possible for several slaves to receive the same transmission from a master, although
the master would not receive return information from all of the receiving slaves.
If the CPHA bit in SPI Control Register 1 is clear, odd numbered edges on the SPSCK
input cause the data at the serial data input pin to be latched. Even numbered edges cause
the value previously latched from the serial data input pin to shift into the LSB or MSB
of the SPI shift register, depending on the LSBFE bit.
If C1[CPHA] is set, even numbered edges on the SPSCK input cause the data at the serial
data input pin to be latched. Odd numbered edges cause the value previously latched
from the serial data input pin to shift into the LSB or MSB of the SPI shift register,
depending on C1[LSBFE].
When C1[CPHA] is set, the first edge is used to get the first data bit onto the serial data
output pin. When C1[CPHA] is clear and the SS input is low (slave selected), the first bit
of the SPI data is driven out of the serial data output pin. After the eighth shift, the
transfer is considered complete and the received data is transferred into the SPI Data
register. To indicate transfer is complete, the SPRF flag in the SPI Status Register is set.
Note
A change of the bits C2[BIDIROE] with C2[SPC0] set,
C1[CPOL], C1[CPHA], C1[SSOE], C1[LSBFE],
C2[MODFEN], and C2[SPC0] in slave mode will corrupt a
transmission in progress and must be avoided.
The following figure shows the clock formats when CPHA = 1. At the top of the figure,
the eight bit times are shown for reference with bit 1 starting at the first SPSCK edge and
bit 8 ending one-half SPSCK cycle after the eighth SPSCK edge. The MSB first and LSB
first lines show the order of SPI data bits depending on the setting in LSBFE. Both
variations of SPSCK polarity are shown, but only one of these waveforms applies for a
specific transfer, depending on the value in C1[CPOL]. The SAMPLE IN waveform
applies to the MOSI input of a slave or the MISO input of a master. The MOSI waveform
applies to the MOSI output pin from a master and the MISO waveform applies to the
MISO output from a slave. The SS OUT waveform applies to the slave select output from
a master (provided C2[MODFEN] and C1[SSOE] = 1). The master SS output goes to
active low one-half SPSCK cycle before the start of the transfer and goes back high at the
end of the eighth bit time of the transfer. The SS IN waveform applies to the slave select
input of a slave.
BIT TIME #
(REFERENCE) 1 2 ... 6 7 8
SPSCK
(CPOL = 0)
SPSCK
(CPOL = 1)
SAMPLE IN
(MISO OR MOSI)
MOSI
(MASTER OUT)
MISO
(SLAVE OUT)
SS OUT
(MASTER)
SS IN
(SLAVE)
When C1[CPHA] = 1, the slave begins to drive its MISO output when SS goes to active
low, but the data is not defined until the first SPSCK edge. The first SPSCK edge shifts
the first bit of data from the shifter onto the MOSI output of the master and the MISO
output of the slave. The next SPSCK edge causes both the master and the slave to sample
the data bit values on their MISO and MOSI inputs, respectively. At the third SPSCK
edge, the SPI shifter shifts one bit position which shifts in the bit value that was just
sampled, and shifts the second data bit value out the other end of the shifter to the MOSI
and MISO outputs of the master and slave, respectively.
When C1[CPHA] = 1, the slave's SS input is not required to go to its inactive high level
between transfers. In this clock format, a back-to-back transmission can occur, as
follows:
1. A transmission is in progress.
2. A new data byte is written to the transmit buffer before the in-progress transmission
is complete.
3. When the in-progress transmission is complete, the new, ready data byte is
transmitted immediately.
Between these two successive transmissions, no pause is inserted; the SS pin remains
low.
The following figure shows the clock formats when C1[CPHA] = 0. At the top of the
figure, the eight bit times are shown for reference with bit 1 starting as the slave is
selected (SS IN goes low), and bit 8 ends at the last SPSCK edge. The MSB first and
LSB first lines show the order of SPI data bits depending on the setting in LSBFE. Both
variations of SPSCK polarity are shown, but only one of these waveforms applies for a
specific transfer, depending on the value in CPOL. The SAMPLE IN waveform applies
to the MOSI input of a slave or the MISO input of a master. The MOSI waveform applies
to the MOSI output pin from a master and the MISO waveform applies to the MISO
output from a slave. The SS OUT waveform applies to the slave select output from a
master (provided C2[MODFEN] and C1[SSOE] = 1). The master SS output goes to
active low at the start of the first bit time of the transfer and goes back high one-half
SPSCK cycle after the end of the eighth bit time of the transfer. The SS IN waveform
applies to the slave select input of a slave.
BIT TIME #
(REFERENCE) 1 2 ... 6 7 8
SPSCK
(CPOL = 0)
SPSCK
(CPOL = 1)
SAMPLE IN
(MISO OR MOSI)
MOSI
(MASTER OUT)
MSB FIRST BIT 7 BIT 6 ... BIT 2 BIT 1 BIT 0
LSB FIRST BIT 0 BIT 1 ... BIT 5 BIT 6 BIT 7
MISO
(SLAVE OUT)
SS OUT
(MASTER)
SS IN
(SLAVE)
When C1[CPHA] = 0, the slave begins to drive its MISO output with the first data bit
value (MSB or LSB depending on LSBFE) when SS goes to active low. The first SPSCK
edge causes both the master and the slave to sample the data bit values on their MISO
and MOSI inputs, respectively. At the second SPSCK edge, the SPI shifter shifts one bit
position which shifts in the bit value that was just sampled and shifts the second data bit
value out the other end of the shifter to the MOSI and MISO outputs of the master and
slave, respectively. When C1[CPHA] = 0, the slave's SS input must go to its inactive high
level between transfers.
The baud rate generator is activated only when the SPI is in the master mode and a serial
transfer is taking place. In the other cases, the divider is disabled to decrease IDD current.
The baud rate divisor equation is as follows (except those reserved combinations in the
SPI Baud Rate Divisor table).
BaudRateDivisor = (SPPR + 1) × 2(SPR + 1)
SPPR2:SPPR1:SPPR0 SPR3:SPR2:SPR1:SPR0
29.4.6.1 SS Output
The SS output feature automatically drives the SS pin low during transmission to select
external devices and drives the SS pin high during idle to deselect external devices. When
the SS output is selected, the SS output pin is connected to the SS input pin of the
external device.
The SS output is available only in master mode during normal SPI operation by asserting
C1[SSOE] and C2[MODFEN] as shown in the description of C1[SSOE].
The mode fault feature is disabled while SS output is enabled.
Note
Be careful when using the SS output feature in a multimaster
system because the mode fault feature is not available for
detecting system errors between masters.
The direction of each serial I/O pin depends on C2[BIDIROE]. If the pin is configured as
an output, serial data from the shift register is driven out on the pin. The same pin is also
the serial input to the shift register.
The SPSCK is an output for the master mode and an input for the slave mode.
SS is the input or output for the master mode, and it is always the input for the slave
mode.
The bidirectional mode does not affect SPSCK and SS functions.
Note
In bidirectional master mode, with the mode fault feature
enabled, both data pins MISO and MOSI can be occupied by
the SPI, though MOSI is normally used for transmissions in
bidirectional mode and MISO is not used by the SPI. If a mode
fault occurs, the SPI is automatically switched to slave mode. In
this case, MISO becomes occupied by the SPI and MOSI is not
used. Consider this scenario if the MISO pin is used for another
purpose.
Note
Care must be taken when expecting data from a master while
the slave is in a Wait mode or a Stop mode where the peripheral
bus clock is stopped but internal logic states are retained. Even
though the shift register continues to operate, the rest of the SPI
is shut down (that is, an SPRF interrupt is not generated until an
exit from Stop or Wait mode). Also, the data from the shift
register is not copied into the SPIx_D registers until after the
slave SPI has exited Wait or Stop mode. An SPRF flag and
SPIx_D copy is only generated if Wait mode is entered or
exited during a transmission. If the slave enters Wait mode in
idle mode and exits Wait mode in idle mode, neither an SPRF
nor a SPIx_D copy occurs.
29.4.9 Reset
The reset values of registers and signals are described in the Memory Map and Register
Descriptions content, which details the registers and their bitfields.
• If a data transmission occurs in slave mode after a reset without a write to SPIx_D,
the transmission consists of "garbage" or the data last received from the master
before the reset.
• Reading from SPIx_D after reset always returns zeros.
29.4.10 Interrupts
The SPI originates interrupt requests only when the SPI is enabled (the SPE bit in the
SPIx_C1 register is set). The following is a description of how the SPI makes a request
and how the MCU should acknowledge that request. The interrupt vector offset and
interrupt priority are chip dependent.
Four flag bits, three interrupt mask bits, and one interrupt vector are associated with the
SPI system. The SPI interrupt enable mask (SPIE) enables interrupts from the SPI
receiver full flag (SPRF) and mode fault flag (MODF). The SPI transmit interrupt enable
mask (SPTIE) enables interrupts from the SPI transmit buffer empty flag (SPTEF). The
SPI match interrupt enable mask bit (SPIMIE) enables interrupts from the SPI match flag
(SPMF). When one of the flag bits is set, and the associated interrupt mask bit is set, a
hardware interrupt request is sent to the CPU. If the interrupt mask bits are cleared,
software can poll the associated flag bits instead of using interrupts. The SPI interrupt
service routine (ISR) should check the flag bits to determine which event caused the
interrupt. The service routine should also clear the flag bit(s) before returning from the
ISR (usually near the beginning of the ISR).
29.4.10.1 MODF
MODF occurs when the master detects an error on the SS pin. The master SPI must be
configured for the MODF feature (see the description of the C1[SSOE] bit). Once MODF
is set, the current transfer is aborted and the master (MSTR) bit in the SPIx_C1 register
resets to 0.
The MODF interrupt is reflected in the status register's MODF flag. Clearing the flag also
clears the interrupt. This interrupt stays active while the MODF flag is set. MODF has an
automatic clearing process that is described in the SPI Status Register.
29.4.10.2 SPRF
SPRF occurs when new data has been received and copied to the SPI receive data buffer.
After SPRF is set, it does not clear until it is serviced. SPRF has an automatic clearing
process that is described in the SPI Status Register details. If the SPRF is not serviced
before the end of the next transfer (that is, SPRF remains active throughout another
transfer), the subsequent transfers are ignored and no new data is copied into the Data
register.
29.4.10.3 SPTEF
SPTEF occurs when the SPI transmit buffer is ready to accept new data.
After SPTEF is set, it does not clear until it is serviced. SPTEF has an automatic clearing
process that is described in the SPI Status Register details.
29.4.10.4 SPMF
SPMF occurs when the data in the receive data buffer is equal to the data in the SPI
Match Register.
5. In the master, read SPIx_S while S[SPTEF] = 1, and then write to the transmit data
register (SPIx_D) to begin transfer.
SPIx_C2 = 0x80(%10000000)
Bit 7 SPMIE = 1 SPI hardware match interrupt enabled
Bit 6 = 0 Unimplemented
Bit 5 = 0 Reserved
Bit 4 MODFEN = 0 Disables mode fault function
Bit 3 BIDIROE = 0 SPI data I/O pin acts as input
Bit 2 = 0 Reserved
Bit 1 SPISWAI = 0 SPI clocks operate in wait mode
Bit 0 SPC0 = 0 uses separate pins for data input and output
SPIx_BR = 0x00(%00000000)
Bit 7 = 0 Reserved
Bit 6:4 = 000 Sets prescale divisor to 1
Bit 3:0 = 0000 Sets baud rate divisor to 2
SPIx_S = 0x00(%00000000)
Bit 7 SPRF = 0 Flag is set when receive data buffer is full
Bit 6 SPMF = 0 Flag is set when SPIx_M = receive data buffer
SPIx_S = 0x00(%00000000)
Bit 5 SPTEF = 0 Flag is set when transmit data buffer is empty
Bit 4 MODF = 0 Mode fault flag for master mode
Bit 3:0 = 0 Reserved
SPIx_M = 0xXX
Holds bits 0–7 of the hardware match buffer.
SPIx_D = 0xxx
Holds bits 0–7 of the data to be transmitted by the transmit buffer and received by the receive buffer.
RESET
INITIALIZE SPI
SPIxC1 = 0x54
SPIxC2 = 0x80
SPIxBR = 0x00
YES
SPTEF = 1 NO
?
YES
WRITE TO
SPIxD
SPRF = 1 NO
?
YES
READ
SPIxD
SPMF = 1 NO
?
YES
READ SPMF WHILE SET
TO CLEAR FLAG,
THEN WRITE A 1 TO IT
CONTINUE
30.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances, see the chip configuration information.
The inter-integrated circuit (I2C, I2C, or IIC) module provides a method of
communication between a number of devices. The interface is designed to operate up to
100 kbit/s with maximum bus loading and timing. The I2C device is capable of operating
at higher baud rates, up to a maximum of clock/20, with reduced bus loading. The
maximum communication length and the number of devices that can be connected are
limited by a maximum bus capacitance of 400 pF. The I2C module also complies with
the System Management Bus (SMBus) Specification, version 2.
30.1.1 Features
The I2C module has the following features:
• Compatible with The I2C-Bus Specification
• Multimaster operation
• Software programmable for one of 64 different serial clock frequencies
• Software-selectable acknowledge bit
• Interrupt-driven byte-by-byte data transfer
• Arbitration-lost interrupt with automatic mode switching from master to slave
• Calling address identification interrupt
• START and STOP signal generation and detection
• Repeated START signal generation and detection
• Acknowledge bit generation and detection
• Bus busy detection
• General call recognition
Input
Sync
In/Out
START Data
STOP Shift
Arbitration Register
Control
Clock
Control Address
Compare
SCL SDA
Figure 30-1. I2C Functional block diagram
This section describes in detail all I2C registers accessible to the end user.
Bit 7 6 5 4 3 2 1 0
Read 0
AD[7:1]
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read MULT ICR
Write
Reset 0 0 0 0 0 0 0 0
00 mul = 1
01 mul = 2
10 mul = 4
11 Reserved
ICR ClockRate
Prescales the bus clock for bit rate selection. This field and the MULT field determine the I2C baud rate,
the SDA hold time, the SCL start hold time, and the SCL stop hold time. For a list of values corresponding
to each ICR setting, see I2C divider and hold values.
The SCL divider multiplied by multiplier factor (mul) determines the I2C baud rate.
SDA hold time = bus period (s) × mul × SDA hold value
The SCL start hold time is the delay from the falling edge of SDA (I2C data) while SCL is high (start
condition) to the falling edge of SCL (I2C clock).
SCL start hold time = bus period (s) × mul × SCL start hold value
The SCL stop hold time is the delay from the rising edge of SCL (I2C clock) to the rising edge of SDA (I2C
data) while SCL is high (stop condition).
SCL stop hold time = bus period (s) × mul × SCL stop hold value
For example, if the bus speed is 8 MHz, the following table shows the possible hold time values with
different ICR and MULT selections to achieve an I2C baud rate of 100 kbit/s.
Bit 7 6 5 4 3 2 1 0
Read 0 0
IICEN IICIE MST TX TXAK WUEN
Write RSTA
Reset 0 0 0 0 0 0 0 0
0 Disabled
1 Enabled
6 I2C Interrupt Enable
IICIE
Enables I2C interrupt requests.
0 Disabled
1 Enabled
5 Master Mode Select
MST
When the MST bit is changed from a 0 to a 1, a START signal is generated on the bus and master mode
is selected. When this bit changes from a 1 to a 0, a STOP signal is generated and the mode of operation
changes from master to slave.
0 Slave mode
1 Master mode
4 Transmit Mode Select
TX
Selects the direction of master and slave transfers. In master mode this bit must be set according to the
type of transfer required. Therefore, for address cycles, this bit is always set. When addressed as a slave
this bit must be set by software according to the SRW bit in the status register.
0 Receive
1 Transmit
3 Transmit Acknowledge Enable
TXAK
Specifies the value driven onto the SDA during data acknowledge cycles for both master and slave
receivers. The value of the FACK bit affects NACK/ACK generation.
0 An acknowledge signal is sent to the bus on the following receiving byte (if FACK is cleared) or the
current receiving byte (if FACK is set).
1 No acknowledge signal is sent to the bus on the following receiving data byte (if FACK is cleared) or
the current receiving data byte (if FACK is set).
0 Normal operation. No interrupt generated when address matching in low power mode.
1 Enables the wakeup function in low power mode.
0 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
Bit 7 6 5 4 3 2 1 0
0 Transfer in progress
1 Transfer complete
6 Addressed As A Slave
IAAS
This bit is set by one of the following conditions:
• The calling address matches the programmed slave primary address in the A1 register or range
address in the RA register (which must be set to a nonzero value).
• GCAEN is set and a general call is received.
• SIICAEN is set and the calling address matches the second programmed slave address.
• ALERTEN is set and an SMBus alert response address is received
• RMEN is set and an address is received that is within the range between the values of the A1 and
RA registers.
This bit sets before the ACK bit. The CPU must check the SRW bit and set TX/RX accordingly. Writing the
C1 register with any value clears this bit.
Table continues on the next page...
0 Bus is idle
1 Bus is busy
4 Arbitration Lost
ARBL
This bit is set by hardware when the arbitration procedure is lost. The ARBL bit must be cleared by
software, by writing a one to it.
0 Not addressed
1 Addressed as a slave
2 Slave Read/Write
SRW
When addressed as a slave, SRW indicates the value of the R/W command bit of the calling address sent
to the master.
NOTE: To clear the I2C bus stop or start detection interrupt: In the interrupt service
routine, first clear the STOPF or STARTF bit in the Input Glitch Filter register by
writing 1 to it, and then clear the IICIF bit. If this sequence is reversed, the IICIF
bit is asserted again.
0 No interrupt pending
1 Interrupt pending
Bit 7 6 5 4 3 2 1 0
Read DATA
Write
Reset 0 0 0 0 0 0 0 0
In master transmit mode, when data is written to this register, a data transfer is initiated. The most
significant bit is sent first. In master receive mode, reading this register initiates receiving of the next byte
of data.
NOTE: When making the transition out of master receive mode, switch the I2C mode before reading the
Data register to prevent an inadvertent initiation of a master receive data transfer.
In slave mode, the same functions are available after an address match occurs.
The C1[TX] bit must correctly reflect the desired direction of transfer in master and slave modes for the
transmission to begin. For example, if the I2C module is configured for master transmit but a master
receive is desired, reading the Data register does not initiate the receive.
Reading the Data register returns the last byte received while the I2C module is configured in master
receive or slave receive mode. The Data register does not reflect every byte that is transmitted on the I2C
bus, and neither can software verify that a byte has been written to the Data register correctly by reading it
back.
In master transmit mode, the first byte of data written to the Data register following assertion of MST (start
bit) or assertion of RSTA (repeated start bit) is used for the address transfer and must consist of the
calling address (in bits 7-1) concatenated with the required R/W bit (in position bit 0).
Bit 7 6 5 4 3 2 1 0
Read 0
GCAEN ADEXT SBRC RMEN AD[10:8]
Write
Reset 0 0 0 0 0 0 0 0
0 Disabled
1 Enabled
6 Address Extension
ADEXT
Controls the number of bits used for the slave address.
0 The slave baud rate follows the master baud rate and clock stretching may occur
1 Slave baud rate is independent of the master baud rate
3 Range Address Matching Enable
RMEN
This bit controls slave address matching for addresses between the values of the A1 and RA registers.
When this bit is set, a slave address match occurs for any address greater than the value of the A1
register and less than or equal to the value of the RA register.
0 Range mode disabled. No address match occurs for an address within the range of values of the A1
and RA registers.
1 Range mode enabled. Address matching occurs when a slave receives an address within the range of
values of the A1 and RA registers.
AD[10:8] Slave Address
Contains the upper three bits of the slave address in the 10-bit address scheme. This field is valid only
while the ADEXT bit is set.
Bit 7 6 5 4 3 2 1 0
If the SHEN bit is set to 1 and the I2C module is in an idle or disabled state when the MCU signals to enter
stop mode, the module immediately acknowledges the request to enter stop mode.
If SHEN is cleared to 0 and the overall data transmission or reception that was suspended by stop mode
entry was incomplete: To resume the overall transmission or reception after the MCU exits stop mode,
software must reinitialize the transfer by resending the address of the slave.
If the I2C Control Register 1's IICIE bit was set to 1 before the MCU entered stop mode, system software
will receive the interrupt triggered by the I2C Status Register's TCF bit after the MCU wakes from the stop
mode.
0 Stop holdoff is disabled. The MCU's entry to stop mode is not gated.
1 Stop holdoff is enabled.
6 I2C Bus Stop Detect Flag
STOPF
Hardware sets this bit when the I2C bus's stop status is detected. The STOPF bit must be cleared by
writing 1 to it.
NOTE: To clear the I2C bus stop or start detection interrupt: In the interrupt service routine, first clear the
STOPF or STARTF bit by writing 1 to it, and then clear the IICIF bit in the status register. If this
sequence is reversed, the IICIF bit is asserted again.
Controls the width of the glitch, in terms of bus clock cycles, that the filter must absorb. For any glitch
whose size is less than or equal to this width setting, the filter does not allow the glitch to pass.
Table continues on the next page...
Bit 7 6 5 4 3 2 1 0
Read 0
RAD
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
NOTE: After the host responds to a device that used the alert response address, you must use software
to put the device's address on the bus. The alert protocol is described in the SMBus specification.
NOTE: The low timeout function is disabled when the SLT register's value is zero.
Bit 7 6 5 4 3 2 1 0
Read 0
SAD
Write
Reset 1 1 0 0 0 0 1 0
Bit 7 6 5 4 3 2 1 0
Read SSLT[15:8]
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read SSLT[7:0]
Write
Reset 0 0 0 0 0 0 0 0
SDA A D 7 A D 6 A D 5 A D 4 A D 3 A D 2 A D 1 R /W XXX D7 D6 D5 D4 D3 D2 D1 D0
M SB LSB M SB LSB
SCL 1 2 3 4 5 6 7 9 1 2 3 4 5 6 7 9
8 8
SDA A D 7 A D 6 A D 5 A D 4 A D 3 A D 2 A D 1 R /W XX A D 7 A D 6 A D 5 A D 4 A D 3 A D 2 A D 1 R /W
No two slaves in the system can have the same address. If the I2C module is the master, it
must not transmit an address that is equal to its own slave address. The I2C module
cannot be master and slave at the same time. However, if arbitration is lost during an
address cycle, the I2C module reverts to slave mode and operates correctly even if it is
being addressed by another master.
D e la y S ta rt C o u n tin g H ig h P e rio d
SCL1
SCL2
SCL
In te rn a l C o u n te r R e s e t
30.4.1.8 Handshaking
The clock synchronization mechanism can be used as a handshake in data transfers. A
slave device may hold SCL low after completing a single byte transfer (9 bits). In this
case, it halts the bus clock and forces the master clock into wait states until the slave
releases SCL.
After the master-transmitter has sent the first byte of the 10-bit address, the slave-receiver
sees an I2C interrupt. User software must ensure that for this interrupt, the contents of the
Data register are ignored and not treated as valid data.
After a repeated START condition (Sr), all other slave devices also compare the first
seven bits of the first byte of the slave address with their own addresses and test the
eighth (R/W) bit. However, none of them are addressed because R/W = 1 (for 10-bit
devices), or the 11110XX slave address (for 7-bit devices) does not match.
Table 30-30. Master-receiver addresses a slave-transmitter with a 10-bit
address
S Slave R/W A1 Slave A2 Sr Slave R/W A3 Data A ... Data A P
address 0 address address 1
first 7 second first 7
bits byte bits
11110 + AD[8:1] 11110 +
AD10 + AD10 +
AD9 AD9
After the master-receiver has sent the first byte of the 10-bit address, the slave-transmitter
sees an I2C interrupt. User software must ensure that for this interrupt, the contents of the
Data register are ignored and not treated as valid data.
30.4.4.1 Timeouts
The TTIMEOUT,MIN parameter allows a master or slave to conclude that a defective device
is holding the clock low indefinitely or a master is intentionally trying to drive devices
off the bus. The slave device must release the bus (stop driving the bus and let SCL and
SDA float high) when it detects any single clock held low longer than TTIMEOUT,MIN.
Devices that have detected this condition must reset their communication and be able to
receive a new START condition within the timeframe of TTIMEOUT,MAX.
SMBus defines a clock low timeout, TTIMEOUT, of 35 ms, specifies TLOW:SEXT as the
cumulative clock low extend time for a slave device, and specifies TLOW:MEXT as the
cumulative clock low extend time for a master device.
A HIGH timeout occurs after a START condition appears on the bus but before a STOP
condition appears on the bus. Any master detecting this scenario can assume the bus is
free when either of the following occurs:
• SHTF1 rises.
• The BUSY bit is high and SHTF1 is high.
When the SMBDAT signal is low and the SMBCLK signal is high for a period of time,
another kind of timeout occurs. The time period must be defined in software. SHTF2 is
used as the flag when the time limit is reached. This flag is also an interrupt resource, so
it triggers IICIF.
ClkAck ClkAck
T LOW:MEXT T LOW:MEXT T LOW:MEXT
SCL
SDA
A master is allowed to abort the transaction in progress to any slave that violates the
TLOW:SEXT or TTIMEOUT,MIN specifications. To abort the transaction, the master issues a
STOP condition at the conclusion of the byte transfer in progress. When a slave, the I2C
module must not cumulatively extend its clock cycles for a period greater than
TLOW:SEXT during any message from the initial START to the STOP. When CSMBCLK
TIMEOUT SEXT occurs, SEXT rises and also triggers SLTF.
NOTE
CSMBCLK TIMEOUT SEXT and CSMBCLK TIMEOUT
MEXT are optional functions that are implemented in the
second step.
30.4.5 Resets
The I2C module is disabled after a reset. The I2C module cannot cause a core reset.
30.4.6 Interrupts
The I2C module generates an interrupt when any of the events in the following table
occur, provided that the IICIE bit is set. The interrupt is driven by the IICIF bit (of the
I2C Status Register) and masked with the IICIE bit (of the I2C Control Register 1). The
IICIF bit must be cleared (by software) by writing 1 to it in the interrupt routine. The
SMBus timeouts interrupt is driven by SLTF and masked with the IICIE bit. The SLTF
bit must be cleared by software by writing 1 to it in the interrupt routine. You can
determine the interrupt type by reading the Status Register.
NOTE
In master receive mode, the FACK bit must be set to zero
before the last byte transfer.
Table 30-31. Interrupt summary
Interrupt source Status Flag Local enable
Complete 1-byte transfer TCF IICIF IICIE
Match of received calling address IAAS IICIF IICIE
Arbitration lost ARBL IICIF IICIE
I2C bus stop detection STOPF IICIF IICIE & SSIE
I2C bus start detection STARTF IICIF IICIE & SSIE
SMBus SCL low timeout SLTF IICIF IICIE
SMBus SCL high SDA low timeout SHTF2 IICIF IICIE & SHTF2IE
Wakeup from stop or wait mode IAAS IICIF IICIE & WUEN
unless the Stop mode holdoff feature is used during this period
(set FLT[SHEN] to 1).
The routine shown in the following figure encompasses both master and slave I2C
operations. For slave operation, an incoming I2C message that contains the proper
address begins I2C communication. For master operation, communication must be
initiated by writing the Data register.
Clear IICIF
Y N
Master
mode?
Tx Rx Y Arbitration
Tx/Rx?
lost?
Last byte Y
Clear ARBL N
transmitted?
N Y N Y
Last byte
RXAK=0? IIAAS=1? IIAAS=1?
to be read?
Y N Y N Data transfer
Address transfer see note 2
Y see note 1
Y End of Y 2nd to Rx
(read)
address cycle last byte to be SRW=1? Tx/Rx?
(master Rx)? read?
N N N (write) Tx
Y
Write next Generate stop ACK from
byte to Data reg Set TXACK signal (MST=0) Set TX mode
receiver?
Switch to Switch to
Set Rx mode
Rx mode Rx mode
RTI
Notes:
1. If general call is enabled, check to determine if the received address is a general call address (0x00).
If the received address is a general call address, the general call must be handled by user software.
2. When 10-bit addressing addresses a slave, the slave sees an interrupt following the first byte of the extended address.
Ensure that for this interrupt, the contents of the Data register are ignored and not treated as a valid data transfer.
Y
Clear IICIF
Y N
Master
mode?
Tx Rx Y Arbitration
Tx/Rx?
lost?
Y Y
Last byte Last byte N
Clear ARBL
transmitted? to be read?
N N
N Y 2nd to N Y
RXAK=0? last byte to be IAAS=1? IAAS=1?
read?
Y N Y N
Address transfer
Y see note 1
Y End of Delay (note 2) (read)
address cycle Read data from
Data reg SRW=1? Tx/Rx?
(master Rx)? Rx
and soft CRC
Set TXAK to
Switch to Clear IICIF proper value Switch to
Set Tx mode Clear IICIF
Rx mode Delay (note 2) Rx mode
Delay (note 2)
RTI
Notes:
1. If general call or SIICAEN is enabled, check to determine if the received address is a general call address (0x00) or an SMBus
device default address. In either case, they must be handled by user software.
2. In receive mode, one bit time delay may be needed before the first and second data reading.
31.1 Introduction
31.1.1 Features
Features of UART module include:
• Full-duplex, standard non-return-to-zero (NRZ) format
• Double-buffered transmitter and receiver with separate enables
• Programmable baud rates (13-bit modulo divider)
• Interrupt-driven or polled operation:
• Transmit data register empty and transmission complete
• Receive data register full
• Receive overrun, parity error, framing error, and noise error
• Idle receiver detect
• Active edge on receive pin
• Break detect supporting LIN
• Hardware parity generation and checking
• Programmable 8-bit or 9-bit character length
• Programmable 1-bit or 2-bit stop bits
• Receiver wakeup by idle-line or address-mark
• Optional 13-bit break character generation / 11-bit break character detection
• Selectable transmitter output polarity
(Write-Only)
LOOPS
UART_D – Tx Buffer
RSRC
Loop
To Receive
11-BIT Transmit Shift Register Control
M Data In
Start
Stop
To TxD Pin
1 Baud H 8 7 6 5 4 3 2 1 0 L
Rate Clock
lsb
SHIFT DIRECTION
TXINV
Load From UARTx_D
T8
PE Parity
Generation
PT
TDRE
TIE
Tx Interrupt
TC
Request
TCIE
(Read-only)
16 × Baud Divide
Rate Clock UART_D – Rx Buffer
By 16
From
Transmitter
11-Bit Receive Shift Register
LOOPS
Start
Single-Wire
Stop
M
lsb
Loop Control
RSRC
LBKDE H 8 7 6 5 4 3 2 1 0 L
From RxD Pin
All 1s
msb
RXINV Data Recovery Shift Direction
WAKE Wakeup
RWU RWUID
Logic
ILT
RDRF
RIE
IDLE
ILIE
Rx Interrupt
Request
LBKDIF
LBKDIE
From RxD Pin
Active Edge
RXEDGIF
Detect
RXEDGIE
OR
ORIE
FE
FEIE
Error Interrupt
Request
NF
NEIE
PE Parity
PF
Checking
PT
PEIE
This register, along with UART_BDL, controls the prescale divisor for UART baud rate
generation. To update the 13-bit baud rate setting [SBR12:SBR0], first write to
UART_BDH to buffer the high half of the new value and then write to UART_BDL. The
working value in UART_BDH does not change until UART_BDL is written.
Address: Base address + 0h offset
Bit 7 6 5 4 3 2 1 0
Read LBKDIE RXEDGIE SBNS SBR
Write
Reset 0 0 0 0 0 0 0 0
The 13 bits in SBR[12:0] are referred to collectively as BR, and they set the modulo divide rate for the
UART baud rate generator. When BR is cleared, the UART baud rate generator is disabled to reduce
supply current. When BR is 1 - 8191, the UART baud rate equals BUSCLK/(16×BR).
UART_BDL is reset to a non-zero value, so after reset the baud rate generator remains
disabled until the first time the receiver or transmitter is enabled; that is, 1 is written to
UART_C2[RE] or UART_C2[TE].
Address: Base address + 1h offset
Bit 7 6 5 4 3 2 1 0
Read SBR
Write
Reset 0 0 0 0 0 1 0 0
These 13 bits in SBR[12:0] are referred to collectively as BR. They set the modulo divide rate for the
UART baud rate generator. When BR is cleared, the UART baud rate generator is disabled to reduce
supply current. When BR is 1 - 8191, the UART baud rate equals BUSCLK/(16×BR).
This read/write register controls various optional features of the UART system.
Address: Base address + 2h offset
Bit 7 6 5 4 3 2 1 0
Read LOOPS UARTSWAI RSRC M WAKE ILT PE PT
Write
Reset 0 0 0 0 0 0 0 0
0 Provided LOOPS is set, RSRC is cleared, selects internal loop back mode and the UART does not
use the RxD pins.
1 Single-wire UART mode where the TxD pin is connected to the transmitter output and receiver input.
4 9-Bit or 8-Bit Mode Select
M
0 Normal - start + 8 data bits (lsb first) + stop.
1 Receiver and transmitter use 9-bit data characters start + 8 data bits (lsb first) + 9th data bit + stop.
3 Receiver Wakeup Method Select
WAKE
0 Idle-line wakeup.
1 Address-mark wakeup.
2 Idle Line Type Select
ILT
Setting this bit to 1 ensures that the stop bits and logic 1 bits at the end of a character do not count toward
the 10 or 11 bit times of logic high level needed by the idle line detection logic.
0 Even parity.
1 Odd parity.
0 Transmitter off.
1 Transmitter on.
2 Receiver Enable
RE
When the UART receiver is off, the RxD pin reverts to being a general-purpose port I/O pin. If LOOPS is
set the RxD pin reverts to being a general-purpose I/O pin even if RE is set.
0 Receiver off.
1 Receiver on.
1 Receiver Wakeup Control
RWU
This bit can be written to 1 to place the UART receiver in a standby state where it waits for automatic
hardware detection of a selected wakeup condition. The wakeup condition is an idle line between
messages, WAKE = 0, idle-line wakeup, or a logic 1 in the most significant data bit in a character, WAKE =
1, address-mark wakeup. Application software sets RWU and, normally, a selected hardware condition
automatically clears RWU.
Write
Reset 1 1 0 0 0 0 0 0
0 No overrun.
1 Receive overrun (new UART data lost).
2 Noise Flag
NF
The advanced sampling technique used in the receiver takes seven samples during the start bit and three
samples in each data bit and the stop bits. If any of these samples disagrees with the rest of the samples
within any bit time in the frame, the flag NF is set at the same time as RDRF is set for the character. To
clear NF, read UART_S1 and then read the UART data register (UART_D).
0 No noise detected.
1 Noise detected in the received character in UART_D.
1 Framing Error Flag
FE
FE is set at the same time as RDRF when the receiver detects a logic 0 where the stop bits was expected.
This suggests the receiver was not properly aligned to a character frame. To clear FE, read UART_S1
with FE set and then read the UART data register (UART_D).
0 No framing error detected. This does not guarantee the framing is correct.
1 Framing error.
0 Parity Error Flag
PF
PF is set at the same time as RDRF when parity is enabled (PE = 1) and the parity bit in the received
character does not agree with the expected parity value. To clear PF, read UART_S1 and then read the
UART data register (UART_D).
0 No parity error.
1 Parity error.
When using an internal oscillator in a LIN system, it is necessary to raise the break
detection threshold one bit time. Under the worst case timing conditions allowed in LIN,
it is possible that a 0x00 data character can appear to be 10.26 bit times long at a slave
running 14% faster than the master. This would trigger normal break detection circuitry
designed to detect a 10-bit break symbol. When the LBKDE bit is set, framing errors are
inhibited and the break detection threshold changes from 10 bits to 11 bits, preventing
false detection of a 0x00 data character as a LIN break symbol.
Address: Base address + 5h offset
Bit 7 6 5 4 3 2 1 0
Read 0 RAF
LBKDIF RXEDGIF RXINV RWUID BRK13 LBKDE
Write
Reset 0 0 0 0 0 0 0 0
NOTE: Setting RXINV inverts the RxD input for all cases: data bits, start and stop bits, break, and idle.
0 During receive standby state (RWU = 1), the IDLE bit does not get set upon detection of an idle
character.
1 During receive standby state (RWU = 1), the IDLE bit gets set upon detection of an idle character.
2 Break Character Generation Length
BRK13
Table continues on the next page...
0 Break character is transmitted with length of 10 bit times (if M = 0, SBNS = 0) or 11 (if M = 1, SBNS =
0 or M = 0, SBNS = 1) or 12 (if M = 1, SBNS = 1).
1 Break character is transmitted with length of 13 bit times (if M = 0, SBNS = 0) or 14 (if M = 1, SBNS =
0 or M = 0, SBNS = 1) or 15 (if M = 1, SBNS = 1).
1 LIN Break Detection Enable
LBKDE
LBKDE enables the break detection. While LBKDE is set, framing error (FE) and receive data register full
(RDRF) flags are prevented from setting.
Read R8
T8 TXDIR TXINV ORIE NEIE FEIE PEIE
Write
Reset 0 0 0 0 0 0 0 0
NOTE: Setting TXINV inverts the TxD output for all cases: data bits, start and stop bits, break, and idle.
This register is actually two separate registers. Reads return the contents of the read-only
receive data buffer and writes go to the write-only transmit data buffer. Reads and writes
of this register are also involved in the automatic flag clearing mechanisms for the UART
status flags.
Address: Base address + 7h offset
Bit 7 6 5 4 3 2 1 0
Read R7T7 R6T6 R5T5 R4T4 R3T3 R2T2 R1T1 R0T0
Write
Reset 0 0 0 0 0 0 0 0
Divide By
16 Tx Baud Rate
UART Module Clock SBR[12:0]
UART communications require the transmitter and receiver, which typically derive baud
rates from independent clock sources, to use the same baud rate. Allowed tolerance on
this baud frequency depends on the details of how the receiver synchronizes to the
leading edge of the start bit and how bit sampling is performed.
The MCU resynchronizes to bit boundaries on every high-to-low transition. In the worst
case, there are no such transitions in the full 10- or 11-bit or 12-bittime character frame
so any mismatch in baud rate is accumulated for the whole character time. For a
Freescale UART system whose bus frequency is driven by a crystal, the allowed baud
rate mismatch is about ±4.5 percent for 8-bit data format and about ±4 percent for 9-bit
data format. Although baud rate modulo divider settings do not always produce baud
rates that exactly match standard rates, it is normally possible to get within a few percent,
which is acceptable for reliable communications.
The central element of the UART transmitter is the transmit shift register that is 10 or 11
or 12 bits long depending on the setting in the UART_C1[M] control bit and
UART_BDH[SBNS] bit. For the remainder of this section, assume UART_C1[M] is
cleared, UART_BDH[SBNS] is also cleared, selecting the normal 8-bit data mode. In 8-
bit data mode, the shift register holds a start bit, eight data bits, and a stop bit. When the
transmit shift register is available for a new UART character, the value waiting in the
transmit data register is transferred to the shift register, synchronized with the baud rate
clock, and the transmit data register empty (UART_S1[TDRE]) status flag is set to
indicate another character may be written to the transmit data buffer at UART_D.
If no new character is waiting in the transmit data buffer after a stop bit is shifted out the
TxD pin, the transmitter sets the transmit complete flag and enters an idle mode, with
TxD high, waiting for more characters to transmit.
Writing 0 to UART_C2[TE] does not immediately release the pin to be a general-purpose
I/O pin. Any transmit activity in progress must first be completed. This includes data
characters in progress, queued idle characters, and queued break characters.
the pin shared with TxD is an output driving a logic 1. This ensures that the TxD line
looks like a normal idle line even if the UART loses control of the port pin between
writing 0 and then 1 to UART_C2[TE].
The length of the break character is affected by the UART_S2[BRK13] and
UART_C1[M] bits as shown below.
Table 31-37. Break character length
BRK13 M SBNS Break character length
0 0 0 10 bit times
0 0 1 11 bit times
0 1 0 11 bit times
0 1 1 12 bit times
1 0 0 13 bit times
1 0 1 14 bit times
1 1 0 14 bit times
1 1 1 15 bit times
When a program detects that the receive data register is full (UART_S1[RDRF] = 1), it
gets the data from the receive data register by reading UART_D. The UART_S1[RDRF]
flag is cleared automatically by a two-step sequence normally satisfied in the course of
the user's program that manages receive data. Refer to Interrupts and status flags for more
details about flag clearing.
When polling is used, this sequence is naturally satisfied in the normal course of the user
program. If hardware interrupts are used, UART_S1 must be read in the interrupt service
routine (ISR). Normally, this is done in the ISR anyway to check for receive errors, so the
sequence is automatically satisfied.
The IDLE status flag includes logic that prevents it from getting set repeatedly when the
RxD line remains idle for an extended period of time. IDLE is cleared by reading
UART_S1 while UART_S1[IDLE] is set and then reading UART_D. After
UART_S1[IDLE] has been cleared, it cannot become set again until the receiver has
received at least one new character and has set UART_S1[RDRF].
If the associated error was detected in the received character that caused
UART_S1[RDRF] to be set, the error flags - noise flag (UART_S1[NF]), framing error
(UART_S1[FE]), and parity error flag (UART_S1[PF]) - are set at the same time as
UART_S1[RDRF]. These flags are not set in overrun cases.
If UART_S1[RDRF] was already set when a new character is ready to be transferred
from the receive shifter to the receive data buffer, the overrun (UART_S1[OR]) flag is
set instead of the data along with any associated NF, FE, or PF condition is lost.
At any time, an active edge on the RxD serial data input pin causes the
UART_S2[RXEDGIF] flag to set. The UART_S2[RXEDGIF] flag is cleared by writing a
1 to it. This function depends on the receiver being enabled (UART_C2[RE] = 1).
MSB STOP
RECEIVER
RT CLOCK
RT10
RT11
RT12
RT13
RT14
RT15
RT16
RT1
RT2
RT3
RT4
RT5
RT6
RT7
RT8
RT9
DATA
SAMPLES
For an 8-bit data and 1 stop bit character, data sampling of the stop bit takes the receiver
9 bit times x 16 RT cycles +10 RT cycles =154 RT cycles.
With the misaligned character shown in Figure 10-13, the receiver counts 154 RT cycles
at the point when the count of the transmitting device is 9 bit times x 16 RT cycles + 3
RT cycles = 147 RT cycles.
The maximum percent difference between the receiver count and the transmitter count of
a slow 8-bit data and 1 stop bit character with no errors is:
((154 - 147) / 154) x 100 = 4.54%
For a 9-bit data or 2 stop bits character, data sampling of the stop bit takes the receiver 10
bit times x 16 RT cycles + 10 RT cycles = 170 RT cycles.
With the misaligned character shown in, the receiver counts 170 RT cycles at the point
when the count of the transmitting device is 10 bit times x 16 RT cycles + 3 RT cycles =
163 RT cycles.
The maximum percent difference between the receiver count and the transmitter count of
a slow 9-bit or 2 stop bits character with no errors is:
((170 - 163) / 170) X 100 = 4.12%
For a 9-bit data and 2 stop bit character, data sampling of the stop bit takes the receiver
11 bit times x 16 RT cycles + 10 RT cycles = 186 RT cycles.
With the misaligned character shown in, the receiver counts 186 RT cycles at the point
when the count of the transmitting device is 11 bit times x 16 RT cycles + 3 RT cycles =
179 RT cycles.
The maximum percent difference between the receiver count and the transmitter count of
a slow 9-bit and 2 stop bits character with no errors is: ((186 - 179) / 186) X 100 = 3.76%
RECEIVER
RT CLOCK
RT10
RT11
RT12
RT13
RT14
RT15
RT16
RT1
RT2
RT3
RT4
RT5
RT6
RT7
RT8
RT9
DATA
SAMPLES
For an 8-bit data and 1 stop bit character, data sampling of the stop bit takes the receiver
9 bit times x 16 RT cycles + 10 RT cycles = 154 RT cycles.
With the misaligned character shown in Figure 31-37, the receiver counts 154 RT cycles
at the point when the count of the transmitting device is 10 bit times x 16 RT cycles =
160 RT cycles.
The maximum percent difference between the receiver count and the transmitter count of
a fast 8-bit and 1 stop bit character with no errors is:
((154 - 160) / 154) x 100 = 3.90%
For a 9-bit data or 2 stop bits character, data sampling of the stop bit takes the receiver 10
bit times x 16 RT cycles + 10 RT cycles = 170 RT cycles.
With the misaligned character shown in, the receiver counts 170 RT cycles at the point
when the count of the transmitting device is 11 bit times x 16 RT cycles = 176 RT cycles.
The maximum percent difference between the receiver count and the transmitter count of
a fast 9-bit or 2 stop bits character with no errors is:
((170 - 176) / 170) x 100 = 3.53%
For a 9-bit data and 2 stop bits character, data sampling of the stop bit takes the receiver
11 bit times x 16 RT cycles + 10 RT cycles = 186 RT cycles.
With the misaligned character shown in, the receiver counts 186 RT cycles at the point
when the count of the transmitting device is 12 bit times x 16 RT cycles = 192 RT cycles.
The maximum percent difference between the receiver count and the transmitter count of
a fast 9-bit and 2 stop bits character with no errors is:
((186 - 192) / 186) x 100 = 3.23%
external system, to help isolate system problems. In this mode, the internal loop back
connection from the transmitter to the receiver causes the receiver to receive characters
that are sent out by the transmitter.
32.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances, see the chip configuration information.
The general-purpose input and output (GPIO) module communicates to the processor
core via a zero wait state interface (IOPORT) for maximum pin performance. The GPIO
registers support 8-bit, 16-bit or 32-bit accesses.
The GPIO data direction and output data registers control the direction and output data of
each pin when the pin is configured for the GPIO function. The GPIO input data register
displays the logic value on each pin when the pin is configured for any digital function,
provided the corresponding Port Control and Interrupt module for that pin is enabled.
Efficient bit manipulation of the general-purpose outputs is supported through the
addition of set, clear, and toggle write-only registers for each port output data register.
32.1.1 Features
• Features of the GPIO module include:
• Pin input data register visible in all digital pin-multiplexing modes
• Pin output data register with corresponding set/clear/toggle registers
• Pin data direction register
• Zero wait state access to GPIO registers through IOPORT
NOTE
GPIO module is clocked by system clock.
NOTE
Not all pins within each port are implemented on each device.
See the chapter on signal multiplexing for the number of GPIO
ports available in the device.
3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
9 8 7 6 5 4 3 2 1 0
1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
PTB7
PTB6
PTB5
PTB4
PTB3
PTB2
PTB1
PTB0
PTD7
PTD6
PTD5
PTD4
PTD3
PTD2
PTD1
PTD0
PTC7
PTC6
PTC5
PTC4
PTC3
PTC2
PTC1
PTC0
PTA7
PTA6
PTA5
PTA4
PTA3
PTA2
PTA1
PTA0
Port pin
3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
9 8 7 6 5 4 3 2 1 0
1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
PTE7
PTE6
PTE5
PTE4
PTE3
PTE2
PTE1
PTE0
PTF7
PTF6
PTF5
PTF4
PTF3
PTF2
PTF1
PTF0
PTG3
PTG2
PTG1
PTG0
PTH7
PTH6
PTH2
PTH1
PTH0
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Port pin
NOTE
Do not modify pin configuration registers associated with pins
not available in your selected package. All un-bonded pins not
available in your package will default to DISABLE state for
lowest power consumption.
Address: Base address + 0h offset
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R
W
PDO
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Register bits for un-bonded pins return a undefined value when read.
0 Logic level 0 is driven on pin, provided pin is configured for general-purpose output.
1 Logic level 1 is driven on pin, provided pin is configured for general-purpose output.
R 0
W PTSO
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Writing to this register will update the contents of the corresponding bit in the PDOR as follows:
R 0
W PTCO
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Writing to this register will update the contents of the corresponding bit in the Port Data Output Register
(PDOR) as follows:
R 0
W PTTO
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Writing to this register will update the contents of the corresponding bit in the PDOR as follows:
NOTE
Do not modify pin configuration registers associated with pins
not available in your selected package. All un-bonded pins not
available in your package will default to DISABLE state for
lowest power consumption.
Address: Base address + 10h offset
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R PDI
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Reads 0 at the unimplemented pins for a particular device. Pins that are not configured for a digital
function read 0. If the Port Control and Interrupt module is disabled, then the corresponding bit in PDIR
does not update.
0 Pin logic level is logic 0, or is not configured for use by digital function.
1 Pin logic level is logic 1.
0 Pin is configured for General Purpose Input, provided the pin is configured for any digital function.
1 Pin is not configured as General Purpose Input.Corresponding Pin Data Input Register bit will read
zero.
3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
9 8 7 6 5 4 3 2 1 0
1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
PTB7
PTB6
PTB5
PTB4
PTB3
PTB2
PTB1
PTB0
PTD7
PTD6
PTD5
PTD4
PTD3
PTD2
PTD1
PTD0
PTC7
PTC6
PTC5
PTC4
PTC3
PTC2
PTC1
PTC0
PTA7
PTA6
PTA5
PTA4
PTA3
PTA2
PTA1
PTA0
Port pin
3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
9 8 7 6 5 4 3 2 1 0
1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
PTE7
PTE6
PTE5
PTE4
PTE3
PTE2
PTE1
PTE0
PTF7
PTF6
PTF5
PTF4
PTF3
PTF2
PTF1
PTF0
PTG3
PTG2
PTG1
PTG0
PTH7
PTH6
PTH2
PTH1
PTH0
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Port pin
0 Logic level 0 is driven on pin, provided pin is configured for general-purpose output.
1 Logic level 1 is driven on pin, provided pin is configured for general-purpose output.
R 0
W PTSO
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
R 0
W PTCO
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Writing to this register will update the contents of the corresponding bit in the Port Data Output Register
(PDOR) as follows:
R 0
W PTTO
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Writing to this register will update the contents of the corresponding bit in the PDOR as follows:
R PDI
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Reads 0 at the unimplemented pins for a particular device. Pins that are not configured for a digital
function read 0. If the Port Control and Interrupt module is disabled, then the corresponding bit in PDIR
does not update.
0 Pin logic level is logic 0, or is not configured for use by digital function.
1 Pin logic level is logic 1.
0 Pin is configured as general-purpose input, for the GPIO function. The pin will be high-Z if the port
input is disabled in FPIOx_PIDR register.
1 Pin is configured as general-purpose output, for the GPIO function.
0 Pin is configured for General Purpose Input, provided the pin is configured for any digital function.
1 Pin is not configured as General Purpose Input.Corresponding Pin Data Input Register bit will read
zero.
To facilitate efficient bit manipulation on the general-purpose outputs, pin data set, pin
data clear, and pin data toggle registers exist to allow one or more outputs within one port
to be set, cleared, or toggled from a single register write.
The corresponding Port Control and Interrupt module does not need to be enabled to
update the state of the port data direction registers and port data output registers including
the set/clear/toggle registers.
32.4.3 IOPORT
The GPIO registers are also aliased to the IOPORT interface on the Cortex-M0+ from
address 0xF800_0000. Accesses via the IOPORT interface occur in parallel with any
instruction fetches and will therefore complete in a single cycle.
33.1 Introduction
33.1.1 Features
The KBI features include:
• Up to eight keyboard interrupt pins with individual pin enable bits
• Each keyboard interrupt pin is programmable as:
• falling-edge sensitivity only
• rising-edge sensitivity only
• both falling-edge and low-level sensitivity
• both rising-edge and high-level sensitivity
• One software-enabled keyboard interrupt
• Exit from low-power modes
Read 0 KBF
KBIE KBMOD
Write KBACK
Reset 0 0 0 0 0 0 0 0
Each of the KBIPEn bits enable the corresponding KBI interrupt pin.
Each of the KBEDGn bits selects the falling edge/low-level or rising edge/high-level function of the
corresponding pin.