K20 Sub-Family Reference Manual: Supports: MK20DX128VLL7, MK20DX256VLL7, MK20DX64VMC7, MK20DX128VMC7, MK20DX256VMC7
K20 Sub-Family Reference Manual: Supports: MK20DX128VLL7, MK20DX256VLL7, MK20DX64VMC7, MK20DX128VMC7, MK20DX256VMC7
K20 Sub-Family Reference Manual: Supports: MK20DX128VLL7, MK20DX256VLL7, MK20DX64VMC7, MK20DX128VMC7, MK20DX256VMC7
Chapter 1
About This Document
1.1 Overview.......................................................................................................................................................................51
1.1.1 Purpose.........................................................................................................................................................51
1.1.2 Audience......................................................................................................................................................51
1.2 Conventions..................................................................................................................................................................51
Chapter 2
Introduction
2.1 Overview.......................................................................................................................................................................53
2.2.4 Clocks...........................................................................................................................................................56
Chapter 3
Chip Configuration
3.1 Introduction...................................................................................................................................................................61
3.6 Security.........................................................................................................................................................................100
3.7 Analog...........................................................................................................................................................................101
3.8 Timers...........................................................................................................................................................................115
Chapter 4
Memory Map
4.1 Introduction...................................................................................................................................................................149
Chapter 5
Clock Distribution
5.1 Introduction...................................................................................................................................................................163
Chapter 6
Reset and Boot
6.1 Introduction...................................................................................................................................................................177
6.2 Reset..............................................................................................................................................................................178
6.3 Boot...............................................................................................................................................................................185
Chapter 7
Power Management
7.1 Introduction...................................................................................................................................................................189
Chapter 8
Security
8.1 Introduction...................................................................................................................................................................197
Chapter 9
Debug
9.1 Introduction...................................................................................................................................................................201
9.1.1 References....................................................................................................................................................203
9.4.1 IR Codes.......................................................................................................................................................205
9.7 AHB-AP........................................................................................................................................................................211
9.8 ITM...............................................................................................................................................................................212
9.10 TPIU..............................................................................................................................................................................212
9.11 DWT.............................................................................................................................................................................212
Chapter 10
Signal Multiplexing and Signal Descriptions
10.1 Introduction...................................................................................................................................................................215
10.3 Pinout............................................................................................................................................................................217
10.4.5 Analog..........................................................................................................................................................229
Chapter 11
Port control and interrupts (PORT)
11.1 Introduction...................................................................................................................................................................237
11.1.1 Overview......................................................................................................................................................237
Chapter 12
System Integration Module (SIM)
12.1 Introduction...................................................................................................................................................................253
12.1.1 Features........................................................................................................................................................253
Chapter 13
Reset Control Module (RCM)
13.1 Introduction...................................................................................................................................................................287
Chapter 14
System Mode Controller
14.1 Introduction...................................................................................................................................................................295
Chapter 15
Power Management Controller
15.1 Introduction...................................................................................................................................................................315
15.2 Features.........................................................................................................................................................................315
Chapter 16
Low-Leakage Wakeup Unit (LLWU)
16.1 Introduction...................................................................................................................................................................323
16.1.1 Features........................................................................................................................................................323
16.4.3 Initialization.................................................................................................................................................343
Chapter 17
Miscellaneous Control Module (MCM)
17.1 Introduction...................................................................................................................................................................345
17.1.1 Features........................................................................................................................................................345
Chapter 18
Crossbar Switch (AXBS)
18.1 Introduction...................................................................................................................................................................349
18.1.1 Features........................................................................................................................................................349
18.3.3 Arbitration....................................................................................................................................................358
Chapter 19
Peripheral Bridge (AIPS-Lite)
19.1 Introduction...................................................................................................................................................................363
19.1.1 Features........................................................................................................................................................363
Chapter 20
Direct Memory Access Multiplexer (DMAMUX)
20.1 Introduction...................................................................................................................................................................381
20.1.1 Overview......................................................................................................................................................381
20.1.2 Features........................................................................................................................................................382
20.5.1 Reset.............................................................................................................................................................389
Chapter 21
Direct Memory Access Controller (eDMA)
21.1 Introduction...................................................................................................................................................................393
21.1.3 Features........................................................................................................................................................396
21.3.21 TCD Signed Minor Loop Offset (Minor Loop Enabled and Offset Disabled)
(DMA_TCDn_NBYTES_MLOFFNO).......................................................................................................435
21.3.22 TCD Signed Minor Loop Offset (Minor Loop and Offset Enabled)
(DMA_TCDn_NBYTES_MLOFFYES).....................................................................................................436
21.3.26 TCD Current Minor Loop Link, Major Loop Count (Channel Linking Enabled)
(DMA_TCDn_CITER_ELINKYES)...........................................................................................................439
21.3.27 TCD Current Minor Loop Link, Major Loop Count (Channel Linking Disabled)
(DMA_TCDn_CITER_ELINKNO)............................................................................................................440
21.3.30 TCD Beginning Minor Loop Link, Major Loop Count (Channel Linking Enabled)
(DMA_TCDn_BITER_ELINKYES)...........................................................................................................444
21.3.31 TCD Beginning Minor Loop Link, Major Loop Count (Channel Linking Disabled)
(DMA_TCDn_BITER_ELINKNO)............................................................................................................445
21.4.4 Performance.................................................................................................................................................451
Chapter 22
External Watchdog Monitor (EWM)
22.1 Introduction...................................................................................................................................................................471
22.1.1 Features........................................................................................................................................................471
Chapter 23
Watchdog Timer (WDOG)
23.1 Introduction...................................................................................................................................................................481
23.2 Features.........................................................................................................................................................................481
Chapter 24
Multipurpose Clock Generator (MCG)
24.1 Introduction...................................................................................................................................................................503
24.1.1 Features........................................................................................................................................................503
Chapter 25
Oscillator (OSC)
25.1 Introduction...................................................................................................................................................................541
25.8.3 Counter.........................................................................................................................................................550
25.9 Reset..............................................................................................................................................................................550
25.11 Interrupts.......................................................................................................................................................................551
Chapter 26
RTC Oscillator
26.1 Introduction...................................................................................................................................................................553
26.7 Interrupts.......................................................................................................................................................................556
Chapter 27
Flash Memory Controller (FMC)
27.1 Introduction...................................................................................................................................................................557
27.1.1 Overview......................................................................................................................................................557
27.1.2 Features........................................................................................................................................................558
Chapter 28
Flash Memory Module (FTFL)
28.1 Introduction...................................................................................................................................................................581
28.1.1 Features........................................................................................................................................................582
28.1.3 Glossary.......................................................................................................................................................584
28.4.3 Interrupts......................................................................................................................................................607
28.4.12 Security........................................................................................................................................................638
Chapter 29
External Bus Interface (FlexBus)
29.1 Introduction...................................................................................................................................................................643
29.1.1 Definition.....................................................................................................................................................643
29.1.2 Features........................................................................................................................................................643
Chapter 30
EzPort
30.1 Overview.......................................................................................................................................................................689
30.1.1 Introduction..................................................................................................................................................689
30.1.2 Features........................................................................................................................................................690
Chapter 31
Cyclic Redundancy Check (CRC)
31.1 Introduction...................................................................................................................................................................701
31.1.1 Features........................................................................................................................................................701
Chapter 32
Analog-to-Digital Converter (ADC)
32.1 Introduction...................................................................................................................................................................711
32.1.1 Features........................................................................................................................................................711
Chapter 33
Comparator (CMP)
33.1 Introduction...................................................................................................................................................................765
Chapter 34
12-bit Digital-to-Analog Converter (DAC)
34.1 Introduction...................................................................................................................................................................793
34.2 Features.........................................................................................................................................................................793
34.5.3 Resets...........................................................................................................................................................801
Chapter 35
Voltage Reference (VREFV1)
35.1 Introduction...................................................................................................................................................................803
35.1.1 Overview......................................................................................................................................................804
35.1.2 Features........................................................................................................................................................804
Chapter 36
Programmable Delay Block (PDB)
36.1 Introduction...................................................................................................................................................................811
36.1.1 Features........................................................................................................................................................811
36.1.2 Implementation............................................................................................................................................812
36.4.4 Pulse-Out's...................................................................................................................................................828
36.4.6 Interrupts......................................................................................................................................................830
36.4.7 DMA............................................................................................................................................................830
36.5.1 Impact of using the prescaler and multiplication factor on timing resolution.............................................831
Chapter 37
FlexTimer Module (FTM)
37.1 Introduction...................................................................................................................................................................833
37.1.2 Features........................................................................................................................................................834
37.4.2 Prescaler.......................................................................................................................................................888
37.4.3 Counter.........................................................................................................................................................888
37.4.12 Inverting.......................................................................................................................................................928
37.4.18 Initialization.................................................................................................................................................939
37.4.23 DMA............................................................................................................................................................944
Chapter 38
Periodic Interrupt Timer (PIT)
38.1 Introduction...................................................................................................................................................................965
38.1.2 Features........................................................................................................................................................966
38.4.2 Interrupts......................................................................................................................................................972
Chapter 39
Low-Power Timer (LPTMR)
39.1 Introduction...................................................................................................................................................................975
39.1.1 Features........................................................................................................................................................975
Chapter 40
Carrier Modulator Transmitter (CMT)
40.1 Introduction...................................................................................................................................................................985
40.2 Features.........................................................................................................................................................................985
40.7.3 Modulator.....................................................................................................................................................1003
Chapter 41
Real Time Clock (RTC)
41.1 Introduction...................................................................................................................................................................1011
41.1.1 Features........................................................................................................................................................1011
41.3.3 Compensation...............................................................................................................................................1025
41.3.8 Interrupt........................................................................................................................................................1027
Chapter 42
Universal Serial Bus OTG Controller (USBOTG)
42.1 Introduction...................................................................................................................................................................1029
42.1.1 USB..............................................................................................................................................................1029
42.9.1 ......................................................................................................................................................................1069
42.10.1 ......................................................................................................................................................................1069
42.10.2 Power...........................................................................................................................................................1069
Chapter 43
USB Device Charger Detection Module (USBDCD)
43.1 Preface...........................................................................................................................................................................1071
43.1.1 References....................................................................................................................................................1071
43.1.3 Glossary.......................................................................................................................................................1072
43.2 Introduction...................................................................................................................................................................1072
43.2.2 Features........................................................................................................................................................1073
43.5.3 Resets...........................................................................................................................................................1095
Chapter 44
USB Voltage Regulator
44.1 Introduction...................................................................................................................................................................1099
44.1.1 Overview......................................................................................................................................................1099
44.1.2 Features........................................................................................................................................................1100
Chapter 45
CAN (FlexCAN)
45.1 Introduction...................................................................................................................................................................1103
45.1.1 Overview......................................................................................................................................................1104
45.4.7 Rx FIFO.......................................................................................................................................................1165
45.4.11 Interrupts......................................................................................................................................................1177
Chapter 46
Serial Peripheral Interface (SPI)
46.1 Introduction...................................................................................................................................................................1181
46.1.2 Features........................................................................................................................................................1182
46.3.3 DSPI Clock and Transfer Attributes Register (In Master Mode) (SPIx_CTARn)......................................1193
46.3.4 DSPI Clock and Transfer Attributes Register (In Slave Mode) (SPIx_CTARn_SLAVE)..........................1198
Chapter 47
Inter-Integrated Circuit (I2C)
47.1 Introduction...................................................................................................................................................................1233
47.1.1 Features........................................................................................................................................................1233
47.4.5 Resets...........................................................................................................................................................1257
47.4.6 Interrupts......................................................................................................................................................1257
Chapter 48
Universal Asynchronous Receiver/Transmitter (UART)
48.1 Introduction...................................................................................................................................................................1265
48.1.1 Features........................................................................................................................................................1265
48.4.1 CEA709.1-B.................................................................................................................................................1320
48.4.2 Transmitter...................................................................................................................................................1330
48.4.3 Receiver.......................................................................................................................................................1336
48.5 Reset..............................................................................................................................................................................1357
Chapter 49
Integrated Interchip Sound (I2S) / Synchronous Audio Interface (SAI)
49.1 Introduction...................................................................................................................................................................1369
49.1.1 Features........................................................................................................................................................1369
Chapter 50
General-Purpose Input/Output (GPIO)
50.1 Introduction...................................................................................................................................................................1403
50.1.1 Features........................................................................................................................................................1403
Chapter 51
Touch sense input (TSI)
51.1 Introduction...................................................................................................................................................................1411
51.2 Features.........................................................................................................................................................................1411
51.3 Overview.......................................................................................................................................................................1412
51.5.1 TSI_IN[15:0]................................................................................................................................................1417
Chapter 52
JTAG Controller (JTAGC)
52.1 Introduction...................................................................................................................................................................1437
52.1.2 Features........................................................................................................................................................1438
1.1 Overview
1.1.1 Purpose
This document describes the features, architecture, and programming model of the
Freescale K20 microcontroller.
1.1.2 Audience
This document is primarily for system architects and software application developers
who are using or considering using the K20 microcontroller in a system.
1.2 Conventions
2.1 Overview
This chapter provides 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
Multi-clock generator (MCG) The MCG provides several clock sources for the MCU that include:
• Phase-locked loop (PLL) — Voltage-controlled oscillator (VCO)
• Frequency-locked loop (FLL) — Digitally-controlled oscillator (DCO)
• Internal reference clocks — Can be used as a clock source for other on-chip
peripherals
System oscillator The system oscillator, in conjunction with an external crystal or resonator,
generates a reference clock for the MCU.
Real-time clock oscillator The RTC oscillator has an independent power supply and supports a 32 kHz
crystal oscillator to feed the RTC clock. Optionally, the RTC oscillator can replace
the system oscillator as the main oscillator source.
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, and
• links for more information.
Debug Interrupts
SRAM
Upper
PPB Modules
PPB
Crossbar ARM Cortex-M4
switch Core
SRAM
Lower
Interrupts
Module
ARM Cortex-M4
PPB Nested Vectored
Module
core
Interrupt Controller
(NVIC)
Module
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 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-4. Interrupt vector assignments
Address Vector IRQ1 NVIC NVIC Source module Source description
non-IPR IPR
register register
number number
2 3
0x0000_00EC 59 43 1 10 — —
0x0000_00F0 60 44 1 11 UART0 Single interrupt vector for UART LON
sources
0x0000_00F4 61 45 1 11 UART0 Single interrupt vector for UART status
sources
0x0000_00F8 62 46 1 11 UART0 Single interrupt vector for UART error
sources
0x0000_00FC 63 47 1 11 UART1 Single interrupt vector for UART status
sources
0x0000_0100 64 48 1 12 UART1 Single interrupt vector for UART error
sources
0x0000_0104 65 49 1 12 UART2 Single interrupt vector for UART status
sources
0x0000_0108 66 50 1 12 UART2 Single interrupt vector for UART error
sources
0x0000_010C 67 51 1 12 UART3 Single interrupt vector for UART status
sources
0x0000_0110 68 52 1 13 UART3 Single interrupt vector for UART error
sources
0x0000_0114 69 53 1 13 UART4 Single interrupt vector for UART status
sources
0x0000_0118 70 54 1 13 UART4 Single interrupt vector for UART error
sources
0x0000_011C 71 55 1 13 — —
0x0000_0120 72 56 1 14 — —
0x0000_0124 73 57 1 14 ADC0 —
0x0000_0128 74 58 1 14 ADC1 —
0x0000_012C 75 59 1 14 CMP0 —
0x0000_0130 76 60 1 15 CMP1 —
0x0000_0134 77 61 1 15 CMP2 —
0x0000_0138 78 62 1 15 FTM0 Single interrupt vector for all sources
0x0000_013C 79 63 1 15 FTM1 Single interrupt vector for all sources
0x0000_0140 80 64 2 16 FTM2 Single interrupt vector for all sources
0x0000_0144 81 65 2 16 CMT —
0x0000_0148 82 66 2 16 RTC Alarm interrupt
0x0000_014C 83 67 2 16 RTC Seconds interrupt
0x0000_0150 84 68 2 17 PIT Channel 0
0x0000_0154 85 69 2 17 PIT Channel 1
0x0000_0158 86 70 2 17 PIT Channel 2
0x0000_015C 87 71 2 17 PIT Channel 3
0x0000_0160 88 72 2 18 PDB —
0x0000_0164 89 73 2 18 USB OTG —
0x0000_0168 90 74 2 18 USB Charger —
Detect
0x0000_016C 91 75 2 18 — —
0x0000_0170 92 76 2 19 — —
0x0000_0174 93 77 2 19 — —
0x0000_0178 94 78 2 19 — —
0x0000_017C 95 79 2 19 — —
0x0000_0180 96 80 2 20 — —
0x0000_0184 97 81 2 20 DAC0 —
0x0000_0188 98 82 2 20 — —
0x0000_018C 99 83 2 20 TSI Single interrupt vector for all sources
0x0000_0190 100 84 2 21 MCG —
0x0000_0194 101 85 2 21 Low Power Timer —
0x0000_0198 102 86 2 21 — —
0x0000_019C 103 87 2 21 Port control module Pin detect (Port A)
0x0000_01A0 104 88 2 22 Port control module Pin detect (Port B)
0x0000_01A4 105 89 2 22 Port control module Pin detect (Port C)
0x0000_01A8 106 90 2 22 Port control module Pin detect (Port D)
0x0000_01AC 107 91 2 22 Port control module Pin detect (Port E)
0x0000_01B0 108 92 2 23 — —
0x0000_01B4 109 93 2 23 — —
0x0000_01B8 110 94 2 23 Software Software interrupt4
• The NVIC registers you would use to configure the interrupts are:
• NVICISER2
• NVICICER2
• NVICISPR2
• NVICICPR2
• NVICIABR2
• NVICIPR21
• To determine the particular IRQ's bitfield location within these particular registers:
• NVICISER2, NVICICER2, NVICISPR2, NVICICPR2, NVICIABR2 bit
location = IRQ mod 32 = 21
• NVICIPR21 bitfield starting location = 8 * (IRQ mod 4) + 4 = 12
Since the NVICIPR bitfields are 4-bit wide (16 priority levels), the NVICIPR21
bitfield range is 12-15
Therefore, the following bitfield locations are used to configure the LPTMR interrupts:
• NVICISER2[21]
• NVICICER2[21]
• NVICISPR2[21]
• NVICICPR2[21]
• NVICIABR2[21]
• NVICIPR21[15:12]
Clock logic
Wake-up
requests
interrupt controller
Nested vectored
Asynchronous
(NVIC)
Module
Wake-up Interrupt
Controller (AWIC)
Module
Signal multiplexing
cJTAG
JTAG controller
Peripheral
bridge
Register
access
System integration
module (SIM)
Register
access
Power Management
Controller (PMC)
Resets
System Mode
Controller (SMC)
Register access
Controller (SMC)
System Mode
Low-Leakage
Module Module
Wakeup Unit
Controller (PMC)
Register
access
Wake-up
requests
Power Management
Controller (PMC)
1. The EZP_CS signal is checked only on Chip Reset not VLLS, so a VLLS wakeup via a non-reset source does not cause
EzPort mode entry. If NMI was enabled on entry to LLS/VLLS, asserting the NMI pin generates an NMI interrupt on exit
from the low power mode. NMI can also be disabled via the FOPT[NMI_DIS] bit.
2. Requires the peripheral and the peripheral interrupt to be enabled. The LLWU's WUME bit enables the internal module flag
as a wakeup input. After wakeup, the flags are cleared based on the peripheral clearing mechanism.
PPB Miscellaneous
core
Control Module
Transfers
(MCM)
NOTE
The DMA and EzPort share a master port. Since these modules
never operate at the same time, no configuration or arbitration
explanations are necessary.
Peripherals
Transfers Transfers
AIPS-Lite
peripheral bridge
Peripheral
bridge 0
Register
access
Requests
Module
DMA controller
Channel
request DMA Request Module
Multiplexer
Module
1. Configuring a DMA channel to select source 0 or any of the reserved sources disables that DMA channel.
Peripheral
bridge 0
Register
access
DMA Multiplexer
Crossbar switch
Transfers Requests
DMA Controller
Peripheral
bridge 0
Register
access
Signal multiplexing
External Watchdog Module signals
Monitor (EWM)
Register
access
Mode Controller
WDOG
Peripheral
bridge
Register
access
oscillator oscillator
System integration
System
module (SIM)
Multipurpose Clock
Generator (MCG)
RTC
Register
access
Signal multiplexing
Module signals
MCG
System oscillator
Signal multiplexing
Module signals
MCG
Peripheral bus
controller 0
Register
access
Flash memory
controller
Transfers
Flash memory
FlexNVM
Peripheral bus
controller 0
Register
access
Crossbar switch
Flash memory
Transfers Transfers
Flash memory
controller
Cortex-M4
SRAM controller
0x2000_0000 – SRAM_size/2
SRAM size / 2
SRAM_L
0x1FFF_FFFF
0x2000_0000
SRAM size / 2
SRAM_U
0x2000_0000 + SRAM_size/2 - 1
Figure 3-22. SRAM blocks memory map
SRAM_L
non-core master
SRAM_U
The following simultaneous accesses can be made to different logical halves of the
SRAM:
• Core code and core system
• Core code and non-core master
• Core system and non-core master
NOTE
Two non-core masters cannot access SRAM simultaneously.
The required arbitration and serialization is provided by the
crossbar switch. The SRAM_{L,U} arbitration is controlled by
the SRAM controller based on the configuration bits in the
MCM module.
NOTE
Burst-access cannot occur across the 0x2000_0000 boundary
that separates the two SRAM arrays. The two arrays should be
treated as separate memory ranges for burst accesses.
Cortex-M4
SRAM
upper
core
SRAM
lower
Crossbar
switch
Register
access
Register file
Register
access
Signal multiplexing
Crossbar switch
Transfers Module signals
EzPort
Register
access
Signal multiplexing
Crossbar switch
To other modules
CSPMCR
FB_ALE
FB_CS1
FB_TS
Group1
Reserved
To other modules
FB_CS4
FB_TSIZ0
FB_BE_31_24 Group2
Reserved
To other modules
External Pins
FB_CS5
FB_TSIZ1
FB_BE_23_16
Group3
Reserved
To other modules
FB_TBST
FB_CS2
FB_BE_15_8
Group4
Reserved
To other modules
FB_TA
FB_CS3
FB_BE_7_0
Group5
Reserved
Therefore, use the CSPMCR and port control registers to configure which control signal
is available on the external pin. All control signals, except for FB_TA, are assigned to the
ALT5 function in the port control module. Since, unlike the other control signals, FB_TA
is an input signal, it is assigned to the ALT6 function.
3.6 Security
Peripheral
bridge
Register
access
CRC
3.7 Analog
Peripheral bus
controller 0
Register
access
Signal multiplexing
Transfers Module signals
Other peripherals 16-bit SAR ADC
ADC0_SE8/ADC1_SE8 ADC0
AD8
ADC0_SE9/ADC1_SE9 AD9
ADC1
AD8
AD9
ADC0
ADC0_DP1
DAD1
ADC0_DM1
DAD0
PGA0_DP/ADC0_DP0/ADC1_DP3
PGA0_DM/ADC0_DM0/ADC1_DM3
PGA0 DAD2
DAD3
ADC1
DAD3
PGA1_DP/ADC1_DP0/ADC0_DP3
PGA1 DAD2
PGA1_DM/ADC1_DM0/ADC0_DM3
DAD0
ADC1_DP1
DAD1
ADC1_DM1
Peripheral
bridge 0
Register
access
Signal multiplexing
Module signals
Other peripherals CMP
Register
access
Signal multiplexing
Transfers Module signals
Other peripherals 12-bit DAC
Register
access
Signal multiplexing
NOTE
PMC_REGSC[BGEN] bit must be set if the VREF regulator is
required to remain operating in VLPx modes.
NOTE
For either an internal or external reference if the VREF_OUT
functionality is being used, VREF_OUT signal must be
connected to an output load capacitor. Refer the device data
sheet for more details.
3.8 Timers
Register
access
Signal multiplexing
Channel 0
pre-trigger 0
Channel 1 Channel 0
pre-trigger 1 pre-trigger 1
Channel 1
pre-trigger 0
The application code can set the PDBx_CHnC1[BB] bits to configure the PDB pre-
triggers as a single chain or several chains.
NOTE
Application code can set the PDBx_DACINTCn[EXT] bit to
allow DAC external trigger input when the corresponding ADC
Conversion complete flag, ADCx_SC1n[COCO], is set.
Peripheral bus
controller 0
Register
access
Signal multiplexing
Transfers Module signals
Other peripherals FlexTimer
Compared with the FTM0 configuration, the FTM1 and FTM2 configuration adds the
Quadrature decoder feature and reduces the number of channels.
• FTM0 hardware trigger 0 = CMP0 Output or FTM1 Match (when enabled in the
FTM1 External Trigger (EXTTRIG) register)
• FTM0 hardware trigger 1 = PDB channel 1 Trigger Output or FTM2 Match (when
enabled in the FTM2 External Trigger (EXTTRIG) register)
• FTM0 hardware trigger 2 = FTM0_FLT0 pin
• FTM1 hardware trigger 0 = CMP0 Output
• FTM1 hardware trigger 1 = CMP1 Output
• FTM1 hardware trigger 2 = FTM1_FLT0 pin
• FTM2 hardware trigger 0 = CMP0 Output
• FTM2 hardware trigger 1 = CMP2 Output
• FTM2 hardware trigger 2 = FTM2_FLT0 pin
For the triggers with more than one option, the SOPT4 register in the SIM module
controls the selection.
FTM0 provides the only source for the FTM global time base. The other FTM modules
can share the time base as shown in the following figure:
FTM1
CONF Register
GTBEOUT = 0
FTM0 FTM Counter
GTBEEN = 1
CONF Register
gtb_in gtb_in
GTBEOUT = 1
FTM Counter
GTBEEN = 1
FTM2
gtb_out
CONF Register
GTBEOUT = 0
GTBEEN = 1 FTM Counter
gtb_in
Register
access
Periodic interrupt
timer
Peripheral
bridge
Register
access
Signal multiplexing
Module signals
Low-power timer
Register
access Signal multiplexing
Module signals
CMT
Register
access
Signal multiplexing
Module signals
Real-time clock
RTC_CR[CLKO]
RTC_CLKOUT
SIM_SOPT2[RTCCLKOUTSEL]
USB controller
VREGIN VOUT33 D+ D-
2 AA Cells
VDD
To PMC and Pads
VOUT33
Cstab
Chip
TYPE A
VBUS VREGIN USB
Regulator
D+ USB0_DP
USB USB
D- USB0_DM XCVR Controller
VDD
To PMC and Pads
VOUT33
Cstab
Chip
TYPE A
VREGIN
VBUS Charger Si2301 USB
Regulator
D+
USB USB
D- USB0_DP Controller
XCVR
VSS Li-Ion USB0_DM
Charger VBUS Sense
Detect
VDD
To PMC and Pads
VOUT33
Cstab
Chip
TYPE A
VBUS VREGIN
USB
Regulator
D+ USB0_DP
XCVR USB
D- USB0_DM USB Controller
Register
access
Signal multiplexing
Crossbar switch
NOTE
When USB is not used in the application, it is recommended
that the USB regulator VREGIN and VOUT33 pins remain
floating.
Register
access
USB OTG
Signal multiplexing
USB OTG
Module signals
USB Voltage
Regulator
NOTE
When USB is not used in the application, it is recommended
that the USB regulator VREGIN and VOUT33 pins remain
floating.
Register
access
Signal multiplexing
Module signals
FlexCAN
Request Sources
Message buffer Message buffers 0-15
Bus off Bus off
Error • Bit1 error
• Bit0 error
• Acknowledge error
• Cyclic redundancy check (CRC) error
• Form error
• Stuffing error
• Transmit error warning
• Receive error warning
Transmit Warning Transmit Warning
Receive Warning Receive Warning
Wake-up Wake-up
Peripheral
bridge
Register
access
Signal multiplexing
Module signals
SPI
There is one way to wake from stop mode via the SPI, which is explained in the
following section.
Register
access
Signal multiplexing
Module signals
I2 C
Peripheral
bridge
Register
access
Signal multiplexing
Module signals
UART
Peripheral
bridge
Register
access
Signal multiplexing
Module signals
I2 S
The module's MCLK Divide Register (MDR) configures the MCLK divide ratio.
The module's MCLK Output Enable bit of the MCLK Control Register (MCR[MOE])
controls the direction of the MCLK pin. The pin is the input from the pin when MOE is 0,
and the pin is the output from the clock divider when MOE is 1.
The transmitter and receiver can independently select between the bus clock and the
audio master clock to generate the bit clock. Each module's Clocking Mode field of the
Transmit Configuration 2 Register and Receive Configuration 2 Register (TCR2[MSEL]
and RCR2[MSEL]) selects the master clock.
Peripheral
bridge
Register
access
Signal multiplexing
Crossbar switch
Transfers Module signals
GPIO controller
Peripheral
bridge
Register
access
Signal multiplexing
Module signals
Touch sense input
module
4.1 Introduction
This device contains various memories and memory-mapped peripherals which are
located in one 32-bit contiguous memory space. This chapter describes the memory and
peripheral locations within that memory space.
NOTE
1. EzPort master port is statically muxed with DMA master
port. Access rights to AIPS-Lite peripheral bridges and
general purpose input/output (GPIO) module address space
is limited to the core, DMA, and EzPort.
2. ARM Cortex-M4 core access privileges also includes
accesses via the debug interface.
31 0 31 0
1 MByte
32 MByte
Figure 4-1. Alias bit-band mapping
NOTE
Each bit in bit-band region has an equivalent bit that can be
manipulated through bit 0 in a corresponding long word in the
alias bit-band region.
FlexNVM
5.1 Introduction
The MCG module controls which clock source is used to derive the system clocks. The
clock generation logic divides the selected clock source into a variety of clock domains,
including the clocks for the system bus masters, system bus slaves, and flash memory.
The clock generation logic also implements module-specific clock gating to allow
granular shutoff of modules.
The primary clocks for the system are generated from the MCGOUTCLK clock. The
clock generation circuitry provides several clock dividers that allow different portions of
the device to be clocked at different frequencies. This allows for trade-offs between
performance and power dissipation.
Various modules, such as the USB OTG Controller, have module-specific clocks that can
be generated from the MCGPLLCLK or MCGFLLCLK clock. In addition, there are
various other module-specific clocks that have other alternate sources. Clock selection for
most modules is controlled by the SOPT registers in the SIM module.
MCG SIM
MCGPLLCLK MCGPLLCLK/
MCGFLLCLK
Option 2:
Clock Frequency
Core clock 72 MHz
System clock 72 MHz
Bus clock 36 MHz
FlexBus clock 36 MHz
Flash clock 24 MHz
This gives the user flexibility for a lower frequency, low-power boot option. The flash
erased state defaults to fast clocking mode, since where the low power boot
(FTFL_FOPT[LPBOOT]) bit resides in flash is logic 1 in the flash erased state.
To enable the low power boot option program FTFL_FOPT[LPBOOT] to zero. During
the reset sequence, if LPBOOT is cleared, the system is in a slow clock configuration.
Upon any system reset, the clock dividers return to this configurable reset state.
LPO
WDOG clock
Bus clock
WDOG_STCTRLH[CLKSRC]
Figure 5-2. WDOG clock generation
MCGOUTCLK
TRACECLKIN
Debug
SIM_SOPT2[TRACECLKSEL]
Bus clock
PORTx digital input
filter clock
LPO
PORTx_DFCR[CS]
Figure 5-4. PORTx digital input filter clock generation
MCGIRCLK
OSCERCLK
LPTMRx_PSR[PCS]
Figure 5-5. LPTMRx prescaler/glitch filter clock generation
USB_CLKIN
USB 48MHz
MCGPLLCLK or SIM_CLKDIV2
MCGFLLCLK [USBFRAC, USBDIV]
SIM_SOPT2[USBSRC]
NOTE
The MCGFLLCLK does not meet the USB jitter specifications
for certification.
OSCERCLK
FlexCAN clock
Bus clock
CANx_CTRL1[CLKSRC]
The I2S/SAI transmitter and receiver support asynchronous bit clocks (BCLKs) that can
be generated internally from the audio master clock or supplied externally. The module
also supports the option for synchronous operation between the receiver and
transmitterproduct.
The transmitter and receiver can independently select between the bus clock and the
audio master clock to generate the bit clock.
The MCLK and BCLK source options appear in the following figure.
Bus clock
TSI clock
MCGIRCLK
in active mode
OSCERCLK
TSI_SCANC[AMCLKS]
Figure 5-9. TSI clock generation
In low-power mode, the TSI can be clocked as shown in the following figure.
NOTE
In the TSI chapter, these two clocks are referred to as LPOCLK
and VLPOSCCLK.
LPO
TSI clock
in low-power mode
ERCLK32K
TSI_GENCS[LPCLKS]
Figure 5-10. TSI low-power clock generation
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)
• Computer operating properly (COP) watchdog reset
• Low leakage wakeup (LLWU) reset
• Multipurpose clock generator loss of clock (LOC) reset
• Multipurpose clock generator loss of lock (LOL) reset
• Stop mode acknowledge error (SACKERR)
• Software reset (SW)
• Lockup reset (LOCKUP)
• EzPort reset
• MDM DAP system reset
Debug reset • JTAG reset
• nTRST reset
Each of the system reset sources, with the exception of the EzPort and MDM-AP reset,
has an associated bit in the system reset status (SRS) registers. See the Reset Control
Module for register details.
The MCU exits reset in functional mode that is controlled by EZP_CS pin to select
between the single chip (default) or serial flash programming (EzPort) modes. See Boot
options 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.
Note that the nTRST signal is initially configured as disabled, however once configured
to its JTAG functionality its associated input pin is configured as:
• nTRST in PU
6.3 Boot
This section describes the boot sequence, including sources and options.
This device only supports booting from internal flash. Any secondary boot must go
through an initialization sequence in flash.
1. CDBGRSTREQ does not affect AHB resources so that debug resources on the private peripheral bus are available
during System Reset.
The device can be in single chip (default) or serial flash programming mode (EzPort).
While in single chip mode the device can be in run or various low power modes
mentioned in Power mode transitions.
Table 6-2. Mode select decoding
EzPort chip select (EZP_CS) Description
0 Serial flash programming mode (EzPort)
1 Single chip (default)
7.1 Introduction
This chapter describes the various chip power modes and functionality of the individual
modules in these modes.
1. Resumes normal run mode operation by executing the LLWU interrupt service routine.
2. Follows the reset flow with the LLWU interrupt flag set for the NVIC.
Any reset
VLPW
4
1
Wait VLPR
3
Run 6
7
2
Stop
VLPS
10
8
11
LLS VLLS
3, 2, 1
1. Using the LLWU module, the external pins available for this chip do not require the associated peripheral function to be
enabled. It only requires the function controlling the pin (GPIO or peripheral) to be configured as an input to allow a
transition to occur to the LLWU.
2. A 16KB portion of SRAM_U block is left powered on in low power mode VLLS2.
3. FlexRAM enabled as EEPROM is not writable in VLPR and writes are ignored. Read accesses to FlexRAM as EEPROM
while in VLPR are allowed. There are no access restrictions for FlexRAM configured as traditional RAM.
4. These components remain powered in BAT power mode.
5. Use an externally generated bit clock or an externally generated audio master clock (including EXTAL).
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 the effects of security
on non-flash modules.
When mass erase is disabled, mass erase via the debugger is blocked.
9.1 Introduction
This device's debug is based on the ARM coresight architecture and is configured in each
device to provide the maximum flexibility as allowed by the restrictions of the pinout and
other available resources.
Four debug interfaces are supported:
• IEEE 1149.1 JTAG
• IEEE 1149.7 JTAG (cJTAG)
• Serial Wire Debug (SWD)
• ARM Real-Time Trace Interface(1-pin asynchronous mode only)
The basic Cortex-M4 debug architecture is very flexible. The following diagram shows
the topology of the core debug architecture and its components.
Cortex-M4
INTNMI Interrupts
INTISR[239:0] Sleep
NVIC Core
SLEEPING Debug ETM
Trigger
SLEEPDEEP Instr. Data
Trace port
(serial wire
or multi-pin)
AWIC TPIU
MCM
FPB DWT ITM
I-code bus
Bus Code bus
D-code bus
Matrix
SW/ System bus
SWJ-DP AHB-AP
JTAG
MDM-AP
The following table presents a brief description of each one of the debug components.
Table 9-1. Debug Components Description
Module Description
SWJ-DP+ cJTAG Modified Debug Port with support for SWD, JTAG, cJTAG
AHB-AP AHB Master Interface from JTAG to debug module and SOC
system memory maps
JTAG-AP Bridge to DFT/BIST resources.
ROM Table Identifies which debug IP is available.
Core Debug Singlestep, Register Access, Run, Core Status
ITM S/W Instrumentation Messaging + Simple Data Trace
Messaging + Watchpoint Messaging
DWT (Data and Address Watchpoints) 4 data and address watchpoints (configurable for less, but 4
seems to be accepted)
9.1.1 References
For more information on ARM debug components, see these documents:
• ARMv7-M Architecture Reference Manual
• ARM Debug Interface v5.1
• ARM CoreSight Architecture Specification
IR==BYPASSor IDCODE
4’b1111 or 4’b0000
jtag_updateinstr[3:0]
A
TDI To Test
JTAGC Resources
nTRST
TCK
TMS
TRACESWO TDO
nSYS_TRST
SWCLKTCK TCK
TCK
nSYS_TCK
TMS_OUT
TMS_OUT_OE nSYS_TMS AHB-AP
JTAGir[3:0]
SWDITMS
TMS_IN
DAP Bus
IR==BYPASSor IDCODE
JTAGNSW
4’b1111 or 4’b1110
A
MDM-AP
SWDO
TMS
SWDOEN
SWCLKTCK
SWDITMS
JTAGSEL
SWDSEL
SWD/ JTAG
SELECT
The debug port comes out of reset in standard JTAG mode and is switched into either
cJTAG or SWD mode by the following sequences. Once the mode has been changed,
unused debug pins can be reassigned to any of their alternative muxed functions.
9.4.1 IR Codes
Table 9-3. JTAG Instructions
Instruction Code[3:0] Instruction Summary
IDCODE 0000 Selects device identification register for shift
SAMPLE/PRELOAD 0010 Selects boundary scan register for shifting, sampling, and
preloading without disturbing functional operation
SAMPLE 0011 Selects boundary scan register for shifting and sampling
without disturbing functional operation
EXTEST 0100 Selects boundary scan register while applying preloaded
values to output pins and asserting functional reset
HIGHZ 1001 Selects bypass register while three-stating all output pins and
asserting functional reset
CLAMP 1100 Selects bypass register while applying preloaded values to
output pins and asserting functional reset
EZPORT 1101 Enables the EZPORT function for the SoC and asserts
functional reset.
ARM_IDCODE 1110 ARM JTAG-DP Instruction
BYPASS 1111 Selects bypass register for data operations
Factory debug reserved 0101, 0110, 0111 Intended for factory debug only
ARM JTAG-DP Reserved 1000, 1010, 1011, 1110 These instructions will go the ARM JTAG-DP controller.
Please look at ARM JTAG-DP documentation for more
information on these instructions.
Reserved 1 All other opcodes Decoded to select bypass register
1. The manufacturer reserves the right to change the decoding of reserved instruction codes in the future
DPACC APACC
Data[31:0] A[3:2] RnW Data[31:0] A[3:2] RnW
0x0C
0x00
0x04
0x08
Debug Port ID Register (DPIDR)
Debug Port
SWJ-DP
Control/Status (CTRL/STAT)
DP Registers
Generic
Debug Port
(DP)
AHB-AP
0x3F
0x00
0x01
(AHB-AP) MDM-AP
Access Port
MDM-AP
Control
Status
• JTAG_TRST_b from an external signal. This signal is optional and may not be
available in all packages.
• Debug reset (CDBGRSTREQ bit within the SWJ-DP CTRL/STAT register) in the
TCLK domain that allows the debugger to reset the debug logic.
• TRST asserted via the cJTAG escape command.
• System POR reset
Conversely the debug system is capable of generating system reset using the following
mechanism:
• A system reset in the DAP control register which allows the debugger to hold the
system in reset.
• SYSRESETREQ bit in the NVIC application interrupt and reset control register
• A system reset in the DAP control register which allows the debugger to hold the
Core in reset.
9.7 AHB-AP
AHB-AP provides the debugger access to all memory and registers in the system,
including processor registers through the NVIC. System access is independent of the
processor status. AHB-AP does not do back-to-back transactions on the bus, so all
transactions are non-sequential. AHB-AP can perform unaligned and bit-band
transactions. AHB-AP transactions bypass the FPB, so the FPB cannot remap AHB-AP
transactions. SWJ/SW-DP-initiated transaction aborts drive an AHB-AP-supported
sideband signal called HABORT. This signal is driven into the Bus Matrix, which resets
the Bus Matrix state, so that AHB-AP can access the Private Peripheral Bus for last ditch
debugging such as read/stop/reset the core. AHB-AP transactions are little endian.
For a short period at the start of a system reset event the system security status is being
determined and debugger access to all AHB-AP transactions is blocked. The MDM-AP
Status register is accessible and can be monitored to determine when this initial period is
completed. After this initial period, if system reset is held via assertion of the RESET pin,
the debugger has access via the bus matrix to the private peripheral bus to configure the
debug IP even while system reset is asserted. While in system reset, access to other
memory and register resources, accessed over the Crossbar Switch, is blocked.
9.8 ITM
The ITM is an application-driven trace source that supports printf style debugging to
trace Operating System (OS) and application events, and emits diagnostic system
information. The ITM emits trace information as packets. There are four sources that can
generate packets. If multiple sources generate packets at the same time, the ITM
arbitrates the order in which packets are output. The four sources in decreasing order of
priority are:
1. Software trace -- Software can write directly to ITM stimulus registers. This emits
packets.
2. Hardware trace -- The DWT generates these packets, and the ITM emits them.
3. Time stamping -- Timestamps are emitted relative to packets. The ITM contains a
21-bit counter to generate the timestamp. The Cortex-M4 clock or the bitclock rate of
the Serial Wire Viewer (SWV) output clocks the counter.
4. Global system timestamping. Timestamps can optionally be generated using a
system-wide 48-bit count value. The same count value can be used to insert
timestamps in the ETM trace stream, allowing coarse-grain correlation.
9.10 TPIU
The TPIU acts as a bridge between the on-chip trace data from the Embedded Trace
Macrocell (ETM) and the Instrumentation Trace Macrocell (ITM), with separate IDs, to a
data stream, encapsulating IDs where required, that is then captured by a Trace Port
Analyzer (TPA). The TPIU is specially designed for low-cost debug.
9.11 DWT
The DWT is a unit that performs the following debug functionality:
NOTE
When using cJTAG and entering LLS mode, the cJTAG
controller must be reset on exit from LLS mode.
Going into a VLLSx mode causes all the debug controls and settings to be reset. To give
time to the debugger to sync up with the HW, the MDM-AP Control register can be
configured hold the system in reset on recovery so that the debugger can regain control
and reconfigure debug logic prior to the system exiting reset and resuming operation.
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 Port Control block controls which signal is present on the external pin. Reference
that chapter to find which register controls the operation of a specific pin.
Register
access
Transfers Transfers
Module
External Pins
10.3 Pinout
121 100 Pin Name Default ALT0 ALT1 ALT2 ALT3 ALT4 ALT5 ALT6 ALT7 EzPort
MAP LQFP
BGA
K1 18 PGA0_DP/ PGA0_DP/ PGA0_DP/
ADC0_DP0/ ADC0_DP0/ ADC0_DP0/
ADC1_DP3 ADC1_DP3 ADC1_DP3
K2 19 PGA0_DM/ PGA0_DM/ PGA0_DM/
ADC0_DM0/ ADC0_DM0/ ADC0_DM0/
ADC1_DM3 ADC1_DM3 ADC1_DM3
L1 20 PGA1_DP/ PGA1_DP/ PGA1_DP/
ADC1_DP0/ ADC1_DP0/ ADC1_DP0/
ADC0_DP3 ADC0_DP3 ADC0_DP3
L2 21 PGA1_DM/ PGA1_DM/ PGA1_DM/
ADC1_DM0/ ADC1_DM0/ ADC1_DM0/
ADC0_DM3 ADC0_DM3 ADC0_DM3
F5 22 VDDA VDDA VDDA
G5 23 VREFH VREFH VREFH
G6 24 VREFL VREFL VREFL
F6 25 VSSA VSSA VSSA
L3 26 VREF_OUT/ VREF_OUT/ VREF_OUT/
CMP1_IN5/ CMP1_IN5/ CMP1_IN5/
CMP0_IN5/ CMP0_IN5/ CMP0_IN5/
ADC1_SE18 ADC1_SE18 ADC1_SE18
K5 27 DAC0_OUT/ DAC0_OUT/ DAC0_OUT/
CMP1_IN3/ CMP1_IN3/ CMP1_IN3/
ADC0_SE23 ADC0_SE23 ADC0_SE23
L7 — RTC_ RTC_ RTC_
WAKEUP_B WAKEUP_B WAKEUP_B
L4 28 XTAL32 XTAL32 XTAL32
L5 29 EXTAL32 EXTAL32 EXTAL32
K6 30 VBAT VBAT VBAT
H5 31 PTE24 ADC0_SE17 ADC0_SE17 PTE24 UART4_TX EWM_OUT_b
J5 32 PTE25 ADC0_SE18 ADC0_SE18 PTE25 UART4_RX EWM_IN
H6 33 PTE26 DISABLED PTE26 UART4_CTS_ RTC_CLKOUT USB_CLKIN
b
J6 34 PTA0 JTAG_TCLK/ TSI0_CH1 PTA0 UART0_CTS_ FTM0_CH5 JTAG_TCLK/ EZP_CLK
SWD_CLK/ b/ SWD_CLK
EZP_CLK UART0_COL_
b
H8 35 PTA1 JTAG_TDI/ TSI0_CH2 PTA1 UART0_RX FTM0_CH6 JTAG_TDI EZP_DI
EZP_DI
J7 36 PTA2 JTAG_TDO/ TSI0_CH3 PTA2 UART0_TX FTM0_CH7 JTAG_TDO/ EZP_DO
TRACE_SWO/ TRACE_SWO
EZP_DO
H9 37 PTA3 JTAG_TMS/ TSI0_CH4 PTA3 UART0_RTS_ FTM0_CH0 JTAG_TMS/
SWD_DIO b SWD_DIO
J8 38 PTA4/ NMI_b/ TSI0_CH5 PTA4/ FTM0_CH1 NMI_b EZP_CS_b
LLWU_P3 EZP_CS_b LLWU_P3
K7 39 PTA5 DISABLED PTA5 USB_CLKIN FTM0_CH2 CMP2_OUT I2S0_TX_ JTAG_TRST_
BCLK b
121 100 Pin Name Default ALT0 ALT1 ALT2 ALT3 ALT4 ALT5 ALT6 ALT7 EzPort
MAP LQFP
BGA
E5 40 VDD VDD VDD
G3 41 VSS VSS VSS
K8 42 PTA12 CMP2_IN0 CMP2_IN0 PTA12 CAN0_TX FTM1_CH0 I2S0_TXD0 FTM1_QD_
PHA
L8 43 PTA13/ CMP2_IN1 CMP2_IN1 PTA13/ CAN0_RX FTM1_CH1 I2S0_TX_FS FTM1_QD_
LLWU_P4 LLWU_P4 PHB
K9 44 PTA14 DISABLED PTA14 SPI0_PCS0 UART0_TX I2S0_RX_ I2S0_TXD1
BCLK
L9 45 PTA15 DISABLED PTA15 SPI0_SCK UART0_RX I2S0_RXD0
J10 46 PTA16 DISABLED PTA16 SPI0_SOUT UART0_CTS_ I2S0_RX_FS I2S0_RXD1
b/
UART0_COL_
b
H10 47 PTA17 ADC1_SE17 ADC1_SE17 PTA17 SPI0_SIN UART0_RTS_ I2S0_MCLK
b
L10 48 VDD VDD VDD
K10 49 VSS VSS VSS
L11 50 PTA18 EXTAL0 EXTAL0 PTA18 FTM0_FLT2 FTM_CLKIN0
K11 51 PTA19 XTAL0 XTAL0 PTA19 FTM1_FLT0 FTM_CLKIN1 LPTMR0_
ALT1
J11 52 RESET_b RESET_b RESET_b
G11 53 PTB0/ ADC0_SE8/ ADC0_SE8/ PTB0/ I2C0_SCL FTM1_CH0 FTM1_QD_
LLWU_P5 ADC1_SE8/ ADC1_SE8/ LLWU_P5 PHA
TSI0_CH0 TSI0_CH0
G10 54 PTB1 ADC0_SE9/ ADC0_SE9/ PTB1 I2C0_SDA FTM1_CH1 FTM1_QD_
ADC1_SE9/ ADC1_SE9/ PHB
TSI0_CH6 TSI0_CH6
G9 55 PTB2 ADC0_SE12/ ADC0_SE12/ PTB2 I2C0_SCL UART0_RTS_ FTM0_FLT3
TSI0_CH7 TSI0_CH7 b
G8 56 PTB3 ADC0_SE13/ ADC0_SE13/ PTB3 I2C0_SDA UART0_CTS_ FTM0_FLT0
TSI0_CH8 TSI0_CH8 b/
UART0_COL_
b
F11 — PTB6 ADC1_SE12 ADC1_SE12 PTB6 FB_AD23
E11 — PTB7 ADC1_SE13 ADC1_SE13 PTB7 FB_AD22
D11 — PTB8 DISABLED PTB8 UART3_RTS_ FB_AD21
b
E10 57 PTB9 DISABLED PTB9 SPI1_PCS1 UART3_CTS_ FB_AD20
b
D10 58 PTB10 ADC1_SE14 ADC1_SE14 PTB10 SPI1_PCS0 UART3_RX FB_AD19 FTM0_FLT1
C10 59 PTB11 ADC1_SE15 ADC1_SE15 PTB11 SPI1_SCK UART3_TX FB_AD18 FTM0_FLT2
— 60 VSS VSS VSS
— 61 VDD VDD VDD
B10 62 PTB16 TSI0_CH9 TSI0_CH9 PTB16 SPI1_SOUT UART0_RX FB_AD17 EWM_IN
E9 63 PTB17 TSI0_CH10 TSI0_CH10 PTB17 SPI1_SIN UART0_TX FB_AD16 EWM_OUT_b
121 100 Pin Name Default ALT0 ALT1 ALT2 ALT3 ALT4 ALT5 ALT6 ALT7 EzPort
MAP LQFP
BGA
D9 64 PTB18 TSI0_CH11 TSI0_CH11 PTB18 CAN0_TX FTM2_CH0 I2S0_TX_ FB_AD15 FTM2_QD_
BCLK PHA
C9 65 PTB19 TSI0_CH12 TSI0_CH12 PTB19 CAN0_RX FTM2_CH1 I2S0_TX_FS FB_OE_b FTM2_QD_
PHB
F10 66 PTB20 DISABLED PTB20 FB_AD31 CMP0_OUT
F9 67 PTB21 DISABLED PTB21 FB_AD30 CMP1_OUT
F8 68 PTB22 DISABLED PTB22 FB_AD29 CMP2_OUT
E8 69 PTB23 DISABLED PTB23 SPI0_PCS5 FB_AD28
B9 70 PTC0 ADC0_SE14/ ADC0_SE14/ PTC0 SPI0_PCS4 PDB0_EXTRG FB_AD14 I2S0_TXD1
TSI0_CH13 TSI0_CH13
D8 71 PTC1/ ADC0_SE15/ ADC0_SE15/ PTC1/ SPI0_PCS3 UART1_RTS_ FTM0_CH0 FB_AD13 I2S0_TXD0
LLWU_P6 TSI0_CH14 TSI0_CH14 LLWU_P6 b
C8 72 PTC2 ADC0_SE4b/ ADC0_SE4b/ PTC2 SPI0_PCS2 UART1_CTS_ FTM0_CH1 FB_AD12 I2S0_TX_FS
CMP1_IN0/ CMP1_IN0/ b
TSI0_CH15 TSI0_CH15
B8 73 PTC3/ CMP1_IN1 CMP1_IN1 PTC3/ SPI0_PCS1 UART1_RX FTM0_CH2 CLKOUT I2S0_TX_
LLWU_P7 LLWU_P7 BCLK
— 74 VSS VSS VSS
— 75 VDD VDD VDD
A8 76 PTC4/ DISABLED PTC4/ SPI0_PCS0 UART1_TX FTM0_CH3 FB_AD11 CMP1_OUT
LLWU_P8 LLWU_P8
D7 77 PTC5/ DISABLED PTC5/ SPI0_SCK LPTMR0_ I2S0_RXD0 FB_AD10 CMP0_OUT
LLWU_P9 LLWU_P9 ALT2
C7 78 PTC6/ CMP0_IN0 CMP0_IN0 PTC6/ SPI0_SOUT PDB0_EXTRG I2S0_RX_ FB_AD9 I2S0_MCLK
LLWU_P10 LLWU_P10 BCLK
B7 79 PTC7 CMP0_IN1 CMP0_IN1 PTC7 SPI0_SIN USB_SOF_ I2S0_RX_FS FB_AD8
OUT
A7 80 PTC8 ADC1_SE4b/ ADC1_SE4b/ PTC8 I2S0_MCLK FB_AD7
CMP0_IN2 CMP0_IN2
D6 81 PTC9 ADC1_SE5b/ ADC1_SE5b/ PTC9 I2S0_RX_ FB_AD6 FTM2_FLT0
CMP0_IN3 CMP0_IN3 BCLK
C6 82 PTC10 ADC1_SE6b ADC1_SE6b PTC10 I2C1_SCL I2S0_RX_FS FB_AD5
C5 83 PTC11/ ADC1_SE7b ADC1_SE7b PTC11/ I2C1_SDA I2S0_RXD1 FB_RW_b
LLWU_P11 LLWU_P11
B6 84 PTC12 DISABLED PTC12 UART4_RTS_ FB_AD27
b
A6 85 PTC13 DISABLED PTC13 UART4_CTS_ FB_AD26
b
A5 86 PTC14 DISABLED PTC14 UART4_RX FB_AD25
B5 87 PTC15 DISABLED PTC15 UART4_TX FB_AD24
— 88 VSS VSS VSS
— 89 VDD VDD VDD
D5 90 PTC16 DISABLED PTC16 UART3_RX FB_CS5_b/
FB_TSIZ1/
FB_BE23_16_
b
121 100 Pin Name Default ALT0 ALT1 ALT2 ALT3 ALT4 ALT5 ALT6 ALT7 EzPort
MAP LQFP
BGA
C4 91 PTC17 DISABLED PTC17 UART3_TX FB_CS4_b/
FB_TSIZ0/
FB_BE31_24_
b
B4 92 PTC18 DISABLED PTC18 UART3_RTS_ FB_TBST_b/
b FB_CS2_b/
FB_BE15_8_b
A4 — PTC19 DISABLED PTC19 UART3_CTS_ FB_CS3_b/ FB_TA_b
b FB_BE7_0_b
D4 93 PTD0/ DISABLED PTD0/ SPI0_PCS0 UART2_RTS_ FB_ALE/
LLWU_P12 LLWU_P12 b FB_CS1_b/
FB_TS_b
D3 94 PTD1 ADC0_SE5b ADC0_SE5b PTD1 SPI0_SCK UART2_CTS_ FB_CS0_b
b
C3 95 PTD2/ DISABLED PTD2/ SPI0_SOUT UART2_RX FB_AD4
LLWU_P13 LLWU_P13
B3 96 PTD3 DISABLED PTD3 SPI0_SIN UART2_TX FB_AD3
A3 97 PTD4/ DISABLED PTD4/ SPI0_PCS1 UART0_RTS_ FTM0_CH4 FB_AD2 EWM_IN
LLWU_P14 LLWU_P14 b
A2 98 PTD5 ADC0_SE6b ADC0_SE6b PTD5 SPI0_PCS2 UART0_CTS_ FTM0_CH5 FB_AD1 EWM_OUT_b
b/
UART0_COL_
b
B2 99 PTD6/ ADC0_SE7b ADC0_SE7b PTD6/ SPI0_PCS3 UART0_RX FTM0_CH6 FB_AD0 FTM0_FLT0
LLWU_P15 LLWU_P15
A1 100 PTD7 DISABLED PTD7 CMT_IRO UART0_TX FTM0_CH7 FTM0_FLT1
A11 — NC NC NC
B11 — NC NC NC
C11 — NC NC NC
K3 — NC NC NC
H4 — NC NC NC
J3 — NC NC NC
H3 — NC NC NC
K4 — NC NC NC
J9 — NC NC NC
J4 — NC NC NC
H11 — NC NC NC
A10 — NC NC NC
A9 — NC NC NC
B1 — NC NC NC
C2 — NC NC NC
C1 — NC NC NC
D2 — NC NC NC
D1 — NC NC NC
E1 — NC NC NC
PTC11/LLWU_P11
PTD6/LLWU_P15
PTD4/LLWU_P14
PTD2/LLWU_P13
PTD0/LLWU_P12
PTC6/LLWU_P10
PTC4/LLWU_P8
PTC5/LLWU_P9
PTC18
PTC17
PTC16
PTC15
PTC14
PTC13
PTC12
PTC10
PTC7
PTD7
PTD5
PTD3
PTD1
PTC9
PTC8
VDD
VSS
79
99
98
97
96
95
94
93
92
91
90
89
88
87
86
85
84
83
82
81
80
78
76
77
100
PTE0 1 75 VDD
PTE1/LLWU_P0 2 74 VSS
PTE2/LLWU_P1 3 73 PTC3/LLWU_P7
PTE3 4 72 PTC2
PTE4/LLWU_P2 5 71 PTC1/LLWU_P6
PTE5 6 70 PTC0
PTE6 7 69 PTB23
VDD 8 68 PTB22
VSS 9 67 PTB21
USB0_DP 10 66 PTB20
USB0_DM 11 65 PTB19
VOUT33 12 64 PTB18
VREGIN 13 63 PTB17
ADC0_DP1 14 62 PTB16
ADC0_DM1 15 61 VDD
ADC1_DP1 16 60 VSS
ADC1_DM1 17 59 PTB11
PGA0_DP/ADC0_DP0/ADC1_DP3 18 58 PTB10
PGA0_DM/ADC0_DM0/ADC1_DM3 19 57 PTB9
PGA1_DP/ADC1_DP0/ADC0_DP3 20 56 PTB3
PGA1_DM/ADC1_DM0/ADC0_DM3 21 55 PTB2
VDDA 22 54 PTB1
VREFH 23 53 PTB0/LLWU_P5
VREFL 24 52 RESET_b
VSSA 25 51 PTA19
26
27
28
29
40
41
42
43
44
45
46
47
48
49
50
30
31
32
33
34
35
36
37
38
39
VREF_OUT/CMP1_IN5/CMP0_IN5/ADC1_SE18
DAC0_OUT/CMP1_IN3/ADC0_SE23
XTAL32
EXTAL32
VBAT
PTE24
PTE25
PTE26
PTA0
PTA1
PTA2
PTA3
PTA4/LLWU_P3
PTA5
VDD
VSS
PTA12
PTA13/LLWU_P4
PTA14
PTA15
PTA16
PTA17
VDD
VSS
PTA18
1 2 3 4 5 6 7 8 9 10 11
PTD4/ PTC4/
A PTD7 PTD5 PTC19 PTC14 PTC13 PTC8 NC NC NC A
LLWU_P14 LLWU_P8
PTD6/ PTC3/
B NC PTD3 PTC18 PTC15 PTC12 PTC7 PTC0 PTB16 NC B
LLWU_P15 LLWU_P7
PTE2/ PTE1/
E NC PTE0 VDD VDD VDD PTB23 PTB17 PTB9 PTB7 E
LLWU_P1 LLWU_P0
F USB0_DP USB0_DM PTE6 PTE3 VDDA VSSA VSS PTB22 PTB21 PTB20 PTB6 F
PTB0/
G VOUT33 VREGIN VSS PTE5 VREFH VREFL VSS PTB3 PTB2 PTB1 G
LLWU_P5
PTE4/
H ADC0_DP1 ADC0_DM1 NC NC PTE24 PTE26 PTA1 PTA3 PTA17 NC H
LLWU_P2
PTA4/
J ADC1_DP1 ADC1_DM1 NC NC PTE25 PTA0 PTA2 NC PTA16 RESET_b J
LLWU_P3
1 2 3 4 5 6 7 8 9 10 11
10.4.5 Analog
Table 10-11. ADC 0 Signal Descriptions
Chip signal name Module signal Description I/O
name
ADC0_DP3, DADP3–DADP0 Differential Analog Channel Inputs I
PGA0_DP,
ADC0_DP[1:0]
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
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
11.1.1 Overview
The port control and interrupt (PORT) module provides support for port control, and
external interrupt functions. Most functions can be configured independently for each pin
in the 32-bit port and affect the pin regardless of its pin muxing state.
There is one instance of the PORT module for each port. Not all pins within each port are
implemented on a specific device.
11.1.1.1 Features
The PORT module has the following features:
• Pin interrupt
• Interrupt flag and enable registers for each pin
• Support for edge sensitive (rising, falling, both) or level sensitive (low, high)
configured per pin
• Support for interrupt or DMA request configured per pin
• Asynchronous wakeup in Low-Power modes
• Pin interrupt is functional in all digital Pin Muxing modes
• Port control
• Individual pull control fields with pullup, pulldown, and pull-disable support on
selected pins
• Individual drive strength field supporting high and low drive strength on selected
pins
• Individual slew rate field supporting fast and slow slew rates on selected pins
• Individual input passive filter field supporting enable and disable of the
individual input passive filter on selected pins
• Individual open drain field supporting enable and disable of the individual open
drain output on selected pins
• Individual mux control field supporting analog or pin disabled, GPIO, and up to
six chip-specific digital functions
• Pad configuration fields are functional in all digital Pin Muxing modes
NOTE
Not all pins within each port are implemented on each device.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 ISF 0
IRQC
W w1c
Reset x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x*
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 0 0
LK MUX DSE ODE PFE SRE PE PS
W
Reset x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x*
* Notes:
• Refer to the Signal Multiplexing and Signal Descriptions chapter for the reset value of this device.x = Undefined at reset.
0 Low drive strength is configured on the corresponding pin, if pin is configured as a digital output.
1 High drive strength is configured on the corresponding pin, if pin is configured as a digital output.
5 Open Drain Enable
ODE
This bit is read only for pins that do not support a configurable open drain output.
Open drain configuration is valid in all digital pin muxing modes.
0 Fast slew rate is configured on the corresponding pin, if the pin is configured as a digital output.
1 Slow slew rate is configured on the corresponding pin, if the pin is configured as a digital output.
1 Pull Enable
PE
This bit is read only for pins that do not support a configurable pull resistor.
Pull configuration is valid in all digital pin muxing modes.
0 Internal pulldown resistor is enabled on the corresponding pin, if the corresponding Port Pull Enable
field is set.
1 Internal pullup resistor is enabled on the corresponding pin, if the corresponding Port Pull Enable field
is set.
R 0 0
W GPWE GPWD
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
0 Corresponding Pin Control Register is not updated with the value in GPWD.
1 Corresponding Pin Control Register is updated with the value in GPWD.
15–0 Global Pin Write Data
GPWD
Write value that is written to all Pin Control Registers bits [15:0] that are selected by GPWE.
R 0 0
W GPWE GPWD
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
0 Corresponding Pin Control Register is not updated with the value in GPWD.
1 Corresponding Pin Control Register is updated with the value in GPWD.
15–0 Global Pin Write Data
GPWD
Write value that is written to all Pin Control Registers bits [15:0] that are selected by GPWE.
The pin interrupt configuration is valid in all digital pin muxing modes. The Interrupt
Status Flag for each pin is also visible in the corresponding Pin Control Register, and
each flag can be cleared in either location.
Address: Base address + A0h 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 ISF
W w1c
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
The configuration of each pin control register is retained when the PORT module is
disabled.
The PORT module generates a single DMA request that asserts when the interrupt status
flag is set for any enabled DMA request in that port. The DMA request negates after the
DMA transfer is completed, because that clears the interrupt status flags for all enabled
DMA requests.
During Stop mode, the interrupt status flag for any enabled interrupt is asynchronously
set if the required level or edge is detected. This also generates an asynchronous wakeup
signal to exit the Low-Power mode.
12.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The System Integration Module (SIM) provides system control and chip configuration
registers.
12.1.1 Features
Features of the SIM include:
• System clocking configuration
• System clock divide values
• Architectural clock gating control
• USB clock selection and divide values
• Flash and system RAM size configuration
• USB regulator configuration
• FlexTimer external clock, hardware trigger, and fault source selection
• UART0 and UART1 receive/transmit source selection/configuration
NOTE
The SIM_SOPT1 and SIM_SOPT1CFG registers are located at
a different base address than the other SIM registers.
SIM memory map
Absolute
Width Section/
address Register name Access Reset value
(in bits) page
(hex)
4004_7000 System Options Register 1 (SIM_SOPT1) 32 R/W See section 12.2.1/255
4004_7004 SOPT1 Configuration Register (SIM_SOPT1CFG) 32 R/W 0000_0000h 12.2.2/257
4004_8004 System Options Register 2 (SIM_SOPT2) 32 R/W 0000_1000h 12.2.3/258
4004_800C System Options Register 4 (SIM_SOPT4) 32 R/W 0000_0000h 12.2.4/260
4004_8010 System Options Register 5 (SIM_SOPT5) 32 R/W 0000_0000h 12.2.5/263
4004_8018 System Options Register 7 (SIM_SOPT7) 32 R/W 0000_0000h 12.2.6/264
4004_8024 System Device Identification Register (SIM_SDID) 32 R Undefined 12.2.7/266
4004_8028 System Clock Gating Control Register 1 (SIM_SCGC1) 32 R/W 0000_0000h 12.2.8/267
4004_802C System Clock Gating Control Register 2 (SIM_SCGC2) 32 R/W 0000_0000h 12.2.9/268
4004_8030 System Clock Gating Control Register 3 (SIM_SCGC3) 32 R/W 0000_0000h 12.2.10/269
4004_8034 System Clock Gating Control Register 4 (SIM_SCGC4) 32 R/W F010_0030h 12.2.11/270
4004_8038 System Clock Gating Control Register 5 (SIM_SCGC5) 32 R/W 0004_0182h 12.2.12/272
4004_803C System Clock Gating Control Register 6 (SIM_SCGC6) 32 R/W 4000_0001h 12.2.13/274
4004_8040 System Clock Gating Control Register 7 (SIM_SCGC7) 32 R/W 0000_0007h 12.2.14/277
4004_8044 System Clock Divider Register 1 (SIM_CLKDIV1) 32 R/W See section 12.2.15/278
4004_8048 System Clock Divider Register 2 (SIM_CLKDIV2) 32 R/W 0000_0000h 12.2.16/280
4004_804C Flash Configuration Register 1 (SIM_FCFG1) 32 R See section 12.2.17/281
4004_8050 Flash Configuration Register 2 (SIM_FCFG2) 32 R See section 12.2.18/283
4004_8054 Unique Identification Register High (SIM_UIDH) 32 R See section 12.2.19/284
4004_8058 Unique Identification Register Mid-High (SIM_UIDMH) 32 R See section 12.2.20/284
4004_805C Unique Identification Register Mid Low (SIM_UIDML) 32 R See section 12.2.21/285
4004_8060 Unique Identification Register Low (SIM_UIDL) 32 R See section 12.2.22/285
NOTE
The SOPT1 register is only reset on POR or LVD.
Address: 4004_7000h base + 0h offset = 4004_7000h
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 0
USBREGEN
USBSSTBY
USBVSTBY
OSC32KSEL
Reset 1* 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 RAMSIZE 0
Reserved
Reset 1* 1* 1* 1* 0* 0* 0* 0* 0* 0* 1* 1* 1* 1* 1* 1*
* Notes:
• Reset value loaded during System Reset from Flash IFR.
0 USB voltage regulator not in standby during VLPR and VLPW modes.
1 USB voltage regulator in standby during VLPR and VLPW modes.
28–20 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
19–18 32K oscillator clock select
OSC32KSEL
Selects the 32 kHz clock source (ERCLK32K) for TSI,and LPTMR. This bit is reset only for POR/LVD.
0000 Undefined
0001 8 KBytes
0010 Undefined
0011 16 KBytes
0100 Undefined
0101 32 KBytes
0110 Undefined
0111 64 KBytes
1000 Undefined
1001 Undefined
1010 Undefined
1011 Undefined
1100 Undefined
1101 Undefined
1110 Undefined
1111 Undefined
11–6 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
5–0 This field is reserved.
Reserved
NOTE
The SOPT1CFG register is reset on System Reset not VLLS.
Address: 4004_7000h base + 4h offset = 4004_7004h
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 0
USSWE
UVSWE
URWE
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
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SOPT2 contains the controls for selecting many of the module clock source options on
this device. See the Clock Distribution chapter for more information including clocking
diagrams and definitions of device clocks.
Address: 4004_7000h base + 1004h offset = 4004_8004h
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
PLLFLLSEL
R 0 0 0 0 0
USBSRC
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
RTCCLKOUTS
TRACECLKSE
R 0 0 0
PTD7PAD
FBSL CLKOUTSEL
EL
L
Reset 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
0 MCGFLLCLK clock
1 MCGPLLCLK clock
15–13 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
12 Debug trace clock select
TRACECLKSEL
Selects the core/system clock or MCG output clock (MCGOUTCLK) as the trace clock source.
0 MCGOUTCLK
1 Core/system clock
11 PTD7 pad drive strength
PTD7PAD
Controls the output drive strength of the PTD7 pin by selecting either one or two pads to drive it.
00 All off-chip accesses (instruction and data) via the FlexBus are disallowed.
01 All off-chip accesses (instruction and data) via the FlexBus are disallowed.
10 Off-chip instruction accesses are disallowed. Data accesses are allowed.
11 Off-chip instruction accesses and data accesses are allowed.
7–5 CLKOUT select
CLKOUTSEL
Selects the clock to output on the CLKOUT pin.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
FTM2CH0SRC
FTM1CH0SRC
FTM0TRG1SR
FTM0TRG0SR
FTM2CLKSEL
FTM1CLKSEL
FTM0CLKSEL
R 0 0 0 0
C
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
FTM2FLT0
FTM1FLT0
FTM0FLT2
FTM0FLT1
FTM0FLT0
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
NOTE: The selected pin must also be configured for the FTM2 module external clock function through
the appropriate pin control register in the port control module.
NOTE: The selected pin must also be configured for the FTM external clock function through the
appropriate pin control register in the port control module.
0 FTM_CLK0 pin
1 FTM_CLK1 pin
24 FlexTimer 0 External Clock Pin Select
FTM0CLKSEL
Selects the external pin used to drive the clock to the FTM0 module.
NOTE: The selected pin must also be configured for the FTM external clock function through the
appropriate pin control register in the port control module.
0 FTM_CLK0 pin
1 FTM_CLK1 pin
23–22 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
21–20 FTM2 channel 0 input capture source select
FTM2CH0SRC
Selects the source for FTM2 channel 0 input capture.
NOTE: When the FTM is not in input capture mode, clear this field.
00 FTM2_CH0 signal
01 CMP0 output
10 CMP1 output
11 Reserved
19–18 FTM1 channel 0 input capture source select
FTM1CH0SRC
Selects the source for FTM1 channel 0 input capture.
NOTE: When the FTM is not in input capture mode, clear this field.
00 FTM1_CH0 signal
01 CMP0 output
10 CMP1 output
11 USB start of frame pulse
NOTE: The pin source for fault 0 must be configured for the FTM module fault function through the
appropriate PORTx pin control register.
0 FTM2_FLT0 pin
1 CMP0 out
7–5 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
4 FTM1 Fault 0 Select
FTM1FLT0
Selects the source of FTM1 fault 0.
NOTE: The pin source for fault 0 must be configured for the FTM module fault function through the
appropriate pin control register in the port control module.
0 FTM1_FLT0 pin
1 CMP0 out
3 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
2 FTM0 Fault 2 Select
FTM0FLT2
Selects the source of FTM0 fault 2.
NOTE: The pin source for fault 2 must be configured for the FTM module fault function through the
appropriate pin control register in the port control module.
0 FTM0_FLT2 pin
1 CMP2 out
1 FTM0 Fault 1 Select
FTM0FLT1
Selects the source of FTM0 fault 1.
NOTE: The pin source for fault 1 must be configured for the FTM module fault function through the
appropriate pin control register in the port control module.
0 FTM0_FLT1 pin
1 CMP1 out
0 FTM0 Fault 0 Select
FTM0FLT0
Selects the source of FTM0 fault 0.
NOTE: The pin source for fault 0 must be configured for the FTM module fault function through the
appropriate pin control register in the port control module.
0 FTM0_FLT0 pin
1 CMP0 out
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 UART1RXSR UART1TXSR UART0RXSR UART0TXSR
W C C C C
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
00 UART1_RX pin
01 CMP0
10 CMP1
11 Reserved
5–4 UART 1 transmit data source select
UART1TXSRC
Selects the source for the UART 1 transmit data.
00 UART1_TX pin
01 UART1_TX pin modulated with FTM1 channel 0 output
10 UART1_TX pin modulated with FTM2 channel 0 output
11 Reserved
3–2 UART 0 receive data source select
UART0RXSRC
Selects the source for the UART 0 receive data.
00 UART0_RX pin
01 CMP0
10 CMP1
11 Reserved
1–0 UART 0 transmit data source select
UART0TXSRC
Selects the source for the UART 0 transmit data.
00 UART0_TX pin
01 UART0_TX pin modulated with FTM1 channel 0 output
10 UART0_TX pin modulated with FTM2 channel 0 output
11 Reserved
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
ADC1PRETRGS
ADC0PRETRGS
ADC1ALTTRGE
ADC0ALTTRGE
R 0 0
ADC1TRGSEL ADC0TRGSEL
EL
EL
N
N
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 Pre-trigger A
1 Pre-trigger B
3–0 ADC0 trigger select
ADC0TRGSEL
Selects the ADC0 trigger source when alternative triggers are functional in stop and VLPS modes. .
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0
W
Reset x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x*
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reset x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
000 K10
001 K20
010 K30
011 K40
100 Reserved
101 Reserved
110 K50
111 K51
0000 Reserved
0001 Reserved
0010 Reserved
0011 Reserved
0100 Reserved
0101 64-pin
0110 80-pin
0111 81-pin
1000 100-pin
1001 Reserved
1010 Reserved
1011 Reserved
1100 Reserved
1101 Reserved
1110 Reserved
1111 Reserved
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 0 0 0 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 0 0 0
UART4
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 Clock disabled
1 Clock enabled
9–8 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
7 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
6 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
5–0 This field is reserved.
Reserved This read-only field is reserved and always has the value 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 0 0 0
DAC0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 Clock disabled
1 Clock enabled
11–1 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
0 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 0 0 0 0 0 0 0
ADC1
FTM2
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 0 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 Clock disabled
1 Clock enabled
23–18 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
17 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
16–13 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
12 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
11–5 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
4 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
3–1 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
0 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 1 0 0
USBOTG
VREF CMP
W
Reset 1 1 1 1 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 0 0 1 0 0
UART3
UART2
UART1
UART0
Reset 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0
0 Clock disabled
1 Clock enabled
19 Comparator Clock Gate Control
CMP
This bit controls the clock gate to the comparator module.
0 Clock disabled
1 Clock enabled
18 USB Clock Gate Control
USBOTG
This bit controls the clock gate to the USB module.
0 Clock disabled
1 Clock enabled
17–14 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
13 UART3 Clock Gate Control
UART3
This bit controls the clock gate to the UART3 module.
0 Clock disabled
1 Clock enabled
12 UART2 Clock Gate Control
UART2
This bit controls the clock gate to the UART2 module.
0 Clock disabled
1 Clock enabled
11 UART1 Clock Gate Control
UART1
This bit controls the clock gate to the UART1 module.
0 Clock disabled
1 Clock enabled
10 UART0 Clock Gate Control
UART0
This bit controls the clock gate to the UART0 module.
0 Clock disabled
1 Clock enabled
9–8 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
0 Clock disabled
1 Clock enabled
6 I2C0 Clock Gate Control
I2C0
This bit controls the clock gate to the I 2 C0 module.
0 Clock disabled
1 Clock enabled
5–4 This field is reserved.
Reserved This read-only field is reserved and always has the value 1.
3 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
2 CMT Clock Gate Control
CMT
This bit controls the clock gate to the CMT module.
0 Clock disabled
1 Clock enabled
1 EWM Clock Gate Control
EWM
This bit controls the clock gate to the EWM module.
0 Clock disabled
1 Clock enabled
0 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 1 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 1 0 0 0 1
LPTIMER
PORTD
PORTC
PORTE
PORTB
PORTA
TSI
W
Reset 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 0
0 Clock disabled
1 Clock enabled
12 Port D Clock Gate Control
PORTD
This bit controls the clock gate to the Port D module.
0 Clock disabled
1 Clock enabled
11 Port C Clock Gate Control
PORTC
This bit controls the clock gate to the Port C module.
0 Clock disabled
1 Clock enabled
10 Port B Clock Gate Control
PORTB
This bit controls the clock gate to the Port B module.
0 Clock disabled
1 Clock enabled
9 Port A Clock Gate Control
PORTA
This bit controls the clock gate to the Port A module.
0 Clock disabled
1 Clock enabled
8–7 This field is reserved.
Reserved This read-only field is reserved and always has the value 1.
6 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
5 TSI Clock Gate Control
TSI
This bit controls the clock gate to the TSI module.
0 Clock disabled
1 Clock enabled
4 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
3–2 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
0 Access disabled
1 Access enabled
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 1 0 0 0 0
USBDCD
ADC0
FTM1
FTM0
RTC PIT PDB CRC
W
Reset 0 1 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
FLEXCAN0
R 0 0 0 0 0
DMAMUX
I2S SPI1 SPI0 FTFL
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 Clock disabled
1 Clock enabled
24 FTM0 Clock Gate Control
FTM0
This bit controls the clock gate to the FTM0 module.
0 Clock disabled
1 Clock enabled
23 PIT Clock Gate Control
PIT
This bit controls the clock gate to the PIT module.
0 Clock disabled
1 Clock enabled
22 PDB Clock Gate Control
PDB
This bit controls the clock gate to the PDB module.
0 Clock disabled
1 Clock enabled
21 USB DCD Clock Gate Control
USBDCD
This bit controls the clock gate to the USB DCD module.
0 Clock disabled
1 Clock enabled
20–19 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
18 CRC Clock Gate Control
CRC
This bit controls the clock gate to the CRC module.
0 Clock disabled
1 Clock enabled
17–16 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
15 I2S Clock Gate Control
I2S
This bit controls the clock gate to the I 2 S module.
0 Clock disabled
1 Clock enabled
0 Clock disabled
1 Clock enabled
12 SPI0 Clock Gate Control
SPI0
This bit controls the clock gate to the SPI0 module.
0 Clock disabled
1 Clock enabled
11–10 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
9 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
8–5 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
4 FlexCAN0 Clock Gate Control
FLEXCAN0
This bit controls the clock gate to the FlexCAN0 module.
0 Clock disabled
1 Clock enabled
3–2 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
1 DMA Mux Clock Gate Control
DMAMUX
This bit controls the clock gate to the DMA Mux module.
0 Clock disabled
1 Clock enabled
0 Flash Memory Clock Gate Control
FTFL
This bit controls the clock gate to the flash memory. Flash reads are still supported while the flash memory
is clock gated, but entry into low power modes is blocked.
0 Clock disabled
1 Clock enabled
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
FLEXBUS
R
DMA
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
0 Clock disabled
1 Clock enabled
0 FlexBus Clock Gate Control
FLEXBUS
This bit controls the clock gate to the FlexBus module.
0 Clock disabled
1 Clock enabled
NOTE
The CLKDIV1 register cannot be written to when the device is
in VLPR mode.
Address: 4004_7000h base + 1044h offset = 4004_8044h
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
OUTDIV1 OUTDIV2 OUTDIV3 OUTDIV4
W
Reset 0* 0* 0* 0* 0* 0* 0* 0* 0* 0* 0* 0* 0* 0* 0* 1* 0* 0* 0* 0* 0* 0* 0* 0* 0* 0* 0* 0* 0* 0* 0* 0*
* Notes:
• Reset value loaded during Syetem Reset from FTFL_FOPT[LPBOOT].
0000 Divide-by-1.
0001 Divide-by-2.
0010 Divide-by-3.
0011 Divide-by-4.
0100 Divide-by-5.
0101 Divide-by-6.
0110 Divide-by-7.
0111 Divide-by-8.
1000 Divide-by-9.
1001 Divide-by-10.
1010 Divide-by-11.
1011 Divide-by-12.
1100 Divide-by-13.
1101 Divide-by-14.
1110 Divide-by-15.
1111 Divide-by-16.
27–24 Clock 2 output divider value
OUTDIV2
This field sets the divide value for the peripheral clock. At the end of reset, it is loaded with either 0000 or
0111 depending on FTFL_FOPT[LPBOOT].
0000 Divide-by-1.
0001 Divide-by-2.
0010 Divide-by-3.
Table continues on the next page...
0000 Divide-by-1.
0001 Divide-by-2.
0010 Divide-by-3.
0011 Divide-by-4.
0100 Divide-by-5.
0101 Divide-by-6.
0110 Divide-by-7.
0111 Divide-by-8.
1000 Divide-by-9.
1001 Divide-by-10.
1010 Divide-by-11.
1011 Divide-by-12.
1100 Divide-by-13.
1101 Divide-by-14.
1110 Divide-by-15.
1111 Divide-by-16.
19–16 Clock 4 output divider value
OUTDIV4
This field sets the divide value for the flash clock. At the end of reset, it is loaded with either 0001 or 1111
depending on FTFL_FOPT[LPBOOT].
0000 Divide-by-1.
0001 Divide-by-2.
0010 Divide-by-3.
0011 Divide-by-4.
0100 Divide-by-5.
0101 Divide-by-6.
0110 Divide-by-7.
0111 Divide-by-8.
1000 Divide-by-9.
Table continues on the next page...
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
USBFRAC
R
USBDIV
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
The reset value of EESIZE and DEPART are based on user programming in user IFR via
the PGMPART flash command.
Address: 4004_7000h base + 104Ch offset = 4004_804Ch
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Reset 1* 1* 1* 1* 1* 1* 1* 1* 0* 0* 0* 0* 1* 1* 1* 1*
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 DEPART 0
FLASHDOZE
FLASHDIS
W
Reset 0* 0* 0* 0* 1* 1* 1* 1* 0* 0* 0* 0* 0* 0* 0* 0*
* Notes:
• Reset value loaded during System Reset from Flash IFR.
0000 0 KB of FlexNVM
0011 32 KB of FlexNVM, 4 KB protection region
27–24 Program flash size
PFSIZE
Table continues on the next page...
0000 Reserved
0001 Reserved
0010 Reserved
0011 2 KB
0100 1 KB
0101 512 Bytes
0110 256 Bytes
0111 128 Bytes
1000 64 Bytes
1001 32 Bytes
1010-1110 Reserved
1111 0 Bytes
15–12 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
11–8 FlexNVM partition
DEPART
Data flash / EEPROM backup split . See DEPART bit description in FTFL chapter.
7–2 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
1 Flash Doze
FLASHDOZE
When set, Flash memory is disabled for the duration of Wait mode. An attempt by the DMA or other bus
master to access the Flash when the Flash is disabled will result in a bus error. This bit should be clear
during VLP modes. The Flash will be automatically enabled again at the end of Wait mode so interrupt
vectors do not need to be relocated out of Flash memory. The wakeup time from Wait mode is extended
when this bit is set.
0 Flash is enabled
1 Flash is disabled
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
PFLSH
R 0 MAXADDR0 MAXADDR1
Reset 0* 1* 1* 1* 1* 1* 1* 1* 0* 1* 1* 1* 1* 1* 1* 1*
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*
* Notes:
• Reset value loaded during System Reset from Flash IFR.
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 UID
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*
* Notes:
• Reset value loaded during System Reset from Flash IFR.
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 UID
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*
* Notes:
• Reset value loaded during System Reset from Flash IFR.
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 UID
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*
* Notes:
• Reset value loaded during System Reset from Flash IFR.
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 UID
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*
* Notes:
• Reset value loaded during System Reset from Flash IFR.
13.1 Introduction
This chapter describes the registers of the Reset Control Module (RCM). The RCM
implements many of the reset functions for the chip. See the chip's reset chapter for more
information.
Bit 7 6 5 4 3 2 1 0
Write
Reset 1 0 0 0 0 0 1 0
Bit 7 6 5 4 3 2 1 0
Write
Reset 0 0 0 0 0 0 0 0
0 Reset not caused by peripheral failure to acknowledge attempt to enter stop mode
1 Reset caused by peripheral failure to acknowledge attempt to enter stop mode
4 EzPort Reset
EZPT
Indicates a reset has been caused by EzPort receiving the RESET command while the device is in EzPort
mode.
0 Reset not caused by EzPort receiving the RESET command while the device is in EzPort mode
1 Reset caused by EzPort receiving the RESET command while the device is in EzPort mode
3 MDM-AP System Reset Request
MDM_AP
Indicates a reset has been caused by the host debugger system setting of the System Reset Request bit
in the MDM-AP Control Register.
0 Reset not caused by host debugger system setting of the System Reset Request bit
1 Reset caused by host debugger system setting of the System Reset Request bit
2 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
The bus clock filter is reset when disabled or when entering
stop mode. The LPO filter is reset when disabled or when
entering any low leakage stop mode .
Address: 4007_F000h base + 4h offset = 4007_F004h
Bit 7 6 5 4 3 2 1 0
NOTE
The reset values of the bits in the RSTFLTSEL field are for
Chip POR only. They are unaffected by other reset types.
Address: 4007_F000h base + 5h offset = 4007_F005h
Bit 7 6 5 4 3 2 1 0
Read 0 RSTFLTSEL
Write
Reset 0 0 0 0 0 0 0 0
This register includes read-only status flags to indicate the state of the mode pins during
the last Chip Reset.
Address: 4007_F000h base + 7h offset = 4007_F007h
Bit 7 6 5 4 3 2 1 0
Read 0 EZP_MS 0
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 chapter.
The system mode controller (SMC) is responsible for sequencing the system into and out
of all low power stop and run modes. Specifically, it monitors events to trigger transitions
between power modes while controlling the power, clocks, and memories of the system
to achieve the power consumption and functionality of that mode.
This chapter describes all the available low power modes, the sequence followed to enter/
exit each mode, and the functionality available while in each of the modes.
The SMC is able to function during even the deepest low power modes.
Accordingly, the ARM CPU documentation refers to sleep and deep sleep, while the
Freescale MCU documentation normally uses wait and stop.
In addition, Freescale MCUs also augment stop, wait, and run modes in a number of
ways. The power management controller (PMC) contains a run and a stop mode
regulator. Run regulation is used in normal run, wait and stop modes. Stop mode
regulation is used during all very low power and low leakage modes. During stop mode
regulation, the bus frequencies are limited in the very low power modes.
The SMC provides the user with multiple power options. The Very Low Power Run
(VLPR) mode can drastically reduce run time power when maximum bus frequency is
not required to handle the application needs. From Normal Run mode, the Run Mode
(RUNM) field can be modified to change the MCU into VLPR mode when limited
frequency is sufficient for the application. From VLPR mode, a corresponding wait
(VLPW) and stop (VLPS) mode can be entered.
Depending on the needs of the user application, a variety of stop modes are available that
allow the state retention, partial power down or full power down of certain logic and/or
memory. I/O states are held in all modes of operation. Several registers are used to
configure the various modes of operation for the device.
The following table describes the power modes available for the device.
Table 14-1. Power modes
Mode Description
RUN The MCU can be run at full speed and the internal supply is fully regulated, that is, in run regulation.
This mode is also referred to as Normal Run mode.
WAIT The core clock is gated off. The system clock continues to operate. Bus clocks, if enabled, continue
to operate. Run regulation is maintained.
STOP The core clock is gated off. System clocks to other masters and bus clocks are gated off after all
stop acknowledge signals from supporting peripherals are valid.
VLPR The core, system, bus, and flash clock maximum frequencies are restricted in this mode. See the
Power Management chapter for details about the maximum allowable frequencies.
VLPW The core clock is gated off. The system, bus, and flash clocks continue to operate, although their
maximum frequency is restricted. See the Power Management chapter for details on the maximum
allowable frequencies.
VLPS The core clock is gated off. System clocks to other masters and bus clocks are gated off after all
stop acknowledge signals from supporting peripherals are valid.
LLS The core clock is gated off. System clocks to other masters and bus clocks are gated off after all
stop acknowledge signals from supporting peripherals are valid. The MCU is placed in a low
leakage mode by reducing the voltage to internal logic. Internal logic states are retained.
1. See the devices' chip configuration details for the size and location of the system RAM partitions.
If the MCU is configured for a disallowed or reserved power mode, the MCU remains in
its current power mode. For example, if the MCU is in normal RUN mode and AVLP is
0, an attempt to enter VLPR mode using PMCTRL[RUNM] is blocked and the RUNM
bits remain 00b, indicating the MCU is still in Normal Run mode.
NOTE
This register is reset on Chip Reset not VLLS and by reset
types that trigger Chip Reset not VLLS. It is unaffected by reset
types that do not trigger Chip Reset not VLLS. See the Reset
section details for more information.
Address: 4007_E000h base + 0h offset = 4007_E000h
Bit 7 6 5 4 3 2 1 0
Read 0 0 0 0
AVLP ALLS AVLLS
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read 0 0 STOPA
RUNM STOPM
Write
Reset 0 0 0 0 0 0 0 0
NOTE: RUNM must be set to VLPR only when PMSTAT=RUN. After being written to VLPR, RUNM
should not be written back to RUN until PMSTAT=VLPR.
NOTE: RUNM must be set to RUN only when PMSTAT=VLPR. After being written to RUN, RUNM
should not be written back to VLPR until PMSTAT=RUN.
NOTE: When set to VLLSx, the VLLSM bits in the VLLSCTRL register is used to further select the
particular VLLS submode which will be entered.
NOTE:
Bit 7 6 5 4 3 2 1 0
Read 0 0 0 0 VLLSM
Write
Reset 0 0 0 0 0 0 1 1
000 Reserved
001 VLLS1
010 VLLS2
011 VLLS3
100 Reserved
101 Reserved
110 Reserved
111 Reserved
Bit 7 6 5 4 3 2 1 0
Read 0 PMSTAT
Write
Reset 0 0 0 0 0 0 0 1
Any reset
VLPW
4
1
WAIT VLPR
3
RUN 6
7
2
STOP
VLPS
10
8
9
11
LLS VLLSx
The following table defines triggers for the various state transitions shown in the previous
figure.
Table 14-7. Power mode transition triggers
Transition # From To Trigger conditions
1 RUN WAIT Sleep-now or sleep-on-exit modes entered with SLEEPDEEP
clear, controlled in System Control Register in ARM core.
See note.1
WAIT RUN Interrupt or Reset
Reset
Control
Low- CPU
Module
Leakage (RCM)
Wakeup
(LLWU) LP exit Stop/Wait
LP exit
Controller Module
(SMC) (CCM)
System
Power System Flash
(PMC) Clocks Memory
(MCG) Module
A module capable of providing an asynchronous interrupt to the device takes the device
out of STOP mode and returns the device to normal RUN mode. Refer to the device's
Power Management chapter for peripheral, I/O, and memory operation in STOP mode.
When an interrupt request occurs, the CPU exits STOP mode and resumes processing,
beginning with the stacking operations leading to the interrupt service routine.
A system reset will cause an exit from STOP mode, returning the device to normal RUN
mode via an MCU reset.
Before entering LLS mode, the user should configure the low-leakage wakeup (LLWU)
module to enable the desired wakeup sources. The available wakeup sources in LLS are
detailed in the chip configuration details for this device.
After wakeup from LLS, the device returns to normal RUN mode with a pending LLWU
module interrupt. In the LLWU interrupt service routine (ISR), the user can poll the
LLWU module wakeup flags to determine the source of the wakeup.
NOTE
The LLWU interrupt must not be masked by the interrupt
controller to avoid a scenario where the system does not fully
exit stop mode on an LLS recovery.
An asserted RESET pin will cause an exit from LLS mode, returning the device to
normal RUN mode. When LLS is exiting via the RESET pin, the PIN and WAKEUP bits
are set in the SRS0 register of the reset control module (RCM).
When entering VLLS, each I/O pin is latched as configured before executing VLLS.
Because all digital logic in the MCU is powered off, all port and peripheral data is lost
during VLLS. This information must be restored before the ACKISO bit in the PMC is
set.
An asserted RESET pin will cause an exit from any VLLS mode, returning the device to
normal RUN mode. When exiting VLLS via the RESET pin, the PIN and WAKEUP bits
are set in the SRS0 register of the reset control module (RCM).
The MDM AP Control Register also includes a Very Low Leakage Debug Acknowledge
(VLLDBGACK) bit that is set to release the ARM core being held in reset following a
VLLS recovery. The debugger reinitializes all debug IP, and then asserts the
VLLDBGACK control bit to allow the RCM to release the ARM core from reset and
allow CPU operation to begin.
The VLLDBGACK bit is cleared by the debugger (or can be left set as is) or clears
automatically due to the reset generated as part of the next VLLS recovery.
15.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The power management controller (PMC) contains the internal voltage regulator, power
on reset (POR), and low voltage detect system.
15.2 Features
The PMC features include:
• Internal voltage regulator
• Active POR providing brown-out detect
• Low-voltage detect supporting two low-voltage trip points with four warning levels
per trip point
• The low voltage detect flag (LVDF) operates in a level sensitive manner. The LVDF
bit is set when the supply voltage falls below the selected trip point (VLVD). The
LVDF bit is cleared by writing one to the LVDACK bit, but only if the internal
supply has returned above the trip point; otherwise, the LVDF bit remains set.
• The low voltage warning flag (LVWF) operates in a level sensitive manner. The
LVWF bit is set when the supply voltage falls below the selected monitor trip point
(VLVW). The LVWF bit is cleared by writing one to the LVWACK bit, but only if
the internal supply has returned above the trip point; otherwise, the LVWF bit
remains set.
When in VLLS modes, the I/O states are held on a wakeup event (with the exception of
wakeup by reset event) until the wakeup has been acknowledged via a write to the
ACKISO bit. In the case of VLLS exit via a RESET pin, the I/O are released and default
to their reset state. In this case, no write to the ACKISO is needed.
NOTE
Different portions of PMC registers are reset only by particular
reset types. Each register's description provides details. For
more information about the types of reset on this chip, refer to
the Reset section details.
PMC memory map
Absolute
Width Section/
address Register name Access Reset value
(in bits) page
(hex)
Low Voltage Detect Status And Control 1 register
4007_D000 8 R/W 10h 15.5.1/317
(PMC_LVDSC1)
Low Voltage Detect Status And Control 2 register
4007_D001 8 R/W 00h 15.5.2/319
(PMC_LVDSC2)
4007_D002 Regulator Status And Control register (PMC_REGSC) 8 R/W 04h 15.5.3/320
While the device is in the very low power or low leakage modes, the LVD system is
disabled regardless of LVDSC1 settings. To protect systems that must have LVD always
on, configure the SMC's power mode protection register (PMPROT) to disallow any very
low power or low leakage modes from being enabled.
See the device's data sheet for the exact LVD trip voltages.
NOTE
The LVDV bits are reset solely on a POR Only event. The
register's other bits are reset on Chip Reset Not VLLS. For
more information about these reset types, refer to the Reset
section details.
Address: 4007_D000h base + 0h offset = 4007_D000h
Bit 7 6 5 4 3 2 1 0
Read LVDF 0 0
LVDIE LVDRE LVDV
Write LVDACK
Reset 0 0 0 1 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read LVWF 0 0
LVWIE LVWV
Write LVWACK
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
NOTE: When the bandgap voltage reference is not needed in low power modes, clear BGEN to avoid
excess power consumption.
NOTE: After recovering from a VLLS mode, user should restore chip configuration before clearing
ACKISO. In particular, pin configuration for enabled LLWU wakeup pins should be restored to
avoid any LLWU flag from being falsely set when ACKISO is cleared.
16.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The LLWU module allows the user to select up to 16 external pin sources and up to 8
internal modules as a wakeup source from low-leakage power modes. The input sources
are described in the device's chip configuration details. Each of the available wakeup
sources can be individually enabled.
The RESET pin is an additional source for triggering an exit from low-leakage power
modes, and causes the MCU to exit both LLS and VLLS through a reset flow. The
LLWU_RST[LLRSTE] bit must be set to allow an exit from low-leakage modes via the
RESET pin. On a device where the RESET pin is shared with other functions, the explicit
port mux control register must be set for the RESET pin before the RESET pin can be
used as a low-leakage reset source.
The LLWU module also includes three optional digital pin filters: two for the external
wakeup pins and one for the RESET pin.
16.1.1 Features
The LLWU module features include:
• Support for up to 16 external input pins and up to 8 internal modules with individual
enable bits
• Input sources may be external pins or from internal peripherals capable of running in
LLS or VLLS. See the chip configuration information for wakeup input sources for
this device.
When theRESET pin filter or wakeup pin filters are enabled, filter operation begins
immediately. If a low leakage mode is entered within 5 LPO clock cycles of an active
edge, the edge event will be detected by the LLWU. For RESET pin filtering, this means
that there is no restart to the minimum LPO cycle duration as the filtering transitions
from a non-low leakage filter, which is implemented in the RCM, to the LLWU filter.
FILT1[FILTSEL] WUME0
LPO FILT1[FILTE]
LLWU_P15
Pin filter 1
wakeup
Synchronizer Edge occurred
Pin filter 1 LLWU
detect
controller
LLWU_P0
LPO FILT2[FILTE]
exit low leakge mode
Pin filter 2
wakeup
Edge occurred interrupt flow
Synchronizer Pin filter 2
detect
reset flow
WUPE15
2
FILT2[FILTSEL]
LLWU_P15
Edge wakeup occurred
detect
External
LLWU_P0 pin sources
Edge wakeup occurred
detect
LPO
RSTFILT
2
WUPE0
RESET
RESET Pin filter reset occurred
NOTE
All LLWU registers are reset by Chip Reset not VLLS and by
reset types that trigger Chip Reset not VLLS. Each register's
displayed reset value represents this subset of reset types.
LLWU registers are unaffected by reset types that do not trigger
Chip Reset not VLLS. For more information about the types of
reset on this chip, refer to the Introduction details.
LLWU memory map
Absolute
Width Section/
address Register name Access Reset value
(in bits) page
(hex)
4007_C000 LLWU Pin Enable 1 register (LLWU_PE1) 8 R/W 00h 16.3.1/328
4007_C001 LLWU Pin Enable 2 register (LLWU_PE2) 8 R/W 00h 16.3.2/329
4007_C002 LLWU Pin Enable 3 register (LLWU_PE3) 8 R/W 00h 16.3.3/330
4007_C003 LLWU Pin Enable 4 register (LLWU_PE4) 8 R/W 00h 16.3.4/331
4007_C004 LLWU Module Enable register (LLWU_ME) 8 R/W 00h 16.3.5/332
4007_C005 LLWU Flag 1 register (LLWU_F1) 8 R/W 00h 16.3.6/334
4007_C006 LLWU Flag 2 register (LLWU_F2) 8 R/W 00h 16.3.7/335
4007_C007 LLWU Flag 3 register (LLWU_F3) 8 R/W 00h 16.3.8/337
4007_C008 LLWU Pin Filter 1 register (LLWU_FILT1) 8 R/W 00h 16.3.9/339
4007_C009 LLWU Pin Filter 2 register (LLWU_FILT2) 8 R/W 00h 16.3.10/340
4007_C00A LLWU Reset Enable register (LLWU_RST) 8 R/W 02h 16.3.11/341
Bit 7 6 5 4 3 2 1 0
Read WUPE3 WUPE2 WUPE1 WUPE0
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read WUPE7 WUPE6 WUPE5 WUPE4
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read WUPE11 WUPE10 WUPE9 WUPE8
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read WUPE15 WUPE14 WUPE13 WUPE12
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read WUME7 WUME6 WUME5 WUME4 WUME3 WUME2 WUME1 WUME0
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
NOTE
This register is reset on Chip Reset not VLLS and by reset
types that trigger Chip Reset not VLLS. It is unaffected by reset
types that do not trigger Chip Reset not VLLS. See the
Introduction details for more information.
Address: 4007_C000h base + 6h offset = 4007_C006h
Bit 7 6 5 4 3 2 1 0
Bit 7 6 5 4 3 2 1 0
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read FILTF 0
FILTE FILTSEL
Write w1c
Reset 0 0 0 0 0 0 0 0
00 Filter disabled
01 Filter posedge detect enabled
10 Filter negedge detect enabled
11 Filter any edge detect enabled
4 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
Read FILTF 0
FILTE FILTSEL
Write w1c
Reset 0 0 0 0 0 0 0 0
00 Filter disabled
01 Filter posedge detect enabled
10 Filter negedge detect enabled
11 Filter any edge detect enabled
4 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
16.4.3 Initialization
For an enabled peripheral wakeup input, the peripheral flag must be cleared by software
before entering LLS or VLLSx mode to avoid an immediate exit from the mode.
Flags associated with external input pins, filtered and unfiltered, must also be cleared by
software prior to entry to LLS or VLLSx mode.
After enabling an external pin filter or changing the source pin, wait at least 5 LPO clock
cycles before entering LLS or VLLSx mode to allow the filter to initialize.
NOTE
The signal selected as a wakeup source pin must be a digital
pin, as selected in the pin mux control.
17.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The Miscellaneous Control Module (MCM) provides a myriad of miscellaneous control
functions.
17.1.1 Features
The MCM includes the following features:
• Program-visible information on the platform configuration and revision
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 1 1 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 1 1 1 1
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 0
SRAMUWP
SRAMLWP
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
Reserved
Reserved Reserved
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
00 Round robin
01 Special round robin (favors SRAM backoor accesses over the processor)
10 Fixed priority. Processor has highest, backdoor has lowest
11 Fixed priority. Backdoor has highest, processor has lowest
27 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
26 SRAM_U write protect
SRAMUWP
When this bit is set, writes to SRAM_U array generates a bus error.
25–24 SRAM_U arbitration priority
SRAMUAP
Defines the arbitration scheme and priority for the processor and SRAM backdoor accesses to the
SRAM_U array.
00 Round robin
01 Special round robin (favors SRAM backoor accesses over the processor)
10 Fixed priority. Processor has highest, backdoor has lowest
11 Fixed priority. Backdoor has highest, processor has lowest
23–10 This field is reserved.
Reserved
9 This field is reserved.
Reserved
8–0 This field is reserved.
Reserved
18.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
This chapter provides information on the layout, configuration, and programming of the
crossbar switch. The crossbar switch connects bus masters and bus slaves using a
crossbar switch structure. This structure allows all bus masters to access different bus
slaves simultaneously, while providing arbitration among the bus masters when they
access the same slave. A variety of bus arbitration methods and attributes may be
programmed on a slave-by-slave basis.
18.1.1 Features
The crossbar switch includes these distinctive features:
• Symmetric crossbar bus switch implementation
• Allows concurrent accesses from different masters to different slaves
• Slave arbitration attributes configured on a slave-by-slave basis
• 32-bit width and support for byte, 2-byte, 4-byte, and 16-byte burst transfers
• Operation at a 1-to-1 clock frequency with the bus masters
• Low-Power Park mode support
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 0 0 0
M3 M2 M1 M0
W
Reset * * * * * * * * * * * * * * * *
* Notes:
• See the device configuration details for the reset value of this register.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 0 0
ARB PCTL PARK
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 The low power mode request has the highest priority for arbitration on this slave port
1 The low power mode request has the lowest initial priority for arbitration on this slave port
29–10 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
9–8 Arbitration Mode
ARB
Selects the arbitration policy for the slave port.
Table continues on the next page...
00 When no master makes a request, the arbiter parks the slave port on the master port defined by the
PARK field
01 When no master makes a request, the arbiter parks the slave port on the last master to be in control
of the slave port
10 When no master makes a request, the slave port is not parked on a master and the arbiter drives all
outputs to a constant safe state
11 Reserved
3 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
2–0 Park
PARK
Determines which master port the current slave port parks on when no masters are actively making
requests and the PCTL bits are cleared.
NOTE: Only select master ports that are actually present on the device. If not, undefined behavior may
occur.
The MGPCR controls only whether the master’s undefined length burst accesses are
allowed to complete uninterrupted or whether they can be broken by requests from higher
priority masters. The MGPCR can be accessed only in Supervisor mode with 32-bit
accesses.
Address: 4000_4000h base + 800h offset + (256d × 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 AULB
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
port, the requesting master simply sees wait states inserted until the targeted slave port
can service the master's request. The latency in servicing the request depends on each
master's priority level and the responding peripheral's access time.
Because the crossbar switch appears to be just another slave to the master device, the
master device has no knowledge of whether it actually owns the slave port it is targeting.
While the master does not have control of the slave port it is targeting, it simply waits.
A master is given control of the targeted slave port only after a previous access to a
different slave port completes, regardless of its priority on the newly targeted slave port.
This prevents deadlock from occurring when:
• A higher priority master has:
• An outstanding request to one slave port that has a long response time and
• A pending access to a different slave port, and
• A lower priority master is also making a request to the same slave port as the pending
access of the higher priority master.
After the master has control of the slave port it is targeting, the master remains in control
of that slave port until it gives up the slave port by running an IDLE cycle or by leaving
that slave port for its next access.
The master could also lose control of the slave port if another higher priority master
makes a request to the slave port; however, if the master is running a fixed-length burst
transfer it retains control of the slave port until that transfer completes. Based on
MGPCR[AULB], the master either retains control of the slave port when doing undefined
length incrementing burst transfers or loses the bus to a higher priority master.
The crossbar terminates all master IDLE transfers, as opposed to allowing the termination
to come from one of the slave buses. Additionally, when no master is requesting access to
a slave port, the crossbar drives IDLE transfers onto the slave bus, even though a default
master may be granted access to the slave port.
When a slave bus is being idled by the crossbar, it can park the slave port on the master
port indicated by CRSn[PARK]. This is done to save the initial clock of arbitration delay
that otherwise would be seen if the master had to arbitrate to gain control of the slave
port. The slave port can also be put into Low Power Park mode to save power, by using
CRSn[PCTL].
The MGPCRx[AULB] bits are the exception to this rule. The update of these bits is only
recognized when the master on that master port runs an IDLE cycle, even though the
slave bus cycle to write them will have already terminated successfully. If the
MGPCRx[AULB] bits are written between two burst accesses, the new AULB encodings
do not take effect until an IDLE cycle is initiated by the master on that master port.
18.3.3 Arbitration
The crossbar switch supports two arbitration schemes:
• A fixed-priority comparison algorithm
• A round-robin fairness algorithm
The arbitration scheme is independently programmable for each slave port.
Master-to-slave 1 2 3 4 5 6 7 8 9 10 11 12
transfer
In this example, a master runs an undefined length burst and the MGPCR[AULB] bits
indicate arbitration occurs after the fourth beat of the burst. The master runs two
sequential beats and then starts what will be a 12-beat undefined length burst access to a
new address within the same slave port region as the previous access. The crossbar does
not allow an arbitration point until the fourth overall access, or the second beat of the
second burst. At that point, all remaining accesses are open for arbitration until the master
loses control of the slave port.
Assume the master loses control of the slave port after the fifth beat of the second burst.
After the master regains control of the slave port no arbitration point is available until
after the master has run four more beats of its burst. After the fourth beat of the now
continued burst, or the ninth beat of the second burst from the master's perspective, is
taken, all beats of the burst are once again open for arbitration until the master loses
control of the slave port.
Assume the master again loses control of the slave port on the fifth beat of the third now
continued burst, or the 10th beat of the second burst from the master's perspective. After
the master regains control of the slave port, it is allowed to complete its final two beats of
its burst without facing arbitration.
Note
Fixed-length burst accesses are not affected by the AULB bits.
All fixed-length burst accesses lock out arbitration until the last
beat of the fixed-length burst.
Table 18-29. How AXBS grants control of a slave port to a master (continued)
When Then AXBS grants control to the requesting master
The requesting master's priority level is lower than the current At the conclusion of one of the following cycles:
master. • An IDLE cycle
• A non-IDLE cycle to a location other than the current
slave port
19.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The peripheral bridge converts the crossbar switch interface to an interface that can
access a majority of peripherals on the device.
The peripheral bridge supports up to 128 peripherals . (Not all peripheral slots might be
used. See the Chip or Device Configuration chapter and Memory Map chapter for details
on slot assignment.) The bridge includes separate clock enable inputs for each of the slots
to accommodate slower peripherals.
19.1.1 Features
Key features of the peripheral bridge are:
• Supports up to 128 peripherals
• Supports peripheral slots with 8-bit, 16-bit, and 32-bit width
• Each independently configurable peripheral includes a clock enable, which allows
peripherals to operate at any speed less than the system clock rate.
• Programming model provides memory protection functionality
R 0 0 0 0
MTW0
MTW1
MTW2
MTW3
MTR0
MTR1
MTR2
MTR3
MPL0
MPL1
MPL2
MPL3
W
Reset x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x*
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 0 0 0
Reset x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 0 0 0
SP4 WP4 TP4 SP5 WP5 TP5 SP6 WP6 TP6 SP7 WP7 TP7
W
Reset 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0
0 This peripheral does not require supervisor privilege level for accesses.
1 This peripheral requires supervisor privilege level for accesses.
25 Write Protect
WP1
Determines whether the peripheral allows write accessses. When this field is set and a write access is
attempted, access terminates with an error response and no peripheral access initiates .
0 This peripheral does not require supervisor privilege level for accesses.
1 This peripheral requires supervisor privilege level for accesses.
17 Write Protect
WP3
Determines whether the peripheral allows write accessses. When this field is set and a write access is
attempted, access terminates with an error response and no peripheral access initiates .
0 This peripheral does not require supervisor privilege level for accesses.
1 This peripheral requires supervisor privilege level for accesses.
9 Write Protect
WP5
Determines whether the peripheral allows write accessses. When this field is set and a write access is
attempted, access terminates with an error response and no peripheral access initiates .
0 This peripheral does not require supervisor privilege level for accesses.
1 This peripheral requires supervisor privilege level for accesses.
1 Write Protect
WP7
Determines whether the peripheral allows write accessses. When this field is set and a write access is
attempted, access terminates with an error response and no peripheral access initiates .
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 0 0 0
SP0 WP0 TP0 SP1 WP1 TP1 SP2 WP2 TP2 SP3 WP3 TP3
W
Reset x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x*
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 0 0 0
SP4 WP4 TP4 SP5 WP5 TP5 SP6 WP6 TP6 SP7 WP7 TP7
W
Reset x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
0 This peripheral does not require supervisor privilege level for accesses.
1 This peripheral requires supervisor privilege level for accesses.
29 Write Protect
WP0
Determines whether the peripheral allows write accessses. When this field is set and a write access is
attempted, access terminates with an error response and no peripheral access initiates .
0 This peripheral does not require supervisor privilege level for accesses.
1 This peripheral requires supervisor privilege level for accesses.
25 Write Protect
WP1
Determines whether the peripheral allows write accessses. When this field is set and a write access is
attempted, access terminates with an error response and no peripheral access initiates .
0 This peripheral does not require supervisor privilege level for accesses.
1 This peripheral requires supervisor privilege level for accesses.
21 Write Protect
WP2
Determines whether the peripheral allows write accessses. When this field is set and a write access is
attempted, access terminates with an error response and no peripheral access initiates .
0 This peripheral does not require supervisor privilege level for accesses.
1 This peripheral requires supervisor privilege level for accesses.
17 Write protect
WP3
Determines whether the peripheral allows write accesss. When this bit is set and a write access is
attempted, access terminates with an error response and no peripheral access initiates .
0 This peripheral does not require supervisor privilege level for accesses.
1 This peripheral requires supervisor privilege level for accesses.
13 Write Protect
WP4
Determines whether the peripheral allows write accessses. When this field is set and a write access is
attempted, access terminates with an error response and no peripheral access initiates .
0 This peripheral does not require supervisor privilege level for accesses.
1 This peripheral requires supervisor privilege level for accesses.
9 Write Protect
WP5
Determines whether the peripheral allows write accessses. When this field is set and a write access is
attempted, access terminates with an error response and no peripheral access initiates .
0 This peripheral does not require supervisor privilege level for accesses.
1 This peripheral requires supervisor privilege level for accesses.
5 Write Protect
WP6
Determines whether the peripheral allows write accessses. When this field is set and a write access is
attempted, access terminates with an error response and no peripheral access initiates .
0 This peripheral does not require supervisor privilege level for accesses.
1 This peripheral requires supervisor privilege level for accesses.
1 Write Protect
WP7
Determines whether the peripheral allows write accessses. When this field is set and a write access is
attempted, access terminates with an error response and no peripheral access initiates .
All accesses to the peripheral slots must be sized less than or equal to the designated
peripheral slot size. If an access is attempted which is larger than the targeted port, an
error response is generated.
20.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
20.1.1 Overview
The direct memory access multiplexer (DMAMUX) routes DMA sources, called slots, to
any of the 16 DMA channels. This process is illustrated in the following figure.
DMA Channel #0
Source #1 DMAMUX
DMA Channel #1
Source #2
Source #3
Source #x
Always #1
Always #y
Trigger #1
DMA Channel #n
Trigger #z
20.1.2 Features
The DMA channel MUX provides these features:
• 52 peripheral slots and 10 always-on slots can be routed to 16 channels.
• 16 independently selectable DMA channel routers.
• The first 4 channels additionally provide a trigger functionality.
• Each channel router can be assigned to one of the 52 possible peripheral DMA slots
or to one of the 10 always-on slots.
In this mode, the DMA channel is disabled. Because disabling and enabling of DMA
channels is done primarily via the DMA configuration registers, this mode is used
mainly as the reset state for a DMA channel in the DMA channel MUX. It may also
be used to temporarily suspend a DMA channel while reconfiguration of the system
takes place, for example, changing the period of a DMA trigger.
• Normal mode
In this mode, a DMA source is routed directly to the specified DMA channel. The
operation of the DMA MUX in this mode is completely transparent to the system.
• Periodic Trigger mode
In this mode, a DMA source may only request a DMA transfer, such as when a
transmit buffer becomes empty or a receive buffer becomes full, periodically.
Configuration of the period is done in the registers of the periodic interrupt timer
(PIT). This mode is available only for channels 0-3.
Bit 7 6 5 4 3 2 1 0
Read ENBL TRIG SOURCE
Write
Reset 0 0 0 0 0 0 0 0
0 DMA channel is disabled. This mode is primarily used during configuration of the DMA Mux. The DMA
has separate channel enables/disables, which should be used to disable or re-configure a DMA
channel.
1 DMA channel is enabled
6 DMA Channel Trigger Enable
TRIG
Enables the periodic trigger capability for the triggered DMA channel.
Table continues on the next page...
Source #1
Source #2
Source #3
DMA Channel #0
Trigger #1
DMA Channel #1
Trigger #2
Source #x
DMA Channel #3
Trigger #4
Always #1
Always #y
The DMA channel triggering capability allows the system to "schedule" regular DMA
transfers, usually on the transmit side of certain peripherals, without the intervention of
the processor. This trigger works by gating the request from the peripheral to the DMA
until a trigger event has been seen. This is illustrated in the following figure.
Peripheral Request
Trigger
DMA Request
After the DMA request has been serviced, the peripheral will negate its request,
effectively resetting the gating mechanism until the peripheral re-asserts its request AND
the next trigger event is seen. This means that if a trigger is seen, but the peripheral is not
requesting a transfer, then that trigger will be ignored. This situation is illustrated in the
following figure.
Peripheral Request
Trigger
DMA Request
This triggering capability may be used with any peripheral that supports DMA transfers,
and is most useful for two types of situations:
• Periodically polling external devices on a particular bus. As an example, the transmit
side of an SPI is assigned to a DMA channel with a trigger, as described above. After
it has been setup, the SPI will request DMA transfers, presumably from memory, as
long as its transmit buffer is empty. By using a trigger on this channel, the SPI
transfers can be automatically performed every 5μs (as an example). On the receive
side of the SPI, the SPI and DMA can be configured to transfer receive data into
memory, effectively implementing a method to periodically read data from external
devices and transfer the results into memory without processor intervention.
• Using the GPIO ports to drive or sample waveforms. By configuring the DMA to
transfer data to one or more GPIO ports, it is possible to create complex waveforms
using tabular data stored in on-chip memory. Conversely, using the DMA to
periodically transfer data from one or more GPIO ports, it is possible to sample
complex waveforms and store the results in tabular form in on-chip memory.
A more detailed description of the capability of each trigger, including resolution, range
of values, and so on, may be found in the periodic interrupt timer section.
• Performing DMA transfers to/from GPIO—Moving data from/to one or more GPIO
pins, either unthrottled (that is as fast as possible), or periodically (using the DMA
triggering capability).
• Performing DMA transfers from memory to memory—Moving data from memory to
memory, typically as fast as possible, sometimes with software activation.
• Performing DMA transfers from memory to the external bus, or vice-versa—Similar
to memory to memory transfers, this is typically done as quickly as possible.
• Any DMA transfer that requires software activation—Any DMA transfer that should
be explicitly started by software.
In cases where software should initiate the start of a DMA transfer, an "always enabled"
DMA source can be used to provide maximum flexibility. When activating a DMA
channel via software, subsequent executions of the minor loop require a new "start" event
be sent. This can either be a new software activation, or a transfer request from the DMA
channel MUX. The options for doing this are:
• Transfer all data in a single minor loop. By configuring the DMA to transfer all of
the data in a single minor loop (that is major loop counter = 1), no reactivation of the
channel is necessary. The disadvantage to this option is the reduced granularity in
determining the load that the DMA transfer will incur on the system. For this option,
the DMA channel must be disabled in the DMA channel MUX.
• Use explicit software reactivation. In this option, the DMA is configured to transfer
the data using both minor and major loops, but the processor is required to reactivate
the channel by writing to the DMA registers after every minor loop. For this option,
the DMA channel must be disabled in the DMA channel MUX.
• Use an "always enabled" DMA source. In this option, the DMA is configured to
transfer the data using both minor and major loops, and the DMA channel MUX does
the channel re-activation. For this option, the DMA channel should be enabled and
pointing to an "always enabled" source. Note that the reactivation of the channel can
be continuous (DMA triggering is disabled) or can use the DMA triggering
capability. In this manner, it is possible to execute periodic transfers of packets of
data from one source to another, without processor intervention.
20.5.1 Reset
The reset state of each individual bit is shown in Memory map/register definition. In
summary, after reset, all channels are disabled and must be explicitly enabled before use.
In File main.c:
#include "registers.h"
:
In File main.c:
#include "registers.h"
:
:
*CHCONFIG2 = 0x00;
*CHCONFIG2 = 0x85;
Disabling a source
A particular DMA source may be disabled by not writing the corresponding source value
into any of the CHCFG registers. Additionally, some module-specific configuration may
be necessary. See the appropriate section for more details.
To switch the source of a DMA channel:
K20 Sub-Family Reference Manual, Rev. 1.1, Dec 2012
390 Freescale Semiconductor, Inc.
Chapter 20 Direct Memory Access Multiplexer (DMAMUX)
1. Disable the DMA channel in the DMA and re-configure the channel for the new
source.
2. Clear the CHCFG[ENBL] and CHCFG[TRIG] bits of the DMA channel.
3. Select the source to be routed to the DMA channel. Write to the corresponding
CHCFG register, ensuring that the CHCFG[ENBL] and CHCFG[TRIG] bits are set.
To switch DMA channel 8 from source #5 transmit to source #7 transmit:
1. In the DMA configuration registers, disable DMA channel 8 and re-configure it to
handle the transfers to peripheral slot 7. This example assumes channel 8 doesn't
have triggering capability.
2. Write 0x00 to CHCFG8 (base address + 0x08).
3. Write 0x87 to CHCFG8 (base address + 0x08). (In this example, setting the
CHCFG[TRIG] bit would have no effect, due to the assumption that channels 8 does
not support the periodic triggering functionality).
The following code example illustrates steps 2 and 3 above:
In File registers.h:
#define DMAMUX_BASE_ADDR 0xFC084000/* Example only ! */
/* Following example assumes char is 8-bits */
volatile unsigned char *CHCONFIG0 = (volatile unsigned char *) (DMAMUX_BASE_ADDR+0x0000);
volatile unsigned char *CHCONFIG1 = (volatile unsigned char *) (DMAMUX_BASE_ADDR+0x0001);
volatile unsigned char *CHCONFIG2 = (volatile unsigned char *) (DMAMUX_BASE_ADDR+0x0002);
volatile unsigned char *CHCONFIG3 = (volatile unsigned char *) (DMAMUX_BASE_ADDR+0x0003);
volatile unsigned char *CHCONFIG4 = (volatile unsigned char *) (DMAMUX_BASE_ADDR+0x0004);
volatile unsigned char *CHCONFIG5 = (volatile unsigned char *) (DMAMUX_BASE_ADDR+0x0005);
volatile unsigned char *CHCONFIG6 = (volatile unsigned char *) (DMAMUX_BASE_ADDR+0x0006);
volatile unsigned char *CHCONFIG7 = (volatile unsigned char *) (DMAMUX_BASE_ADDR+0x0007);
volatile unsigned char *CHCONFIG8 = (volatile unsigned char *) (DMAMUX_BASE_ADDR+0x0008);
volatile unsigned char *CHCONFIG9 = (volatile unsigned char *) (DMAMUX_BASE_ADDR+0x0009);
volatile unsigned char *CHCONFIG10= (volatile unsigned char *) (DMAMUX_BASE_ADDR+0x000A);
volatile unsigned char *CHCONFIG11= (volatile unsigned char *) (DMAMUX_BASE_ADDR+0x000B);
volatile unsigned char *CHCONFIG12= (volatile unsigned char *) (DMAMUX_BASE_ADDR+0x000C);
volatile unsigned char *CHCONFIG13= (volatile unsigned char *) (DMAMUX_BASE_ADDR+0x000D);
volatile unsigned char *CHCONFIG14= (volatile unsigned char *) (DMAMUX_BASE_ADDR+0x000E);
volatile unsigned char *CHCONFIG15= (volatile unsigned char *) (DMAMUX_BASE_ADDR+0x000F);
In File main.c:
#include "registers.h"
:
:
*CHCONFIG8 = 0x00;
*CHCONFIG8 = 0x87;
21.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The enhanced direct memory access (eDMA) controller is a second-generation module
capable of performing complex data transfers with minimal intervention from a host
processor. The hardware microarchitecture includes:
• A DMA engine that performs:
• Source- and destination-address calculations
• Data-movement operations
• Local memory containing transfer control descriptors for each of the 16 channels
Write Data
0
1
2
Transfer Control
Descriptor (TCD) n-1
64
eDMA Engine
Program Model/
Read Data
Channel Arbitration
Read Data
Address Path
Control
Data Path
Write Data
Address
eDMA Peripheral
eDMA Done
Request
21.1.3 Features
The eDMA is a highly-programmable data-transfer engine optimized to minimize the
required intervention from the host processor. It is intended for use in applications where
the data size to be transferred is statically known and not defined within the data packet
itself. The eDMA module features:
• All data movement via dual-address transfers: read from source, write to destination
• Programmable source and destination addresses and transfer size
• Support for enhanced addressing modes
• 16-channel implementation that performs complex data transfers with minimal
intervention from a host processor
• Internal data buffer, used as temporary storage to support 16-byte burst transfers
• Connections to the crossbar switch for bus mastering the data movement
• Transfer control descriptor (TCD) organized to support two-deep, nested transfer
operations
• 32-byte TCD stored in local memory for each channel
• An inner data transfer loop defined by a minor byte transfer count
• An outer data transfer loop defined by a major iteration count
• Channel activation via one of three methods:
• Explicit software initiation
• Initiation via a channel-to-channel linking mechanism for continuous transfers
• Peripheral-paced hardware requests, one per channel
• Fixed-priority and round-robin channel arbitration
Each channel requires a 32-byte transfer control descriptor for defining the desired data
movement operation. The channel descriptors are stored in the local memory in
sequential order: channel 0, channel 1,... channel 15 . Each TCDn definition is presented
as 11 registers of 16 or 32 bits.
Reading reserved bits in a register returns the value of zero. Writes to reserved bits in a
register are ignored. Reading or writing a reserved memory location generates a bus
error.
DMA memory map
Absolute
Width Section/
address Register name Access Reset value
(in bits) page
(hex)
4000_8000 Control Register (DMA_CR) 32 R/W 0000_0000h 21.3.1/409
4000_8004 Error Status Register (DMA_ES) 32 R 0000_0000h 21.3.2/410
4000_800C Enable Request Register (DMA_ERQ) 32 R/W 0000_0000h 21.3.3/412
4000_8014 Enable Error Interrupt Register (DMA_EEI) 32 R/W 0000_0000h 21.3.4/415
W
4000_8018 Clear Enable Error Interrupt Register (DMA_CEEI) 8 (always 00h 21.3.5/417
reads 0)
W
4000_8019 Set Enable Error Interrupt Register (DMA_SEEI) 8 (always 00h 21.3.6/418
reads 0)
W
4000_801A Clear Enable Request Register (DMA_CERQ) 8 (always 00h 21.3.7/419
reads 0)
W
4000_801B Set Enable Request Register (DMA_SERQ) 8 (always 00h 21.3.8/420
reads 0)
W
4000_801C Clear DONE Status Bit Register (DMA_CDNE) 8 (always 00h 21.3.9/421
reads 0)
W
4000_801D Set START Bit Register (DMA_SSRT) 8 (always 00h 21.3.10/422
reads 0)
W
4000_801E Clear Error Register (DMA_CERR) 8 (always 00h 21.3.11/423
reads 0)
W
4000_801F Clear Interrupt Request Register (DMA_CINT) 8 (always 00h 21.3.12/424
reads 0)
4000_8024 Interrupt Request Register (DMA_INT) 32 R/W 0000_0000h 21.3.13/424
4000_802C Error Register (DMA_ERR) 32 R/W 0000_0000h 21.3.14/427
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0
CX ECX
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
EMLM
EDBG
ERCA
HALT
CLM HOE
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 VLD 0 ECX
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 CPE 0 ERRCHN SAE SOE DAE DOE NCE SGE SBE DBE
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
DMA request input signals and this enable request flag must be asserted before a
channel’s hardware service request is accepted. The state of the DMA enable request flag
does not affect a channel service request made explicitly through software or a linked
channel request.
Address: 4000_8000h base + Ch offset = 4000_800Ch
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
ERQ15
ERQ14
ERQ13
ERQ12
ERQ11
ERQ10
ERQ9 ERQ8 ERQ7 ERQ6 ERQ5 ERQ4 ERQ3 ERQ2 ERQ1 ERQ0
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
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
EEI15
EEI14
EEI13
EEI12
EEI11
EEI10
EEI9 EEI8 EEI7 EEI6 EEI5 EEI4 EEI3 EEI2 EEI1 EEI0
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
The CEEI provides a simple memory-mapped mechanism to clear a given bit in the EEI
to disable the error interrupt for a given channel. The data value on a register write causes
the corresponding bit in the EEI to be cleared. Setting the CAEE bit provides a global
clear function, forcing the EEI contents to be cleared, disabling all DMA request inputs.
If the NOP bit is set, the command is ignored. This allows you to write multiple-byte
registers as a 32-bit word. Reads of this register return all zeroes.
Address: 4000_8000h base + 18h offset = 4000_8018h
Bit 7 6 5 4 3 2 1 0
Read 0 0 0
The SEEI provides a simple memory-mapped mechanism to set a given bit in the EEI to
enable the error interrupt for a given channel. The data value on a register write causes
the corresponding bit in the EEI to be set. Setting the SAEE bit provides a global set
function, forcing the entire EEI contents to be set. If the NOP bit is set, the command is
ignored. This allows you to write multiple-byte registers as a 32-bit word. Reads of this
register return all zeroes.
Address: 4000_8000h base + 19h offset = 4000_8019h
Bit 7 6 5 4 3 2 1 0
Read 0 0 0
The CERQ provides a simple memory-mapped mechanism to clear a given bit in the
ERQ to disable the DMA request for a given channel. The data value on a register write
causes the corresponding bit in the ERQ to be cleared. Setting the CAER bit provides a
global clear function, forcing the entire contents of the ERQ to be cleared, disabling all
DMA request inputs. If NOP is set, the command is ignored. This allows you to write
multiple-byte registers as a 32-bit word. Reads of this register return all zeroes.
Address: 4000_8000h base + 1Ah offset = 4000_801Ah
Bit 7 6 5 4 3 2 1 0
Read 0 0 0
The SERQ provides a simple memory-mapped mechanism to set a given bit in the ERQ
to enable the DMA request for a given channel. The data value on a register write causes
the corresponding bit in the ERQ to be set. Setting the SAER bit provides a global set
function, forcing the entire contents of ERQ to be set. If the NOP bit is set, the command
is ignored. This allows you to write multiple-byte registers as a 32-bit word. Reads of this
register return all zeroes.
Address: 4000_8000h base + 1Bh offset = 4000_801Bh
Bit 7 6 5 4 3 2 1 0
Read 0 0 0
The CDNE provides a simple memory-mapped mechanism to clear the DONE bit in the
TCD of the given channel. The data value on a register write causes the DONE bit in the
corresponding transfer control descriptor to be cleared. Setting the CADN bit provides a
global clear function, forcing all DONE bits to be cleared. If the NOP bit is set, the
command is ignored. This allows you to write multiple-byte registers as a 32-bit word.
Reads of this register return all zeroes.
Address: 4000_8000h base + 1Ch offset = 4000_801Ch
Bit 7 6 5 4 3 2 1 0
Read 0 0 0
The SSRT provides a simple memory-mapped mechanism to set the START bit in the
TCD of the given channel. The data value on a register write causes the START bit in the
corresponding transfer control descriptor to be set. Setting the SAST bit provides a global
set function, forcing all START bits to be set. If the NOP bit is set, the command is
ignored. This allows you to write multiple-byte registers as a 32-bit word. Reads of this
register return all zeroes.
Address: 4000_8000h base + 1Dh offset = 4000_801Dh
Bit 7 6 5 4 3 2 1 0
Read 0 0 0
The CERR provides a simple memory-mapped mechanism to clear a given bit in the ERR
to disable the error condition flag for a given channel. The given value on a register write
causes the corresponding bit in the ERR to be cleared. Setting the CAEI bit provides a
global clear function, forcing the ERR contents to be cleared, clearing all channel error
indicators. If the NOP bit is set, the command is ignored. This allows you to write
multiple-byte registers as a 32-bit word. Reads of this register return all zeroes.
Address: 4000_8000h base + 1Eh offset = 4000_801Eh
Bit 7 6 5 4 3 2 1 0
Read 0 0 0
The CINT provides a simple, memory-mapped mechanism to clear a given bit in the INT
to disable the interrupt request for a given channel. The given value on a register write
causes the corresponding bit in the INT to be cleared. Setting the CAIR bit provides a
global clear function, forcing the entire contents of the INT to be cleared, disabling all
DMA interrupt requests. If the NOP bit is set, the command is ignored. This allows you
to write multiple-byte registers as a 32-bit word. Reads of this register return all zeroes.
Address: 4000_8000h base + 1Fh offset = 4000_801Fh
Bit 7 6 5 4 3 2 1 0
Read 0 0 0
The state of any given channel’s interrupt request is directly affected by writes to this
register; it is also affected by writes to the CINT register. On writes to INT, a 1 in any bit
position clears the corresponding channel’s interrupt request. A zero in any bit position
has no affect on the corresponding channel’s current interrupt status. The CINT register is
provided so the interrupt request for a single channel can easily be cleared without the
need to perform a read-modify-write sequence to the INT register.
Address: 4000_8000h base + 24h offset = 4000_8024h
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
INT15
INT14
INT13
INT12
INT11
INT10
INT9
INT8
INT7
INT6
INT5
INT4
INT3
INT2
INT1
INT0
R
W w1c w1c w1c w1c w1c w1c w1c w1c w1c w1c w1c w1c w1c w1c w1c w1c
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
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
ERR15
ERR14
ERR13
ERR12
ERR11
ERR10
ERR9
ERR8
ERR7
ERR6
ERR5
ERR4
ERR3
ERR2
ERR1
ERR0
W w1c w1c w1c w1c w1c w1c w1c w1c w1c w1c w1c w1c w1c w1c w1c w1c
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
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
HRS15
HRS14
HRS13
HRS12
HRS11
HRS10
HRS9 HRS8 HRS7 HRS6 HRS5 HRS4 HRS3 HRS2 HRS1 HRS0
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
When fixed-priority channel arbitration is enabled (CR[ERCA] = 0), the contents of these
registers define the unique priorities associated with each channel . The channel priorities
are evaluated by numeric value; for example, 0 is the lowest priority, 1 is the next
priority, then 2, 3, etc. Software must program the channel priorities with unique values.
Otherwise, a configuration error is reported. The range of the priority value is limited to
the values of 0 through 15 .
Address: 4000_8000h base + 100h offset + (1d × i), where i=0d to 15d
Bit 7 6 5 4 3 2 1 0
Read 0
ECP DPA CHPRI
Write
Reset 0 0 0 0 * * * *
* Notes:
• CHPRI field: See bit field description
NOTE: Reset value for the channel priority fields, CHPRI, is equal to the corresponding channel number
for each priority register, i.e., DCHPRI15[CHPRI] equals 0b1111.
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
SADDR
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 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Read SOFF
Write
Reset x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Read SMOD SSIZE DMOD DSIZE
Write
Reset x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
000 8-bit
001 16-bit
010 32-bit
011 Reserved
100 16-byte
101 Reserved
110 Reserved
111 Reserved
7–3 Destination Address Modulo
DMOD
See the SMOD definition
2–0 Destination Data Transfer Size
DSIZE
See the SSIZE definition
TCD word 2's register definition depends on the status of minor loop mapping. If minor
loop mapping is disabled (CR[EMLM] = 0), TCD word 2 is defined as follows. If minor
loop mapping is enabled, see the TCD_NBYTES_MLOFFNO and
TCD_NBYTES_MLOFFYES register descriptions for TCD word 2's register definition.
Address: 4000_8000h base + 1008h offset + (32d × i), where i=0d to 15d
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
NBYTES
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.
21.3.21 TCD Signed Minor Loop Offset (Minor Loop Enabled and
Offset Disabled) (DMA_TCDn_NBYTES_MLOFFNO)
TCD word 2 is defined as follows if:
• Minor loop mapping is enabled (CR[EMLM] = 1) and
• SMLOE = 0 and DMLOE = 0
If minor loop mapping is enabled and SMLOE or DMLOE is set then refer to the
TCD_NBYTES_MLOFFYES register description.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
DMLOE
SMLOE
NBYTES
W
Reset x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x*
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
NBYTES
W
Reset x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
21.3.22 TCD Signed Minor Loop Offset (Minor Loop and Offset
Enabled) (DMA_TCDn_NBYTES_MLOFFYES)
TCD word 2 is defined as follows if:
• Minor loop mapping is enabled (CR[EMLM] = 1) and
• Minor loop offset enabled (SMLOE or DMLOE = 1)
K20 Sub-Family Reference Manual, Rev. 1.1, Dec 2012
436 Freescale Semiconductor, Inc.
Chapter 21 Direct Memory Access Controller (eDMA)
If minor loop mapping is enabled and SMLOE and DMLOE are cleared then refer to the
TCD_NBYTES_MLOFFNO register description.
Address: 4000_8000h base + 1008h offset + (32d × i), where i=0d to 15d
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R
DMLOE
SMLOE
MLOFF
W
Reset x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x*
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
MLOFF NBYTES
W
Reset 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 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R
W
SLAST
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 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R
W
DADDR
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 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Read DOFF
Write
Reset x* x* x* x* x* x* x* x* x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
21.3.26 TCD Current Minor Loop Link, Major Loop Count (Channel
Linking Enabled) (DMA_TCDn_CITER_ELINKYES)
Bit 15 14 13 12 11 10 9 8
Read 0
ELINK LINKCH CITER
Write
Reset x* x* x* x* x* x* x* x*
Bit 7 6 5 4 3 2 1 0
Read CITER
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
NOTE: This bit must be equal to the BITER[ELINK] bit. Otherwise, a configuration error is reported.
NOTE: When the CITER field is initially loaded by software, it must be set to the same value as that
contained in the BITER field.
NOTE: If the channel is configured to execute a single service request, the initial values of BITER and
CITER should be 0x0001.
21.3.27 TCD Current Minor Loop Link, Major Loop Count (Channel
Linking Disabled) (DMA_TCDn_CITER_ELINKNO)
Bit 15 14 13 12 11 10 9 8
Read ELINK CITER
Write
Reset x* x* x* x* x* x* x* x*
Bit 7 6 5 4 3 2 1 0
Read CITER
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
NOTE: This bit must be equal to the BITER[ELINK] bit. Otherwise, a configuration error is reported.
NOTE: When the CITER field is initially loaded by software, it must be set to the same value as that
contained in the BITER field.
NOTE: If the channel is configured to execute a single service request, the initial values of BITER and
CITER should be 0x0001.
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
DLASTSGA
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 15 14 13 12 11 10 9 8
Read 0
BWC MAJORLINKCH
Write
Reset x* x* x* x* x* x* x* x*
Bit 7 6 5 4 3 2 1 0
Read MAJORELI
DONE ACTIVE ESG DREQ INTHALF INTMAJOR START
Write NK
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
NOTE: If the source and destination sizes are equal, this field is ignored between the first and second
transfers and after the last write of each minor loop. This behavior is a side effect of reducing
start-up latency.
else
Table continues on the next page...
NOTE: This bit must be cleared to write the MAJORELINK or ESG bits.
6 Channel Active
ACTIVE
This flag signals the channel is currently in execution. It is set when channel service begins, and the
eDMA clears it as the minor loop completes or if any error condition is detected. This bit resets to zero.
5 Enable channel-to-channel linking on major loop complete
MAJORELINK
As the channel completes the major loop, this flag enables the linking to another channel, defined by
MAJORLINKCH. The link target channel initiates a channel service request via an internal mechanism that
sets the TCDn_CSR[START] bit of the specified channel.
NOTE: To support the dynamic linking coherency model, this field is forced to zero when written to while
the TCDn_CSR[DONE] bit is set.
NOTE: To support the dynamic scatter/gather coherency model, this field is forced to zero when written
to while the TCDn_CSR[DONE] bit is set.
21.3.30 TCD Beginning Minor Loop Link, Major Loop Count (Channel
Linking Enabled) (DMA_TCDn_BITER_ELINKYES)
If the TCDn_BITER[ELINK] bit is set, the TCDn_BITER register is defined as follows.
Address: 4000_8000h base + 101Eh offset + (32d × i), where i=0d to 15d
Bit 15 14 13 12 11 10 9 8
Read 0
ELINK LINKCH BITER
Write
Reset x* x* x* x* x* x* x* x*
Bit 7 6 5 4 3 2 1 0
Read BITER
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
NOTE: When the software loads the TCD, this field must be set equal to the corresponding CITER field.
Otherwise, a configuration error is reported. As the major iteration count is exhausted, the
contents of this field is reloaded into the CITER field.
Table continues on the next page...
NOTE: When the software loads the TCD, this field must be set equal to the corresponding CITER field.
Otherwise, a configuration error is reported. As the major iteration count is exhausted, the
contents of this field is reloaded into the CITER field.
8–0 Starting Major Iteration Count
BITER
As the transfer control descriptor is first loaded by software, this 9-bit (ELINK = 1) or 15-bit (ELINK = 0)
field must be equal to the value in the CITER field. As the major iteration count is exhausted, the contents
of this field are reloaded into the CITER field.
NOTE: When the software loads the TCD, this field must be set equal to the corresponding CITER field.
Otherwise, a configuration error is reported. As the major iteration count is exhausted, the
contents of this field is reloaded into the CITER field. If the channel is configured to execute a
single service request, the initial values of BITER and CITER should be 0x0001.
21.3.31 TCD Beginning Minor Loop Link, Major Loop Count (Channel
Linking Disabled) (DMA_TCDn_BITER_ELINKNO)
If the TCDn_BITER[ELINK] bit is cleared, the TCDn_BITER register is defined as
follows.
Address: 4000_8000h base + 101Eh offset + (32d × i), where i=0d to 15d
Bit 15 14 13 12 11 10 9 8
Read ELINK BITER
Write
Reset x* x* x* x* x* x* x* x*
Bit 7 6 5 4 3 2 1 0
Read BITER
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
NOTE: When the software loads the TCD, this field must be set equal to the corresponding CITER field.
Otherwise, a configuration error is reported. As the major iteration count is exhausted, the
contents of this field is reloaded into the CITER field.
NOTE: When the software loads the TCD, this field must be set equal to the corresponding CITER field.
Otherwise, a configuration error is reported. As the major iteration count is exhausted, the
contents of this field is reloaded into the CITER field. If the channel is configured to execute a
single service request, the initial values of BITER and CITER should be 0x0001.
eDMA
Write Address
Write Data
0
1
2
Control
Descriptor (TCD) n-1
64
eDMA Engine
Program Model/
Read Data
Channel Arbitration
Read Data
Address Path
Control
Data Path
Write Data
Address
eDMA Peripheral
eDMA Done
Request
This example uses the assertion of the eDMA peripheral request signal to request service
for channel n. Channel activation via software and the TCDn_CSR[START] bit follows
the same basic flow as peripheral requests. The eDMA request input signal is registered
internally and then routed through the eDMA engine: first through the control module,
then into the program model and channel arbitration. In the next cycle, the channel
arbitration performs, using the fixed-priority or round-robin algorithm. After arbitration is
complete, the activated channel number is sent through the address path and converted
into the required address to access the local memory for TCDn. Next, the TCD memory
is accessed and the required descriptor read from the local memory and loaded into the
eDMA engine address path channel x or y registers. The TCD memory is 64 bits wide to
minimize the time needed to fetch the activated channel descriptor and load it into the
address path channel x or y registers.
The following diagram illustrates the second part of the basic data flow:
eDMA
Write Address
Write Data
0
1
2
Control
Descriptor (TCD) n-1
64
eDMA Engine
Program Model/
Read Data
Channel Arbitration
Read Data
Address Path
Control
Data Path
Write Data
Address
eDMA Peripheral
eDMA Done
Request
The modules associated with the data transfer (address path, data path, and control)
sequence through the required source reads and destination writes to perform the actual
data movement. The source reads are initiated and the fetched data is temporarily stored
in the data path block until it is gated onto the internal bus during the destination write.
This source read/destination write processing continues until the minor byte count has
transferred.
After the minor byte count has moved, the final phase of the basic data flow is performed.
In this segment, the address path logic performs the required updates to certain fields in
the appropriate TCD, e.g., SADDR, DADDR, CITER. If the major iteration count is
exhausted, additional operations are performed. These include the final address
adjustments and reloading of the BITER field into the CITER. Assertion of an optional
interrupt request also occurs at this time, as does a possible fetch of a new TCD from
memory using the scatter/gather address pointer included in the descriptor (if scatter/
gather is enabled). The updates to the TCD memory and the assertion of an interrupt
request are shown in the following diagram.
eDMA
Write Address
Write Data
0
1
2
Control
Descriptor (TCD) n-1
64
eDMA En g in e
Program Model/
Read Data
Channel Arbitration
Read Data
Address Path
Control
Data Path
Write Data
Address
eDMA Peripheral
eDMA Done
Request
• All source reads and destination writes must be configured to the natural boundary of
the programmed transfer size respectively.
• In fixed arbitration mode, a configuration error is caused by any two channel
priorities being equal. All channel priority levels must be unique when fixed
arbitration mode is enabled.
• If a scatter/gather operation is enabled upon channel completion, a configuration
error is reported if the scatter/gather address (DLAST_SGA) is not aligned on a 32-
byte boundary.
• If minor loop channel linking is enabled upon channel completion, a configuration
error is reported when the link is attempted if the TCDn_CITER[E_LINK] bit does
not equal the TCDn_BITER[E_LINK] bit.
If enabled, all configuration error conditions, except the scatter/gather and minor-loop
link errors, report as the channel activates and asserts an error interrupt request. A scatter/
gather configuration error is reported when the scatter/gather operation begins at major
loop completion when properly enabled. A minor loop channel link configuration error is
reported when the link operation is serviced at minor loop completion.
If a system bus read or write is terminated with an error, the data transfer is stopped and
the appropriate bus error flag set. In this case, the state of the channel's transfer control
descriptor is updated by the eDMA engine with the current source address, destination
address, and current iteration count at the point of the fault. When a system bus error
occurs, the channel terminates after the next transfer. Due to pipeline effect, the next
transfer is already in progress when the bus error is received by the eDMA. If a bus error
occurs on the last read prior to beginning the write sequence, the write executes using the
data captured during the bus error. If a bus error occurs on the last write prior to
switching to the next read sequence, the read sequence executes before the channel
terminates due to the destination bus error.
A transfer may be cancelled by software with the CR[CX] bit. When a cancel transfer
request is recognized, the DMA engine stops processing the channel. The current read-
write sequence is allowed to finish. If the cancel occurs on the last read-write sequence of
a major or minor loop, the cancel request is discarded and the channel retires normally.
The error cancel transfer is the same as a cancel transfer except the ES register is updated
with the cancelled channel number and ECX is set. The TCD of a cancelled channel
contains the source and destination addresses of the last transfer saved in the TCD. If the
channel needs to be restarted, you must re-initialize the TCD because the aforementioned
fields no longer represent the original parameters. When a transfer is cancelled by the
error cancel transfer mechanism, the channel number is loaded into DMA_ES[ERRCHN]
and ECX and VLD are set. In addition, an error interrupt may be generated if enabled.
The occurrence of any error causes the eDMA engine to stop normal processing of the
active channel immediately (it goes to its error processing states and the transaction to the
system bus still has peipeline effect), and the appropriate channel bit in the eDMA error
register is asserted. At the same time, the details of the error condition are loaded into the
ES register. The major loop complete indicators, setting the transfer control descriptor
DONE flag and the possible assertion of an interrupt request, are not affected when an
error is detected. After the error status has been updated, the eDMA engine continues
operating by servicing the next appropriate channel. A channel that experiences an error
condition is not automatically disabled. If a channel is terminated by an error and then
issues another service request before the error is fixed, that channel executes and
terminates with the same error condition.
21.4.4 Performance
This section addresses the performance of the eDMA module, focusing on two separate
metrics:
• In the traditional data movement context, performance is best expressed as the peak
data transfer rates achieved using the eDMA. In most implementations, this transfer
rate is limited by the speed of the source and destination address spaces.
• In a second context where device-paced movement of single data values to/from
peripherals is dominant, a measure of the requests that can be serviced in a fixed time
is a more relevant metric. In this environment, the speed of the source and destination
address spaces remains important. However, the microarchitecture of the eDMA also
factors significantly into the resulting metric.
Assuming zero wait states on the system bus, DMA requests can be processed every 9
cycles. Assuming an average of the access times associated with internal peripheral bus-
to-SRAM (4 cycles) and SRAM-to-internal peripheral bus (5 cycles), DMA requests can
be processed every 11.5 cycles (4 + (4+5)/2 + 3). This is the time from Cycle 4 to Cycle x
+5. The resulting peak request rate, as a function of the system frequency, is shown in the
following table.
Table 21-294. eDMA peak request rate (MReq/sec)
Request rate Request rate
System frequency (MHz)
with zero wait states with wait states
66.6 7.4 5.8
83.3 9.2 7.2
100.0 11.1 8.7
133.3 14.8 11.6
150.0 16.6 13.0
A general formula to compute the peak request rate with overlapping requests is:
PEAKreq = freq / [ entry + (1 + read_ws) + (1 + write_ws) + exit ]
where:
Table 21-295. Peak request formula operands
Operand Description
PEAKreq Peak request rate
freq System frequency
entry Channel startup (4 cycles)
read_ws Wait states seen during the system bus read data phase
write_ws Wait states seen during the system bus write data phase
exit Channel shutdown (3 cycles)
Two cycles account for the arbitration pipeline and one extra cycle on the hardware
request resulting from the internal registering of the eDMA peripheral request signals.
For the peak request rate calculations above, the arbitration and request registering is
absorbed in or overlaps the previous executing channel.
Note
When channel linking or scatter/gather is enabled, a two cycle
delay is imposed on the next channel selection and startup. This
allows the link channel or the scatter/gather channel to be
eligible and considered in the arbitration pool for next channel
selection.
The following figure shows how each DMA request initiates one minor-loop transfer, or
iteration, without CPU intervention. DMA arbitration can occur after each minor loop,
and one level of minor loop DMA preemption is allowed. The number of minor loops in
a major loop is specified by the beginning iteration count (BITER).
Current major
loop iteration
Source or destination memory count (CITER)
DMA request
Minor loop
DMA request
Minor loop
Major loop
DMA request
Minor loop
The following figure lists the memory array terms and how the TCD settings interrelate.
TCDn_CITER = TCDn_BITER = 1
TCDn_NBYTES = 16
TCDn_SADDR = 0x1000
TCDn_SOFF = 1
TCDn_ATTR[SSIZE] = 0
TCDn_SLAST = -16
TCDn_DADDR = 0x2000
TCDn_DOFF = 4
TCDn_ATTR[DSIZE] = 2
TCDn_DLAST_SGA= –16
TCDn_CSR[INT_MAJ] = 1
TCDn_CSR[START] = 1 (Should be written last after all other fields have been initialized)
All other TCDn fields = 0
4. eDMA engine reads: channel TCD data from local memory to internal register file.
5. The source-to-destination transfers are executed as follows:
a. Read byte from location 0x1000, read byte from location 0x1001, read byte from
0x1002, read byte from 0x1003.
b. Write 32-bits to location 0x2000 → first iteration of the minor loop.
c. Read byte from location 0x1004, read byte from location 0x1005, read byte from
0x1006, read byte from 0x1007.
d. Write 32-bits to location 0x2004 → second iteration of the minor loop.
e. Read byte from location 0x1008, read byte from location 0x1009, read byte from
0x100A, read byte from 0x100B.
f. Write 32-bits to location 0x2008 → third iteration of the minor loop.
g. Read byte from location 0x100C, read byte from location 0x100D, read byte
from 0x100E, read byte from 0x100F.
h. Write 32-bits to location 0x200C → last iteration of the minor loop → major loop
complete.
6. The eDMA engine writes: TCDn_SADDR = 0x1000, TCDn_DADDR = 0x2000,
TCDn_CITER = 1 (TCDn_BITER).
7. The eDMA engine writes: TCDn_CSR[ACTIVE] = 0, TCDn_CSR[DONE] = 1,
INT[n] = 1.
8. The channel retires and the eDMA goes idle or services the next channel.
The best method to test for minor-loop completion when using hardware, that is,
peripheral, initiated service requests is to read the TCDn_CITER field and test for a
change. The hardware request and acknowledge handshake signals are not visible in the
programmer's model.
The TCD status bits execute the following sequence for a hardware-activated channel:
TCDn_CSR bits
Stage State
START ACTIVE DONE
Channel service request via hardware (peripheral
1 0 0 0
request asserted)
2 0 1 0 Channel is executing
3a 0 0 0 Channel has completed the minor loop and is idle
3b 0 0 1 Channel has completed the major loop and is idle
For both activation types, the major-loop-complete status is explicitly indicated via the
TCDn_CSR[DONE] bit.
The TCDn_CSR[START] bit is cleared automatically when the channel begins execution
regardless of how the channel activates.
TCDn_CITER[E_LINK] = 1
TCDn_CITER[LINKCH] = 0xC
TCDn_CITER[CITER] value = 0x4
TCDn_CSR[MAJOR_E_LINK] = 1
TCDn_CSR[MAJOR_LINKCH] = 0x7
executes as:
1. Minor loop done → set TCD12_CSR[START] bit
2. Minor loop done → set TCD12_CSR[START] bit
3. Minor loop done → set TCD12_CSR[START] bit
4. Minor loop done, major loop done→ set TCD7_CSR[START] bit
Step Action
1 Write 1b to the TCD.major.e_link bit.
2 Read back the TCD.major.e_link bit.
3 Test the TCD.major.e_link request status:
• If TCD.major.e_link = 1b, the dynamic link attempt was
successful.
• If TCD.major.e_link = 0b, the attempted dynamic link
did not succeed (the channel was already retiring).
For this request, the TCD local memory controller forces the TCD.major.e_link bit to
zero on any writes to a channel’s TCD.word7 after that channel’s TCD.done bit is set,
indicating the major loop is complete.
NOTE
The user must clear the TCD.done bit before writing the
TCD.major.e_link bit. The TCD.done bit is cleared
automatically by the eDMA engine after a channel begins
execution.
For a channel not using major loop channel linking, the coherency model described here
may be used for a dynamic scatter/gather request.
When the TCD.major.e_link bit is zero, the TCD.major.linkch field is not used by the
eDMA. In this case, the TCD.major.linkch bits may be used for other purposes. This
method uses the TCD.major.linkch field as a TCD indentification (ID).
1. When the descriptors are built, write a unique TCD ID in the TCD.major.linkch field
for each TCD associated with a channel using dynamic scatter/gather.
2. Write 1b to the TCD.d_req bit.
Should a dynamic scatter/gather attempt fail, setting the TCD.d_req bit will prevent a
future hardware activation of this channel. This stops the channel from executing
with a destination address (daddr) that was calculated using a scatter/gather address
(written in the next step) instead of a dlast final offest value.
3. Write the TCD.dlast_sga field with the scatter/gather address.
4. Write 1b to the TCD.e_sg bit.
5. Read back the 16 bit TCD control/status field.
6. Test the TCD.e_sg request status and TCD.major.linkch value:
If e_sg = 1b, the dynamic link attempt was successful.
If e_sg = 0b and the major.linkch (ID) did not change, the attempted dynamic link
did not succeed (the channel was already retiring).
If e_sg = 0b and the major.linkch (ID) changed, the dynamic link attempt was
successful (the new TCD’s e_sg value cleared the e_sg bit).
For a channel using major loop channel linking, the coherency model described here may
be used for a dynamic scatter/gather request. This method uses the TCD.dlast_sga field as
a TCD indentification (ID).
1. Write 1b to the TCD.d_req bit.
Should a dynamic scatter/gather attempt fail, setting the d_req bit will prevent a
future hardware activation of this channel. This stops the channel from executing
with a destination address (daddr) that was calculated using a scatter/gather address
(written in the next step) instead of a dlast final offest value.
2. Write theTCD.dlast_sga field with the scatter/gather address.
3. Write 1b to the TCD.e_sg bit.
4. Read back the TCD.e_sg bit.
5. Test the TCD.e_sg request status:
If e_sg = 1b, the dynamic link attempt was successful.
If e_sg = 0b, read the 32 bit TCD dlast_sga field.
If e_sg = 0b and the dlast_sga did not change, the attempted dynamic link did not
succeed (the channel was already retiring).
If e_sg = 0b and the dlast_sga changed, the dynamic link attempt was successful (the
new TCD’s e_sg value cleared the e_sg bit).
22.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The watchdog is generally used to monitor the flow and execution of embedded software
within an MCU. The watchdog consists of a counter that if allowed to overflow, forces an
internal reset (asynchronous) to all on-chip peripherals and optionally assert the RESET
pin to reset external devices/circuits. The overflow of the watchdog counter must not
occur if the software code works well and services the watchdog to re-start the actual
counter.
For safety, a redundant watchdog system, External Watchdog Monitor (EWM), is
designed to monitor external circuits, as well as the MCU software flow. This provides a
back-up mechanism to the internal watchdog that resets the MCU's CPU and peripherals.
The EWM differs from the internal watchdog in that it does not reset the MCU's CPU
and peripherals. The EWM if allowed to time-out, provides an independent EWM_out
pin that when asserted resets or places an external circuit into a safe mode. The CPU
resets the EWM counter that is logically ANDed with an external digital input pin. This
pin allows an external circuit to influence the reset_out signal.
22.1.1 Features
Features of EWM module include:
• Independent LPO clock source
• Programmable time-out period specified in terms of number of EWM LPO clock
cycles.
Note the following if the EWM enters the stop mode during CPU service mechanism: At
the exit from stop mode by an interrupt, refresh mechanism state machine starts from the
previous state which means, if first service command is written correctly and EWM
enters the stop mode immediately, the next command has to be written within the next 15
(EWM_service_time) peripheral bus clocks after exiting from stop mode. User must mask
all interrupts prior to executing EWM service instructions.
Clock Gating
Low Power Cell
Clock Reset to Counter Counter Overflow
Enable
OR
EWM refresh CPU Reset
1
Compare High > Counter > Compare Low
Bit 7 6 5 4 3 2 1 0
Bit 7 6 5 4 3 2 1 0
Read 0
Write SERVICE
Reset 0 0 0 0 0 0 0 0
NOTE
This register can be written only once after a CPU reset.
Writing this register more than once generates a bus transfer
error.
Address: 4006_1000h base + 2h offset = 4006_1002h
Bit 7 6 5 4 3 2 1 0
Read COMPAREL
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read COMPAREH
Write
Reset 1 1 1 1 1 1 1 1
On a normal reset, the EWM_out is asserted. To deassert the EWM_out, set EWMEN bit
in the CTRL register to enable the EWM.
If the EWM_out signal shares its pad with a digital I/O pin, on reset this actual pad defers
to being an input signal. It takes the EWM_out output condition only after you enable the
EWM by the EWMEN bit in the CTRL register.
When the EWM_out pin is asserted, it can only be deasserted by forcing a MCU reset.
Note
EWM_out pad must be in pull down state when EWM
functionality is used and when EWM is under Reset.
• If the CPU services the EWM when the counter value lies between CMPL value and
CMPH value, the counter is reset to zero. This is a legal service operation.
• If the CPU executes a EWM service/refresh action outside the legal service window,
EWM_out is asserted.
It is illegal to program CMPL and CMPH with same value. In this case, as soon as
counter reaches (CMPL + 1), EWM_out is asserted.
23.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The Watchdog Timer (WDOG) keeps a watch on the system functioning and resets it in
case of its failure. Reasons for failure include run-away software code and the stoppage
of the system clock that in a safety critical system can lead to serious consequences. In
such cases, the watchdog brings the system into a safe state of operation. The watchdog
monitors the operation of the system by expecting periodic communication from the
software, generally known as servicing or refreshing the watchdog. If this periodic
refreshing does not occur, the watchdog resets the system.
23.2 Features
The features of the Watchdog Timer (WDOG) include:
• Clock source input independent from CPU/bus clock. Choice between two clock
sources:
• Low-power oscillator (LPO)
• External system clock
• Unlock sequence for allowing updates to write-once WDOG control/configuration
bits.
• All WDOG control/configuration bits are writable once only within 256 bus clock
cycles of being unlocked.
• You need to always update these bits after unlocking within 256 bus clock
cycles. Failure to update these bits resets the system.
• Programmable time-out period specified in terms of number of WDOG clock cycles.
• Ability to test WDOG timer and reset with a flag indicating watchdog test.
• Quick test—Small time-out value programmed for quick test.
• Byte test—Individual bytes of timer tested one at a time.
• Read-only access to the WDOG timer—Allows dynamic check that WDOG
timer is operational.
NOTE
Reading the watchdog timer counter while running the
watchdog on the bus clock might not give the accurate
counter value.
• Windowed refresh option
• Provides robust check that program flow is faster than expected.
• Programmable window.
• Refresh outside window leads to reset.
• Robust refresh mechanism
• Write values of 0xA602 and 0xB480 to WDOG Refresh Register within 20 bus
clock cycles.
• Count of WDOG resets as they occur.
• Configurable interrupt on time-out to provide debug breadcrumbs. This is followed
by a reset after 256 bus clock cycles.
WDOGEN
WAITEN
Window_begin
WINEN No unlock
STOPEN after reset
Interrupt
No config
R after unlocking Y
LPO
WDOG
reset count
Osc
WDOG
Alt Clock Clock WDOG CLK WDOGEN = WDOG Enable
Selection WINEN = Windowed Mode Enable
Fast
Fn Test WDOGT = WDOG Time-out Value
Clock WDOGCLKSRC = WDOG Clock Source
WDOG Test = WDOG Test Mode
WAIT EN = Enable in wait mode
STOP EN = Enable in stop mode
The preceding figure shows the operation of the watchdog. The values for N and K are:
• N = 256
• K = 20
The watchdog is a fail safe mechanism that brings the system into a known initial state in
case of its failure due to CPU clock stopping or a run-away condition in code execution.
In its simplest form, the watchdog timer runs continuously off a clock source and expects
to be serviced periodically, failing which it resets the system. This ensures that the
software is executing correctly and has not run away in an unintended direction. Software
can adjust the period of servicing or the time-out value for the watchdog timer to meet the
needs of the application.
You can select a windowed mode of operation that expects the servicing to be done only
in a particular window of the time-out period. An attempted servicing of the watchdog
outside this window results in a reset. By operating in this mode, you can get an
indication of whether the code is running faster than expected. The window length is also
user programmable.
If a system fails to update/refresh the watchdog due to an unknown and persistent cause,
it will be caught in an endless cycle of resets from the watchdog. To analyze the cause of
such conditions, you can program the watchdog to first issue an interrupt, followed by a
reset. In the interrupt service routine, the software can analyze the system stack to aid
debugging.
To enhance the independence of watchdog from the system, it runs off an independent
LPO oscillator clock. You can also switch over to an alternate clock source if required,
through a control register bit.
The update feature is useful for applications that have an initial, non-safety critical part,
where the watchdog is kept disabled or with a conveniently long time-out period. This
means the application coder does not have to frequently service the watchdog. After the
critical part of the application begins, the watchdog can be reconfigured as needed.
The watchdog issues a reset, that is, interrupt-then-reset if enabled, to the system for any
of these invalid unlock sequences:
• You write any value other than 0xC520 or 0xD928 to the unlock register.
• ALLOW_UPDATE is set and you allow a gap of more than 20 bus clock cycles
between the writing of the unlock sequence values.
An attempted refresh operation between the two writes of the unlock sequence and in the
WCT time following a successful unlock, goes undetected. Also, see Watchdog
Operation with 8-bit access for guidelines related to 8-bit accesses to the unlock register.
Note
A context switch during unlocking and refreshing may lead to a
watchdog reset.
Updates in the write-once registers take effect only after the WCT window closes with
the following exceptions for which changes take effect immediately:
• Stop, Wait, and Debug mode enable
• IRQ_RST_EN
The operations of refreshing the watchdog goes undetected during the WCT.
time-out exception. See Generated Resets and Interrupts. You need to unlock the
watchdog before enabling it. A system reset brings the watchdog out of the disabled
mode.
Modulus Register
(Time-out Value)
Byte 3 Byte 4
Byte 1 Byte 2
WDOG
Reset
WDOG
Test Equality Comparison Mod = = Timer?
32-bit Timer
CLK
other stages, N – 2, N – 3... and N + 1, N + 2... are enabled for the test on byte N. These
disabled stages, except the most significant stage of the counter, are loaded with a value
of 0xFF.
The watchdog can also generate an interrupt. If IRQ_RST_EN is set, then on the above
mentioned events WDOG_ST_CTRL_L[INT_FLG] is set, generating an interrupt. A
watchdog reset is also generated WCT time later to ensure the watchdog is fault tolerant.
The interrupt can be cleared by writing 1 to INT_FLG.
The gap of WCT between interrupt and reset means that the WDOG time-out value must
be greater than WCT. Otherwise, if the interrupt was generated due to a time-out, a
second consecutive time-out will occur in that WCT gap. This will trigger the backup
reset generator to generate a reset to the system, prematurely ending the interrupt service
routine execution. Also, jobs such as counting the number of watchdog resets would not
be done.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
ALLOWUPDAT
DISTESTWDO
BYTESEL[1:0]
TESTWDOG
Read 0 0
IRQRSTEN
WDOGEN
TESTSEL
Reserved
STOPEN
CLKSRC
WAITEN
DBGEN
WINEN
G
E
Write
Reset 0 0 0 0 0 0 0 1 1 1 0 1 0 0 1 1
0 WDOG is disabled.
1 WDOG is enabled.
Bit 15 14 13 12 11 10 9 8
Read INTFLG Reserved
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read Reserved
Write
Reset 0 0 0 0 0 0 0 1
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Read TOVALHIGH
Write
Reset 0 0 0 0 0 0 0 0 0 1 0 0 1 1 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Read TOVALLOW
Write
Reset 0 1 0 0 1 0 1 1 0 1 0 0 1 1 0 0
NOTE
You must set the Window Register value lower than the Time-
out Value Register.
Address: 4005_2000h base + 8h offset = 4005_2008h
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Read WINHIGH
Write
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
NOTE
You must set the Window Register value lower than the Time-
out Value Register.
Address: 4005_2000h base + Ah offset = 4005_200Ah
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Read WINLOW
Write
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
Read WDOGREFRESH
Write
Reset 1 0 1 1 0 1 0 0 1 0 0 0 0 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Read WDOGUNLOCK
Write
Reset 1 1 0 1 1 0 0 1 0 0 1 0 1 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Read TIMEROUTHIGH
Write
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
Read TIMEROUTLOW
Write
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
Read RSTCNT
Write
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
Read 0 0
PRESCVAL
Write
Reset 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
Whereas the match for a correct value for a refresh/unlock sequence is as according to the
original definition, the match for an incorrect value is done byte-wise on the refresh/
unlock rather than for the whole 16-bit value. This means that if the high byte of the
refresh/unlock register contains any value other than high bytes of the two values that
make up the sequence, it is treated as an exception condition, leading to a reset or
interrupt-then-reset. The same holds true for the lower byte of the refresh or unlock
register. Take the refresh operation that expects a write of 0xA602 followed by 0xB480
to the refresh register, as an example.
Table 23-15. Refresh for 8-bit access
Sequence value1 or Mismatch
WDOG_REFRESH[15:8] WDOG_REFRESH[7:0]
value2 match exception
Current Value 0xB4 0x80 Value2 match No
Write 1 0xB4 0x02 No match No
Write 2 0xA6 0x02 Value1 match No
Write 3 0xB4 0x02 No match No
Write 4 0xB4 0x80 Value2 match. No
Sequence complete.
Write 5 0x02 0x80 No match Yes
As shown in the preceding table, the refresh register holds its reset value initially.
Thereafter, two 8-bit accesses are performed on the register to write the first value of the
refresh sequence. No mismatch exception is registered on the intermediate write, Write1.
The sequence is completed by performing two more 8-bit accesses, writing in the second
value of the sequence for a successful refresh. It must be noted that the match of value2
takes place only when the complete 16-bit value is correctly written, write4. Hence, the
requirement of writing value2 of the sequence within 20 bus clock cycles of value1 is
checked by measuring the gap between write2 and write4.
It is reiterated that the condition for matching values 1 and 2 of the refresh or unlock
sequence remains unchanged. It is only the criterion for detecting a wrong value in these
registers which has been relaxed, as explained, for 8-bit accesses. Any 16-bit access still
needs to adhere to the original guidelines, mentioned in the sections Refreshing the
Watchdog.
• Trying to unlock the watchdog within the WCT time after an initial unlock has no
effect.
• The refresh and unlock operations and interrupt are not automatically disabled in the
watchdog functional test mode.
• After emerging from a reset due to a watchdog functional test, you are still expected
to go through the mandatory steps of unlocking and configuring the watchdog. The
watchdog continues to be in its functional test mode and therefore you should pull
the watchdog out of the functional test mode within WCT time of reset.
• After emerging from a reset due to a watchdog functional test, you still need to go
through the mandatory steps of unlocking and configuring the watchdog.
• You must ensure that both the clock inputs to the glitchless clock multiplexers are
alive during the switching of clocks. Failure to do so results in a loss of clock at their
outputs.
• There is a gap of two to three watchdog clock cycles from the point that stop mode is
entered to the watchdog timer actually pausing, due to synchronization. The same
holds true for an exit from the stop mode, this time resulting in a two to three
watchdog clock cycle delay in the timer restarting. In case the duration of the stop
mode is less than one watchdog clock cycle, the watchdog timer is not guaranteed to
pause.
• Consider the case when the first refresh value is written, following which the system
enters stop mode with system bus clk still on. If the second refresh value is not
written within 20 bus cycles of the first value, the system is reset, or interrupt-then-
reset if enabled.
24.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The multipurpose clock generator (MCG) module provides several clock source choices
for the MCU. The module contains a frequency-locked loop (FLL) and a phase-locked
loop (PLL). The FLL is controllable by either an internal or an external reference clock.
The PLL is controllable by the external reference clock. The module can select either of
the FLL or PLL output clocks, or either of the internal or external reference clocks as a
source for the MCU system clock. The MCG operates in conjuction with a crystal
oscillator, which allows an external crystal, ceramic resonator, or another external clock
source to produce the external reference clock.
24.1.1 Features
Key features of the MCG module are:
• Frequency-locked loop (FLL):
• Digitally-controlled oscillator (DCO)
• DCO frequency range is programmable for up to four different frequency ranges.
• Option to program and maximize DCO output frequency for a low frequency
external reference clock source.
• Option to prevent FLL from resetting its current locked frequency when
switching clock modes if FLL reference frequency is not changed.
• Internal Reference Clocks Auto Trim Machine (ATM) capability using an external
clock as a reference
• Reference dividers for both the FLL and PLL are provided
• Reference dividers for the Fast Internal Reference Clock are provided
• MCG PLL Clock (MCGPLLCLK) is provided as a clock source for other on-chip
peripherals
• MCG FLL Clock (MCGFLLCLK) is provided as a clock source for other on-chip
peripherals
• MCG Fixed Frequency Clock (MCGFFCLK) is provided as a clock source for other
on-chip peripherals
• MCG Internal Reference Clock (MCGIRCLK) is provided as a clock source for other
on-chip peripherals
RTC
Crystal Oscillator
Oscillator
CLKS
OSCINIT0 PLLCLKEN0 MCG Crystal Oscillator
EREFS0 IREFS Enable Detect
HGO0 PLLS
ATMS
OSCSEL RANGE0 STOP
MCGFLLCLK
CME0 LOCRE0
DRS
External
Clock DMX32 Filter DCO
Monitor
FLTPRSRV
PRDIV0
LOLIE0
/(1,2,3,4,5....,25) Phase Charge
Detector Pump VCO Lock
PLLCLKEN0 Detector
IREFST Internal
VDIV0
Filter
PLLST LOLS0 LOCK0
Peripheral BUSCLK MCGPLLCLK
CLKST VCOOUT
/(24,25,26,...,55)
IRCST
PLL
ATMST
Multipurpose Clock Generator (MCG)
RTC
Crystal Oscillator
Oscillator
CLKS
OSCINIT0 PLLCLKEN0 MCG Crystal Oscillator
K20 Sub-Family IREFS Rev. 1.1, DecEnable
Reference Manual,
EREFS0 2012Detect
HGO0
506 ATMS Freescale Semiconductor, Inc.
OSCSEL
Chapter 24 Multipurpose Clock Generator (MCG)
Bit 7 6 5 4 3 2 1 0
Read CLKS FRDIV IREFS IRCLKEN IREFSTEN
Write
Reset 0 0 0 0 0 1 0 0
000 If RANGE 0 = 0 or OSCSEL=1 , Divide Factor is 1; for all other RANGE 0 values, Divide Factor is
32.
001 If RANGE 0 = 0 or OSCSEL=1 , Divide Factor is 2; for all other RANGE 0 values, Divide Factor is
64.
010 If RANGE 0 = 0 or OSCSEL=1 , Divide Factor is 4; for all other RANGE 0 values, Divide Factor is
128.
011 If RANGE 0 = 0 or OSCSEL=1 , Divide Factor is 8; for all other RANGE 0 values, Divide Factor is
256.
100 If RANGE 0 = 0 or OSCSEL=1 , Divide Factor is 16; for all other RANGE 0 values, Divide Factor is
512.
101 If RANGE 0 = 0 or OSCSEL=1 , Divide Factor is 32; for all other RANGE 0 values, Divide Factor is
1024.
110 If RANGE 0 = 0 or OSCSEL=1 , Divide Factor is 64; for all other RANGE 0 values, Divide Factor is
1280 .
111 If RANGE 0 = 0 or OSCSEL=1 , Divide Factor is 128; for all other RANGE 0 values, Divide Factor is
1536 .
2 Internal Reference Select
IREFS
Selects the reference clock source for the FLL.
Bit 7 6 5 4 3 2 1 0
Read 0
LOCRE0 RANGE0 HGO0 EREFS0 LP IRCS
Write
Reset 1 0 0 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.
1. A value for SCTRIM is loaded during reset from a factory programmed location .
NOTE
Reset values for DRST and DMX32 bits are 0.
Address: 4006_4000h base + 3h offset = 4006_4003h
Bit 7 6 5 4 3 2 1 0
Read DMX32 DRST_DRS FCTRIM SCFTRIM
Write
Reset 0 0 0 x* x* x* x* x*
* Notes:
• x = Undefined at reset.
• A value for FCTRIM is loaded during reset from a factory programmed location . x = Undefined at reset.
NOTE: The system clocks derived from this source should not exceed their specified maximums.
1. A value for FCTRIM is loaded during reset from a factory programmed location .
2. A value for SCFTRIM is loaded during reset from a factory programmed location .
Bit 7 6 5 4 3 2 1 0
0 MCGPLLCLK is inactive.
1
MCGPLLCLK is active.
5 PLL Stop Enable
PLLSTEN0
Table continues on the next page...
Selects the amount to divide down the external reference clock for the PLL. The resulting frequency must
be in the range of 2 MHz to 4 MHz. After the PLL is enabled (by setting either PLLCLKEN 0 or PLLS), the
PRDIV 0 value must not be changed when LOCK 0 is zero.
Bit 7 6 5 4 3 2 1 0
Read LOLIE0 PLLS CME0 VDIV0
Write
Reset 0 0 0 0 0 0 0 0
0 FLL is selected.
1
PLL is selected (PRDIV 0 need to be programmed to the correct divider to generate a PLL reference
clock in the range of 2–4 MHz prior to setting the PLLS bit).
5 Clock Monitor Enable
CME0
Enables the loss of clock monitoring circuit for the OSC0 external reference mux select. The LOCRE0 bit
will determine if a interrupt or a reset request is generated following a loss of OSC0 indication. The CME0
bit should only be set to a logic 1 when the MCG is in an operational mode that uses the external clock
(FEE, FBE, PEE, PBE, or BLPE) . Whenever the CME0 bit is set to a logic 1, the value of the RANGE0
bits in the C2 register should not be changed. CME0 bit should be set to a logic 0 before the MCG enters
any Stop mode. Otherwise, a reset request may occur while in Stop mode. CME0 should also be set to a
logic 0 before entering VLPR or VLPW power modes if the MCG is in BLPE mode.
Selects the amount to divide the VCO output of the PLL. The VDIV 0 bits establish the multiplication factor
(M) applied to the reference clock frequency. After the PLL is enabled (by setting either PLLCLKEN 0 or
PLLS), the VDIV 0 value must not be changed when LOCK 0 is zero.
Bit 7 6 5 4 3 2 1 0
Write
Reset 0 0 0 1 0 0 0 0
0 PLL has not lost lock since LOLS 0 was last cleared.
1 PLL has lost lock since LOLS 0 was last cleared.
6 Lock Status
LOCK0
This bit indicates whether the PLL has acquired lock. Lock detection is disabled when not operating in
either PBE or PEE mode unless PLLCLKEN 0 =1 and the MCG is not configured in BLPI or BLPE mode.
While the PLL clock is locking to the desired frequency, the MCG PLL clock (MCGPLLCLK) will be gated
off until the LOCK 0 bit gets asserted. If the lock status bit is set, changing the value of the PRDIV 0 [4:0]
bits in the C5 register or the VDIV0[4:0] bits in the C6 register causes the lock status bit to clear and stay
cleared until the PLL has reacquired lock. Loss of PLL reference clock will also cause the LOCK 0 bit to
clear until PLL has reacquired lock. Entry into LLS, VLPS, or regular Stop with PLLSTEN 0 =0 also causes
the lock status bit to clear and stay cleared until the Stop mode is exited and the PLL has reacquired lock.
Any time the PLL is enabled and the LOCK 0 bit is cleared, the MCGPLLCLK will be gated off until the
LOCK 0 bit is asserted again.
0 Source of internal reference clock is the slow clock (32 kHz IRC).
1 Source of internal reference clock is the fast clock (2 MHz IRC).
Bit 7 6 5 4 3 2 1 0
NOTE: ATME deasserts after the Auto Trim Machine has completed trimming all trim bits of the IRCS
clock selected by the ATMS bit.
Writing to C1, C3, C4, and SC registers or entering Stop mode aborts the auto trim operation and clears
this bit.
0 FLL filter and FLL frequency will reset on changes to currect clock mode.
1 Fll filter and FLL frequency retain their previous values during new clock mode change.
3–1 Fast Clock Internal Reference Divider
FCRDIV
Selects the amount to divide down the fast internal reference clock. The resulting frequency will be in the
range 31.25 kHz to 4 MHz (Note: Changing the divider when the Fast IRC is enabled is not supported).
Bit 7 6 5 4 3 2 1 0
Read ATCVH
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read ATCVL
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read 0 OSCSEL
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read 0 LOCS1
LOCRE1 LOLRE CME1
Write
Reset 1 0 0 0 0 0 0 0
FBI FBE
BLPI BLPE
PBE
PEE
NOTE
• During exits from LLS or VLPS when the MCG is in PEE
mode, the MCG will reset to PBE clock mode and the
C1[CLKS] and S[CLKST] will automatically be set to
2’b10.
• If entering Normal Stop mode when the MCG is in PEE
mode with C5[PLLSTEN]=0, the MCG will reset to PBE
clock mode and C1[CLKS] and S[CLKST] will
automatically be set to 2’b10.
In FEI mode, MCGOUTCLK is derived from the FLL clock (DCOCLK) that is controlled by the 32
kHz Internal Reference Clock (IRC). The FLL loop will lock the DCO frequency to the FLL factor, as
selected by C4[DRST_DRS] and C4[DMX32] bits, times the internal reference frequency. See the
C4[DMX32] bit description for more details. In FEI mode, the PLL is disabled in a low-power state
unless C5[PLLCLKEN0] is set.
In FEE mode, MCGOUTCLK is derived from the FLL clock (DCOCLK) that is controlled by the
external reference clock. The FLL loop will lock the DCO frequency to the FLL factor, as selected by
C4[DRST_DRS] and C4[DMX32] bits, times the external reference frequency, as specified by
C1[FRDIV] and C2[RANGE0]. See the C4[DMX32] bit description for more details. In FEE mode,
the PLL is disabled in a low-power state unless C5[PLLCLKEN0] is set.
FLL Bypassed Internal FLL bypassed internal (FBI) mode is entered when all the following conditions occur:
(FBI)
• C1[CLKS] bits are written to 01
• C1[IREFS] bit is written to 1
• C6[PLLS] is written to 0
• C2[LP] is written to 0
In FBI mode, the MCGOUTCLK is derived either from the slow (32 kHz IRC) or fast (2 MHz IRC)
internal reference clock, as selected by the C2[IRCS] bit. The FLL is operational but its output is not
used. This mode is useful to allow the FLL to acquire its target frequency while the MCGOUTCLK is
driven from the C2[IRCS] selected internal reference clock. The FLL clock (DCOCLK) is controlled
by the slow internal reference clock, and the DCO clock frequency locks to a multiplication factor, as
selected by C4[DRST_DRS] and C4[DMX32] bits, times the internal reference frequency. See the
C4[DMX32] bit description for more details. In FBI mode, the PLL is disabled in a low-power state
unless C5[PLLCLKEN0] is set.
FLL Bypassed External FLL bypassed external (FBE) mode is entered when all the following conditions occur:
(FBE)
• C1[CLKS] bits are written to 10
• C1[IREFS] bit is written to 0
• C1[FRDIV] must be written to divide external reference clock to be within the range of 31.25
kHz to 39.0625 kHz.
• C6[PLLS] bit is written to 0
• C2[LP] is written to 0
In FBE mode, the MCGOUTCLK is derived from the OSCSEL external reference clock. The FLL is
operational but its output is not used. This mode is useful to allow the FLL to acquire its target
frequency while the MCGOUTCLK is driven from the external reference clock. The FLL clock
(DCOCLK) is controlled by the external reference clock, and the DCO clock frequency locks to a
multiplication factor, as selected by C4[DRST_DRS] and C4[DMX32] bits, times the divided external
reference frequency. See the C4[DMX32] bit description for more details. In FBI mode the PLL is
disabled in a low-power state unless C5[PLLCLKEN0] is set.
In PEE mode, the MCGOUTCLK is derived from the PLL clock, which is controlled by the external
reference clock. The PLL clock frequency locks to a multiplication factor, as specified by C6[VDIV0],
times the external reference frequency, as specified by C5[PRDIV0]. The PLL's programmable
reference divider must be configured to produce a valid PLL reference clock. The FLL is disabled in
a low-power state.
PLL Bypassed External PLL Bypassed External (PBE) mode is entered when all the following conditions occur:
(PBE)
• C1[CLKS] bits are written to 10
• C1[IREFS] bit is written to 0
• C6[PLLS] bit is written to 1
• C2[LP] bit is written to 0
In PBE mode, MCGOUTCLK is derived from the OSCSEL external reference clock; the PLL is
operational, but its output clock is not used. This mode is useful to allow the PLL to acquire its target
frequency while MCGOUTCLK is driven from the external reference clock. The PLL clock frequency
locks to a multiplication factor, as specified by its [VDIV], times the PLL reference frequency, as
specified by its [PRDIV]. In preparation for transition to PEE, the PLL's programmable reference
divider must be configured to produce a valid PLL reference clock. The FLL is disabled in a low-
power state.
Bypassed Low Power Bypassed Low Power Internal (BLPI) mode is entered when all the following conditions occur:
Internal (BLPI)1
• C1[CLKS] bits are written to 01
• C1[IREFS] bit is written to 1
• C6[PLLS] bit is written to 0
• C2[LP] bit is written to 1
In BLPI mode, MCGOUTCLK is derived from the internal reference clock. The FLL is disabled and
PLL is disabled even if the C5[PLLCLKEN0] is set to 1.
Bypassed Low Power Bypassed Low Power External (BLPE) mode is entered when all the following conditions occur:
External (BLPE)
• C1[CLKS] bits are written to 10
• C1[IREFS] bit is written to 0
• C2[LP] bit is written to 1
In BLPE mode, MCGOUTCLK is derived from the OSCSEL external reference clock. The FLL is
disabled and PLL is disabled even if the C5[PLLCLKEN0] is set to 1.
NOTE: • When entering Low Power Stop modes (LLS or VLPS) from PEE mode, on exit the
MCG clock mode is forced to PBE clock mode . C1[CLKS] and S[CLKST] will be
configured to 2’b10 and S[LOCK0] bit will be cleared without setting S[LOLS0].
• When entering Normal Stop mode from PEE mode and if C5[PLLSTEN0]=0, on exit
the MCG clock mode is forced to PBE mode, the C1[CLKS] and S[CLKST] will be
configured to 2’b10 and S[LOCK0] bit will clear without setting S[LOLS0]. If
C5[PLLSTEN0]=1, the S[LOCK0] bit will not get cleared and on exit the MCG will
continue to run in PEE mode.
1. If entering VLPR mode, MCG has to be configured and enter BLPE mode or BLPI mode with the 4 MHz IRC clock selected
(C2[IRCS]=1). After it enters VLPR mode, writes to any of the MCG control registers that can cause an MCG clock mode
switch to a non low power clock mode must be avoided.
NOTE
For the chip-specific modes of operation, see the power
management chapter of this MCU.
the FLL remains unlocked for several reference cycles. DCO startup time is equal to the
FLL acquisition time. After the selected DCO startup time is over, the FLL is locked. The
completion of the switch is shown by the C4[DRST_DRS] read bits.
If the auto trim is being performed on the 4 MHz IRC, the calculated expected count
value must be multiplied by 128 before storing it in the ATCV register. Therefore, the
ATCV Expected Count Value for trimming the 4 MHz IRC is calculated using the
following formula.
(128)
appropriately here according to the external reference frequency to keep the FLL
reference clock in the range of 31.25 kHz to 39.0625 kHz. Although the FLL is
bypassed, it is still on in FBE mode.
• The internal reference can optionally be kept running by setting the
C1[IRCLKEN] bit. This is useful if the application will switch back and forth
between internal and external modes. For minimum power consumption, leave
the internal reference disabled while in an external clock mode.
3. Once the proper configuration bits have been set, wait for the affected bits in the
MCG status register to be changed appropriately, reflecting that the MCG has moved
into the proper mode.
• If the MCG is in FEE, FBE, PEE, PBE, or BLPE mode, and C2[EREFS0] was
also set in step 1, wait here for S[OSCINIT0] bit to become set indicating that
the external clock source has finished its initialization cycles and stabilized.
• If in FEE mode, check to make sure the S[IREFST] bit is cleared before moving
on.
• If in FBE mode, check to make sure the S[IREFST] bit is cleared and S[CLKST]
bits have changed to 2'b10 indicating the external reference clock has been
appropriately selected. Although the FLL is bypassed, it is still on in FBE mode.
4. Write to the C4 register to determine the DCO output (MCGFLLCLK) frequency
range.
• By default, with C4[DMX32] cleared to 0, the FLL multiplier for the DCO
output is 640. For greater flexibility, if a mid-low-range FLL multiplier of 1280
is desired instead, set C4[DRST_DRS] bits to 2'b01 for a DCO output frequency
of 40 MHz. If a mid high-range FLL multiplier of 1920 is desired instead, set the
C4[DRST_DRS] bits to 2'b10 for a DCO output frequency of 60 MHz. If a high-
range FLL multiplier of 2560 is desired instead, set the C4[DRST_DRS] bits to
2'b11 for a DCO output frequency of 80 MHz.
• When using a 32.768 kHz external reference, if the maximum low-range DCO
frequency that can be achieved with a 32.768 kHz reference is desired, set
C4[DRST_DRS] bits to 2'b00 and set C4[DMX32] bit to 1. The resulting DCO
output (MCGOUTCLK) frequency with the new multiplier of 732 will be 24
MHz.
• When using a 32.768 kHz external reference, if the maximum mid-range DCO
frequency that can be achieved with a 32.768 kHz reference is desired, set
C4[DRST_DRS] bits to 2'b01 and set C4[DMX32] bit to 1. The resulting DCO
output (MCGOUTCLK) frequency with the new multiplier of 1464 will be 48
MHz.
• When using a 32.768 kHz external reference, if the maximum mid high-range
DCO frequency that can be achieved with a 32.768 kHz reference is desired, set
C4[DRST_DRS] bits to 2'b10 and set C4[DMX32] bit to 1. The resulting DCO
output (MCGOUTCLK) frequency with the new multiplier of 2197 will be 72
MHz.
• When using a 32.768 kHz external reference, if the maximum high-range DCO
frequency that can be achieved with a 32.768 kHz reference is desired, set
C4[DRST_DRS] bits to 2'b11 and set C4[DMX32] bit to 1. The resulting DCO
output (MCGOUTCLK) frequency with the new multiplier of 2929 will be 96
MHz.
5. Wait for the FLL lock time to guarantee FLL is running at new C4[DRST_DRS] and
C4[DMX32] programmed frequency.
To change from FEI clock mode to FBI clock mode, follow this procedure:
1. Change C1[CLKS] bits in C1 register to 2'b01 so that the internal reference clock is
selected as the system clock source.
2. Wait for S[CLKST] bits in the MCG status register to change to 2'b01, indicating
that the internal reference clock has been appropriately selected.
3. Write to the C2 register to determine the IRCS output (IRCSCLK) frequency range.
• By default, with C2[IRCS] cleared to 0, the IRCS selected output clock is the
slow internal reference clock (32 kHz IRC). If the faster IRC is desired, set
C2[IRCS] bit to 1 for a IRCS clock derived from the 4 MHz IRC source.
resulting DCO output frequency is 62.91 MHz at mid high-range. If C4[DRST_DRS] bits
are set to 2'b11, the multiplication factor is set to 2560, and the resulting DCO output
frequency is 83.89 MHz at high-range.
In FBI and FEI modes, setting C4[DMX32] bit is not recommended. If the internal
reference is trimmed to a frequency above 32.768 kHz, the greater FLL multiplication
factor could potentially push the microcontroller system clock out of specification and
damage the part.
1. FLL_R is the reference divider selected by the C1[FRDIV] bits, PLL_R is the reference divider selected by C5[PRDIV0]
bits, F is the FLL factor selected by C4[DRST_DRS] and C4[DMX32] bits, and M is the multiplier selected by C6[VDIV0]
bits.
This section will include three mode switching examples using an 4 MHz external
crystal. If using an external clock source less than 2 MHz, the MCG must not be
configured for any of the PLL modes (PEE and PBE).
• C1[CLKS] set to 2'b00 to select the output of the PLL as the system clock
source.
b. Loop until S[CLKST] are 2'b11, indicating that the PLL output is selected to
feed MCGOUTCLK in the current clock mode.
• Now, with PRDIV0 of divide-by-2, and C6[VDIV0] of multiply-by-24,
MCGOUTCLK = [(4 MHz / 2) * 24] = 48 MHz.
START
IN FEI MODE
C6 = 0x40
C2 = 0x1C
IN
BLPE MODE ? NO
(S[LP]=1)
C1 = 0x90
YES
C2 = 0x1C
(S[LP]=0)
CHECK NO
S[OSCINIT] = 1?
CHECK NO
YES S[PLLST] = 1?
YES
CHECK NO
S[IREFST] = 0?
CHECK NO
YES
S[LOCK] = 1?
CHECK NO YES
S[CLKST] = %10?
C1 = 0x10
YES
C5 = 0x01
(C5[VDIV] = 1) CHECK NO
S[CLKST] = %11?
YES
ENTER NO
BLPE MODE ?
CONTINUE
C2 = 0x1E
(C2[LP] = 1)
Figure 24-15. Flowchart of FEI to PEE mode transition using an 4 MHz crystal
K20 Sub-Family Reference Manual, Rev. 1.1, Dec 2012
Freescale Semiconductor, Inc. 535
Initialization / Application information
START
IN PEE MODE
C1 = 0x90
CHECK NO
S[PLLST] = 0?
CHECK NO
S[CLKST] = %10 ? YES
C1 = 0x54
YES
ENTER NO
BLPE MODE ? CHECK NO
S[IREFST] = 0?
YES YES
C2 = 0x1E
(C2[LP] = 1)
CHECK NO
S[CLKST] = %01?
C6 = 0x00
YES
C2 = 0x02
IN
NO
BLPE MODE ?
(C2[LP]=1)
CONTINUE
YES IN BLPI MODE
C2 = 0x1C
(C2[LP] = 0)
Figure 24-16. Flowchart of PEE to BLPI mode transition using an 4 MHz crystal
START
IN BLPI MODE
CHECK NO
S[IREFST] = 0?
C2 =0x00
YES
C2 = 0x1C
CHECK NO
S[CLKST] = %00?
C1 =0x10
YES
CONTINUE
CHECK NO IN FEE MODE
S[OSCINIT] = 1 ?
YES
Figure 24-17. Flowchart of BLPI to FEE mode transition using an 4 MHz crystal
25.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The OSC module is a crystal oscillator. The module, in conjunction with an external
crystal or resonator, generates a reference clock for the MCU.
EXTAL XTAL
OSC_CLK_OUT
Mux
OSC Clock Enable
OSCERCLK
ERCLKEN
XTL_CLK
Range selections
Low Power config Oscillator Circuits EN
OSC32KCLK
4096
ERCLKEN EREFSTEN OSC_EN Counter
CNT_DONE_4096
STOP
1. With the low-power mode, the oscillator has the internal feedback resistor RF. Therefore, the feedback resistor must not be
externally with the Connection 3.
2. When the load capacitors (Cx, Cy) are greater than 30 pF, use Connection 3.
OSC
XTAL VSS EXTAL
Crystal or Resonator
OSC
RF
Crystal or Resonator
NOTE
Connection 1 and Connection 2 should use internal capacitors
as the load of the oscillator by configuring the CR[SCxP] bits.
OSC
Cx Cy
RF
Crystal or Resonator
OSC
XTAL VSS EXTAL
NOTE
After OSC is enabled and starts generating the clocks, the
configurations such as low power and frequency range, must
not be changed.
Address: 4006_5000h base + 0h offset = 4006_5000h
Bit 7 6 5 4 3 2 1 0
Read 0 0
ERCLKEN EREFSTEN SC2P SC4P SC8P SC16P
Write
Reset 0 0 0 0 0 0 0 0
Off
Oscillator OFF
OSCCLK
not requested OSC_CLK_OUT = Static
CNT_DONE_4096
Stable
Oscillator ON, Stable
OSC_CLK_OUT = XTL_CLK
NOTE
XTL_CLK is the clock generated internally from OSC circuits.
25.8.1.1 Off
The OSC enters the Off state when the system does not require OSC clocks. Upon
entering this state, XTL_CLK is static unless OSC is configured to select the clock from
the EXTAL pad by clearing the external reference clock selection bit. For details
regarding the external reference clock source in this MCU, refer to the chip configuration
chapter. 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.
NOTE
For information about low power modes of operation used in
this chip and their alignment with some OSC modes, refer to
the chip's Power Management details.
25.8.3 Counter
The oscillator output clock (OSC_CLK_OUT) is gated off until the counter has detected
4096 cycles of its input clock (XTL_CLK). After 4096 cycles are completed, the counter
passes XTL_CLK onto OSC_CLK_OUT. This counting time-out is used to guarantee
output clock stability.
25.9 Reset
There is no reset state associated with the OSC module. The counter logic is reset when
the OSC is not configured to generate clocks.
There are no sources of reset requests for the OSC module.
25.11 Interrupts
The OSC module does not generate any interrupts.
26.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The RTC oscillator module provides the clock source for the RTC. The RTC oscillator
module, in conjunction with an external crystal, generates a reference clock for the RTC.
control
Amplitude clk out for RTC
detector EXTAL32
gm
Rf
XTAL32
C1 C2
PAD PAD
Crystal or Resonator
26.7 Interrupts
The RTC oscillator does not generate any interrupts.
27.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The Flash Memory Controller (FMC) is a memory acceleration unit that provides:
• an interface between the device and the dual-bank nonvolatile memory. Bank 0
consists of program flash memory, and bank 1 consists of FlexNVM.
• buffers that can accelerate flash memory transfers.
27.1.1 Overview
The Flash Memory Controller manages the interface between the device and the dual-
bank flash memory. The FMC receives status information detailing the configuration of
the memory and uses this information to ensure a proper interface. The following table
shows the supported read/write operations.
Flash memory type Read Write
Program flash memory 8-bit, 16-bit, and 32-bit reads —1
FlexNVM used as Data flash memory 8-bit, 16-bit, and 32-bit reads —1
FlexNVM and FlexRAM used as 8-bit, 16-bit, and 32-bit reads 8-bit, 16-bit, and 32-bit writes
EEPROM
1. A write operation to program flash memory or to FlexNVM used as data flash memory results in a bus error.
In addition, for bank 0, the FMC provides three separate mechanisms for accelerating the
interface between the device and the flash memory. A 64-bit speculation buffer can
prefetch the next 64-bit flash memory location, and both a 4-way, 8-set cache and a
single-entry 64-bit buffer can store previously accessed flash memory data for quick
access times.
27.1.2 Features
The FMC's features include:
• Interface between the device and the dual-bank flash memory and FlexMemory:
• 8-bit, 16-bit, and 32-bit read operations to program flash memory and FlexNVM
used as data flash memory.
• 8-bit, 16-bit, and 32-bit read and write operations to FlexNVM and FlexRAM
used as EEPROM.
• For bank 0: Read accesses to consecutive 32-bit spaces in memory return the
second read data with no wait states. The memory returns 64 bits via the 32-bit
bus access.
• Crossbar master access protection for setting no access, read-only access, write-
only access, or read/write access for each crossbar master.
• For bank 0: Acceleration of data transfer from program flash memory and
FlexMemory to the device:
• 64-bit prefetch speculation buffer with controls for instruction/data access per
master
• 4-way, 8-set, 64-bit line size cache for a total of thirty-two 64-bit entries with
controls for replacement algorithm and lock per way
• Single-entry buffer with enable
• Invalidation control for the speculation buffer and the single-entry buffer
The programming model consists of the FMC control registers and the program visible
cache (data and tag/valid entries).
NOTE
Program the registers only while the flash controller is idle (for
example, execute from RAM). Changing configuration settings
while a flash access is in progress can lead to non-deterministic
behavior.
Table 27-2. FMC register access
Registers Read access Write access
Mode Length Mode Length
Control registers: Supervisor (privileged) 32 bits Supervisor (privileged) 32 bits
PFAPR, PFB0CR, mode or user mode mode only
PFB1CR
Cache registers Supervisor (privileged) 32 bits Supervisor (privileged) 32 bits
mode or user mode mode only
NOTE
Accesses to unimplemented registers within the FMC's 4 KB
address space return a bus error.
The cache entries, both data and tag/valid, can be read at any time.
NOTE
System software is required to maintain memory coherence
when any segment of the flash cache is programmed. For
example, all buffer data associated with the reprogrammed flash
should be invalidated. Accordingly, cache program visible
writes must occur after a programming or erase event is
completed and before the new memory image is accessed.
The cache is a 4-way, set-associative cache with 8 sets. The ways are numbered 0-3 and
the sets are numbered 0-7. The following table elaborates on the tag/valid and data
entries.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0
M7PFD
M6PFD
M5PFD
M4PFD
M3PFD
M2PFD
M1PFD
M0PFD
W
Reset 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R B0RWSC[3:0] 0 0 B0MW[1:0] 0
CLCK_WAY[3:0]
S_B_
W CINV_WAY[3:0]
INV
Reset 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0
B0SEBE
B0DCE
B0DPE
B0ICE
B0IPE
CRC[2:0]
Reset 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1
00 32 bits
01 64 bits
10 Reserved
11 Reserved
16 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
15–8 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
7–5 Cache Replacement Control
CRC[2:0]
This 3-bit field defines the replacement algorithm for accesses that are cached.
000 LRU replacement algorithm per set across all four ways
001 Reserved
010 Independent LRU with ways [0-1] for ifetches, [2-3] for data
011 Independent LRU with ways [0-2] for ifetches, [3] for data
1xx Reserved
4 Bank 0 Data Cache Enable
B0DCE
This bit controls whether data references are loaded into the cache.
This register has a format similar to that for PFB0CR, except it controls the operation of
flash bank 1, and the "global" cache control fields are empty.
Address: 4001_F000h base + 8h offset = 4001_F008h
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R B1RWSC[3:0] 0 B1MW[1:0] 0
W
Reset 0 0 1 1 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
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
00 32 bits
01 64 bits
10 Reserved
11 Reserved
16 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
15–8 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
7–5 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
4–0 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
The cache is a 4-way, set-associative cache with 8 sets. The ways are numbered 0-3 and
the sets are numbered 0-7. In TAGVDWxSy, x denotes the way, and y denotes the set.
This section represents tag/vld information for all sets in the indicated way.
Address: 4001_F000h base + 100h offset + (4d × i), where i=0d to 7d
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 tag[18:6]
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
tag[18:6] valid
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
The cache is a 4-way, set-associative cache with 8 sets. The ways are numbered 0-3 and
the sets are numbered 0-7. In TAGVDWxSy, x denotes the way, and y denotes the set.
This section represents tag/vld information for all sets in the indicated way.
Address: 4001_F000h base + 120h offset + (4d × i), where i=0d to 7d
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 tag[18:6]
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
tag[18:6] valid
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
The cache is a 4-way, set-associative cache with 8 sets. The ways are numbered 0-3 and
the sets are numbered 0-7. In TAGVDWxSy, x denotes the way, and y denotes the set.
This section represents tag/vld information for all sets in the indicated way.
Address: 4001_F000h base + 140h offset + (4d × i), where i=0d to 7d
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 tag[18:6]
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
tag[18:6] valid
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
The cache is a 4-way, set-associative cache with 8 sets. The ways are numbered 0-3 and
the sets are numbered 0-7. In TAGVDWxSy, x denotes the way, and y denotes the set.
This section represents tag/vld information for all sets in the indicated way.
Address: 4001_F000h base + 160h offset + (4d × i), where i=0d to 7d
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 tag[18:6]
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
tag[18:6] valid
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
The cache of 64-bit entries is a 4-way, set-associative cache with 8 sets. The ways are
numbered 0-3 and the sets are numbered 0-7. In DATAWxSyU and DATAWxSyL, x
denotes the way, y denotes the set, and U and L represent upper and lower word,
respectively. This section represents data for the upper word (bits [63:32]) of all sets in
the indicated way.
Address: 4001_F000h base + 200h 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
W
data[63:32]
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
The cache of 64-bit entries is a 4-way, set-associative cache with 8 sets. The ways are
numbered 0-3 and the sets are numbered 0-7. In DATAWxSyU and DATAWxSyL, x
denotes the way, y denotes the set, and U and L represent upper and lower word,
respectively. This section represents data for the lower word (bits [31:0]) of all sets in the
indicated way.
Address: 4001_F000h base + 204h 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
W
data[31:0]
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
The cache of 64-bit entries is a 4-way, set-associative cache with 8 sets. The ways are
numbered 0-3 and the sets are numbered 0-7. In DATAWxSyU and DATAWxSyL, x
denotes the way, y denotes the set, and U and L represent upper and lower word,
respectively. This section represents data for the upper word (bits [63:32]) of all sets in
the indicated way.
Address: 4001_F000h base + 240h 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
W
data[63:32]
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
The cache of 64-bit entries is a 4-way, set-associative cache with 8 sets. The ways are
numbered 0-3 and the sets are numbered 0-7. In DATAWxSyU and DATAWxSyL, x
denotes the way, y denotes the set, and U and L represent upper and lower word,
respectively. This section represents data for the lower word (bits [31:0]) of all sets in the
indicated way.
Address: 4001_F000h base + 244h 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
W
data[31:0]
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
The cache of 64-bit entries is a 4-way, set-associative cache with 8 sets. The ways are
numbered 0-3 and the sets are numbered 0-7. In DATAWxSyU and DATAWxSyL, x
denotes the way, y denotes the set, and U and L represent upper and lower word,
respectively. This section represents data for the upper word (bits [63:32]) of all sets in
the indicated way.
Address: 4001_F000h base + 280h 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
W
data[63:32]
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
The cache of 64-bit entries is a 4-way, set-associative cache with 8 sets. The ways are
numbered 0-3 and the sets are numbered 0-7. In DATAWxSyU and DATAWxSyL, x
denotes the way, y denotes the set, and U and L represent upper and lower word,
respectively. This section represents data for the lower word (bits [31:0]) of all sets in the
indicated way.
Address: 4001_F000h base + 284h 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
W
data[31:0]
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
The cache of 64-bit entries is a 4-way, set-associative cache with 8 sets. The ways are
numbered 0-3 and the sets are numbered 0-7. In DATAWxSyU and DATAWxSyL, x
denotes the way, y denotes the set, and U and L represent upper and lower word,
respectively. This section represents data for the upper word (bits [63:32]) of all sets in
the indicated way.
Address: 4001_F000h base + 2C0h 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
W
data[63:32]
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
The cache of 64-bit entries is a 4-way, set-associative cache with 8 sets. The ways are
numbered 0-3 and the sets are numbered 0-7. In DATAWxSyU and DATAWxSyL, x
denotes the way, y denotes the set, and U and L represent upper and lower word,
respectively. This section represents data for the lower word (bits [31:0]) of all sets in the
indicated way.
Address: 4001_F000h base + 2C4h 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
W
data[31:0]
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
• These masters have write access to a portion of bank 1 when FlexNVM is used with
FlexRAM as EEPROM.
• For bank 0:
• Prefetch support for data and instructions is enabled for crossbar masters 0, 1, 2.
• The cache is configured for least recently used (LRU) replacement for all four
ways.
• The cache is configured for data or instruction replacement.
• The single-entry buffer is enabled.
2. the phase relationship of the core clock and flash clock at the time the read is
requested.
The ratio of the core clock to the flash clock is equal to the value of PFB0CR[B0RWSC]
+ 1 for bank 0 and to the value of PFB1CR[B1RWSC] + 1 for bank 1.
For example, in a system with a 4:1 core-to-flash clock ratio, a read that does not hit in
the speculation buffer or the cache can take between 4 and 7 core clock cycles to
complete.
• The best-case scenario is a period of 4 core clock cycles because a read from the
flash memory takes 1 flash clock, which translates to 4 core clocks.
• The worst-case scenario is a period of 7 core clock cycles, consisting of 4 cycles for
the read operation and 3 cycles of delay to align the core and flash clocks.
• A delay to align the core and flash clocks might occur because you can request a
read cycle on any core clock edge, but that edge does not necessarily align with a
flash clock edge where the read can start.
• In this case, the read operation is delayed by a number of core clocks equal to the
core-to-flash clock ratio minus one: 4 - 1 = 3. That is, 3 additional core clock
cycles are required to synchronize the clocks before the read operation can start.
All wait states and synchronization delays are handled automatically by the Flash
Memory Controller. No direct user configuration is required or even allowed to set up the
flash wait states.
• The core requests four sequential longwords in back-to-back requests, meaning there
are no core cycle delays except for stalls waiting for flash memory data to be
returned.
• None of the data is already stored in the cache or speculation buffer.
In this scenario, the sequence of events for accessing the four longwords is as follows:
1. The first longword read requires 4 to 7 core clocks. See Wait states for more
information.
2. Due to the 64-bit data bus of the flash memory, the second longword read takes only
1 core clock because the data is already available inside the FMC. While the data for
the second longword is being returned to the core, the FMC also starts reading the
third and fourth longwords from the flash memory.
3. Accessing the third longword requires 3 core clock cycles. The flash memory read
itself takes 4 clocks, but the first clock overlaps with the second longword read.
4. Reading the fourth longword, like the second longword, takes only 1 clock due to the
64-bit flash memory data bus.
28.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The flash memory module includes the following accessible memory regions:
• Program flash memory for vector space and code store
• FlexNVM for data store and additional code store
• FlexRAM for high-endurance data store or traditional RAM
Flash memory is ideal for single-supply applications, permitting in-the-field erase and
reprogramming operations without the need for any external high voltage power sources.
The flash memory module includes a memory controller that executes commands to
modify flash memory contents. An erased bit reads '1' and a programmed bit reads '0'.
The programming operation is unidirectional; it can only move bits from the '1' state
(erased) to the '0' state (programmed). Only the erase operation restores bits from '0' to
'1'; bits cannot be programmed from a '0' to a '1'.
CAUTION
A flash memory location must be in the erased state before
being programmed. Cumulative programming of bits (back-to-
back program operations without an intervening erase) within a
flash memory location is not allowed. Re-programming of
existing 0s to 0 is not allowed as this overstresses the device.
The standard shipping condition for flash memory is erased
with security disabled. Data loss over time may occur due to
degradation of the erased ('1') states and/or programmed ('0')
28.1.1 Features
The flash memory module includes the following features.
NOTE
See the device's Chip Configuration details for the exact
amount of flash memory available on your device.
Control
registers
To MCU's
flash controller
FlexNVM
Data flash
FlexRAM
EEPROM backup
28.1.3 Glossary
Command write sequence — A series of MCU writes to the flash FCCOB register
group that initiates and controls the execution of flash algorithms that are built into the
flash memory module.
Data flash memory — Partitioned from the FlexNVM block, the data flash memory
provides nonvolatile storage for user data, boot code, and additional code store.
Data flash sector — The data flash sector is the smallest portion of the data flash
memory that can be erased.
EEPROM — Using a built-in filing system, the flash memory module emulates the
characteristics of an EEPROM by effectively providing a high-endurance, byte-writeable
(program and erase) NVM.
EEPROM backup data header — The EEPROM backup data header is comprised of a
32-bit field found in EEPROM backup data memory which contains information used by
the EEPROM filing system to determine the status of a specific EEPROM backup flash
sector.
EEPROM backup data record — The EEPROM backup data record is comprised of a
2-bit status field, a 14-bit address field, and a 16-bit data field found in EEPROM backup
data memory which is used by the EEPROM filing system. If the status field indicates a
record is valid, the data field is mirrored in the FlexRAM at a location determined by the
address field.
EEPROM backup data memory — Partitioned from the FlexNVM block, EEPROM
backup data memory provides nonvolatile storage for the EEPROM filing system
representing data written to the FlexRAM requiring highest endurance.
EEPROM backup data sector — The EEPROM backup data sector contains one
EEPROM backup data header and up to 255 EEPROM backup data records, which are
used by the EEPROM filing system.
Endurance — The number of times that a flash memory location can be erased and
reprogrammed.
FCCOB (Flash Common Command Object) — A group of flash registers that are used
to pass command, address, data, and any associated parameters to the memory controller
in the flash memory module.
Flash block — A macro within the flash memory module which provides the nonvolatile
memory storage.
FlexMemory — Flash configuration that supports data flash, EEPROM, and FlexRAM.
FlexNVM Block — The FlexNVM block can be configured to be used as data flash
memory, EEPROM backup flash memory, or a combination of both.
FlexRAM — The FlexRAM refers to a RAM, dedicated to the flash memory module,
that can be configured to store EEPROM data or as traditional RAM. When configured
for EEPROM, valid writes to the FlexRAM generate new EEPROM backup data records
stored in the EEPROM backup flash memory.
Flash Memory Module — All flash blocks plus a flash management unit providing
high-level control and an interface to MCU buses.
IFR — Nonvolatile information register found in each flash block, separate from the
main memory array.
NVM — Nonvolatile memory. A memory technology that maintains stored data during
power-off. The flash array is an NVM using NOR-type flash memory technology.
NVM Normal Mode — An NVM mode that provides basic user access to flash memory
module resources. The CPU or other bus masters initiate flash program and erase
operations (or other flash commands) using writes to the FCCOB register group in the
flash memory module.
NVM Special Mode — An NVM mode enabling external, off-chip access to the memory
resources in the flash memory module. A reduced flash command set is available when
the MCU is secured. See the Chip Configuration details for information on when this
mode is used.
Phrase — 64 bits of data with an aligned phrase having byte-address[2:0] = 000.
Longword — 32 bits of data with an aligned longword having byte-address[1:0] = 00.
Word — 16 bits of data with an aligned word having byte-address[0] = 0.
Program flash — The program flash memory provides nonvolatile storage for vectors
and code store.
Program flash Sector — The smallest portion of the program flash memory
(consecutive addresses) that can be erased.
Retention — The length of time that data can be kept in the NVM without experiencing
errors upon readout. Since erased (1) states are subject to degradation just like
programmed (0) states, the data retention limit may be reached from the last erase
operation (not from the programming time).
RWW— Read-While-Write. The ability to simultaneously read from one memory
resource while commanded operations are active in another memory resource.
Section Program Buffer — Lower half of the FlexRAM allocated for storing large
amounts of data for programming via the Program Section command.
Secure — An MCU state conveyed to the flash memory module as described in the Chip
Configuration details for this device. In the secure state, reading and changing NVM
contents is restricted.
Bit 7 6 5 4 3 2 1 0
Bit 7 6 5 4 3 2 1 0
0 No suspend requested
1 Suspend the current Erase Flash Sector command execution.
3 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
2 Flash memory configuration
PFLSH
0 Flash memory module configured for FlexMemory that supports data flash and/or EEPROM
1 Reserved
1 RAM Ready
RAMRDY
This flag indicates the current status of the FlexRAM .
The state of the RAMRDY flag is normally controlled by the Set FlexRAM Function command. During the
reset sequence, the RAMRDY flag is cleared if the FlexNVM block is partitioned for EEPROM and is set if
the FlexNVM block is not partitioned for EEPROM. The RAMRDY flag is cleared if the Program Partition
command is run to partition the FlexNVM block for EEPROM. The RAMRDY flag sets after completion of
the Erase All Blocks command or execution of the erase-all operation triggered external to the flash
memory module .
Table continues on the next page...
Bit 7 6 5 4 3 2 1 0
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 OPT
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
The FCCOB register group provides 12 bytes for command codes and parameters. The
individual bytes within the set append a 0-B hex identifier to the FCCOB register name:
FCCOB0, FCCOB1, ..., FCCOBB.
Address: 4002_0000h base + 4h offset + (1d × i), where i=0d to 11d
Bit 7 6 5 4 3 2 1 0
Read CCOBn
Write
Reset 0 0 0 0 0 0 0 0
During the reset sequence, the FPROT registers are loaded with the contents of the
program flash protection bytes in the Flash Configuration Field as indicated in the
following table.
Program flash protection register Flash Configuration Field offset address
FPROT0 0x0008
FPROT1 0x0009
FPROT2 0x000A
FPROT3 0x000B
To change the program flash protection that is loaded during the reset sequence,
unprotect the sector of program flash memory that contains the Flash Configuration
Field. Then, reprogram the program flash protection byte.
Address: 4002_0000h base + 10h offset + (1d × i), where i=0d to 3d
Bit 7 6 5 4 3 2 1 0
Read PROT
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
Restriction: The user must never write to any FPROT register while a command is running (CCIF=0).
Trying to alter data in any protected area in the program flash memory results in a protection violation
error and sets the FSTAT[FPVIOL] bit. A full block erase of a program flash block is not possible if it
contains any protected region.
Each bit in the 32-bit protection register represents 1/32 of the total program flash .
The FEPROT register defines which EEPROM regions of the FlexRAM are protected
against program and erase operations. Protected EEPROM regions cannot have their
content changed by writing to it. Unprotected regions can be changed by writing to the
FlexRAM.
Address: 4002_0000h base + 16h offset = 4002_0016h
Bit 7 6 5 4 3 2 1 0
Read EPROT
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
Individual EEPROM regions can be protected from alteration by setting the associated EPROT bit. The
EPROT bits are not used when the FlexNVM Partition Code is set to data flash only. When the FlexNVM
Partition Code is set to data flash and EEPROM or EEPROM only, each EPROT bit covers one-eighth of
the configured EEPROM data (see the EEPROM Data Set Size parameter description).
In NVM Normal mode: The protection can only be increased. This means that currently-unprotected
memory can be protected, but currently-protected memory cannot be unprotected. Since unprotected
regions are marked with a 1 and protected regions use a 0, only writes changing 1s to 0s are accepted.
This 1-to-0 transition check is performed on a bit-by-bit basis. Those FEPROT bits with 1-to-0 transitions
are accepted while all bits with 0-to-1 transitions are ignored .
In NVM Special mode : All bits of the FEPROT register are writable without restriction. Unprotected areas
can be protected and protected areas can be unprotected.
Restriction: Never write to the FEPROT register while a command is running (CCIF=0).
Reset: During the reset sequence, the FEPROT register is loaded with the contents of the FlexRAM
protection byte in the Flash Configuration Field located in program flash. The flash basis for the reset
values is signified by X in the register diagram. To change the EEPROM protection that will be loaded
during the reset sequence, the sector of program flash that contains the Flash Configuration Field must be
unprotected; then the EEPROM protection byte must be erased and reprogrammed.
Trying to alter data by writing to any protected area in the EEPROM results in a protection violation error
and sets the FPVIOL bit in the FSTAT register.
The FDPROT register defines which data flash regions are protected against program and
erase operations. Protected Flash regions cannot have their content changed; that is, these
regions cannot be programmed and cannot be erased by any flash command. Unprotected
regions can be changed by both program and erase operations.
Address: 4002_0000h base + 17h offset = 4002_0017h
Bit 7 6 5 4 3 2 1 0
Read DPROT
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
Restriction: The user must never write to the FDPROT register while a command is running (CCIF=0).
Reset: During the reset sequence, the FDPROT register is loaded with the contents of the data flash
protection byte in the Flash Configuration Field located in program flash memory. The flash basis for the
reset values is signified by X in the register diagram. To change the data flash protection that will be
loaded during the reset sequence, unprotect the sector of program flash that contains the Flash
Configuration Field. Then, erase and reprogram the data flash protection byte.
Trying to alter data with the program and erase commands in any protected area in the data flash memory
results in a protection violation error and sets the FSTAT[FPVIOL] bit. A full block erase of the data flash
memory (see the Erase Flash Block command description) is not possible if the data flash memory
contains any protected region or if the FlexNVM block has been partitioned for EEPROM.
EEPROM backup
Unavailable
To handle varying customer requirements, the FlexRAM and FlexNVM blocks can be
split into partitions as shown in the figure below.
1. EEPROM partition (EEESIZE) — The amount of FlexRAM used for EEPROM
can be set from 0 Bytes (no EEPROM) to the maximum FlexRAM size (see Table
28-2). The remainder of the FlexRAM is not accessible while the FlexRAM is
configured for EEPROM (see Set FlexRAM Function Command). The EEPROM
partition grows upward from the bottom of the FlexRAM address space.
2. Data flash partition (DEPART) — The amount of FlexNVM memory used for data
flash can be programmed from 0 bytes (all of the FlexNVM block is available for
EEPROM backup) to the maximum size of the FlexNVM block (see Table 28-4).
3. FlexNVM EEPROM partition — The amount of FlexNVM memory used for
EEPROM backup, which is equal to the FlexNVM block size minus the data flash
memory partition size. The EEPROM backup size must be at least 16 times the
EEPROM partition size in FlexRAM.
The partition information (EEESIZE, DEPART) is stored in the data flash IFR and is
programmed using the Program Partition command (see Program Partition Command).
Typically, the Program Partition command is executed only once in the lifetime of the
device.
Data flash memory is useful for applications that need to quickly store large amounts of
data or store data that is static. The EEPROM partition in FlexRAM is useful for storing
smaller amounts of data that will be changed often.
FlexNVM
FlexNVM base
address
DEPART
Data flash
FlexRAM
FlexRAM base
EEESIZE
address
EEPROM partition
EEPROM backup
Unavailable
and copies the newest data to FlexRAM. The FSTAT[CCIF] and FCNFG[EEERDY] bits
are set after data from all valid EEPROM data records is copied to the FlexRAM. After
the CCIF bit is set, the FlexRAM is available for read or write access.
When configured for EEPROM use, writes to an unprotected location in FlexRAM
invokes the EEPROM file system to program a new EEPROM data record in the
EEPROM backup memory in a round-robin fashion. As needed, the EEPROM file
system identifies the EEPROM backup sector that is being erased for future use and
partially erases that EEPROM backup sector. After a write to the FlexRAM, the
FlexRAM is not accessible until the FSTAT[CCIF] bit is set. The FCNFG[EEERDY] bit
will also be set. If enabled, the interrupt associated with the FSTAT[CCIF] bit can be
used to determine when the FlexRAM is available for read or write access.
After a sector in EEPROM backup is full of EEPROM data records, EEPROM data
records from the sector holding the oldest data are gradually copied over to a previously-
erased EEPROM backup sector. When the sector copy completes, the EEPROM backup
sector holding the oldest data is tagged for erase.
where
• Writes_FlexRAM — minimum number of writes to each FlexRAM location
• EEPROM — allocated FlexNVM based on DEPART; entered with Program
Partition command
• EEESIZE — allocated FlexRAM based on DEPART; entered with Program Partition
command
• Write_efficiency —
• 0.25 for 8-bit writes to FlexRAM
• 0.50 for 16-bit or 32-bit writes to FlexRAM
• nnvmcycd — data flash cycling endurance
28.4.3 Interrupts
The flash memory module can generate interrupt requests to the MCU upon the
occurrence of various flash events. These interrupt events and their associated status and
control bits are shown in the following table.
Table 28-30. Flash Interrupt Sources
Flash Event Readable Interrupt
Status Bit Enable Bit
Flash Command Complete FSTAT[CCIF] FCNFG[CCIE]
Note
Vector addresses and their relative interrupt priority are
determined at the MCU level.
The MCU must not read from the flash memory while commands are running (as
evidenced by CCIF=0) on that block. Read data cannot be guaranteed from a flash block
while any command is processing within that block. The block arbitration logic detects
any simultaneous access and reports this as a read collision error (see the
FSTAT[RDCOLERR] bit).
• The command write sequence used to set flash command parameters and launch
execution
• A description of all flash commands available
If the parameter check fails, the FSTAT[ACCERR] (access error) flag is set.
ACCERR reports invalid instruction codes and out-of bounds addresses. Usually,
access errors suggest that the command was not set-up with valid parameters in the
FCCOB register group.
Program and erase commands also check the address to determine if the operation is
requested to execute on protected areas. If the protection check fails, the
FSTAT[FPVIOL] (protection error) flag is set.
Command processing never proceeds to execution when the parameter or protection
step fails. Instead, command processing is terminated after setting the FSTAT[CCIF]
bit.
2. If the parameter and protection checks pass, the command proceeds to execution.
Run-time errors, such as failure to erase verify, may occur during the execution
phase. Run-time errors are reported in the FSTAT[MGSTAT0] bit. A command may
have access errors, protection errors, and run-time errors, but the run-time errors are
not seen until all access and protection errors have been corrected.
3. Command execution results, if applicable, are reported back to the user via the
FCCOB and FSTAT registers.
4. The flash memory module sets the FSTAT[CCIF] bit signifying that the command
has completed.
The flow for a generic command write sequence is illustrated in the following figure.
START
no
CCIF Previous command complete?
= ‘1’?
yes
Results from previous command
More yes
Parameters?
no
EXIT
1. When FlexRAM configured for EEPROM (writes are effectively multi-cycle operations).
2. When FlexRAM configured as traditional RAM (writes are single-cycle operations).
3. When FlexRAM configured as traditional RAM, writes to the RAM are ignored while the Program Section command is
active (CCIF = 0).
The 'user' and 'factory' levels become, in effect, a minimum safety margin; i.e. if the reads
pass at the tighter tolerances of the 'user' and 'factory' margins, then the 'normal' reads
have at least this much safety margin before they experience data loss.
The 'user' margin is a small delta to the normal read reference level. 'User' margin levels
can be employed to check that flash memory contents have adequate margin for normal
level read operations. If unexpected read results are encountered when checking flash
memory contents at the 'user' margin levels, loss of information might soon occur during
'normal' readout.
The 'factory' margin is a bigger deviation from the norm, a more stringent read criteria
that should only be attempted immediately (or very soon) after completion of an erase or
program command, early in the cycling life. 'Factory' margin levels can be used to check
that flash memory contents have adequate margin for long-term data retention at the
normal level setting. If unexpected results are encountered when checking flash memory
contents at 'factory' margin levels, the flash memory contents should be erased and
reprogrammed.
CAUTION
Factory margin levels must only be used during verify of the
initial factory programming.
Ensure that the ACCERR and FPVIOL bits in the FSTAT register are cleared prior to
starting the command write sequence. As described in Launch the Command by Clearing
CCIF, a new command cannot be launched while these error flags are set.
Do not attempt to read a flash block while the flash memory module is running a
command (CCIF = 0) on that same block. The flash memory module may return invalid
data to the MCU with the collision error flag (FSTAT[RDCOLERR]) set.
When required by the command, address bit 23 selects between:
After clearing CCIF to launch the Read 1s Block command, the flash memory module
sets the read margin for 1s according to Table 28-34 and then reads all locations within
the selected program flash or data flash block.
When the data flash is targeted, DEPART must be set for no EEPROM, else the Read 1s
Block command aborts setting the FSTAT[ACCERR] bit. If the flash memory module
fails to read all 1s (i.e. the flash block is not fully erased), the FSTAT[MGSTAT0] bit is
set. The CCIF flag sets after the Read 1s Block operation has completed.
Table 28-34. Margin Level Choices for Read 1s Block
Read Margin Choice Margin Level Description
0x00 Use the 'normal' read level for 1s
0x01 Apply the 'User' margin to the normal read-1 level
0x02 Apply the 'Factory' margin to the normal read-1 level
Upon clearing CCIF to launch the Read 1s Section command, the flash memory module
sets the read margin for 1s according to Table 28-38 and then reads all locations within
the specified section of flash memory. If the flash memory module fails to read all 1s (i.e.
the flash section is not erased), the FSTAT(MGSTAT0) bit is set. The CCIF flag sets
after the Read 1s Section operation completes.
Table 28-38. Margin Level Choices for Read 1s Section
Read Margin Choice Margin Level Description
0x00 Use the 'normal' read level for 1s
0x01 Apply the 'User' margin to the normal read-1 level
0x02 Apply the 'Factory' margin to the normal read-1 level
Upon clearing CCIF to launch the Program Check command, the flash memory module
sets the read margin for 1s according to Table 28-41, reads the specified longword, and
compares the actual read data to the expected data provided by the FCCOB. If the
comparison at margin-1 fails, the MGSTAT0 bit is set.
The flash memory module then sets the read margin for 0s, re-reads, and compares again.
If the comparison at margin-0 fails, the MGSTAT0 bit is set. The CCIF flag is set after
the Program Check operation completes.
The supplied address must be longword aligned (the lowest two bits of the byte address
must be 00):
• Byte 0 data is expected at the supplied address ('start'),
• Byte 1 data is expected at byte address start + 0b01,
• Byte 2 data is expected at byte address start + 0b10, and
• Byte 3 data is expected at byte address start + 0b11.
NOTE
See the description of margin reads, Margin Read Commands
Table 28-41. Margin Level Choices for Program Check
Read Margin Choice Margin Level Description
0x01 Read at 'User' margin-1 and 'User' margin-0
0x02 Read at 'Factory' margin-1 and 'Factory' margin-0
1. Flash address [23] selects between program flash (=0) and data flash (=1) resources.
2. Located in program flash 0 reserved space; Flash address [23] = 0
After clearing CCIF to launch the Read Resource command, four consecutive bytes are
read from the selected resource at the provided relative address and stored in the FCCOB
register. The CCIF flag sets after the Read Resource operation completes. The Read
Resource command exits with an access error if an invalid resource code is provided or if
the address for the applicable area is out-of-range.
Table 28-45. Read Resource Command Error Handling
Error Condition Error Bit
Command not available in current mode/security FSTAT[ACCERR]
An invalid resource code is entered FSTAT[ACCERR]
Flash address is out-of-range for the targeted resource. FSTAT[ACCERR]
Flash address is not longword aligned FSTAT[ACCERR]
CAUTION
A flash memory location must be in the erased state before
being programmed. Cumulative programming of bits (back-to-
back program operations without an intervening erase) within a
flash memory location is not allowed. Re-programming of
existing 0s to 0 is not allowed as this overstresses the device.
Table 28-46. Program Longword Command FCCOB Requirements
FCCOB Number FCCOB Contents [7:0]
0 0x06 (PGM4)
1 Flash address [23:16]
2 Flash address [15:8]
3 Flash address [7:0]1
4 Byte 0 program value
5 Byte 1 program value
6 Byte 2 program value
7 Byte 3 program value
Upon clearing CCIF to launch the Program Longword command, the flash memory
module programs the data bytes into the flash using the supplied address. The targeted
flash locations must be currently unprotected (see the description of the FPROT and
FDPROT registers) to permit execution of the Program Longword operation.
The programming operation is unidirectional. It can only move NVM bits from the erased
state ('1') to the programmed state ('0'). Erased bits that fail to program to the '0' state are
flagged as errors in MGSTAT0. The CCIF flag is set after the Program Longword
operation completes.
The supplied address must be longword aligned (flash address [1:0] = 00):
• Byte 0 data is written to the supplied address ('start'),
• Byte 1 data is programmed to byte address start+0b01,
• Byte 2 data is programmed to byte address start+0b10, and
• Byte 3 data is programmed to byte address start+0b11.
Table 28-47. Program Longword Command Error Handling
Error Condition Error Bit
Command not available in current mode/security FSTAT[ACCERR]
An invalid flash address is supplied FSTAT[ACCERR]
Flash address is not longword aligned FSTAT[ACCERR]
Flash address points to a protected area FSTAT[FPVIOL]
Upon clearing CCIF to launch the Erase Flash Block command, the flash memory
module erases the main array of the selected flash block and verifies that it is erased.
When the data flash is targeted, DEPART must be set for no EEPROM (see Table 28-4)
else the Erase Flash Block command aborts setting the FSTAT[ACCERR] bit. The Erase
Flash Block command aborts and sets the FSTAT[FPVIOL] bit if any region within the
block is protected (see the description of the FPROT and FDPROT registers). If the erase
verify fails, the MGSTAT0 bit in FSTAT is set. The CCIF flag will set after the Erase
Flash Block operation has completed.
Table 28-49. Erase Flash Block Command Error Handling
Error Condition Error Bit
Command not available in current mode/security FSTAT[ACCERR]
Program flash is selected and the address is out of program flash range FSTAT[ACCERR]
Data flash is selected and the address is out of data flash range FSTAT[ACCERR]
Data flash is selected with EEPROM enabled FSTAT[ACCERR]
Flash address is not longword aligned FSTAT[ACCERR]
Any area of the selected flash block is protected FSTAT[FPVIOL]
Any errors have been encountered during the verify operation FSTAT[MGSTAT0]
After clearing CCIF to launch the Erase Flash Sector command, the flash memory
module erases the selected program flash or data flash sector and then verifies that it is
erased. The Erase Flash Sector command aborts if the selected sector is protected (see the
description of the FPROT and FDPROT registers). If the erase-verify fails the
FSTAT[MGSTAT0] bit is set. The CCIF flag is set after the Erase Flash Sector operation
completes. The Erase Flash Sector command is suspendable (see the FCNFG[ERSSUSP]
bit and Figure 28-33).
Table 28-51. Erase Flash Sector Command Error Handling
Error Condition Error Bit
Command not available in current mode/security FSTAT[ACCERR]
An invalid Flash address is supplied FSTAT[ACCERR]
Flash address is not phrase/longword aligned FSTAT[ACCERR]
The selected program flash or data flash sector is protected FSTAT[FPVIOL]
Any errors have been encountered during the verify operation FSTAT[MGSTAT0]
If an Erase Flash Sector operation effectively completes before the flash memory module
detects that a suspend request has been made, the flash memory module clears the
ERSSUSP bit prior to setting CCIF. When an Erase Flash Sector operation has been
successfully suspended, the flash memory module sets CCIF and leaves the ERSSUSP bit
set. While CCIF is set, the ERSSUSP bit can only be cleared to prevent the withdrawal of
a suspend request before the flash memory module has acknowledged it.
Command Initiation
ERSSCR Command
(Write FCCOB)
Memory Controller
Command Processing
Launch/Resume Command
(Clear CCIF)
Resume
ERSSCR
Yes
SUSPACK=1
Next Command Yes CCIF = 1?
(Write FCCOB) No Restore Erase Algo
Start Clear SUSPACK = 0
No New
No Interrupt?
Execute
Yes Yes
DONE?
Request Suspend
(Set ERSSUSP) No
No
ERSSUSP=1?
No Yes
CCIF = 1?
Save Erase Algo Clear ERSSUSP
Yes
ERSSCR Suspended No
After clearing CCIF to launch the Program Section command, the flash memory module
blocks access to the FlexRAM and programs the data residing in the section program
buffer into the flash memory starting at the flash address provided.
The starting address must be unprotected (see the description of the FPROT and
FDPROT registers) to permit execution of the Program Section operation. Programming,
which is not allowed to cross a flash sector boundary, continues until all requested
phrases or longwords have been programmed. The Program Section command also
verifies that after programming, all bits requested to be programmed are programmed.
After the Program Section operation completes, the CCIF flag is set and normal access to
the FlexRAM is restored. The contents of the section program buffer may be changed by
the Program Section operation.
Table 28-54. Program Section Command Error Handling
Error Condition Error Bit
Command not available in current mode/security FSTAT[ACCERR]
An invalid flash address is supplied FSTAT[ACCERR]
Flash address is not phrase/longword aligned FSTAT[ACCERR]
The requested section crosses a program flash sector boundary FSTAT[ACCERR]
The requested number of phrases/longwords is zero FSTAT[ACCERR]
The space required to store data for the requested number of phrases/longwords is more
FSTAT[ACCERR]
than half the size of the FlexRAM
The FlexRAM is not set to function as a traditional RAM, i.e. set if RAMRDY=0 FSTAT[ACCERR]
The flash address falls in a protected area FSTAT[FPVIOL]
Any errors have been encountered during the verify operation FSTAT[MGSTAT0]
5. If a flash sector is larger than half the FlexRAM, repeat steps 3 and 4 until the sector
is completely programmed.
6. To program additional flash sectors, repeat steps 2 through 4.
7. To restore EEPROM functionality, execute the Set FlexRAM Function command to
make the FlexRAM available as EEPROM.
After clearing CCIF to launch the Read 1s All Blocks command, the flash memory
module :
• sets the read margin for 1s according to Table 28-56,
• checks the contents of the program flash, data flash, EEPROM backup records, and
data flash IFR are in the erased state.
If the flash memory module confirms that these memory resources are erased, security is
released by setting the FSEC[SEC] field to the unsecure state. The security byte in the
flash configuration field (see Flash Configuration Field Description) remains unaffected
by the Read 1s All Blocks command. If the read fails, i.e. all memory resources are not in
the fully erased state, the FSTAT[MGSTAT0] bit is set.
The EEERDY and RAMRDY bits are clear during the Read 1s All Blocks operation and
are restored at the end of the Read 1s All Blocks operation.
The CCIF flag sets after the Read 1s All Blocks operation has completed.
Table 28-56. Margin Level Choices for Read 1s All Blocks
Read Margin Choice Margin Level Description
0x00 Use the 'normal' read level for 1s
0x01 Apply the 'User' margin to the normal read-1 level
0x02 Apply the 'Factory' margin to the normal read-1 level
After clearing CCIF to launch the Read Once command, a 4-byte Read Once record is
read from the program flash IFR and stored in the FCCOB register. The CCIF flag is set
after the Read Once operation completes. Valid record index values for the Read Once
command range from 0x00 to 0x0F. During execution of the Read Once command, any
attempt to read addresses within the program flash block containing this 64-byte field
returns invalid data. The Read Once command can be executed any number of times.
Table 28-59. Read Once Command Error Handling
Error Condition Error Bit
Command not available in current mode/security FSTAT[ACCERR]
An invalid record index is supplied FSTAT[ACCERR]
After clearing CCIF to launch the Program Once command, the flash memory module
first verifies that the selected record is erased. If erased, then the selected record is
programmed using the values provided. The Program Once command also verifies that
the programmed values read back correctly. The CCIF flag is set after the Program Once
operation has completed.
The reserved program flash IFR location accessed by the Program Once command cannot
be erased and any attempt to program one of these records when the existing value is not
Fs (erased) is not allowed. Valid record index values for the Program Once command
range from 0x00 to 0x0F. During execution of the Program Once command, any attempt
to read addresses within program flash returns invalid data.
Table 28-61. Program Once Command Error Handling
Error Condition Error Bit
Command not available in current mode/security FSTAT[ACCERR]
An invalid record index is supplied FSTAT[ACCERR]
The requested record has already been programmed to a non-FFFF value1 FSTAT[ACCERR]
Any errors have been encountered during the verify operation FSTAT[MGSTAT0]
1. If a Program Once record is initially programmed to 0xFFFF_FFFF, the Program Once command is allowed to execute
again on that same record.
After clearing CCIF to launch the Erase All Blocks command, the flash memory module
erases all program flash memory, data flash memory, data flash IFR space, EEPROM
backup memory, and FlexRAM, then verifies that all are erased.
If the flash memory module verifies that all flash memories and the FlexRAM were
properly erased, security is released by setting the FSEC[SEC] field to the unsecure state
and the FCNFG[RAMRDY] bit is set. The Erase All Blocks command aborts if any flash
or FlexRAM region is protected. The security byte and all other contents of the flash
configuration field (see Flash Configuration Field Description) are erased by the Erase
All Blocks command. If the erase-verify fails, the FSTAT[MGSTAT0] bit is set. The
CCIF flag is set after the Erase All Blocks operation completes.
Table 28-63. Erase All Blocks Command Error Handling
Error Condition Error Bit
Command not available in current mode/security FSTAT[ACCERR]
Any region of the program flash memory, data flash memory, or FlexRAM is protected FSTAT[FPVIOL]
Any errors have been encountered during the verify operation FSTAT[MGSTAT0]
After clearing CCIF to launch the Verify Backdoor Access Key command, the flash
memory module checks the FSEC[KEYEN] bits to verify that this command is enabled.
If not enabled, the flash memory module sets the FSTAT[ACCERR] bit and terminates.
If the command is enabled, the flash memory module compares the key provided in
FCCOB to the backdoor comparison key in the Flash Configuration Field. If the
backdoor keys match, the FSEC[SEC] field is changed to the unsecure state and security
is 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 immediately aborted
and the FSTAT[ACCERR] bit is (again) set to 1 until a reset of the flash memory module
module occurs. If the entire 8-byte key is all zeros or all ones, the Verify Backdoor
Access Key command fails with an access error. The CCIF flag is set after the Verify
Backdoor Access Key operation completes.
1. FCCOB4[7:6] = 00
2. EEPROM Data Set Size must be set to 0 bytes when the FlexNVM Partition Code is set for no EEPROM.
1. FCCOB5[7:4] = 0000
After clearing CCIF to launch the Program Partition command, the flash memory module
first verifies that the EEPROM Data Size Code and FlexNVM Partition Code in the data
flash IFR are erased. If erased, the Program Partition command erases the contents of the
FlexNVM memory. If the FlexNVM is to be partitioned for EEPROM backup, the
allocated EEPROM backup sectors are formatted for EEPROM use. Finally, the partition
codes are programmed into the data flash IFR using the values provided. The Program
Partition command also verifies that the partition codes read back correctly after
programming. If the FlexNVM is partitioned for EEPROM, the allocated EEPROM
backup sectors are formatted for EEPROM use. The CCIF flag is set after the Program
Partition operation completes.
Prior to launching the Program Partition command, the data flash IFR must be in an
erased state, which can be accomplished by executing the Erase All Blocks command or
by an external request (see Erase All Blocks Command). The EEPROM Data Size Code
and FlexNVM Partition Code are read using the Read Resource command (see Read
Resource Command).
After clearing CCIF to launch the Set FlexRAM Function command, the flash memory
module sets the function of the FlexRAM based on the FlexRAM Function Control Code.
When making the FlexRAM available as traditional RAM, the flash memory module
clears the FCNFG[EEERDY] and FCNFG[RAMRDY] flags, overwrites the contents of
the entire FlexRAM with a background pattern of all ones, and sets the
FCNFG[RAMRDY] flag. The state of the FEPROT register does not prevent the
FlexRAM from being overwritten. When the FlexRAM is set to function as a RAM,
normal read and write accesses to the FlexRAM are available. When large sections of
flash memory need to be programmed, e.g. during factory programming, the FlexRAM
can be used as the Section Program Buffer for the Program Section command (see
Program Section Command).
When making the FlexRAM available for EEPROM, the flash memory module clears the
FCNFG[EEERDY] and FCNFG[RAMRDY] flags, overwrites the contents of the
FlexRAM allocated for EEPROM with a background pattern of all ones, and copies the
existing EEPROM data from the EEPROM backup record space to the FlexRAM. After
completion of the EEPROM copy-down, the FCNFG[EEERDY] flag is set. When the
FlexRAM is set to function as EEPROM, normal read and write access to the FlexRAM
is available, but writes to the FlexRAM also invoke EEPROM activity. The CCIF flag is
set after the Set FlexRAM Function operation completes.
Table 28-72. Set FlexRAM Function Command Error Handling
Error Condition Error Bit
Command not available in current mode/security FSTAT[ACCERR]
FlexRAM Function Control Code is not defined FSTAT[ACCERR]
FlexRAM Function Control Code is set to make the FlexRAM available for EEPROM, but
FSTAT[ACCERR]
FlexNVM is not partitioned for EEPROM
28.4.12 Security
The flash memory module provides security information to the MCU based on contents
of the FSEC security register. The MCU then limits access to flash memory resources as
defined in the device's Chip Configuration details. During reset, the flash memory
module initializes the FSEC register using data read from the security byte of the Flash
Configuration Field (see Flash Configuration Field Description).
The following fields are available in the FSEC register. The settings are described in the
Flash Security Register (FTFL_FSEC) details.
Backdoor Access Key command as valid comparison values. While the Verify Backdoor
Access Key command is active, program flash memory is not available for read access
and returns invalid data.
The user code stored in the program 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 bits are in the enabled state, the chip can be unsecured by the following
backdoor key access sequence:
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 chip is unsecured and
the FSEC[SEC] bits are forced to the unsecure state
An illegal key provided to the Verify Backdoor Access Key command prohibits further
use of the Verify Backdoor Access Key command. A reset of the chip is the only method
to re-enable the Verify Backdoor Access Key command when a comparison fails.
After the backdoor keys have been correctly matched, the chip is unsecured by changing
the FSEC[SEC] bits. A successful execution of the Verify Backdoor Access Key
command changes the security in the FSEC register only. It does not alter the security
byte or the keys stored in the Flash Configuration Field (Flash Configuration Field
Description). After the next reset of the chip, the security state of the flash memory
module reverts back to the flash security byte in the Flash Configuration Field. The
Verify Backdoor Access Key command sequence has no effect on the program and erase
protections defined in the program flash protection registers.
If the backdoor keys successfully match, the unsecured chip has full control of the
contents of the Flash Configuration Field. The chip may erase the sector containing the
Flash Configuration Field and reprogram the flash security byte to the unsecure state and
change the backdoor keys to any desired value.
CCIF is cleared throughout the reset sequence. The flash memory module holds off CPU
access during the reset sequence. Flash reads are possible when the hold is removed.
Completion of the reset sequence is marked by setting CCIF which enables flash user
commands.
If a reset occurs while any flash command is in progress, that command is immediately
aborted. The state of the word being programmed or the sector/block being erased is not
guaranteed. Commands and operations do not automatically resume after exiting reset.
29.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
This chapter describes external bus data transfer operations and error conditions. It
describes transfers initiated by the core processor (or any other bus master) and includes
detailed timing diagrams showing the interaction of signals in supported bus operations.
29.1.1 Definition
The FlexBus multifunction external bus interface controller is a hardware module that:
• Provides memory expansion and provides connection to external peripherals with a
parallel bus
• Can be directly connected to the following asynchronous or synchronous slave-only
devices with little or no additional circuitry:
• External ROMs
• Flash memories
• Programmable logic devices
• Other simple target (slave) devices
29.1.2 Features
FlexBus offers the following features:
• Six independent, user-programmable chip-select signals (FB_CS5 –FB_CS0)
• 8-bit, 16-bit, and 32-bit port sizes with configuration for multiplexed or
nonmultiplexed address and data buses
• 8-bit, 16-bit, 32-bit, and 16-byte transfers
• Programmable burst and burst-inhibited transfers selectable for each chip-select and
transfer direction
• Programmable address-setup time with respect to the assertion of a chip-select
• Programmable address-hold time with respect to the deassertion of a chip-select and
transfer direction
• Extended address latch enable option to assist with glueless connections to
synchronous and asynchronous memory devices
For misaligned transfers, FB_TSIZ1–FB_TSIZ0 indicate the size of each transfer. For
example, if a 32-bit access through a 32-bit port device occurs at a misaligned offset of
1h, 8 bits are transferred first (FB_TSIZ1–FB_TSIZ0 = 01b), 16 bits are transferred
next at offset 2h (FB_TSIZ1–FB_TSIZ0 = 10b), and the final 8 bits are transferred at
offset 4h (FB_TSIZ1–FB_TSIZ0 = 01b).
For aligned transfers larger than the port size, FB_TSIZ1–FB_TSIZ0 behave as follows:
• If bursting is used, FB_TSIZ1–FB_TSIZ0 are driven to the transfer size.
• If bursting is inhibited, FB_TSIZ1–FB_TSIZ0 first show the entire transfer size
and then show the port size.
FB memory map
Absolute
Width Section/
address Register name Access Reset value
(in bits) page
(hex)
4000_C000 Chip Select Address Register (FB_CSAR0) 32 R/W 0000_0000h 29.3.1/648
4000_C004 Chip Select Mask Register (FB_CSMR0) 32 R/W 0000_0000h 29.3.2/649
4000_C008 Chip Select Control Register (FB_CSCR0) 32 R/W 0000_0000h 29.3.3/650
4000_C00C Chip Select Address Register (FB_CSAR1) 32 R/W 0000_0000h 29.3.1/648
4000_C010 Chip Select Mask Register (FB_CSMR1) 32 R/W 0000_0000h 29.3.2/649
4000_C014 Chip Select Control Register (FB_CSCR1) 32 R/W 0000_0000h 29.3.3/650
4000_C018 Chip Select Address Register (FB_CSAR2) 32 R/W 0000_0000h 29.3.1/648
4000_C01C Chip Select Mask Register (FB_CSMR2) 32 R/W 0000_0000h 29.3.2/649
4000_C020 Chip Select Control Register (FB_CSCR2) 32 R/W 0000_0000h 29.3.3/650
4000_C024 Chip Select Address Register (FB_CSAR3) 32 R/W 0000_0000h 29.3.1/648
4000_C028 Chip Select Mask Register (FB_CSMR3) 32 R/W 0000_0000h 29.3.2/649
4000_C02C Chip Select Control Register (FB_CSCR3) 32 R/W 0000_0000h 29.3.3/650
4000_C030 Chip Select Address Register (FB_CSAR4) 32 R/W 0000_0000h 29.3.1/648
4000_C034 Chip Select Mask Register (FB_CSMR4) 32 R/W 0000_0000h 29.3.2/649
4000_C038 Chip Select Control Register (FB_CSCR4) 32 R/W 0000_0000h 29.3.3/650
4000_C03C Chip Select Address Register (FB_CSAR5) 32 R/W 0000_0000h 29.3.1/648
4000_C040 Chip Select Mask Register (FB_CSMR5) 32 R/W 0000_0000h 29.3.2/649
4000_C044 Chip Select Control Register (FB_CSCR5) 32 R/W 0000_0000h 29.3.3/650
Chip Select port Multiplexing Control Register
4000_C060 32 R/W 0000_0000h 29.3.4/653
(FB_CSPMCR)
Specifies the address mask and allowable access types for the associated chip-select.
Address: 4000_C000h base + 4h offset + (12d × i), where i=0d to 5d
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R
W
BAM
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
WP V
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 Chip-select is invalid.
1 Chip-select is valid.
R 0
SWSEN
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
BSTW
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
00 Assert FB_CSn on the first rising clock edge after the address is asserted (default for all but
FB_CS0 ).
01 Assert FB_CSn on the second rising clock edge after the address is asserted.
10 Assert FB_CSn on the third rising clock edge after the address is asserted.
11 Assert FB_CSn on the fourth rising clock edge after the address is asserted (default for FB_CS0 ).
19–18 Read Address Hold or Deselect
RDAH
Controls the address and attribute hold time after the termination during a read cycle that hits in the
associated chip-select's address space.
NOTE: • The hold time applies only at the end of a transfer. Therefore, during a burst transfer or a
transfer to a port size smaller than the transfer size, the hold time is only added after the
last bus cycle.
• The number of cycles the address and attributes are held after FB_CSn deassertion
depends on the value of the AA bit.
NOTE: The hold time applies only at the end of a transfer. Therefore, during a burst transfer or a transfer
to a port size smaller than the transfer size, the hold time is only added after the last bus cycle.
NOTE: If AA is 1b for a corresponding FB_CSn and the external system asserts an external FB_TA
before the wait-state countdown asserts the internal FB_TA, the cycle is terminated. Burst cycles
increment the address bus between each internal termination.
0 Disabled. No internal transfer acknowledge is asserted and the cycle is terminated externally.
1 Enabled. Internal transfer acknowledge is asserted as specified by WS.
7–6 Port Size
PS
Specifies the data port width of the associated chip-select, and determines where data is driven during
write cycles and where data is sampled during read cycles.
0 Disabled. Data exceeding the specified port size is broken into individual, port-sized, non-burst reads.
For example, a 32-bit read from an 8-bit port is broken into four 8-bit reads.
1 Enabled. Enables data burst reads larger than the specified port size, including 32-bit reads from 8-
and 16-bit ports, 16-bit reads from 8-bit ports, and line reads from 8, 16-, and 32-bit ports.
0 Disabled. Data exceeding the specified port size is broken into individual, port-sized, non-burst writes.
For example, a 32-bit write to an 8-bit port takes four byte writes.
1 Enabled. Enables burst write of data larger than the specified port size, including 32-bit writes to 8 and
16-bit ports, 16-bit writes to 8-bit ports, and line writes to 8-, 16-, and 32-bit ports.
2–0 This field is reserved.
Reserved This read-only field is reserved and always has the value 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
GROUP1 GROUP2 GROUP3 GROUP4 GROUP5
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
0000 FB_ALE
0001 FB_CS1
0010 FB_TS
Any other value Reserved
27–24 FlexBus Signal Group 2 Multiplex control
GROUP2
Controls the multiplexing of the FB_CS4 , FB_TSIZ0, and FB_BE_31_24 signals.
0000 FB_CS4
0001 FB_TSIZ0
0010 FB_BE_31_24
Any other value Reserved
0000 FB_CS5
0001 FB_TSIZ1
0010 FB_BE_23_16
Any other value Reserved
19–16 FlexBus Signal Group 4 Multiplex control
GROUP4
Controls the multiplexing of the FB_TBST , FB_CS2 , and FB_BE_15_8 signals.
0000 FB_TBST
0001 FB_CS2
0010 FB_BE_15_8
Any other value Reserved
15–12 FlexBus Signal Group 5 Multiplex control
GROUP5
Controls the multiplexing of the FB_TA , FB_CS3 , and FB_BE_7_0 signals.
NOTE: When GROUP5 is not 0000b, you must write 1b to the CSCR[AA] bit. Otherwise, the bus hangs
during a transfer.
0000 FB_TA
0001 FB_CS3 . You must also write 1b to CSCR[AA].
0010 FB_BE_7_0 . You must also write 1b to CSCR[AA].
Any other value Reserved
11–0 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
No bit ordering is required when connecting address and data lines to the FB_AD bus.
For example, a full 16-bit address/16-bit data device connects its addr15–addr0 to
FB_AD16–FB_AD1 and data15–data0 to FB_AD31–FB_AD16. See Data-byte
alignment and physical connections for a graphical connection.
Byte 3
The following figure shows the byte lanes that external memory or peripheral connects to
and the sequential transfers of a 32-bit transfer for the supported port sizes when byte
lane shift is enabled.
External Data Bus FB_AD[31:24] FB_AD[23:16] FB_AD15:8] FB_AD[7:0]
Byte Select FB_BE31_24 FB_BE23_16 FB_BE15_8 FB_BE7_0
Next Cycle S0
Wait States
S3 S1
S2
If the external memory or perihperal asserts FB_TA, then the process moves to S2. If FB_TA is not
asserted internally or externally, then S1 repeats.
Read The external memory or peripheral drives the data before the next rising edge of FB_CLK (the rising
edge that begins S2) with FB_TA asserted.
S2 All For internal termination, FlexBus negates FB_CSn and the transfer is complete. For external
termination, the external memory or peripheral negates FB_TA, and FlexBus negates FB_CSn after
the rising edge of FB_CLK at the end of S2.
Read FlexBus latches the data on the rising clock edge entering S2. The external memory or peripheral
can stop driving the data after this edge or continue to drive the data until the end of S3 or through
any additional address hold cycles.
S3 All FlexBus invalidates the address, data, and FB_R/W on the rising edge of FB_CLK at the beginning
of S3, terminating the transfer.
Note
Throughout this section:
• FB_D[X] indicates a 32-, 16-, or 8-bit wide data bus
• FB_A[Y] indicates an address bus that can be 32, 24, or 16
bits wide.
The address and data busses are muxed between the FlexBus
and another module. At the end of the read bus cycles the
address signals are indeterminate.
FB_CLK
FB_A[Y] Address
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ
FB_CLK
FB_A[Y] Address
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ
FB_CLK
FB_A[Y] Address
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ = 01
The following figure shows the similar configuration for a write transfer. The data is
driven from the second clock on FB_AD[31:24].
FB_CLK
FB_A[Y] Address
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ=01
The following figure illustrates the basic word read transfer to a 16-bit device with no
wait states.
• The address is driven on the full FB_AD[31:8] bus in the first clock.
• The device tristates FB_AD[31:16] on the second clock and continues to drive
address on FB_AD[15:0] throughout the bus cycle.
• The external device returns the read data on FB_AD[31:16] and may tristate the data
line or continue driving the data one clock after FB_TA is sampled asserted.
FB_CLK
FB_A[Y] Address
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ = 10
The following figure shows the similar configuration for a write transfer. The data is
driven from the second clock on FB_AD[31:16].
FB_CLK
FB_A[Y] Address
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ=10
FB_CLK
FB_A[Y] Address
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ = 00
FB_CLK
FB_A[Y] Address
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ=00
FB_CLK
FB_A[Y] Address
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ
FB_CLK
FB_A[Y] Address
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ
If wait states are used, the S1 state repeats continuously until the chip-select auto-
acknowledge unit asserts internal transfer acknowledge or the external FB_TA is
recognized as asserted. The following figures show a read and write cycle with one wait
state respectively.
FB_CLK
FB_A[Y] Address
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ
FB_CLK
FB_A[Y] Address
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ
FB_CLK
FB_A[Y] Address
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ
Figure 29-39. Read-Bus Cycle with Two-Clock Address Setup (No Wait States)
FB_CLK
FB_A[Y] Address
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ
Figure 29-40. Write-Bus Cycle with Two Clock Address Setup (No Wait States)
In addition to address setup, a programmable address hold option for each chip select
exists. Address and attributes can be held one to four clocks after chip-select, byte-
selects, and output-enable negate. The following figures show read and write bus cycles
with two clocks of address hold respectively.
FB_CLK
FB_A[Y] Address
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ
Figure 29-41. Read Cycle with Two-Clock Address Hold (No Wait States)
FB_CLK
FB_A[Y] Address
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ
Figure 29-42. Write Cycle with Two-Clock Address Hold (No Wait States)
The following figure shows a bus cycle using address setup, wait states, and address hold.
FB_CLK
FB_A[Y] Address
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ
Figure 29-43. Write Cycle with Two-Clock Address Setup and Two-Clock Hold (One Wait
State)
The FlexBus can support X-1-1-1 burst cycles to maximize system performance, where X
is the primary number of wait states (max 63). Delaying termination of the cycle can add
wait states. If internal termination is used, different wait state counters can be used for the
first access and the following beats.
29.4.12.3 32-bit-Read burst from 8-Bit port 2-1-1-1 (no wait states)
The following figure shows a 32-bit read to an 8-bit external chip programmed for burst
enable. The transfer results in a 4-beat burst and the data is driven on FB_AD[31:24].
The transfer size is driven at 32-bit (00b) throughout the bus cycle.
Note
In non-multiplexed address/data mode, the address on FB_A
increments only during internally-terminated burst cycles. The
first address is driven throughout the entire burst for externally-
terminated cycles.
In multiplexed address/data mode, the address is driven on
FB_AD only during the first cycle for all terminated cycles.
FB_CLK
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ = 11
FB_CLK
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ
FB_CLK
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TBST
29.4.12.6 32-bit-read burst from 8-bit port 3-2-2-2 (one wait state)
The following figure illustrates another read burst transfer, but in this case a wait state is
added between individual beats.
Note
CSCRn[WS] determines the number of wait states in the first
beat. However, for subsequent beats, the CSCRn[WS] (or
CSCRn[SWS] if CSCRn[SWSEN] = 1b) determines the
number of wait states.
FB_CLK
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ = 00
FB_CLK
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ = 00
29.4.12.8 32-bit-read burst from 8-bit port 3-1-1-1 (address setup and
hold)
If address setup and hold are used, only the first and last beat of the burst cycle are
affected. The following figure shows a read cycle with one clock of address setup and
address hold.
Note
In non-multiplexed address/data mode, the address on FB_A
increments only during internally-terminated burst cycles
(CSCRn[AA] = 1b). The attached device must be able to
account for this, or a wait state must be added. The first address
is driven throughout the entire burst for externally-terminated
cycles.
In multiplexed address/data mode, the address is driven on
FB_AD only during the first cycle for internally- and
externally-terminated cycles.
FB_CLK
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ=11
FB_CLK
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ=11
FB_CLK
FB_A[Y] Address
FB_RW
FB_TS
FB_ALE
AA=1
FB_CSn AA=0
FB_OEn
FB_BE/BWEn
AA=1
FB_TA AA=0
FB_TSIZ[1:0] TSIZ
To initialize a chip-select:
1. Write to the associated CSAR.
2. Write to the associated CSCR.
3. Write to the associated CSMR, including writing 1b to the Valid field (CSMRn[V]).
30.1 Overview
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The EzPort module is a serial flash programming interface that allows In-System
Programming (ISP) of flash memory contents on a 32 bit general-purpose
microcontroller. Memory contents can be read, erased, and programmed from an external
source in a format that is compatible with many stand-alone flash memory chips, without
necessitating the removal of the microcontroller from the system.
30.1.1 Introduction
The following figure is a high level block diagram of the EzPort.
EzPort Enabled
EZP_CS
EZP_CK
Flash EzPort
Controller
EZP_D
EZP_Q
Reset Controller
Microcontroller
Core
30.1.2 Features
EzPort includes the following features:
• Serial interface that is compatible with a subset of the SPI format.
• Ability to read, erase, and program flash memory.
• Ability to reset the microcontroller, allowing it to boot from the flash memory after
the memory has been configured.
The EzPort provides a simple interface to connect an external device to the flash memory
on board a 32 bit microcontroller. The interface itself is compatible with the SPI
interface, with the EzPort operating as a slave, running in either of the two following
modes. The data is transmitted with the most significant bit first.
• CPOL = 0, CPHA = 0
• CPOL = 1, CPHA = 1
Commands are issued by the external device to erase, program, or read the contents of the
flash memory. The serial data out from the EzPort is tri-stated unless data is being driven.
This allows the signal to be shared among several different EzPort (or compatible)
devices in parallel, as long as they have different chip-selects.
Data continues being returned for as long as the EzPort chip select (EZP_CS) is asserted,
with the address automatically incrementing. In this way, the entire contents of FlexRAM
can be returned by one command.
The initial address must be 32-bit aligned (the two LSBs must be zero). Attempts to read
from an address which does not fall within the valid address range for the FlexRAM
returns unknown data. See Flash memory map for EzPort access for more information.
For this command to return the correct data, the EzPort clock (EZP_CK) must run at the
internal system clock divided by eight or slower. This command is not accepted if the
WEF, WIP, or FS fields in the EzPort status register are set.
31.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
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.
31.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
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
Identify 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.
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.
32.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The 16-bit analog-to-digital converter (ADC) is a successive approximation ADC
designed for operation within an integrated microcontroller system-on-chip.
NOTE
For the chip specific modes of operation, see the power
management information of the device.
32.1.1 Features
Features of the ADC module include:
• Linear successive approximation algorithm with up to 16-bit resolution
• Up to four pairs of differential and 24 single-ended external analog inputs
• Output modes:
• differential 16-bit, 13-bit, 11-bit, and 9-bit modes
• single-ended 16-bit, 12-bit, 10-bit, and 8-bit modes
• Output format in 2's complement 16-bit sign extended for differential modes
• Output in right-justified unsigned format for single-ended
• Single or continuous conversion, that is, automatic return to idle after single
conversion
ADHWTSA SC1A
Conversion
ADHWTSn trigger SC1n
control ADTRG
ADHWT
C o m p a re tru e 1 Control Registers (SC2, CFG1, CFG2)
ADACKEN
ADLSMP/ADLSTS
ADLPC/ADHSC
COCO
ADCH
AIEN
c o m p le te
MODE
trig g e r
A D IV
ADCO
Async
DIFF
A D IC L K
Clock Gen
Interrupt ADACK
MCU STOP
ADCK Clock
Control sequencer Bus clock
VREF_OUT divide
2
DADP0
initialize
ALTCLK
convert
transfer
sample
abort
PGA DADP2
DADP3
AD4 A D V IN P PG, MG
PG, MG
A D V IN M CLPx
AD23 SAR converter CLPx
TempP CLM x
CLMx
VREF_OUT
DADM0 OFS
Offset subtractor ADCOFS Calibration
PGA DADM2
DADM3 CAL CALF
AVGE, AVGS
Averager SC3
TempM
V REFSH
MODE
Formatting CFG1,2
V REFH D
RA
VALTH
tra n s fe r
V REFSL
Rn
V REFL ACFE
VALTL Compare ACFGT, ACREN SC2
logic Compare true 1
C V1 CV2
CV1:CV2
In some packages, VREFH is connected in the package to VDDA and VREFL to VSSA. If
externally available, the positive reference(s) may be connected to the same potential as
VDDA or may be driven by an external source to a level between the minimum Ref
Voltage High and the VDDA potential. VREFH must never exceed VDDA. Connect the
ground references to the same voltage potential as VSSA.
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
Reset 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1
00000 When DIFF=0, DADP0 is selected as input; when DIFF=1, DAD0 is selected as input.
00001 When DIFF=0, DADP1 is selected as input; when DIFF=1, DAD1 is selected as input.
00010 When DIFF=0, DADP2 is selected as input; when DIFF=1, DAD2 is selected as input.
00011 When DIFF=0, DADP3 is selected as input; when DIFF=1, DAD3 is selected as input.
00100 When DIFF=0, AD4 is selected as input ; when DIFF=1, it is reserved .
00101 When DIFF=0, AD5 is selected as input ; when DIFF=1, it is reserved .
00110 When DIFF=0, AD6 is selected as input ; when DIFF=1, it is reserved .
00111 When DIFF=0, AD7 is selected as input ; when DIFF=1, it is reserved .
01000 When DIFF=0, AD8 is selected as input ; when DIFF=1, it is reserved .
01001 When DIFF=0, AD9 is selected as input ; when DIFF=1, it is reserved .
01010 When DIFF=0, AD10 is selected as input ; when DIFF=1, it is reserved .
01011 When DIFF=0, AD11 is selected as input ; when DIFF=1, it is reserved .
Table continues on the next page...
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
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
00 When DIFF=0: It is single-ended 8-bit conversion ; when DIFF=1, it is differential 9-bit conversion
with 2's complement output .
01 When DIFF=0: It is single-ended 12-bit conversion ; when DIFF=1, it is differential 13-bit conversion
with 2's complement output .
10 When DIFF=0: It is single-ended 10-bit conversion ; when DIFF=1, it is differential 11-bit conversion
with 2's complement output .
11 When DIFF=0: It is single-ended 16-bit conversion ; when DIFF=1, it is differential 16-bit conversion
with 2's complement output .
1–0 Input Clock Select
ADICLK
Selects the input clock source to generate the internal clock, ADCK. Note that when the ADACK clock
source is selected, it is not required to be active prior to conversion start. When it is selected and it is not
active prior to a conversion start, when CFG2[ADACKEN]=0, the asynchronous clock is activated at the
start of a conversion and deactivated when conversions are terminated. In this case, there is an
associated clock startup delay each time the clock source is re-activated.
00 Bus clock
01 (Bus clock)/2
10 Alternate clock (ALTCLK)
11 Asynchronous clock (ADACK)
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
ADACKEN
R
MUXSEL
ADHSC
ADLSTS
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 Asynchronous clock output disabled; Asynchronous clock is enabled only if selected by ADICLK and a
conversion is active.
1 Asynchronous clock and clock output is enabled regardless of the state of the ADC.
2 High-Speed Configuration
ADHSC
Configures the ADC for very high-speed operation. The conversion sequence is altered with 2 ADCK
cycles added to the conversion time to allow higher speed conversion clocks.
Table continues on the next page...
00 Default longest sample time; 20 extra ADCK cycles; 24 ADCK cycles total.
01 12 extra ADCK cycles; 16 ADCK cycles total sample time.
10 6 extra ADCK cycles; 10 ADCK cycles total sample time.
11 2 extra ADCK cycles; 6 ADCK cycles total sample time.
NOTE
S: Sign bit or sign bit extension;
D: Data, which is 2's complement data if indicated
Address: Base address + 10h offset + (4d × i), where i=0d to 1d
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 D
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
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
ADACT
R 0 DMAEN
ADTRG
ACREN
ACFGT
ACFE
REFSEL
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 Configures less than threshold, outside range not inclusive and inside range not inclusive; functionality
based on the values placed in CV1 and CV2.
1 Configures greater than or equal to threshold, outside and inside ranges inclusive; functionality based
on the values placed in CV1 and CV2.
3 Compare Function Range Enable
ACREN
Configures the compare function to check if the conversion result of the input being monitored is either
between or outside the range formed by CV1 and CV2 determined by the value of ACFGT. ACFE must be
set for ACFGT to have any effect.
00 Default voltage reference pin pair, that is, external pins V and V REFHREFL
01 Alternate reference pair, that is, V and V . This pair may be additional external pins or internal
sources depending on the MCU configuration. See the chip configuration information for details
specific to this MCU. ALTHALTL
Table continues on the next page...
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
CALF
R 0 0 ADCO
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 One conversion or one set of conversions if the hardware average function is enabled, that is,
AVGE=1, after initiating a conversion.
1 Continuous conversions or sets of conversions if the hardware average function is enabled, that is,
AVGE=1, after initiating a conversion.
2 Hardware Average Enable
AVGE
Enables the hardware average function of the ADC.
00 4 samples averaged.
01 8 samples averaged.
10 16 samples averaged.
11 32 samples averaged.
The ADC Offset Correction Register (OFS) contains the user-selected or calibration-
generated offset error correction value. This register is a 2’s complement, left-justified,
16-bit value . The value in OFS is subtracted from the conversion and the result is
transferred into the result registers, Rn. If the result is greater than the maximum or less
than the minimum result value, it is forced to the appropriate limit for the current mode of
operation.
Address: Base address + 28h 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 0 OFS
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 1 0 0
The Plus-Side Gain Register (PG) contains the gain error correction for the plus-side
input in differential mode or the overall conversion in single-ended mode. PG, a 16-bit
real number in binary format, is the gain adjustment factor, with the radix point fixed
between ADPG15 and ADPG14. This register must be written by the user with the value
described in the calibration procedure. Otherwise, the gain error specifications may not
be met.
R 0 0
PGALPb
PGAEN
PGAG
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 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0000 1
0001 2
0010 4
0011 8
0100 16
0101 32
0110 64
0111 Reserved
1000 Reserved
1001 Reserved
Table continues on the next page...
initiated. When it is idle and the asynchronous clock output enable is disabled, or
CFG2[ADACKEN]= 0, the module is in its lowest power state. The ADC can perform an
analog-to-digital conversion on any of the software selectable channels. All modes
perform conversion by a successive approximation algorithm.
To meet accuracy specifications, the ADC module must be calibrated using the on-chip
calibration function. See Calibration function for details on how to perform calibration.
When the conversion is completed, the result is placed in the Rn data registers. The
respective SC1n[COCO] is then set and an interrupt is generated if the respective
conversion complete interrupt has been enabled, or, when SC1n[AIEN]=1.
The ADC module has the capability of automatically comparing the result of a
conversion with the contents of the CV1 and CV2 registers. The compare function is
enabled by setting SC2[ACFE] and operates in any of the conversion modes and
configurations.
The ADC module has the capability of automatically averaging the result of multiple
conversions. The hardware average function is enabled by setting SC3[AVGE] and
operates in any of the conversion modes and configurations.
NOTE
For the chip specific modes of operation, see the power
management information of this MCU.
Whichever clock is selected, its frequency must fall within the specified frequency range
for ADCK. If the available clocks are too slow, the ADC may 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 CFG1[ADIV] and can be divide-by 1,
2, 4, or 8.
selected using SC2[REFSEL]. The alternate (VALTH and VALTL) voltage reference pair
may select additional external pins or internal sources depending on MCU configuration.
See the chip configuration information on the voltage references specific to this MCU.
The conversion complete flag associated with the ADHWTSn received, that is,
SC1n[COCO], is then set and an interrupt is generated if the respective conversion
complete interrupt has been enabled, that is, SC1[AIEN]=1.
• Following the transfer of the result to the data registers when continuous conversion
is enabled, that is, when ADCO=1.
When a conversion is aborted, the contents of the data registers, Rn, are not altered. The
data registers continue to be the values transferred after the completion of the last
successful conversion. If the conversion was aborted by a reset or Low-Power Stop
modes, RA and Rn return to their reset states.
1. To achieve this time, CFG2[ADACKEN] must be 1 for at least 5 μs prior to the conversion is initiated.
Note
The ADCK frequency must be between fADCK minimum and
fADCK maximum to meet ADC specifications.
The resulting conversion time is generated using the parameters listed in the preceding
table. Therefore, for a bus clock and an ADCK frequency equal to 8 MHz, the resulting
conversion time is 3.75 µs.
The resulting conversion time is generated using the parameters listed in the preceding
table. Therefore, for bus clock equal to 8 MHz and ADCK equal to 1 MHz, the resulting
conversion time is 57.625 µs, that is, AverageNum. This results in a total conversion time
of 1.844 ms.
The resulting conversion time is generated using the parameters listed in in the preceding
table. Therefore, for bus clock and ADCK frequency equal to 20 MHz, the resulting
conversion time is 1.45 µs.
With SC2[ACREN] =1, and if the value of CV1 is less than or equal to the value of CV2,
then setting SC2[ACFGT] will select a trigger-if-inside-compare-range inclusive-of-
endpoints function. Clearing SC2[ACFGT] will select a trigger-if-outside-compare-
range, not-inclusive-of-endpoints function.
If CV1 is greater than CV2, setting SC2[ACFGT] will select a trigger-if-outside-
compare-range, inclusive-of-endpoints function. Clearing SC2[ACFGT] will select a
trigger-if-inside-compare-range, not-inclusive-of-endpoints function.
If the condition selected evaluates true, SC1n[COCO] is set.
Upon completion of a conversion while the compare function is enabled, if the compare
condition is not true, SC1n[COCO] is not set and the conversion result data will not be
transferred to the result register, Rn. If the hardware averaging function is enabled, the
compare function compares the averaged result to the compare values. The same compare
function definitions apply. An ADC interrupt is generated when SC1n[COCO] is set and
the respective ADC interrupt is enabled, that is, SC1n[AIEN]=1.
Note
The compare function can monitor the voltage on a channel
while the MCU is in Wait or Normal Stop modes. The ADC
interrupt wakes the MCU when the compare condition is met.
2. Add the plus-side calibration results CLP0, CLP1, CLP2, CLP3, CLP4, and CLPS to
the variable.
3. Divide the variable by two.
4. Set the MSB of the variable.
5. The previous two steps can be achieved by setting the carry bit, rotating to the right
through the carry bit on the high byte and again on the low byte.
6. Store the value in the plus-side gain calibration register PG.
7. Repeat the procedure for the minus-side gain calibration value.
When calibration is complete, the user may reconfigure and use the ADC as desired. A
second calibration may also be performed, if desired, by clearing and again setting
SC3[CAL].
Overall, the calibration routine may take as many as 14k ADCK cycles and 100 bus
cycles, depending on the results and the clock source chosen. For an 8 MHz clock source,
this length amounts to about 1.7 ms. To reduce this latency, the calibration values, which
are offset, plus-side and minus-side gain, and plus-side and minus-side calibration values,
may be stored in flash memory after an initial calibration and recovered prior to the first
ADC conversion. This method can reduce the calibration latency to 20 register store
operations on all subsequent power, reset, or Low-Power Stop mode recoveries.
where:
• VTEMP is the voltage of the temperature sensor channel at the ambient temperature.
• VTEMP25 is the voltage of the temperature sensor channel at 25 °C.
• m is referred as temperature sensor slope in the device data sheet. It is the hot or cold
voltage versus temperature slope in V/°C.
For temperature calculations, use the VTEMP25 and temperature sensor slope values from
the ADC Electricals table.
In application code, the user reads the temperature sensor channel, calculates VTEMP, and
compares to VTEMP25. If VTEMP is greater than VTEMP25 the cold slope value is applied in
the preceding equation. If VTEMP is less than VTEMP25, the hot slope value is applied in
the preceding equation. ADC Electricals table may only specify one temperature sensor
slope value. In that case, the user could use the same slope for the calculation across the
operational temperature range.
For more information on using the temperature sensor, see the application note titled
Temperature Sensor for the HCS08 Microcontroller Family (document AN3031).
6. Update the PGA register to enable or disable PGA and configure appropriate gain.
This register is also used to select Power Mode and to check whether the module is
chopper-stabilized.
RA = 0xxx
Holds results of conversion.
CV = 0xxx
Holds compare value when compare function enabled.
Reset
Initialize ADC
CFG1 = 0x98
SC2 = 0x00
SC1n = 0x41
Check No
SC1n[COCO]=1?
Yes
Read Rn
to clear
SC1n[COCO]
Continue
Where:
RAS = External analog source resistance
SC = Number of ADCK cycles used during sample window
CADIN = Internal ADC input capacitance
NUMTAU = -ln(LSBERR / 2N)
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 Normal Stop mode, or I/O activity cannot be
halted, the following 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
1 LSB, one-time error.
• Reduce the effect of synchronous noise by operating off the asynchronous clock, that
is, ADACK, and averaging. Noise that is synchronous to ADCK cannot be averaged
out.
LSB
Figure 32-99. Ideal code width for an N-bit converter
There is an inherent quantization error due to the digitization of the result. For 8-bit, 10-
bit, or 12-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-bit, 10-
bit, or 12-bit modes. 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 16-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.
33.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The comparator (CMP) module provides a circuit for comparing two analog input
voltages. The comparator circuit is designed to operate across the full range of the supply
voltage, known as rail-to-rail operation.
The Analog MUX (ANMUX) provides a circuit for selecting an analog input signal from
eight channels. One signal is provided by the 6-bit digital-to-analog converter (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 levels. A 6-bit digital signal
input selects the output voltage level, which varies from Vin to Vin/64. Vin can be selected
from two voltage sources, Vin1 and Vin2. The 6-bit DAC from a comparator is available
as an on-chip internal signal only and is not available externally to a pin.
VRSEL
Vin1 Vin2
VOSEL[5:0]
MUX
DACEN
DAC output
64-level
MUX
DAC
PSEL[2:0]
Reference Input 0
Reference Input 1
CMP
Reference Input 2
Reference Input 3 INP
MUX
INM
MUX
CMPO
MSEL[2:0]
Internal bus
FILT_PER OPE
EN,PMODE,HYSCTRL[1:0] COS INV WE FILTER_CNT SE COUT IER/F CFR/F
INP
+
Polarity Window Filter Interrupt
select control block control
- CMPO IRQ
INM
COUT
To other SOC functions
WINDOW/SAMPLE
1
0
bus clock
Clock 0 COUTA CMPO to
prescaler divided 1
FILT_PER bus CGMUX PAD
clock
SE
COS
• If enabled, the Filter block will incur up to one bus clock additional latency penalty
on COUT due to the fact that COUT, which is crossing clock domain boundaries,
must be resynchronized to the bus clock.
• CR1[WE] and CR1[SE] are mutually exclusive.
Read 0 0 0
FILTER_CNT HYSTCTR
Write
Reset 0 0 0 0 0 0 0 0
000 Filter is disabled. If SE = 1, then COUT is a logic 0. This is not a legal state, and is not
recommended. If SE = 0, COUT = COUTA.
001 One sample must agree. The comparator output is simply sampled.
010 2 consecutive samples must agree.
011 3 consecutive samples must agree.
100 4 consecutive samples must agree.
101 5 consecutive samples must agree.
110 6 consecutive samples must agree.
111 7 consecutive samples must agree.
3 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
2 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
1–0 Comparator hard block hysteresis control
HYSTCTR
Defines the programmable hysteresis level. The hysteresis values associated with each level are device-
specific. See the Data Sheet of the device for the exact values.
00 Level 0
01 Level 1
10 Level 2
11 Level 3
Read 0
SE WE PMODE INV COS OPE EN
Write
Reset 0 0 0 0 0 0 0 0
0 Low-Speed (LS) Comparison mode selected. In this mode, CMP has slower output propagation delay
and lower current consumption.
1 High-Speed (HS) Comparison mode selected. In this mode, CMP has faster output propagation delay
and higher current consumption.
3 Comparator INVERT
INV
Allows selection of the polarity of the analog comparator function. It is also driven to the COUT output, on
both the device pin and as SCR[COUT], when OPE=0.
0 DMA is disabled.
1 DMA is enabled.
5 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
4 Comparator Interrupt Enable Rising
IER
Enables the CFR interrupt from the CMP. When this field is set, an interrupt will be asserted when CFR is
set.
Table continues on the next page...
0 Interrupt is disabled.
1 Interrupt is enabled.
2 Analog Comparator Flag Rising
CFR
Detects a rising-edge on COUT, when set, during normal operation. CFR is cleared by writing 1 to it.
During Stop modes, CFR is level sensitive .
0 DAC is disabled.
1 DAC is enabled.
6 Supply Voltage Reference Source Select
VRSEL
Table continues on the next page...
NOTE: When an inappropriate operation selects the same input for both muxes, the comparator
automatically shuts down to prevent itself from becoming a noise generator.
000 IN0
001 IN1
010 IN2
011 IN3
100 IN4
101 IN5
110 IN6
111 IN7
2–0 Minus Input Mux Control
MSEL
Determines which input is selected for the minus input of the comparator. For INx inputs, see CMP, DAC,
and ANMUX block diagrams.
Table continues on the next page...
000 IN0
001 IN1
010 IN2
011 IN3
100 IN4
101 IN5
110 IN6
111 IN7
The "windowing mode" is enabled by setting CR1[WE]. When set, the comparator output
is sampled only when WINDOW=1. This feature can be used to ignore the comparator
output during time periods in which the input voltages are not valid. This is especially
useful when implementing zero-crossing-detection for certain PWM applications.
The comparator filter and sampling features can be combined as shown in the following
table. Individual modes are discussed below.
Table 33-29. Comparator sample/filter controls
CR0[FILTER_C
Mode # CR1[EN] CR1[WE] CR1[SE] FPR[FILT_PER] Operation
NT]
1 0 X X X X Disabled
See the Disabled mode (# 1).
2A 1 0 0 0x00 X Continuous Mode
2B 1 0 0 X 0x00 See the Continuous mode (#s 2A &
2B).
3A 1 0 1 0x01 X Sampled, Non-Filtered mode
3B 1 0 0 0x01 > 0x00 See the Sampled, Non-Filtered
mode (#s 3A & 3B).
4A 1 0 1 > 0x01 X Sampled, Filtered mode
4B 1 0 0 > 0x01 > 0x00 See the Sampled, Filtered mode (#s
4A & 4B).
5A 1 1 0 0x00 X Windowed mode
5B 1 1 0 X 0x00 Comparator output is sampled on
every rising bus clock edge when
SAMPLE=1 to generate COUTA.
See the Windowed mode (#s 5A &
5B).
6 1 1 0 0x01 0x01–0xFF Windowed/Resampled mode
Comparator output is sampled on
every rising bus clock edge when
SAMPLE=1 to generate COUTA,
which is then resampled on an
interval determined by FILT_PER to
generate COUT.
See the Windowed/Resampled
mode (# 6).
7 1 1 0 > 0x01 0x01–0xFF Windowed/Filtered mode
Comparator output is sampled on
every rising bus clock edge when
SAMPLE=1 to generate COUTA,
which is then resampled and filtered
to generate COUT.
See the Windowed/Filtered mode
(#7).
All other combinations of CR1[EN], CR1[WE], CR1[SE], CR0[FILTER_CNT], and FPR[FILT_PER] are illegal.
For cases where a comparator is used to drive a fault input, for example, for a motor-
control module such as FTM, it must be configured to operate in Continuous mode so
that an external fault can immediately pass through the comparator to the target fault
circuitry.
Note
Filtering and sampling settings must be changed only after
setting CR1[SE]=0 and CR0[FILTER_CNT]=0x00. This resets
the filter to a known state.
FILT_PER OPE
EN,PMODE,HYSTCTR[1:0] COS INV WE FILTER_CNT SE COUT IER/F CFR/F
0
INP
+
Polarity Window Filter Interrupt
select control block control
- CMPO IRQ
INM
COUT
To other SOC functions
WINDOW/SAMPLE
1
0
bus clock Clock 0 COUTA CMPO to
prescaler divided 1
FILT_PER bus CGMUX PAD
clock
SE
COS
NOTE
See the chip configuration section for the source of sample/
window input.
The analog comparator block is powered and active. CMPO may be optionally inverted,
but is not subject to external sampling or filtering. Both window control and filter blocks
are completely bypassed. SCR[COUT] is updated continuously. The path from
comparator input pins to output pin is operating in combinational unclocked mode.
COUT and COUTA are identical.
For control configurations which result in disabling the filter block, see the Filter Block
Bypass Logic diagram.
FILT_PER OPE
EN,PMODE,HYSTCTR[1:0] COS INV WE FILTER_CNT SE COUT IER/F CFR/F
0 0x01 1
INP
+ Polarity Filter
Window Interrupt
select control block control
- CMPO IRQ
INM
COUT
To other SOC functions
WINDOW/SAMPLE
1
0
bus clock Clock 0 COUTA CMPO to
prescaler divided 1
FILT_PER bus CGMUX PAD
clock
SE=1
COS
In Sampled, Non-Filtered mode, the analog comparator block is powered and active. The
path from analog inputs to COUTA is combinational unclocked. Windowing control is
completely bypassed. COUTA is sampled whenever a rising-edge is detected on the filter
block clock input.
The only difference in operation between Sampled, Non-Filtered (# 3A) and Sampled,
Non-Filtered (# 3B) is in how the clock to the filter block is derived. In #3A, the clock to
filter block is externally derived while in #3B, the clock to filter block is internally
derived.
The comparator filter has no other function than sample/hold of the comparator output in
this mode (# 3B).
Internal bus
FILT_PER OPE
EN,PMODE,HYSTCTR[1:0] COS INV WE FILTER_CNT SE COUT IER/F CFR/F
0 0x01 0
INP
+
Polarity Window Filter Interrupt
select control block control
- CMPO IRQ
INM
COUT
To other SOC functions
WINDOW/SAMPLE
1
0
bus clock Clock 0 COUTA CMPO to
prescaler divided bus clock 1
FILT_PER CGMUX PAD
SE=0
COS
Internal bus
FILT_PER OPE
EN, PMODE, HYSTCTR[1:0] COS INV WE FILTER_CNT SE COUT IER/F CFR/F
0 > 0x01 1
INP
+
Polarity Window Filter Interrupt
select control block control
- CMPO IRQ
INM
COUT
To other SOC functions
WINDOW/SAMPLE
1
0
bus clock Clock 0 COUTA CMPO to
prescaler divided 1
FILT_PER bus CGMUX PAD
clock
SE=1
COS
Internal bus
FILT_PER OPE
EN, PMODE,HYSTCTR[1:0] COS INV WE FILTER_CNT SE COUT IER/F CFR/F
>0x01
0 1
INP
+
Polarity Window Filter Interrupt
CMPO select control block control
- IRQ
INM
COUT
To other SOC functions
WINDOW/SAMPLE
1
0
bus clock Clock 0 COUTA CMPO to
prescaler divided 1
FILT_PER bus CGMUX PAD
clock
SE=0
COS
The only difference in operation between Sampled, Non-Filtered (# 3B) and Sampled,
Filtered (# 4B) is that now, CR0[FILTER_CNT]>1, which activates filter operation.
WI NDOW
Plus input
Minus input
CMPO
COUTA
Internal bus
FILT_PER OPE
EN, PMODE,HYSCTR[1:0] COS INV WE FILTER_CNT SE COUT IER/F CFR/F
0x01 0
INP
+
Polarity Window Filter Interrupt
select control block control
- CMPO IRQ
INM
COUT
To other SOC functions
WINDOW/SAMPLE
1
0
bus clock
Clock 0 COUTA CMPO to
prescaler divided 1
FILT_PER bus CGMUX PAD
clock
SE=0
COS
For control configurations which result in disabling the filter block, see Filter Block
Bypass Logic diagram.
When any windowed mode is active, COUTA is clocked by the bus clock whenever
WINDOW = 1. The last latched value is held when WINDOW = 0.
WI NDOW
Plus input
Minus input
CMPO
COUTA
COUT
This mode of operation results in an unfiltered string of comparator samples where the
interval between the samples is determined by FPR[FILT_PER] and the bus clock rate.
Configuration for this mode is virtually identical to that for the Windowed/Filtered Mode
shown in the next section. The only difference is that the value of CR0[FILTER_CNT]
must be 1.
FILT_PER OPE
EN, PMODE,HYSCTR[1:0] COS INV WE FILTER_CNT SE COUT IER/F CFR/F
1 > 0x01 0
INP
+ Window
Polarity Filter Interrupt
control block control
- CMPO select IRQ
INM
COUT
To other SOC functions
WINDOW/SAMPLE
1
0
bus clock
Clock 0 COUTA CMPO to
prescaler divided 1
FILT_PER bus CGMUX PAD
clock
SE=0
COS
During operation, the propagation delay of the selected data paths must always be
considered. It may take many bus clock cycles for COUT and SCR[CFR]/SCR[CFF] to
reflect an input change or a configuration change to one of the components involved in
the data path.
When programmed for filtering modes, COUT will initially be equal to 0, until sufficient
clock cycles have elapsed to fill all stages of the filter. This occurs even if COUTA is at a
logic 1.
Setting both CR1[SE] and FPR[FILT_PER] to 0 disables the filter and eliminates
switching current associated with the filtering process.
Note
Always switch to this setting prior to making any changes in
filter parameters. This resets the filter to a known state.
Switching CR0[FILTER_CNT] on the fly without this
intermediate step can result in unexpected behavior.
If CR1[SE]=1, the filter takes samples of COUTA on each positive transition of the
sample input. The output state of the filter changes when all the consecutive
CR0[FILTER_CNT] samples agree that the output value has changed.
1. TPD represents the intrinsic delay of the analog component plus the polarity select logic. TSAMPLE is the clock period of the
external sample clock. Tper is the period of the bus clock.
Vin1 Vin2
Vin
DACO
MUX
34.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The 12-bit digital-to-analog converter (DAC) is a low-power general-purpose DAC. The
output of this DAC can be placed on an external pin or set as one of the inputs to the
analog comparator, operational amplifiers (OPAMPs), analog-to-digital converter (ADC),
or other peripherals.
34.2 Features
The features of the DAC module include:
• On-chip programmable reference generator output. The voltage output range is from
1⁄4096 Vin to Vin, and the step is 1⁄4096 Vin, where Vin is the input voltage.
• Vin can be selected from two reference sources
• Static operation in Normal Stop mode
• 16-word data buffer supported with configurable watermark and multiple operation
modes
• DMA support
DACREF_2 DACREF_1
MUX DACRFS
DACEN
VDD
LPEN -
4096-level
Vout
MUX
Vo
+
DACDAT[11:0]
12
NOTE
The below memory map describes 2 DACs (DAC0 and DAC1)
map.
The address of a register is the sum of a base address and an address offset. The base
address is defined at the chip level. The address offset is defined at the module level.
Bit 7 6 5 4 3 2 1 0
Read DATA[7:0]
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read 0 DATA[11:8]
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Bit 7 6 5 4 3 2 1 0
Read DACTRGSE 0
DACEN DACRFS LPEN DACBWIEN DACBTIEN DACBBIEN
Write L DACSWTRG
Reset 0 0 0 0 0 0 0 0
0 High-Power mode
1 Low-Power mode
2 DAC Buffer Watermark Interrupt Enable
DACBWIEN
0 The DAC buffer watermark interrupt is disabled.
1 The DAC buffer watermark interrupt is enabled.
1 DAC Buffer Read Pointer Top Flag Interrupt Enable
DACBTIEN
0 The DAC buffer read pointer top flag interrupt is disabled.
1 The DAC buffer read pointer top flag interrupt is enabled.
0 DAC Buffer Read Pointer Bottom Flag Interrupt Enable
DACBBIEN
0 The DAC buffer read pointer bottom flag interrupt is disabled.
1 The DAC buffer read pointer bottom flag interrupt is enabled.
Bit 7 6 5 4 3 2 1 0
Read 0
DMAEN DACBFWM DACBFMD DACBFEN
Write
Reset 0 0 0 0 0 0 0 0
00 1 word
01 2 words
10 3 words
11 4 words
Bit 7 6 5 4 3 2 1 0
Read DACBFRP DACBFUP
Write
Reset 0 0 0 0 1 1 1 1
NOTE: If the software set the read pointer to the upper limit,
the read pointer will not advance in this mode.
34.5.3 Resets
During reset, the DAC is configured in the default mode and is disabled.
NOTE
The assignment of module modes to core modes is chip-
specific. For module-to-core mode assignments, see the chapter
that describes how modules are configured.
35.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The Voltage Reference(VREF) is intended to supply an accurate voltage output that can
be trimmed in 0.5 mV steps. The VREF can be used in applications to provide a reference
voltage to external devices or used internally as a reference to analog peripherals such as
the ADC, DAC, or CMP. The voltage reference has three operating modes that provide
different levels of supply rejection and power consumption..
The following figure is a block diagram of the Voltage Reference.
6 BITS
TRM 1.75 V Regulator
SC[VREFEN]
1.75 V
2 BITS
SC[MODE_LV]
SC[VREFST]
BANDGAP
VDDA DEDICATED
OUTPUT PIN
VREF_OUT
100nF
REGULATION
BUFFER
35.1.1 Overview
The Voltage Reference provides a buffered reference voltage for use as an external
reference. In addition, the buffered reference is available internally for use with on chip
peripherals such as ADCs and DACs. Refer to the chip configuration chapter for a
description of these options. The reference voltage is output on a dedicated output pin
when the VREF is enabled. The Voltage Reference output can be trimmed with a
resolution of 0.5mV by means of the TRM register TRIM[5:0] bitfield.
35.1.2 Features
The Voltage Reference has the following features:
• Programmable trim register with 0.5 mV steps, automatically loaded with factory
trimmed value upon reset
• Programmable buffer mode selection:
• Off
NOTE
When the VREF output buffer is disabled, the status of the
VREF_OUT signal is high-impedence.
This register contains bits that contain the trim data for the Voltage Reference.
Address: 4007_4000h base + 0h offset = 4007_4000h
Bit 7 6 5 4 3 2 1 0
Read
Reserved CHOPEN TRIM
Write
Reset x* 0 x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
This bit is set during factory trimming of the VREF voltage. This bit should be written to 1 to achieve the
performance stated in the data sheet.
NOTE: Min = minimum and max = maximum voltage reference output. For minimum and maximum
voltage reference output values, refer to the Data Sheet for this chip.
000000 Min
.... ....
111111 Max
This register contains the control bits used to enable the internal voltage reference and to
select the buffer mode to be used.
Address: 4007_4000h base + 1h offset = 4007_4001h
Bit 7 6 5 4 3 2 1 0
Read 0 0 VREFST
VREFEN REGEN ICOMPEN MODE_LV
Write
Reset 0 0 0 0 0 0 0 0
NOTE: After the VREF is enabled, turning off the clock to the VREF module via the corresponding clock
gate register will not disable the VREF. VREF must be disabled via this VREFEN bit.
0 Disabled
1 Enabled
4 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
3 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
2 Internal Voltage Reference stable
VREFST
Table continues on the next page...
35.3.2.1 SC[MODE_LV]=00
The internal VREF bandgap is enabled to generate an accurate 1.2 V output that can be
trimmed with the TRM register's TRIM[5:0] bitfield. The bandgap requires some time for
startup and stabilization. SC[VREFST] can be monitored to determine if the stabilization
and startup is complete.
The output buffer is disabled in this mode, and there is no buffered voltage output. The
Voltage Reference is in standby mode. If this mode is first selected and the low power or
high power buffer mode is subsequently enabled, there will be a delay before the buffer
output is settled at the final value. This is the buffer start up delay (Tstup) and the value is
specified in the appropriate device data sheet.
35.3.2.2 SC[MODE_LV] = 01
The internal VREF bandgap is on. The high power buffer is enabled to generate a
buffered 1.2 V voltage to VREF_OUT. It can also be used as a reference to internal
analog peripherals such as an ADC channel or analog comparator input.
If this mode is entered from the standby mode (SC[MODE_LV] = 00, SC[VREFEN] = 1)
there will be a delay before the buffer output is settled at the final value. This is the buffer
start up delay (Tstup) and the value is specified in the appropriate device data sheet. If
this mode is entered when the VREF module is enabled then you must wait the longer of
Tstup or until SC[VREFST] = 1.
In this mode, a 100 nF capacitor is required to connect between the VREF_OUT pin and
VSSA.
35.3.2.3 SC[MODE_LV] = 10
The internal VREF bandgap is on. The low power buffer is enabled to generate a buffered
1.2 V voltage to VREF_OUT. It can also be used as a reference to internal analog
peripherals such as an ADC channel or analog comparator input.
If this mode is entered from the standby mode (SC[MODE_LV] = 00, SC[VREFEN] = 1)
there will be a delay before the buffer output is settled at the final value. This is the buffer
start up delay (Tstup) and the value is specified in the appropriate device data sheet. If
this mode is entered when the VREF module is enabled then you must wait the longer of
Tstup or until SC[VREFST] = 1.
In this mode, a 100 nF capacitor is required to connect between the VREF_OUT pin and
VSSA.
35.3.2.4 SC[MODE_LV] = 11
Reserved
36.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The Programmable Delay Block (PDB) provides controllable delays from either an
internal or an external trigger, or a programmable interval tick, to the hardware trigger
inputs of ADCs and/or generates the interval triggers to DACs, so that the precise timing
between ADC conversions and/or DAC updates can be achieved. The PDB can
optionally provide pulse outputs (Pulse-Out's) that are used as the sample window in the
CMP block.
36.1.1 Features
• Up to 15 trigger input sources and software trigger source
• Up to eight configurable PDB channels for ADC hardware trigger
• One PDB channel is associated with one ADC.
• One trigger output for ADC hardware trigger and up to eight pre-trigger outputs
for ADC trigger select per PDB channel
• Trigger outputs can be enabled or disabled independently.
• One 16-bit delay register per pre-trigger output
• Optional bypass of the delay registers of the pre-trigger outputs
• Operation in One-Shot or Continuous modes
NOTE
The number of PDB input and output triggers are chip-specific.
See the chip configuration information for details.
36.1.2 Implementation
In this section, the following letters refer to the number of output triggers:
• N — Total available number of PDB channels.
• n — PDB channel number, valid from 0 to N-1.
• M — Total available pre-trigger per PDB channel.
• m — Pre-trigger number, valid from 0 to M-1.
• X — Total number of DAC interval triggers.
• x — DAC interval trigger output number, valid from 0 to X-1.
NOTE
The number of module output triggers to core is chip-specific.
For module to core output triggers implementation, see the chip
configuration information.
Ack 0
PDBCHnDLY0
= Pre-trigger 0
Ack m
PDBCHnDLYm
= Pre-trigger m
Sequence Error
Detection
ERR[M - 1:0]
Ch n trigger
PDBMOD Control
= Logic DACINTx
PDBCNT = DAC interval trigger x
DAC Interval
PDB Counter Counter x
CONT TOEx
MULT EXTx
DAC ext trigger input x
PRESCALER
DAC interval trigger x
Trigger-In 0
Trigger-In 1
POyDLY1
= Pulse Pulse-Out y
Trigger-In 14
Generation
SWTRIG
= PDBPOEN[y]
TRIGSEL POyDLY2
Pulse-Out y
= PDB interrupt
PDBIDLY
TOEx
In this diagram, only one PDB channel n, one DAC interval trigger x, and one Pulse-Out
y is shown. The PDB enable control logic and the sequence error interrupt logic is not
shown.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 0
PDBEIE
LDMOD
SWTRIG
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
DMAEN
PDBEN
PDBIE
PDBIF
CONT
LDOK
PRESCALER TRGSEL MULT
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
00 The internal registers are loaded with the values from their buffers immediately after 1 is written to
LDOK.
01 The internal registers are loaded with the values from their buffers when the PDB counter reaches
the MOD register value after 1 is written to LDOK.
10 The internal registers are loaded with the values from their buffers when a trigger input event is
detected after 1 is written to LDOK.
11 The internal registers are loaded with the values from their buffers when either the PDB counter
reaches the MOD register value or a trigger input event is detected, after 1 is written to LDOK.
17 PDB Sequence Error Interrupt Enable
PDBEIE
Enables the PDB sequence error interrupt. When this bit is set, any of the PDB channel sequence error
flags generates a PDB sequence error interrupt.
Table continues on the next page...
0 DMA disabled
1 DMA enabled
14–12 Prescaler Divider Select
PRESCALER
000 Counting uses the peripheral clock divided by multiplication factor selected by MULT.
001 Counting uses the peripheral clock divided by twice of the multiplication factor selected by MULT.
010 Counting uses the peripheral clock divided by four times of the multiplication factor selected by
MULT.
011 Counting uses the peripheral clock divided by eight times of the multiplication factor selected by
MULT.
100 Counting uses the peripheral clock divided by 16 times of the multiplication factor selected by
MULT.
101 Counting uses the peripheral clock divided by 32 times of the multiplication factor selected by
MULT.
110 Counting uses the peripheral clock divided by 64 times of the multiplication factor selected by
MULT.
111 Counting uses the peripheral clock divided by 128 times of the multiplication factor selected by
MULT.
11–8 Trigger Input Source Select
TRGSEL
Selects the trigger input source for the PDB. The trigger input source can be internal or external (EXTRG
pin), or the software trigger. Please refer to Chip Configuration chapter for the actual PDB input trigger
connections.
00 Multiplication factor is 1
01 Multiplication factor is 10
10 Multiplication factor is 20
11 Multiplication factor is 40
1 Continuous Mode Enable
CONT
Enables the PDB operation in Continuous mode.
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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
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
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 IDLY
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 PDB channel's corresponding pre-trigger is in bypassed mode. The pre-trigger asserts one peripheral
clock cycle after a rising edge is detected on selected trigger input source or software trigger is
selected and SWTRIG is written with 1.
1 PDB channel's corresponding pre-trigger asserts when the counter reaches the channel delay register
and one peripheral clock cycle after a rising edge is detected on selected trigger input source or
software trigger is selected and SETRIG is written with 1.
7–0 PDB Channel Pre-Trigger Enable
EN
These bits enable the PDB ADC pre-trigger outputs. Only lower M pre-trigger bits are implemented in this
MCU.
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 EXT TOE
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 DAC external trigger input disabled. DAC interval counter is reset and started counting when a rising
edge is detected on selected trigger input source or software trigger is selected and SWTRIG is
written with 1.
1 DAC external trigger input enabled. DAC interval counter is bypassed and DAC external trigger input
triggers the DAC interval trigger.
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 INT
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 POEN
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
Each channel is associated with one ADC block. PDB channel n pre-trigger outputs 0 to
M and trigger output is connected to ADC hardware trigger select and hardware trigger
inputs. The pre-triggers are used to precondition the ADC block prior to the actual
trigger. The ADC contains M sets of configuration and result registers, allowing it to
operate in a ping-pong fashion, alternating conversions between M different analog
sources. The pre-trigger outputs are used to specify which signal will be sampled next.
When pre-trigger m is asserted, the ADC conversion is triggered with set m of the
configuration and result registers.
The waveforms shown in the following diagram illustrate the pre-trigger and trigger
outputs of PDB channel n. The delays can be independently set via the CHnDLYm
registers. And the pre-triggers can be enabled or disabled in CHnC1[EN[m]].
Trigger input event
Ch n pre-trigger 0
Ch n pre-trigger 1
Ch n trigger
When an ADC conversion, which is triggered by one of the pre-triggers from PDB
channel n, is in progress and ADCnSC1[COCO] is not set, a new trigger from PDB
channel n pre-trigger m cannot be accepted by ADCn. Therefore every time when one
PDB channel n pre-trigger and trigger output starts an ADC conversion, an internal lock
associated with the corresponding pre-trigger is activated. The lock becomes inactive
when the corresponding ADCnSC1[COCO] is set, or the corresponding PDB pre-trigger
is disabled, or the PDB is disabled. The channel n trigger output is suppressed when any
of the locks of the pre-triggers in channel n is active. If a new pre-trigger m asserts when
there is active lock in the PDB channel n, a register flag bit, CHnS[ERR[m]], associated
with the pre-trigger m is set. If SC[PDBEIE] is set, the sequence error interrupt is
generated. Sequence error is typically happened because the delay m is set too short and
the pre-trigger m asserts before the previously triggered ADC conversion is completed.
When the PDB counter reaches the value set in IDLY register, the SC[PDBIF] flag is set.
A PDB interrupt can be generated if SC[PDBIE] is set and SC[DMAEN] is cleared. If
SC[DMAEN] is set, PDB requests a DMA transfer when SC[PDBIF] is set.
The modulus value in MOD register, is used to reset the counter back to zero at the end
of the count. If SC[CONT] bit is set, the counter will then resume a new count.
Otherwise, the counter operation will cease until the next trigger input event occurs.
DAC interval counters are also reset when the PDB counter reaches the MOD register
value; therefore, when the PDB counter rolls over to zero, the DAC interval counters
starts anew.
Together, the DAC interval trigger pulse and the ADC pre-trigger/trigger pulses allow
precise timing of DAC updates and ADC measurements. This is outlined in the typical
use case described in the following diagram.
MOD, IDLY
CHnDLY1
CHnDLY0
DACINTx x3
DACINTx x2
PDB DACINTx
counter 0
Ch n pre-trigger 0
Ch n pre-trigger 1
Ch n trigger
PDB interrupt
Figure 36-53. PDB ADC triggers and DAC interval triggers use case
NOTE
Because the DAC interval counters share the prescaler with
PDB counter, PDB must be enabled if the DAC interval trigger
outputs are used in the applications.
36.4.4 Pulse-Out's
PDB can generate pulse outputs of configurable width. When PDB counter reaches the
value set in POyDLY[DLY1], the Pulse-Out goes high; when the counter reaches
POyDLY[DLY2], it goes low. POyDLY[DLY2] can be set either greater or less than
POyDLY[DLY1].
Because the PDB counter is shared by both ADC pre-trigger/trigger outputs and Pulse-
Out generation, they have the same time base.
The pulse-out connections implemented in this MCU are described in the device's chip
configuration details.
The internal registers of them are buffered and any values written to them are written first
to their buffers. The circumstances that cause their internal registers to be updated with
the values from the buffers are summarized as shown in the table below.
Table 36-54. Circumstances of update to the delay registers
SC[LDMOD] Update to the delay registers
00 The internal registers are loaded with the values from their
buffers immediately after 1 is written to SC[LDOK].
01 The PDB counter reaches the MOD register value after 1 is
written to SC[LDOK].
10 A trigger input event is detected after 1 is written to
SC[LDOK].
11 Either the PDB counter reaches the MOD register value, or a
trigger input event is detected, after 1 is written to SC[LDOK].
After 1 is written to SC[LDOK], the buffers cannot be written until the values in buffers
are loaded into their internal registers. SC[LDOK] is self-cleared when the internal
registers are loaded, so the application code can read it to determine the updates to the
internal registers.
The following diagrams show the cases of the internal registers being updated with
SC[LDMOD] is 00 and x1.
CHnDLY1
CHnDLY0
PDB Counter
SC[LDOK]
Ch n pre-trigger 0
Ch n pre-trigger 1
CHnDLY1
CHnDLY0
PDB Counter
SC[LDOK]
Ch n pre-trigger 0
Ch n pre-trigger 1
36.4.6 Interrupts
PDB can generate two interrupts: PDB interrupt and PDB sequence error interrupt. The
following table summarizes the interrupts.
Table 36-55. PDB interrupt summary
Interrupt Flags Enable bit
PDB Interrupt SC[PDBIF] SC[PDBIE] = 1 and
SC[DMAEN] = 0
PDB Sequence Error Interrupt CHnS[ERRm] SC[PDBEIE] = 1
36.4.7 DMA
If SC[DMAEN] is set, PDB can generate DMA transfer request when SC[PDBIF] is set.
When DMA is enabled, the PDB interrupt will not be issued.
37.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
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.
37.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
• Quadrature decoder with input filters, relative position counting, and interrupt on
position count or capture of position count on external event
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.
FAULTM[1:0]
FTM counter TOIE timer overflow
MOD TOF interrupt
FFVAL[3:0]
FAULTIE TOFDIR
FAULTIN
FAULTnEN*
FAULTF
FFLTRnEN* QUADIR
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
The second set has the FTM specific registers. Any second set registers, or bits within
these registers, that are used by an unavailable function in the FTM configuration remain
in the memory map and in the reset value, so they have no active function.
Note
Do not write to the FTM specific registers (second set registers)
when FTMEN = 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
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
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
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 CHF 0
CHIE MSB MSA ELSB ELSA DMA
W 0
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 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
Each CHnF bit in STATUS is a mirror of CHnF bit in CnSC. All CHnF bits can be
checked using only one read of STATUS. All CHnF bits can be cleared by reading
STATUS followed by writing 0x00 to STATUS.
Hardware sets the individual channel flags when an event occurs on the channel. CHF is
cleared by reading STATUS while CHnF is set and then writing a 0 to the CHF bit.
Writing a 1 to CHF has no effect.
If another event occurs between the read and write operations, the write operation has no
effect; therefore, CHF remains set indicating an event has occurred. In this case, a CHF
interrupt request is not lost due to the clearing sequence for a previous CHF.
NOTE
The STATUS register should be used only in Combine mode.
Address: Base address + 50h 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
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.
Reserved
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
INITTRIGEN
R
CH1TRIG
CH0TRIG
CH5TRIG
CH4TRIG
CH3TRIG
CH2TRIG
TRIGF
Reserved
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
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
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
QUADIR
TOFDIR
R 0
PHAFLTREN
PHBFLTREN
QUADMODE
QUADEN
PHAPOL
PHBPOL
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 Normal polarity. Phase A input signal is not inverted before identifying the rising and falling edges of
this signal.
1 Inverted polarity. Phase A input signal is inverted before identifying the rising and falling edges of this
signal.
4 Phase B Input Polarity
PHBPOL
Selects the polarity for the quadrature decoder phase B input.
0 Normal polarity. Phase B input signal is not inverted before identifying the rising and falling edges of
this signal.
1 Inverted polarity. Phase B input signal is inverted before identifying the rising and falling edges of this
signal.
3 Quadrature Decoder Mode
QUADMODE
Selects the encoding mode used in the Quadrature Decoder mode.
0 TOF bit was set on the bottom of counting. There was an FTM counter decrement and FTM counter
changes from its minimum value (CNTIN register) to its maximum value (MOD register).
1 TOF bit was set on the top of counting. There was an FTM counter increment and FTM counter
changes from its maximum value (MOD register) to its minimum value (CNTIN register).
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
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.
37.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
37.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
• Quadrature Decoder mode
37.4.3.1 Up counting
Up counting is selected when (QUADEN = 0) and (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 37-170. 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
If (FTMEN = 1), (QUADEN = 0), (CPWMS = 0), (CNTIN = 0x0000), and (MOD =
0xFFFF), the FTM counter is a free running counter. In this case, the FTM counter runs
free from 0x0000 through 0xFFFF and the TOF bit is set when the FTM counter changes
from 0xFFFF to 0x0000.
FTM counter
NUMTOF[4:0] 0x02
TOF counter 0x01 0x02 0x00 0x01 0x02 0x00 0x01 0x02
FTM counter
NUMTOF[4:0] 0x00
• DECAPEN = 0
• COMBINE = 0
• CPWMS = 0
• MSnB:MSnA = 0:0
• ELSnB:ELSnA ≠ 0:0
When a selected edge occurs on the channel input, the current value of the FTM counter
is captured into the CnV register, at the same time the CHnF bit is set and the channel
interrupt is generated if enabled by CHnIE = 1. See the following figure.
When a channel is configured for input capture, the FTMxCHn pin is an edge-sensitive
input. ELSnB:ELSnA control bits determine which edge, falling or rising, triggers input-
capture event. Note that the maximum frequency for the channel input signal to be
detected correctly is system clock divided by 4, which is required to meet Nyquist criteria
for signal sampling.
Writes to the CnV register is ignored in Input Capture mode.
While in BDM, the input capture function works as configured. When a selected edge
event occurs, the FTM counter value, which is frozen because of BDM, is captured into
the CnV register and the CHnF bit is set.
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 synchronizer the filter counter filter output
S Q
5-bit up counter Logic to define
C
divided by 4 the filter output
CLK
system clock
When there is a state change in the input signal, the 5-bit counter is reset and starts
counting up. As long as the new state is stable on the input, the counter continues to
increment. If the 5-bit counter overflows, that is, the counter exceeds the value of
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 5-bit counter in the channel input filter is the system clock divided by 4.
5-bit counter
CHnFVAL[3:0] = 0010
(binary value)
Time
filter output
TOF bit
Figure 37-178. Example of the Output Compare mode when the match toggles the
channel output
TOF bit
Figure 37-179. 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 37-180. Example of the Output Compare mode when the match sets the channel
output
Using the Output Compare mode is possible with (ELSnB:ELSnA = 0:0). In this case,
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 EPWM period is determined by (MOD − CNTIN + 0x0001) and the pulse width
(duty cycle) is determined by (CnV − CNTIN).
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 37-181. 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 are 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.
The other channel modes are not compatible with the up-down counter (CPWMS = 1).
Therefore, all FTM channels must be used in CPWM mode when (CPWMS = 1).
FTM counter = CNTIN
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 37-184. 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.
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.
The CHnF bit is set and the channel (n) interrupt is generated (if CHnIE = 1) at the
channel (n) match (FTM counter = C(n)V). The CH(n+1)F bit is set and the channel (n
+1) interrupt is generated, if CH(n+1)IE = 1, at the channel (n+1) match (FTM counter =
C(n+1)V).
If (ELSnB:ELSnA = 1:0), then the channel (n) output is forced low 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 high at the channel (n) match (FTM counter = C(n)V). See the
following figure.
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.
MOD
C(n+1)V
C(n)V
CNTIN
Figure 37-188. 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
C(n)V
CNTIN
Figure 37-189. 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 37-190. Channel (n) output if (C(n)V = CNTIN) and (CNTIN < C(n+1)V < MOD)
C(n)V
CNTIN
Figure 37-191. Channel (n) output if (CNTIN < C(n)V < MOD) and (C(n)V is Almost Equal
to CNTIN) and (C(n+1)V = MOD)
FTM counter
MOD
C(n+1)V
C(n)V = CNTIN
Figure 37-192. 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)
CNTIN
C(n)V
Figure 37-193. Channel (n) output if C(n)V and C(n+1)V are not between CNTIN and MOD
FTM counter
MOD
C(n+1)V = C(n)V
CNTIN
Figure 37-194. 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 =
C(n+1)V = CNTIN
CNTIN
C(n)V
C(n+1)V
CNTIN
Figure 37-197. 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+1)V
CNTIN
C(n)V
Figure 37-198. Channel (n) output if (C(n)V < CNTIN) and (CNTIN < C(n+1)V < MOD)
FTM counter
MOD
C(n)V
CNTIN
C(n+1)V
Figure 37-199. Channel (n) output if (C(n+1)V < CNTIN) and (CNTIN < C(n)V < MOD)
C(n)V
MOD
C(n+1)V
CNTIN
Figure 37-200. Channel (n) output if (C(n)V > MOD) and (CNTIN < C(n+1)V < MOD)
FTM counter
C(n+1)V
MOD
C(n)V
CNTIN
Figure 37-201. Channel (n) output if (C(n+1)V > MOD) and (CNTIN < C(n)V < MOD)
C(n+1)V
MOD = C(n)V
CNTIN
Figure 37-202. Channel (n) output if (C(n+1)V > MOD) and (CNTIN < C(n)V = MOD)
FTM counter
channel (n) match
Figure 37-203. Channel (n+1) output in Complementary mode with (ELSnB:ELSnA = 1:0)
FTM counter
channel (n) match
Figure 37-204. Channel (n+1) output in Complementary mode with (ELSnB:ELSnA = X:1)
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).
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 37-209. 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 37-211. 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 37-222. FTM counter synchronization with (SYNCMODE = 0), (REINIT = 1),
(PWMSYNC = 0), and software trigger was used
system clock
TRIG0 bit
trigger 0 event
Figure 37-223. 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 37-224. FTM counter synchronization with (SYNCMODE = 0), (HWTRIGMODE = 0),
(REINIT = 1), (PWMSYNC = 1), and a hardware trigger was used
37.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), (QUADEN = 0),
(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.
channel (n+1) match
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 37-225. 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.
K20 Sub-Family Reference Manual, Rev. 1.1, Dec 2012
928 Freescale Semiconductor, Inc.
Chapter 37 FlexTimer Module (FTM)
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 37-226. 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.
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 37-246. 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 37-247. 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
1 1 1 0 is forced to one is forced to zero
1 1 1 1 is forced to one is forced to zero
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 bitfield
description in the Status and Control register).
FTM counter
channel (n) match
Figure 37-228. Deadtime insertion with ELSnB:ELSnA = 1:0, POL(n) = 0, and POL(n+1) =
0
FTM counter
channel (n) match
Figure 37-229. 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 37-230. 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 37-231. 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 37-248. 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.
37.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 37-249. 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 37-250. 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 ../dil/
FTM.xml#ftm_sc_clks field in the Status and Control register.
FTM counter
QUADEN
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 37-237. 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 37-239. 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 37-240. 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
synchronization
trigger event
initialization trigger
Figure 37-241. Initialization trigger is generated when there is the FTM counter
synchronization
system clock
CLKS[1:0] bits 00 01
initialization trigger
Figure 37-242. 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), (QUADEN = 0), (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)
37.4.23 DMA
The channel generates a DMA transfer request according to DMA and CHnIE bits. See
the following table.
Table 37-251. Channel DMA transfer request
DMA CHnIE Channel DMA Transfer Request Channel Interrupt
0 0 The channel DMA transfer request is not The channel interrupt is not generated.
generated.
0 1 The channel DMA transfer request is not The channel interrupt is generated if (CHnF = 1).
generated.
1 0 The channel DMA transfer request is not The channel interrupt is not generated.
generated.
1 1 The channel DMA transfer request is generated if The channel interrupt is not generated.
(CHnF = 1).
If DMA = 1, the CHnF bit is cleared either by channel DMA transfer done or reading
CnSC while CHnF is set and then writing a zero to CHnF bit according to CHnIE bit. See
the following table.
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.
4 8 12 16 20 24
3 28
7 11 15 19
FTM counter 23 27
2 6 10 14 18 22
1 26
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 37-245. 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
3 28
7 11 15 19
FTM counter 23 27
2 6 10 14 18 22
1 26
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 37-246. Dual Edge Capture – Continuous mode for positive polarity pulse width
measurement
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 37-247. 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
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 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 37-248. Dual Edge Capture – Continuous mode to measure of the period between
two consecutive rising edges
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.
CH0FVAL[3:0]
synchronizer CNTIN
0
MOD
phase A input D Q D Q filtered phase A signal
PHAPOL PHBPOL
Filter 1
system clock CLK CLK FTM counter
enable
FTM counter up/down
direction
PHBFLTREN
CH1FVAL[3:0]
synchronizer TOFDIR QUADIR
0
phase B input D Q D Q
filtered phase B signal
Filter 1
CLK CLK
Each one of input signals phase A and B has a filter that is equivalent to the filter used in
the channels input; Filter for Input Capture mode. The phase A input filter is enabled by
PHAFLTREN bit and this filter’s value is defined by CH0FVAL[3:0] bits
(CH(n)FVAL[3:0] bits in FILTER0 register). The phase B input filter is enabled by
PHBFLTREN bit and this filter’s value is defined by CH1FVAL[3:0] bits (CH(n
+1)FVAL[3:0] bits in FILTER0 register).
Except for CH0FVAL[3:0] and CH1FVAL[3:0] bits, no channel logic is used in
Quadrature Decoder mode.
Note
Notice that the FTM counter is clocked by the phase A and B
input signals when quadrature decoder mode is selected.
Therefore it is expected that the Quadrature Decoder be used
only with the FTM channels in input capture or output compare
modes.
The PHAPOL bit selects the polarity of the phase A input, and the PHBPOL bit selects
the polarity of the phase B input.
The QUADMODE selects the encoding mode used in the Quadrature Decoder mode. If
QUADMODE = 1, then the count and direction encoding mode is enabled; see the
following figure. In this mode, the phase B input value indicates the counting direction,
and the phase A input defines the counting rate. The FTM counter is updated when there
is a rising edge at phase A input signal.
FTM counter
increment/decrement +1 +1 +1 +1 +1 +1 +1 +1 -1 -1 -1 -1 -1
FTM counter
MOD
CNTIN
0x0000
Time
If QUADMODE = 0, then the Phase A and Phase B Encoding mode is enabled; see the
following figure. In this mode, the relationship between phase A and B signals indicates
the counting direction, and phase A and B signals define the counting rate. The FTM
counter is updated when there is an edge either at the phase A or phase B signals.
If PHAPOL = 0 and PHBPOL = 0, then the FTM counter increment happens when:
• there is a rising edge at phase A signal and phase B signal is at logic zero;
• there is a rising edge at phase B signal and phase A signal is at logic one;
• there is a falling edge at phase B signal and phase A signal is at logic zero;
• there is a falling edge at phase A signal and phase B signal is at logic one;
phase A
phase B
FTM counter
increment/decrement +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 +1 +1 +1 +1 +1
FTM counter
MOD
CNTIN
0x0000
Time
The following figure shows the FTM counter overflow in up counting. In this case, when
the FTM counter changes from MOD to CNTIN, TOF and TOFDIR bits are set. TOF bit
indicates the FTM counter overflow occurred. TOFDIR indicates the counting was up
when the FTM counter overflow occurred.
phase A
phase B
FTM counter +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1
increment/decrement
FTM counter
MOD
CNTIN
0x0000
Time
set TOF set TOF
set TOFDIR set TOFDIR
Figure 37-253. FTM Counter overflow in up counting for Quadrature Decoder mode
The following figure shows the FTM counter overflow in down counting. In this case,
when the FTM counter changes from CNTIN to MOD, TOF bit is set and TOFDIR bit is
cleared. TOF bit indicates the FTM counter overflow occurred. TOFDIR indicates the
counting was down when the FTM counter overflow occurred.
phase A
phase B
FTM counter
-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
increment/decrement
FTM counter
MOD
CNTIN
0x0000
Time
set TOF set TOF
clear TOFDIR clear TOFDIR
Figure 37-254. FTM counter overflow in down counting for Quadrature Decoder mode
phase B
FTM counter
MOD
CNTIN
0x0000
Time
The following figure shows motor jittering produced by the phase B and A pulses
respectively:
phase A
phase B
FTM counter
MOD
CNTIN
0x0000
Time
Figure 37-256. Motor position jittering near maximum and minimum count value
The first highlighted transition causes a jitter on the FTM counter value near the
maximum count value (MOD). The second indicated transition occurs on phase A and
causes the FTM counter transition between the maximum and minimum count values
which are defined by MOD and CNTIN registers.
The appropriate settings of the phase A and phase B input filters are important to avoid
glitches that may cause oscillation on the FTM counter value. The preceding figures
show examples of oscillations that can be caused by poor input filter setup. Thus, it is
important to guarantee a minimum pulse width to avoid these oscillations.
Table 37-253. FTM behavior when the chip Is in BDM mode (continued)
FTM
BDMMODE CH(n)F Bit FTM Channels Output Writes to MOD, CNTIN, and C(n)V Registers
Counter
11 Functional can be set Functional mode Functional mode
mode
Note that if BDMMODE[1:0] = 2’b00 then the channels outputs remain at the value
when the chip enters in BDM mode, because the FTM counter is stopped. However, the
following situations modify the channels outputs in this BDM 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 as defined 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 37-255. 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.
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 internal input signal gtb_in, and the internal 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 internal 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 37-259. 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 37-260. FTM behavior after reset when the channel (n) is in Output Compare
mode
38.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The PIT module is an array of timers that can be used to raise interrupts and trigger DMA
channels.
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.
38.1.2 Features
The main features of this block are:
• Ability of timers to generate DMA 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
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 MDIS FRZ
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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
38.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.
Timer enabled Disable Re-enable
Start value = p1 timer timer
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.
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
38.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 3for 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
39.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The low-power timer (LPTMR) can be configured to operate as a time counter with
optional prescaler, or as a pulse counter with optional glitch filter, across all power
modes, including the low-leakage modes. It can also continue operating through most
system reset events, allowing it to be used as a time of day counter.
39.1.1 Features
The features of the LPTMR module include:
• 16-bit time counter or pulse counter with compare
• Optional interrupt can generate asynchronous wakeup from any low-power mode
• Hardware trigger output
• Counter supports free-running mode or reset on compare
• Configurable clock source for prescaler/glitch filter
• Configurable input source for pulse counter
• Rising-edge or falling-edge
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 TCF
TIE TPS TPP TFC TMS TEN
W w1c
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 Pulse Counter input source is active-high, and the CNR will increment on the rising-edge.
1 Pulse Counter input source is active-low, and the CNR will increment on the falling-edge.
2 Timer Free-Running Counter
TFC
When clear, TFC configures the CNR to reset whenever TCF is set. When set, TFC configures the CNR to
reset on overflow. TFC must be altered only when the LPTMR is disabled.
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 PRESCALE PBYP PCS
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0000 Prescaler divides the prescaler clock by 2; glitch filter does not support this configuration.
0001 Prescaler divides the prescaler clock by 4; glitch filter recognizes change on input pin after 2 rising
clock edges.
0010 Prescaler divides the prescaler clock by 8; glitch filter recognizes change on input pin after 4 rising
clock edges.
0011 Prescaler divides the prescaler clock by 16; glitch filter recognizes change on input pin after 8
rising clock edges.
0100 Prescaler divides the prescaler clock by 32; glitch filter recognizes change on input pin after 16
rising clock edges.
0101 Prescaler divides the prescaler clock by 64; glitch filter recognizes change on input pin after 32
rising clock edges.
0110 Prescaler divides the prescaler clock by 128; glitch filter recognizes change on input pin after 64
rising clock edges.
0111 Prescaler divides the prescaler clock by 256; glitch filter recognizes change on input pin after 128
rising clock edges.
1000 Prescaler divides the prescaler clock by 512; glitch filter recognizes change on input pin after 256
rising clock edges.
1001 Prescaler divides the prescaler clock by 1024; glitch filter recognizes change on input pin after 512
rising clock edges.
1010 Prescaler divides the prescaler clock by 2048; glitch filter recognizes change on input pin after
1024 rising clock edges.
1011 Prescaler divides the prescaler clock by 4096; glitch filter recognizes change on input pin after
2048 rising clock edges.
1100 Prescaler divides the prescaler clock by 8192; glitch filter recognizes change on input pin after
4096 rising clock edges.
1101 Prescaler divides the prescaler clock by 16,384; glitch filter recognizes change on input pin after
8192 rising clock edges.
Table continues on the next page...
NOTE: See the chip configuration details for information on the connections to these inputs.
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 COMPARE
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 COUNTER
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
In Pulse Counter mode with the prescaler/glitch filter bypassed, the selected input source
directly clocks the CNR and no other clock source is required. To minimize power in this
case, configure the prescaler clock source for a clock that is not toggling.
NOTE
The clock source or pulse input source selected for the LPTMR
should not exceed the frequency fLPTMR defined in the device
datasheet.
NOTE
The input is only sampled on the rising clock edge.
The CNR will increment each time the glitch filter output asserts. In Pulse Counter mode,
the maximum rate at which the CNR can increment is once every 22 to 216 prescaler
clock edges. When first enabled, the glitch filter will wait an additional one or two
prescaler clock edges due to synchronization logic.
40.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The carrier modulator transmitter (CMT) module provides the means to generate the
protocol timing and carrier signals for a wide variety of encoding schemes. The CMT
incorporates hardware to off-load the critical and/or lengthy timing requirements
associated with signal generation from the CPU, releasing much of its bandwidth to
handle other tasks such as:
• Code data generation
• Data decompression, or,
• Keyboard scanning
. The CMT does not include dedicated hardware configurations for specific protocols, but
is intended to be sufficiently programmable in its function to handle the timing
requirements of most protocols with minimal CPU intervention.
When the modulator is disabled, certain CMT registers can be used to change the state of
the infrared output (IRO) signal directly. This feature allows for the generation of future
protocol timing signals not readily producible by the current architecture.
40.2 Features
The features of this module include:
• Four modes of operation:
• Time; with independent control of high and low times
• Baseband
• Frequency-shift key (FSK)
• Direct software control of the IRO signal
• Extended space operation in Time, Baseband, and FSK modes
• Selectable input clock divider
• Interrupt on end-of-cycle
• Ability to disable the IRO signal and use as timer interrupt
CMT
divider_enable
Clock divider
Peripheral bus clock
Peripheral bus
The following table summarizes the modes of operation of the CMT module.
Table 40-2. CMT modes of operation
Mode MSC[MCGEN]1 MSC[BASE]2 MSC[FSK]2 MSC[EXSPC] Comment
fcg controlled by primary high and
low registers.
Time 1 0 0 0
fcg transmitted to the IRO signal
when modulator gate is open.
fcg is always high. The IRO signal is
Baseband 1 1 X 0 high when the modulator gate is
open.
fcg control alternates between
primary high/low registers and
FSK 1 0 1 0 secondary high/low registers.
fcg transmitted to the IRO signal
when modulator gate is open.
Setting MSC[EXSPC] causes
subsequent modulator cycles to be
Extended
1 X X 1 spaces (modulator out not asserted)
Space
for the duration of the modulator
period (mark and space times).
OC[IROL] controls the state of the
IRO Latch 0 X X X
IRO signal.
1. To prevent spurious operation, initialize all data and control registers before beginning a transmission when
MSC[MCGEN]=1.
2. This field is not double-buffered and must not be changed during a transmission while MSC[MCGEN]=1.
NOTE
The assignment of module modes to core modes is chip-
specific. For module-to-core mode assignments, see the chapter
that describes how modules are configured.
The address of a register is the sum of a base address and an address offset. The base
address is defined at the chip level. The address offset is defined at the module level.
CMT memory map
Absolute
Width Section/
address Register name Access Reset value
(in bits) page
(hex)
4006_2000 CMT Carrier Generator High Data Register 1 (CMT_CGH1) 8 R/W Undefined 40.6.1/991
4006_2001 CMT Carrier Generator Low Data Register 1 (CMT_CGL1) 8 R/W Undefined 40.6.2/992
4006_2002 CMT Carrier Generator High Data Register 2 (CMT_CGH2) 8 R/W Undefined 40.6.3/992
4006_2003 CMT Carrier Generator Low Data Register 2 (CMT_CGL2) 8 R/W Undefined 40.6.4/993
4006_2004 CMT Output Control Register (CMT_OC) 8 R/W 00h 40.6.5/993
4006_2005 CMT Modulator Status and Control Register (CMT_MSC) 8 R/W 00h 40.6.6/994
4006_2006 CMT Modulator Data Register Mark High (CMT_CMD1) 8 R/W Undefined 40.6.7/996
This data register contains the primary high value for generating the carrier output.
Address: 4006_2000h base + 0h offset = 4006_2000h
Bit 7 6 5 4 3 2 1 0
Read PH
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
This data register contains the primary low value for generating the carrier output.
Address: 4006_2000h base + 1h offset = 4006_2001h
Bit 7 6 5 4 3 2 1 0
Read PL
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
This data register contains the secondary high value for generating the carrier output.
Address: 4006_2000h base + 2h offset = 4006_2002h
Bit 7 6 5 4 3 2 1 0
Read SH
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
This data register contains the secondary low value for generating the carrier output.
Address: 4006_2000h base + 3h offset = 4006_2003h
Bit 7 6 5 4 3 2 1 0
Read SL
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
This register is used to control the IRO signal of the CMT module.
Address: 4006_2000h base + 4h offset = 4006_2004h
Bit 7 6 5 4 3 2 1 0
Read 0
IROL CMTPOL IROPEN
Write
Reset 0 0 0 0 0 0 0 0
This register contains the modulator and carrier generator enable (MCGEN), end of cycle
interrupt enable (EOCIE), FSK mode select (FSK), baseband enable (BASE), extended
space (EXSPC), prescaler (CMTDIV) bits, and the end of cycle (EOCF) status bit.
Address: 4006_2000h base + 5h offset = 4006_2005h
Bit 7 6 5 4 3 2 1 0
Read EOCF
CMTDIV EXSPC BASE FSK EOCIE MCGEN
Write
Reset 0 0 0 0 0 0 0 0
0 End of modulation cycle has not occured since the flag last cleared.
1
End of modulator cycle has occurred.
6–5 CMT Clock Divide Prescaler
CMTDIV
Causes the CMT to be clocked at the IF signal frequency, or the IF frequency divided
by 2 ,4, or 8 . This field must not be changed during a transmission because it is not
double-buffered.
00 IF ÷ 1
01 IF ÷ 2
10 IF ÷ 4
11 IF ÷ 8
4 Extended Space Enable
EXSPC
Enables the extended space operation.
Setting MCGEN will initialize the carrier generator and modulator and will enable all
clocks. When enabled, the carrier generator and modulator will function continuously.
When MCGEN is cleared, the current modulator cycle will be allowed to expire before
all carrier and modulator clocks are disabled to save power and the modulator output
is forced low.
NOTE: To prevent spurious operation, the user should initialize all data and control
registers before enabling the system.
The contents of this register are transferred to the modulator down counter upon the
completion of a modulation period.
Address: 4006_2000h base + 6h offset = 4006_2006h
Bit 7 6 5 4 3 2 1 0
Read MB[15:8]
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
The contents of this register are transferred to the modulator down counter upon the
completion of a modulation period.
Address: 4006_2000h base + 7h offset = 4006_2007h
Bit 7 6 5 4 3 2 1 0
Read MB[7:0]
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
The contents of this register are transferred to the space period register upon the
completion of a modulation period.
Address: 4006_2000h base + 8h offset = 4006_2008h
Bit 7 6 5 4 3 2 1 0
Read SB[15:8]
Write
Reset x* x* x* x* x* x* x* x*
* Notes:
• x = Undefined at reset.
The contents of this register are transferred to the space period register upon the
completion of a modulation period.
Address: 4006_2000h base + 9h offset = 4006_2009h
Bit 7 6 5 4 3 2 1 0
Read SB[7:0]
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 0 PPSDIV
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read 0 DMA
Write
Reset 0 0 0 0 0 0 0 0
For compatibility with previous versions of CMT, when bus clock = 8 MHz, the PPS
must be configured to zero. The PPS counter is selected according to the bus clock to
generate an intermediate frequency approximately equal to 8 MHz.
The possible duty cycle options depend upon the number of counts required to complete
the carrier period. For example, 1.6 MHz signal has a period of 625 ns and will therefore
require 5 x 125 ns counts to generate. These counts may be split between high and low
times, so the duty cycles available will be:
• 20% with one high and four low times
• 40% with two high and three low times
• 60% with three high and two low times, and
• 80% with four high and one low time
.
For low-frequency signals with large periods, high-resolution duty cycles as a percentage
of the total period, are possible.
The carrier signal is generated by counting a register-selected number of input clocks
(125 ns for an 8 MHz bus) for both the carrier high time and the carrier low time. The
period is determined by the total number of clocks counted. The duty cycle is determined
by the ratio of high-time clocks to total clocks counted. The high and low time values are
user-programmable and are held in two registers.
An alternate set of high/low count values is held in another set of registers to allow the
generation of dual-frequency FSK protocols without CPU intervention.
Note
Only nonzero data values are allowed. The carrier generator
will not work if any of the count values are equal to zero.
MSC[MCGEN] must be set and MSC[BASE] must be cleared to enable carrier generator
clocks. When MSC[BASE] is set, the carrier output to the modulator is held high
continuously. The following figure represents the block diagram of the clock generator.
=?
The high/low time counter is an 8-bit up counter. After each increment, the contents of
the counter are compared with the appropriate high or low count value register. When the
compare value is reached, the counter is reset to a value of 0x01, and the compare is
redirected to the other count value register.
Assuming that the high time count compare register is currently active, a valid compare
will cause the carrier output to be driven low. The counter will continue to increment
starting at the reset value of 0x01. When the value stored in the selected low count value
register is reached, the counter will again be reset and the carrier output will be driven
high.
The cycle repeats, automatically generating a periodic signal which is directed to the
modulator. The lower frequency with maximum period, fmax, and highest frequency with
minimum period, fmin, which can be generated, are defined as:
fmax = fCMTCLK ÷ (2 * 1) Hz
fmin = fCMTCLK ÷ (2 * (28 − 1)) Hz
In the general case, the carrier generator output frequency is:
fcg = fCMTCLK ÷ (High count + Low count) Hz
Where: 0 < High count < 256 and
0 < Low count < 256
The duty cycle of the carrier signal is controlled by varying the ratio of high time to low
+ high time. As the input clock period is fixed, the duty cycle resolution will be
proportional to the number of counts required to generate the desired carrier period.
40.7.3 Modulator
The modulator block controls the state of the infrared out signal (IRO). The modulator
output is gated on to the IRO signal when the modulator/carrier generator is enabled. .
When the modulator/carrier generator is disabled, the IRO signal is controlled by the state
of the IRO latch. OC[CMTPOL] enables the IRO signal to be active-high or active-low.
The following table describes the functions of the modulators in different modes:
Table 40-20. Mode functions
Mode Function
Time The modulator can gate the carrier onto the modulator output.
Baseband The modulator can control the logic level of the modulator
output.
FSK The modulator can count carrier periods and instruct the
carrier generator to alternate between two carrier frequencies
whenever a modulation period consisting of mark and space
counts, expires.
The modulator provides a simple method to control protocol timing. The modulator has a
minimum resolution of 1.0 μs with an 8 MHz. It can count bus clocks to provide real-
time control, or carrier clocks for self-clocked protocols.
The modulator includes a 17-bit down counter with underflow detection. The counter is
loaded from the 16-bit modulation mark period buffer registers, CMD1 and CMD2. The
most significant bit is loaded with a logic 0 and serves as a sign bit.
When Then
The counter holds a positive value The modulator gate is open and the carrier signal is driven to
the transmitter block.
The counter underflows The modulator gate is closed and a 16-bit comparator is
enabled which compares the logical complement of the value
of the down counter with the contents of the modulation space
period register which has been loaded from the registers,
CMD3 and CMD4.
When a match is obtained, the cycle repeats by opening the modulator gate, reloading the
counter with the contents of CMD1 and CMD2, and reloading the modulation space
period register with the contents of CMD3 and CMD4.
The modulation space period is activated when the carrier signal is low to prohibit cutting
off the high pulse of a carrier signal. If the carrier signal is high, the modulator extends
the mark period until the carrier signal becomes low. To deassert the space period and
assert the mark period, the carrier signal must have gone low to ensure that a space period
is not erroneously shortened.
If the contents of the modulation space period register are all zeroes, the match will be
immediate and no space period will be generated, for instance, for FSK protocols that
require successive bursts of different frequencies).
MSC[MCGEN] must be set to enable the modulator timer.
The following figure presents the block diagram of the modulator.
16 bits Mode
0 CMTCMD1:CMTCMD2
8 CMTCLK
Clock control
17-bit down counter * Carrier out (fcg)
Counter
16
Modulator
Load Modulator gate
MS bit
out
=?
EOC Flag set
System control Module interrupt request
Primary/Secondary select
16
FSK
EXSPC
BASE
EOCIE
CMTCMD3:CMTCMD4
16 bits
* Denotes hidden register
CMTCLK 8
Carrier out
(fcg)
IRO signal
(Time mode)
IRO signal
(Baseband mode)
Figure 40-17. Example: CMT output in Time and Baseband modes with OC[CMTPOL]=0
In this mode, the modulator output will be at a logic 1 for the duration of the mark period
and at a logic 0 for the duration of a space period. See Figure 40-17 for an example of the
output for both Baseband and Time modes. In the example, the carrier out frequency (fcg)
is generated with a high count of 0x01 and a low count of 0x02 that results in a divide of
3 of CMTCLK with a 33% duty cycle. The modulator down counter was loaded with the
value 0x0003 and the space period register with 0x0002.
Note
The waveforms in Figure 40-17 and Figure 40-18 are for the
purpose of conceptual illustration and are not meant to
represent precise timing relationships between the signals
shown.
IRO signal
Where the subscripts p and s refer to mark and space times for the primary and secondary
modulation cycles.
MSC[EOCF] is set:
• When the modulator is not currently active and MSC[MCGEN] is set to begin the
initial CMT transmission.
• At the end of each modulation cycle when the counter is reloaded from
CMD1:CMD2, while MSC[MCGEN] is set.
When MSC[MCGEN] is cleared and then set before the end of the modulation cycle,
MSC[EOCF] will not be set when MSC[MCGEN] is set, but will become set at the end
of the current modulation cycle.
When MSC[MCGEN] becomes disabled, the CMT module does not set MSC[EOCF] at
the end of the last modulation cycle.
If MSC[EOCIE] is high when MSC[EOCF] is set, the CMT module will generate an
interrupt request or a DMA transfer request.
MSC[EOCF] must be cleared to prevent from being generated by another event like
interrupt or DMA request, after exiting the service routine. See the following table.
Table 40-24. How to clear MSC[EOCF]
DMA[DM
MSC[EOCIE] Description
A]
0 X MSC[EOCF] is cleared by reading MSC followed by an access of CMD2 or CMD4.
1 X MSC[EOCF] is cleared by the CMT DMA transfer done.
41.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
41.1.1 Features
The RTC module features include:
• Independent power supply, POR, and 32 kHz crystal oscillator
• 32-bit seconds counter with roll-over protection and 32-bit alarm
• 16-bit prescaler with compensation that can correct errors between 0.12 ppm and
3906 ppm
• Register write protection
• Lock register requires VBAT POR or software reset to enable write access
• Access control registers require system reset to enable read and/or write access
• 1 Hz square wave output
During chip power-down, RTC is powered from the backup power supply (VBAT) and is
electrically isolated from the rest of the chip but continues to increment the time counter
(if enabled) and retain the state of the RTC registers. The RTC registers are not
accessible.
During chip power-up, RTC remains powered from the backup power supply (VBAT).
All RTC registers are accessible by software and all functions are operational. If enabled,
the 32.768 kHz clock can be supplied to the rest of the chip.
Write accesses to any register by non-supervisor mode software, when the supervisor
access bit in the control register is clear, will terminate with a bus error.
Read accesses by non-supervisor mode software complete as normal.
Writing to a register protected by the write access register or lock register does not
generate a bus error, but the write will not complete.
Reading a register protected by the read access register does not generate a bus error, but
the register will read zero.
RTC memory map
Absolute
Width Section/
address Register name Access Reset value
(in bits) page
(hex)
4003_D000 RTC Time Seconds Register (RTC_TSR) 32 R/W 0000_0000h 41.2.1/1013
4003_D004 RTC Time Prescaler Register (RTC_TPR) 32 R/W 0000_0000h 41.2.2/1014
4003_D008 RTC Time Alarm Register (RTC_TAR) 32 R/W 0000_0000h 41.2.3/1014
4003_D00C RTC Time Compensation Register (RTC_TCR) 32 R/W 0000_0000h 41.2.4/1014
4003_D010 RTC Control Register (RTC_CR) 32 R/W 0000_0000h 41.2.5/1016
4003_D014 RTC Status Register (RTC_SR) 32 R/W 0000_0001h 41.2.6/1018
4003_D018 RTC Lock Register (RTC_LR) 32 R/W 0000_00FFh 41.2.7/1019
4003_D01C RTC Interrupt Enable Register (RTC_IER) 32 R/W 0000_0007h 41.2.8/1020
4003_D800 RTC Write Access Register (RTC_WAR) 32 R/W 0000_00FFh 41.2.9/1021
41.2.10/
4003_D804 RTC Read Access Register (RTC_RAR) 32 R/W 0000_00FFh
1022
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
TSR
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 TPR
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
W
TAR
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 CIC TCV
CIR TCR
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
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 0
SC16P
OSCE
CLKO
W 0
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
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 Time is valid.
1 Time is invalid and time counter is read as zero.
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 1 1
LRL SRL CRL TCL
W
Reset 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
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
Reserved
Reserved TSIE TAIE TOIE TIIE
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
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
TCRW
TARW
TPRW
TSRW
IERW LRW SRW CRW
W
Reset 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
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 IERR LRR SRR CRR TCRR TARR TPRR TSRR
W
Reset 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
41.3.3 Compensation
The compensation logic provides an accurate and wide compensation range and can
correct errors as high as 3906 ppm and as low as 0.12 ppm. The compensation factor
must be calculated externally to the RTC and supplied by software to the compensation
register. The RTC itself does not calculate the amount of compensation that is required,
although the 1 Hz clock is output to an external pin in support of external calibration
logic.
time seconds and prescaler registers to be initialized whenever time is invalidated, while
preventing the time seconds and prescaler registers from being changed on the fly. When
LR[SRL] is set, CR[UM] has no effect on SR[TCE].
41.3.8 Interrupt
The RTC interrupt is asserted whenever a status flag and the corresponding interrupt
enable bit are both set. It is always asserted on VBAT POR, and software reset, and when
the VBAT power supply is powered down. The RTC interrupt is enabled at the chip level
by enabling the chip-specific RTC clock gate control bit. The RTC interrupt can be used
to wakeup the chip from any low-power mode. If the RTC wakeup pin is enabled and the
chip is powered down, the RTC interrupt will cause the wakeup pin to assert.
The optional RTC seconds interrupt is an edge-sensitive interrupt with a dedicated
interrupt vector that is generated once a second and requires no software overhead (there
is no corresponding status flag to clear). It is enabled in the RTC by the time seconds
interrupt enable bit and enabled at the chip level by setting the chip-specific RTC clock
gate control bit. The RTC seconds interrupt does not cause the RTC wakeup pin to assert.
This interrupt is optional and may not be implemented on all devices.
42.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
This section describes the USB. The OTG implementation in this module provides
limited host functionality and device solutions for implementing a USB 2.0 full-speed/
low-speed compliant peripheral. The OTG implementation supports the On-The-Go
(OTG) addendum to the USB 2.0 Specification. Only one protocol can be active at any
time. A negotiation protocol must be used to switch to a USB host functionality from a
USB device. This is known as the Master Negotiation Protocol (MNP).
42.1.1 USB
The USB is a cable bus that supports data exchange between a host computer and a wide
range of simultaneously accessible peripherals. The attached peripherals share USB
bandwidth through a host-scheduled, token-based protocol. The bus allows peripherals to
be attached, configured, used, and detached while the host and other peripherals are in
operation.
USB software provides a uniform view of the system for all application software, hiding
implementation details making application software more portable. It manages the
dynamic attach and detach of peripherals.
There is only one host in any USB system. The USB interface to the host computer
system is referred to as the Host Controller.
There may be multiple USB devices in any system such as joysticks, speakers, printers,
etc. USB devices present a standard USB interface in terms of comprehension, response,
and standard capability.
The host initiates transactions to specific peripherals, whereas the device responds to
control transactions. The device sends and receives data to and from the host using a
standard USB data format. USB 2.0 full-speed /low-speed peripherals operate at 12Mbit/s
or 1.5 Mbit/s.
For additional information, see the USB 2.0 specification.
Host PC
External Hub
External Hub
Print Photos
Keyboard Input
Swap Songs
Hot Sync
memory when the OWN bit is 0. When the OWN bit is set to 1, the BD entry and the
buffer in system memory are owned by the USB-FS. The USB-FS now has full read and
write access and the microprocessor must not modify the BD or its corresponding data
buffer. The BD also contains indirect address pointers to where the actual buffer resides
in system memory. This indirect address mechanism is shown in the following diagram.
System Memory
BDT Page
BDT_PAGE Registers END_POINT TX ODD 000 Current
Endpoint
BDT
•••
Start of Buffer
•••
Buffer in Memory
While the processor uses the data stored in the BDs to determine:
• Who owns the buffer in system memory
• Data0 or Data1 PID
• The received TOKEN PID
• How much data was transmitted or received
• Where the buffer resides in system memory
0 No stall issued.
1 The BDT is not consumed by the SIE (the OWN bit remains set and the rest of the BDT is
unchanged).
In host mode, this field is used to report the last returned PID or a transfer status indication. The
possible values returned are:
• 0x3h DATA0
• 0xBh DATA1
• 0x2h ACK
• 0xEh STALL
• 0xAh NAK
• 0x0h Bus Timeout
• 0xFh Data Error
1–0 Reserved, should read as zeroes.
Reserved
ADDR[31:0] Address
Represents the 32-bit buffer address in system memory. These bits are unchanged by the USB-
FS.
TOK_DNE
Interrupt Generated
TOK_DNE
Interrupt Generated
TOK_DNE
USB Host Function Interrupt Generated
The USB has two sources for the DMA overrun error:
Memory Latency
The memory latency may be too high and cause the receive FIFO to overflow. This is
predominantly a hardware performance issue, usually caused by transient memory access
issues.
Oversized Packets
The packet received may be larger than the negotiated MaxPacket size. Typically, this is
caused by a software bug. For DMA overrun errors due to oversized data packets, the
USB specification is ambiguous. It assumes correct software drivers on both sides.
NAKing the packet can result in retransmission of the already oversized packet data.
Therefore, in response to oversized packets, the USB core continues ACKing the packet
for non-isochronous transfers.
Table 42-5. USB responses to DMA overrun errors
Errors due to Memory Latency Errors due to Oversized Packets
Non-Acknowledgment (NAK) or Bus Timeout (BTO) — See Continues acknowledging (ACKing) the packet for non-
bit 4 in "Error Interrupt Status Register (ERRSTAT)" as isochronous transfers.
appropriate for the class of transaction.
The data written to memory is clipped to the MaxPacket size
—
so as not to corrupt system memory.
The DMAERR bit is set in the ERRSTAT register for host and Asserts ERRSTAT[DMAERR] ,which can trigger an interrupt
device modes of operation. Depending on the values of the and TOKDNE interrupt fires. Note: The TOK_PID field of the
INTENB and ERRENB register, the core may assert an BDT is not 1111 because the DMAERR is not due to latency.
interrupt to notify the processor of the DMA error.
Bit 7 6 5 4 3 2 1 0
Read 0 ID
Write
Reset 0 0 0 0 0 1 0 0
Bit 7 6 5 4 3 2 1 0
Read 1 NID
Write
Reset 1 1 1 1 1 0 1 1
Bit 7 6 5 4 3 2 1 0
Read REV
Write
Reset 0 0 1 1 0 0 1 1
Bit 7 6 5 4 3 2 1 0
Write
Reset 0 0 0 0 0 0 0 1
Bit 7 6 5 4 3 2 1 0
Read LINE_ 0 0
SESSVLDC B_SESS_
IDCHG ONEMSEC STATE_ AVBUSCHG
Write HG CHG
CHG
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Bit 7 6 5 4
Read 0
ID ONEMSECEN LINESTATESTABLE
Write
Reset 0 0 0 0
Bit 3 2 1 0
Read 0
SESS_VLD BSESSEND AVBUSVLD
Write
Reset 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read 0 0 0
DPHIGH DPLOW DMLOW OTGEN
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Bit 7 6 5 4 3 2 1 0
Read STALLEN ATTACHEN RESUMEEN SLEEPEN TOKDNEEN SOFTOKEN ERROREN USBRSTEN
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Bit 7 6 5 4 3 2 1 0
Read 0 CRC5EOFE
BTSERREN DMAERREN BTOERREN DFN8EN CRC16EN PIDERREN
Write N
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4
Read TXSUSPENDTOKENB
JSTATE SE0 RESET
Write USY
Reset 0 0 0 0
Bit 3 2 1 0
Read HOSTMODEEN RESUME ODDRST USBENSOFEN
Write
Reset 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read LSEN ADDR
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read 0
BDTBA
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read FRM[7:0]
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read 0 FRM[10:8]
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read TOKENPID TOKENENDPT
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read CNT
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read BDTBA
Write
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read BDTBA
Write
Reset 0 0 0 0 0 0 0 0
In Host mode ENDPT0 is used to determine the handshake, retry and low speed
characteristics of the host transfer. For Control, Bulk and Interrupt transfers, the
EPHSHK bit should be 1. For Isochronous transfers it should be 0. Common values to
use for ENDPT0 in host mode are 0x4D for Control, Bulk, and Interrupt transfers, and
0x4C for Isochronous transfers.
Address: 4007_2000h base + C0h offset + (4d × i), where i=0d to 15d
Bit 7 6 5 4 3 2 1 0
Read HOSTWOH 0
RETRYDIS EPCTLDIS EPRXEN EPTXEN EPSTALL EPHSHK
Write UB
Reset 0 0 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read 0
SUSP PDE
Write
Reset 1 1 0 0 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Write
Reset 0 1 0 1 0 0 0 0
Bit 7 6 5 4
Read 0 DPPULLUPNONOTG
Write
Reset 0 0 0 0
Bit 3 2 1 0
Read 0
Write
Reset 0 0 0 0
Bit 7 6 5 4
Read 0 0
USBRESMEN
Write USBRESET
Reset 0 0 0 0
Bit 3 2 1 0
Write
Reset 0 0 0 0
Bit 7 6 5 4 3 2 1 0
Read ADJ
Write
Reset 0 0 0 0 0 0 0 0
A_IDLE B_IDLE
A_WAIT_VFALL A_WAIT_VRISE
A_PERIPHERAL A_WAIT_BCON
A_SUSPEND A_HOST
Table 42-96. State descriptions for the dual role A device flow
State Action Response
A_IDLE If ID Interrupt. Go to B_IDLE
The cable has been un-plugged or a Type B cable has been
attached. The device now acts as a Type B device.
If the A application wants to use the bus or if the B device is doing Go to A_WAIT_VRISE
an SRP as indicated by an A_SESS_VLD Interrupt or Attach or Port
Turn on DRV_VBUS
Status Change Interrupt check data line for 5 –10 msec pulsing.
A_WAIT_VRISE If ID Interrupt or if A_VBUS_VLD is false after 100 msec Go to A_WAIT_VFALL
The cable has been changed or the A device cannot support the Turn off DRV_VBUS
current required from the B device.
If A_VBUS_VLD interrupt Go to A_WAIT_BCON
Table 42-96. State descriptions for the dual role A device flow (continued)
State Action Response
A_WAIT_BCON After 200 ms without Attach or ID Interrupt. (This could wait forever Go to A_WAIT_FALL
if desired.)
Turn off DRV_VBUS
A_VBUS_VLD Interrupt and B device attaches Go to A_HOST
Turn on Host mode
A_HOST Enumerate Device determine OTG Support.
If A_VBUS_VLD/ Interrupt or A device is done and doesn't think he Go to A_WAIT_VFALL
wants to do something soon or the B device disconnects
Turn off Host mode
Turn off DRV_VBUS
If the A device is finished with session or if the A device wants to Go to A_SUSPEND
allow the B device to take bus.
ID Interrupt or the B device disconnects Go to A_WAIT_BCON
A_SUSPEND If ID Interrupt, or if 150 ms B disconnect timeout (This timeout value Go to A_WAIT_VFALL
could be longer) or if A_VBUS_VLD\ Interrupt
Turn off DRV_VBUS
If HNP enabled, and B disconnects in 150 ms then B device is Go to A_PERIPHERAL
becoming the host.
Turn off Host mode
If A wants to start another session Go to A_HOST
A_PERIPHERAL If ID Interrupt or if A_VBUS_VLD interrupt Go to A_WAIT_VFALL
Turn off DRV_VBUS.
If 3 –200 ms of Bus Idle Go to A_WAIT_BCON
Turn on Host mode
A_WAIT_VFALL If ID Interrupt or (A_SESS_VLD/ & b_conn/) Go to A_IDLE
B_IDLE A_IDLE
B_HOST B_SRP_INIT
B_WAIT_ACON B_PERIPHERAL
Table 42-97. State descriptions for the dual role B device flow
State Action Response
B_IDLE If ID\ Interrupt. Go to A_IDLE
A Type A cable has been plugged in and the device should now
respond as a Type A device.
If B_SESS_VLD Interrupt. Go to B_PERIPHERAL
The A device has turned on VBUS and begins a session. Turn on DP_HIGH
If B application wants the bus and Bus is Idle for 2 ms and the Go to B_SRP_INIT
B_SESS_END bit is set, the B device can perform an SRP.
Pulse CHRG_VBUS
Pulse DP_HIGH 5-10
ms
B_SRP_INIT If ID\ Interrupt or SRP Done (SRP must be done in less than 100 Go to B_IDLE
ms.)
B_PERIPHERAL If HNP enabled and the bus is suspended and B wants the bus, the Go to B_WAIT_ACON
B device can become the host.
Turn off DP_HIGH
B_WAIT_ACON If A connects, an attach interrupt is received Go to B_HOST
Turn on Host Mode
If ID\ Interrupt or B_SESS_VLD/ Interrupt Go to B_IDLE
If the cable changes or if VBUS goes away, the host doesn't support
us.
Go to B_IDLE
If 3.125 ms expires or if a Resume occurs Go to B_PERIPHERAL
B_HOST If ID\ Interrupt or B_SESS_VLD\ Interrupt Go to B_IDLE
If the cable changes or if VBUS goes away, the host doesn't support
us.
If B application is done or A disconnects Go to B_PERIPHERAL
42.9.1
Figure 42-95.
42.10.1
42.10.2 Power
The USB-FS core is a fully synchronous static design. The power used by the design is
dependant on the application usage of the core. Applications that transfer more data or
cause a greater number of packets to be sent consumes a greater amount of power.
Because the design is synchronous and static, reducing the transitions on the clock net
may conserve power. This may be done in the following ways.
The first is to reduce the clock frequency to the USB module. The clock frequency may
not be reduced below the minimum recommended operating frequency of the USB
module without first disabling the USB operation and disconnecting (via software
disconnect) the USB module from the USB bus.
Alternately, the clock may be shut off to the core to conserve power. Again, this may
only be done after the USB operations on the bus have been disabled and the device has
been disconnected from the USB.
maximum USB bus power budget of 500 uA. To achieve that level of power
conservation, most of the device circuits need to be switched off. When the clock is
disabled to the USB-FScore all functions are disabled, but all operational states are
retained. The transceiver VP and VM signals can be used to construct a circuit able to
detect the resume signaling on the bus and restore the clocks to the rest of the circuit
when the USB host takes the bus out of the suspend state.
43.1 Preface
43.1.1 References
The following publications are referenced in this document. For updates to these
specifications, see http://www.usb.org.
• USB Battery Charging Specification Revision 1.1, USB Implementers Forum
• Universal Serial Bus Specification Revision 2.0, USB Implementers Forum
43.1.3 Glossary
The following table shows a glossary of terms used in this document.
Table 43-2. Glossary of terms
Term Definition
Transceiver Module that implements the physical layer of the USB standard (FS or LS only).
PHY Module that implements the physical layer of the USB standard (HS capable).
Attached Device is physically plugged into USB port, but has not enabled either D+ or D– pullup resistor.
Connected Device is physically plugged into USB port, and has enabled either D+ or D– pullup resistor.
Suspended After 3 ms of no bus activity, the USB device enters suspend mode.
Component The hardware and software that make up a subsystem.
43.2 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The USBDCD module works with the USB transceiver to detect whether the USB device
is attached to a charging port, either a dedicated charging port or a charging host. System
software coordinates the detection activites of the module and controls an off-chip
integrated circuit that performs the battery charging.
bus
Control and
Feedback D+
Current Sink
state of D–
D
D–
D– pulldown
enable Voltage Source
43.2.2 Features
The USBDCD module offers the following features:
• Compliant with the latest industry standard specification: USB Battery Charging
Specification, Revision 1.1
• Programmable timing parameters default to values required by the industry
standards:
• Having standard default values allows for easy configuration- simply set the
clock frequency before enabling the module.
• Programmability allows the flexibility to meet future updates of the standards.
Disabled The module is not active and is held System software should disable the module when either of the
in a low power state. following conditions is true:
• The charger detect sequence is complete.
• The conditions for being enabled are not met.
Powered Off The digital supply voltage dvdd is Low system performance requirements allow putting the device into
removed. a very low-power stop mode.
Powered Perform the following actions: Perform the following actions: Disabled
Off
1. Put the device into very low-power stop 1. Restore the supply voltages.
mode.
2. Take the device out of very low-power stop
2. Adjust the supply voltages. mode.
1. The effect of setting the SR bit is immediate; that is, the module is disabled even if the sequence has not completed.
1. Voltage must be 3.3 V +/- 10% for full functionality of the module. That is, the charger detection function does not work
when this voltage is below 3.0 V, and the CONTROL[START] bit should not be set.
NOTE
The transceiver module also interfaces to the usb_dm and
usb_dp signals. Both modules and the USB host/hub use these
signals as bidirectional, tristate signals.
Information about the signal integrity aspects of the lines including shielding, isolated
return paths, input or output impedance, packaging, suggested external components,
ESD, and other protections can be found in the USB 2.0 specification and in Application
information.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 0 0 0
IE
START
W SR
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R IF 0 0
Reserved
IACK
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 No interrupt is pending.
1 An interrupt is pending.
7–1 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
0 Interrupt Acknowledge
IACK
Determines whether the interrupt is cleared.
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
CLOCK_UNIT
R 0 0
CLOCK_SPEED
W
Reset 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1
Provides the current state of the module for system software monitoring.
Address: 4003_5000h base + 8h offset = 4003_5008h
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
ACTIVE
R 0 TO ERR SEQ_STAT SEQ_RES
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
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 No sequence errors.
1 Error in the detection sequence. See the SEQ_STAT field to determine the phase in which the error
occurred.
19–18 Charger Detection Sequence Status
SEQ_STAT
Indicates the status of the charger detection sequence.
00 The module is either not enabled, or the module is enabled but the data pins have not yet been
detected.
01 Data pin contact detection is complete.
10 Charging port detection is complete.
11 Charger type detection is complete.
17–16 Charger Detection Sequence Results
SEQ_RES
Reports how the charger detection is attached.
00 No results to report.
01 Attached to a standard host. Must comply with USB 2.0 by drawing only 2.5 mA (max) until
connected.
10 Attached to a charging port. The exact meaning depends on bit 18:
• 0: Attached to either a charging host or a dedicated charger. The charger type detection has
not completed.
• 1: Attached to a charging host. The charger type detection has completed.
11 Attached to a dedicated charger.
15–0 This field is reserved.
Reserved
NOTE: Bits do not always read as 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 0 TUNITCON
TSEQ_INIT
W
Reset 0 0 0 0 0 0 0 0 0 0 0 1 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 0
TDCD_DBNC TVDPSRC_ON
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 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 0
TVDPSRC_CON CHECK_DM
W
Reset 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1. If the USB host has suspended the USB device, system software must configure the
system to limit the current drawn from the USB bus to 2.5 mA or less.
Comm Module A communications module on the device can be used to control the charge rate of the battery
charger IC.
System software Coordinates the detection activities of the subsystem.
USB Controller The D+ pullup enable control signal plays a role during the charger type detection phase.
System software must issue a command to the USB controller to assert this signal. After this
pullup is enabled, the device is considered to be connected to the USB bus. The host then
attempts to enumerate it.
NOTE: The USB controller must be used only for USB device applications when using the
USBDCD module. For USB host applications, the USBDCD module must be
disabled.
USBDCD Module Detects whether the device has been plugged into either a standard host port, a charging
host port, or a dedicated charger.
VBUS_detect This interrupt pin connected to the USB VBUS signal detects when the device has been
plugged into or unplugged from the USB bus. If the system requires waking up from a low
power mode on being plugged into the USB port, this interrupt should also be a low power
wake up source. If this pin multiplexes other functions, such as GPIO, the pin can be
configured as an interrupt so that the USB plug or unplug event can be detected.
1. If the USB host has suspended the USB device, system software must configure the system to limit the current drawn from
the USB bus to 2.5 mA or less.
1 2 3 4 5 6
Initial VBUS Data Pin Charging Port Charger
Charger Contact Type Timeout
Detection Conditions Detect
Detection
Detection
Detection
Phase
T UNIT_CON_ELAPSED = T SEQ_INIT T UNIT_CON_ELAPSED
=1s
V B U S a t p o rta b le D e d ic a te d C h a rg e r
U S B d e v ice
T SEQ_INIT C h a rg in g H o s t
I DEV_DCHG Dedicated Charger
I DEV_HCHG_LFS C h a rg in g H o s t
I SUSP
0m A
I DP_SRC on
R DM_DWN o ff
TDCD_DBNC
Full-
lgc_hi
Speed D+
Portable lgc_lo
USB T VDPSRC_ON CHECK_DM
Device V DP_SRC on
I DM_SINK o ff
1 ms T VDPSRC_CON
on
D P_PU LLU P
o ff
T CON_IDPSNK_DIS
on
I DP_SINK
o ff
VDM_SRC could turn on if ground currents
Charging c a u s e D + v o lta g e to e x c e e d VDAT_REF
Host Port T VDMSRC_DIS a t c h a rg in g h o s t p o rt.
T VDMSRC_EN
on
V DM_SRC
o ff
The following table provides an overview description of the charger detection sequence
shown in the preceding figure.
Timing parameter values used in this module are listed in the following table.
Table 43-15. Timing parameters for the charger detection sequence
Module
Parameter USB Battery Charging Spec Module default
programmable range
TDCD_DBNC1 10 ms min (no max) 10 ms 0– 1023 ms
TVDPSRC_ON1 40 ms min (no max) 40 ms 0 –1023 ms
TVDPSRC_CON1 40 ms min (no max) 40 ms 0 –1023 ms
CHECK_DM N/A 1 ms 0– 15 ms
TSEQ_INIT N/A 16 ms 0 –1023 ms
TUNIT_CON 1 1s N/A N/A
TVDMSRC_EN 1 1– 20 ms From the USB host N/A
TVDMSRC_DIS1 0 –20 ms From the USB host N/A
TCON_IDPSINK_DIS 1 0– 20 ms From the USB host N/A
VBUS VBUS
D D
D+ D+
GND GND
As a result, when a portable USB device is attached to an upstream port, the portable
USB device detects VBUS before the data pins have made contact. The time between
power pins and data pins making contact depends on how fast the plug is inserted into the
receptable. Delays of several hundred milliseconds are possible.
When system software has initiated the charger detection sequence, as described in Initial
System Conditions, the USBDCD module turns on the IDP_SRC current source and
enables the RDM_DWN pulldown resistor. If the data pins have not made contact, the D+
line remains high. After the data pins make contact, the D+ line goes low and debouncing
begins.
After the D+ line goes low, the module continuously samples the D+ line over the
duration of the TDCD_DBNC debounce time interval.By deafult, TDCD_DBNC is 10 ms, but it
can be programmed in the TIMER0[TDCD_DBNC] field. See the description of the
TIMER0 Register for register information.
When it has remained low for the entire interval, the debouncing is complete. However, if
the D+ line returns high during the debounce interval, the module waits until the D+ line
goes low again to restart the debouncing. This cycle repeats until either of the following
happens:
• The data pin contact has been successfully debounced (see Success in detecting data
pin contact (phase completion)).
• A timeout occurs (see Charger detection sequence timeout).
After a time of TVDPSRC_ON, the module samples the D– line. The TVDPSRC_ON parameter
is programmable and defaults to 40 ms. After sampling the D– line, the module
disconnects the voltage source, current sink, and comparator.
The next steps in the sequence depend on the voltage on the D– line as determined by the
voltage comparator. See the following table.
Table 43-16. Sampling D– in the charging port detection phase
If the voltage on D- is... Then... See...
The port is a standard host that does not support the Standard host
Below VDAT_REF
USB Battery Charging Specification v1.1. port
Above VDAT_REF but below VLGC The port is a charging port. Charging port
Error in charging
Above VLGC This is an error condition.
port detection
At this point, control has been passed to system software via the interrupt. The rest of the
sequence, which detects the type of charging port, is not applicable, so software should
perform the following steps:
At this point, control has passed to system software via the interrupt. Software should:
1. Read the STATUS register.
2. Set CONTROL[IACK] to acknowledge the interrupt.
3. Issue a command to the USB controller to pullup the USB D+ line.
4. Wait for the module to complete the final phase of the sequence. See Charger type
detection.
Note that in this case the module does not wait for the TVDPSRC_CON interval to elapse.
At this point, control has been passed to system software via the interrupt. The rest of the
sequence (detecting the type of charging port) is not applicable, so software should:
1. Read the STATUS register.
2. Set CONTROL[IACK] to acknowledge the interrupt.
3. Set CONTROL[SR] to issue a software reset to the module.
4. Disable the module.
1. In a dedicated charger, the D+ and D– lines are shorted together through a small resistor.
2. In a charging host port, the D+ and D– lines are not shorted.
At this point, control has been passed to system software via the interrupt. Software
should:
1. Read the STATUS register.
2. Disable the USB controller to prevent transitions on the USB D+ or D– lines from
causing spurious interrupt or wakeup events to the system.
3. Set CONTROL[IACK] to acknowledge the interrupt.
4. Set CONTROL[SR] to issue a software reset to the module.
5. Disable the module.
6. Communicate the appropriate charge rate to the external battery charger IC; see
Table 43-13.
At this point, control has been passed to system software via the interrupt. Software
should:
1. Read the STATUS register.
2. Set CONTROL[IACK] to acknowledge the interrupt.
3. Set CONTROL[SR] to issue a software reset to the module.
4. Disable the module.
5. Communicate the appropriate charge rate to the external battery charger IC; see
Table 43-13.
• Updates the STATUS register to reflect that a timeout error has occured. See Table
43-18 for field values.
• Sets the CONTROL[IF] bit.
• Generates an interrupt if enabled in CONTROL[IE].
• The detection sequence continues until explicitly halted by software setting the
CONTROL[SR] bit.
• The Unit Connection Timer continues counting. See the description of the TIMER0
Register.
At this point, control has been passed to system software via the interrupt, which has two
options: ignore the interrupt and allow more time for the sequence to complete, or halt the
sequence. To halt the sequence, software should:
1. Read the STATUS register.
2. Set the CONTROL[IACK] bit to acknowledge the interrupt.
3. Set the CONTROL[SR] bit to issue a software reset to the module.
4. Disable the module.
This timeout function is also useful in case software does not realize that the USB device
is unplugged from USB port during the charger detection sequence. If the interrupt occurs
but the VBUS_DETECT input is low, software can disable and reset the module.
System software might allow the sequence to run past the timeout interrupt under these
conditions:
1. The USB Battery Charging Spec is amended to allow more time. In this case,
software should poll TIMER0[TUNITCON] periodically to track elapsed time after 1s;
or
2. For debug purposes.
Note that the TUNITCON register field will stop incrementing when it reaches its maximum
value so it will not rollover to zero and start counting up again.
43.5.3 Resets
There are two ways to reset various register contents in this module: hardware resets and
a software reset.
A software reset also returns all internal logic, timers, and counters to their reset states. If
the module is already active (STATUS[ACTIVE] = 1), a software reset stops the
sequence.
Note
Software must always initiate a software reset before starting
the sequence to ensure the module is in a known state.
The module is also compatible with systems that do check the strength of the battery. In
these systems, if it is known that the battery is weak or dead, software can delay
connecting to the USB while charging at 1.5A. Once the battery is charged to the good
battery threshold, software can then connect to the USB host by pulling the D+ line high.
44.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The USB Voltage Regulator module is a LDO linear voltage regulator to provide 3.3V
power from an input power supply varying from 2.7 V to 5.5 V. It consists of one 3.3 V
power channel. When the input power supply is below 3.6 V, the regulator goes to pass-
through mode. The following figure shows the ideal relation between the regulator output
and input power supply.
OUTPUT
(Volt)
3.3
2.7
2.4
Figure 44-1. Ideal Relation Between the Regulator Output and Input Power Supply
44.1.1 Overview
A simplified block diagram for the USB Voltage Regulator module is shown below.
STANDBY Regulator
Yes
Other Modules
No
STANDBY
Regulated Output
Power reg33_in reg33_out Voltage
Supply RUN Regulator
ESR: 5m -> 100m Ohms
Voltage Regulator
External Capacitor
Chip typical = 2.2uF
This module uses 2 regulators in parallel. In run mode, the RUN regulator with the
bandgap voltage reference is enabled and can provide up to 120 mA load current. In run
mode, the STANDBY regulator and the low power reference are also enabled, but a
switch disconnects its output from the external pin. In STANDBY mode, the RUN
regulator is disabled and the STANDBY regulator output is connected to the external pin
supplying up to 3 mA load current.
Internal power mode signals control whether the module is in RUN or STANDBY mode.
44.1.2 Features
• Low drop-out linear voltage regulator with one power channel (3.3V).
• Low drop-out voltage: 300 mV.
• Output current: 120 mA.
• Three different power modes: RUN, STANDBY and SHUTDOWN.
• Low quiescent current in RUN mode.
• Typical value is around 120 uA (one thousand times smaller than the maximum
load current).
• Very low quiescent current in STANDBY mode.
• Typical value is around 1 uA.
• Automatic current limiting if the load current is greater than 290 mA.
• Automatic power-up once some voltage is applied to the regulator input.
• Pass-through mode for regulator input voltages less than 3.6 V
• Small output capacitor: 2.2 uF
• Stable with aluminum, tantalum or ceramic capacitors.
The regulator is enabled by default. This means that once the power supply is provided,
the module power-up sequence to RUN mode starts.
45.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The FlexCAN module is a communication controller implementing the CAN protocol
according to the CAN 2.0B protocol specification. A general block diagram is shown in
the following figure, which describes the main sub-blocks implemented in the FlexCAN
module, including one associated memory for storing Message Buffers, Rx Global Mask
Registers, Rx Individual Mask Registers, Rx FIFO and Rx FIFO ID Filters. The functions
of the sub-modules are described in subsequent sections.
Registers
Message
CAN Control Buffers
Host Interface (MBs)
Tx Rx
RAM
Arbitration Matching
CAN Transceiver
CAN Bus
Figure 45-1. FlexCAN block diagram
45.1.1 Overview
The CAN protocol was primarily designed to be used as a vehicle serial data bus, meeting
the specific requirements of this field: real-time processing, reliable operation in the EMI
environment of a vehicle, cost-effectiveness and required bandwidth. The FlexCAN
module is a full implementation of the CAN protocol specification, Version 2.0 B, which
supports both standard and extended message frames. The Message Buffers are stored in
an embedded RAM dedicated to the FlexCAN module. See the chip configuration details
for the actual number of Message Buffers configured in the MCU.
The CAN Protocol Engine (PE) sub-module manages the serial communication on the
CAN bus, requesting RAM access for receiving and transmitting message frames,
validating received messages and performing error handling. The Controller Host
Interface (CHI) sub-module handles Message Buffer selection for reception and
transmission, taking care of arbitration and ID matching algorithms. The Bus Interface
Unit (BIU) sub-module controls the access to and from the internal interface bus, in order
to establish connection to the CPU and to other blocks. Clocks, address and data buses,
interrupt outputs and test signals are accessed through the BIU.
K20 Sub-Family Reference Manual, Rev. 1.1, Dec 2012
1104 Freescale Semiconductor, Inc.
Chapter 45 CAN (FlexCAN)
• Listen-Only mode:
The module enters this mode when the LOM bit in the Control 1 Register is asserted.
In this mode, transmission is disabled, all error counters are frozen and the module
operates in a CAN Error Passive mode. Only messages acknowledged by another
CAN station will be received. If FlexCAN detects a message that has not been
acknowledged, it will flag a BIT0 error (without changing the REC), as if it was
trying to acknowledge the message.
• Loop-Back mode:
The module enters this mode when the LPB bit in the Control 1 Register is asserted.
In this mode, FlexCAN performs an internal loop back that can be used for self test
operation. The bit stream output of the transmitter is internally fed back to the
receiver input. The Rx CAN input pin is ignored and the Tx CAN output goes to the
recessive state (logic '1'). FlexCAN behaves as it normally does when transmitting
and treats its own transmitted message as a message received from a remote node. In
this mode, FlexCAN ignores the bit sent during the ACK slot in the CAN frame
acknowledge field to ensure proper reception of its own message. Both transmit and
receive interrupts are generated.
45.2.1 CAN Rx
This pin is the receive pin from the CAN bus transceiver. Dominant state is represented
by logic level 0. Recessive state is represented by logic level 1.
45.2.2 CAN Tx
This pin is the transmit pin to the CAN bus transceiver. Dominant state is represented by
logic level 0. Recessive state is represented by logic level 1.
Each individual register is identified by its complete name and the corresponding
mnemonic. The access type can be Supervisor (S) or Unrestricted (U). Most of the
registers can be configured to have either Supervisor or Unrestricted access by
programming the SUPV bit in the MCR Register. These registers are identified as S/U in
the Access column of Table 45-2.
Table 45-2. Module memory map
Affected by Affected by
Register Access Type
Hard Reset Soft Reset
Module Configuration Register (MCR) S Yes Yes
Control 1 register (CTRL1) S/U Yes No
Free Running Timer register (TIMER) S/U Yes Yes
Rx Mailboxes Global Mask register (RXMGMASK) S/U No No
Rx Buffer 14 Mask register (RX14MASK) S/U No No
Rx Buffer 15 Mask register (RX15MASK) S/U No No
Error Counter Register (ECR) S/U Yes Yes
Error and Status 1 Register (ESR1) S/U Yes Yes
Interrupt Masks 2 register (IMASK2) S/U Yes Yes
Interrupt Masks 1 register (IMASK1) S/U Yes Yes
Interrupt Flags 2 register (IFLAG2) S/U Yes Yes
Interrupt Flags 1 register (IFLAG1) S/U Yes Yes
Control 2 Register (CTRL2) S/U Yes No
Error and Status 2 Register (ESR2) S/U Yes Yes
Individual Matching Elements Update Register (IMUER) S/U Yes Yes
Lost Rx Frames Register (LRFR) S/U Yes Yes
CRC Register (CRCR) S/U Yes Yes
Rx FIFO Global Mask register (RXFGMASK) S/U No No
Rx FIFO Information Register (RXFIR) S/U No No
Message Buffers S/U No No
Rx Individual Mask Registers S/U No No
The FlexCAN module can store CAN messages for transmission and reception using
Mailboxes and Rx FIFO structures.
This module's memory map includes sixteen 128-bit message buffers (MBs) that occupy
the range from offset 0x80 to 0x17F.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
NOTRDY
LPMACK
FRZACK
R 0
SOFTRST
WAKMSK
WAKSRC
SLFWAK
WRNEN
SRXDIS
SUPV
HALT
Reset 1 1 0 1 1 0 0 0 1 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 0 0 0
LPRIOEN
Reset 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1
0 No reset request.
1 Resets the registers affected by soft reset.
NOTE: FRZACK will be asserted within 178 CAN bits from the freeze mode request by the CPU, and
negated within 2 CAN bits after the freeze mode request removal (see Section "Protocol Timing").
0 FlexCAN is in User mode. Affected registers allow both Supervisor and Unrestricted accesses.
1 FlexCAN is in Supervisor mode. Affected registers allow only Supervisor access. Unrestricted access
behaves as though the access was done to an unimplemented register location.
22 Self Wake Up
SLFWAK
This bit enables the Self Wake Up feature when FlexCAN is in a low-power mode other than Disable
mode. When this feature is enabled, the FlexCAN module monitors the bus for wake up event, that is, a
recessive-to-dominant transition.
If a wake up event is detected during Stop mode, then FlexCAN generates, if enabled to do so, a Wake
Up interrupt to the CPU so that it can exit Stop mode globally and FlexCAN can request to resume the
clocks.
When FlexCAN is in a low-power mode other than Disable mode, this bit cannot be written as it is blocked
by hardware.
0 TWRNINT and RWRNINT bits are zero, independent of the values in the error counters.
1 TWRNINT and RWRNINT bits are set when the respective error counter transitions from less than 96
to greater than or equal to 96.
20 Low-Power Mode Acknowledge
LPMACK
This read-only bit indicates that FlexCAN is in a low-power mode (Disable mode, Stop mode). A low-
power mode cannot be entered until all current transmission or reception processes have finished, so the
CPU can poll the LPMACK bit to know when FlexCAN has actually entered low power mode.
Table continues on the next page...
0 FlexCAN uses the unfiltered Rx input to detect recessive to dominant edges on the CAN bus.
1 FlexCAN uses the filtered Rx input to detect recessive to dominant edges on the CAN bus.
18 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
17 Self Reception Disable
SRXDIS
This bit defines whether FlexCAN is allowed to receive frames transmitted by itself. If this bit is asserted,
frames transmitted by the module will not be stored in any MB, regardless if the MB is programmed with
an ID that matches the transmitted frame, and no interrupt flag or interrupt signal will be generated due to
the frame reception. This bit can be written only in Freeze mode because it is blocked by hardware in
other modes.
0 Individual Rx masking and queue feature are disabled. For backward compatibility with legacy
applications, the reading of C/S word locks the MB even if it is EMPTY.
1 Individual Rx masking and queue feature are enabled.
15–14 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
13 Local Priority Enable
LPRIOEN
This bit is provided for backwards compatibility with legacy applications. It controls whether the local
priority feature is enabled or not. It is used to expand the ID used during the arbitration process. With this
expanded ID concept, the arbitration process is done based on the full 32-bit word, but the actual
transmitted ID still has 11-bit for standard frames and 29-bit for extended frames. This bit can be written
only in Freeze mode because it is blocked by hardware in other modes.
CAUTION: Writing the Abort code into Rx Mailboxes can cause unpredictable results when the
MCR[AEN] is asserted.
0 Abort disabled.
1 Abort enabled.
11–10 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
9–8 ID Acceptance Mode
IDAM
This 2-bit field identifies the format of the Rx FIFO ID Filter Table elements. Note that all elements of the
table are configured at the same time by this field (they are all the same format). See Section "Rx FIFO
Structure". This field can be written only in Freeze mode because it is blocked by hardware in other
modes.
00 Format A: One full ID (standard and extended) per ID Filter Table element.
01 Format B: Two full standard IDs or two partial 14-bit (standard and extended) IDs per ID Filter Table
element.
10 Format C: Four partial 8-bit Standard IDs per ID Filter Table element.
11 Format D: All frames rejected.
7 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
6–0 Number Of The Last Message Buffer
MAXMB
This 7-bit field defines the number of the last Message Buffers that will take part in the matching and
arbitration processes. The reset value (0x0F) is equivalent to 16 MB configuration. This field can be written
only in Freeze mode because it is blocked by hardware in other modes.
Number of the last MB = MAXMB
NOTE: MAXMB must be programmed with a value smaller than the parameter NUMBER_OF_MB,
otherwise the number of the last effective Message Buffer will be: (NUMBER_OF_MB - 1)
Additionally, the value of MAXMB must encompass the FIFO size defined by CTRL2[RFFN]. MAXMB also
impacts the definition of the minimum number of peripheral clocks per CAN bit as described in Table
"Minimum Ratio Between Peripheral Clock Frequency and CAN Bit Rate" (in Section "Arbitration and
Matching Timing").
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
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
RWRNMSK
TWRNMSK
0
BOFFMSK
BOFFREC
R
ERRMSK
CLKSRC
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 The CAN engine clock source is the oscillator clock. Under this condition, the oscillator clock
frequency must be lower than the bus clock.
1 The CAN engine clock source is the peripheral clock.
12 Loop Back Mode
LPB
This bit configures FlexCAN to operate in Loop-Back mode. In this mode, FlexCAN performs an internal
loop back that can be used for self test operation. The bit stream output of the transmitter is fed back
internally to the receiver input. The Rx CAN input pin is ignored and the Tx CAN output goes to the
recessive state (logic 1). FlexCAN behaves as it normally does when transmitting, and treats its own
transmitted message as a message received from a remote node. In this mode, FlexCAN ignores the bit
sent during the ACK slot in the CAN frame acknowledge field, generating an internal acknowledge bit to
ensure proper reception of its own message. Both transmit and receive interrupts are generated. This bit
can be written only in Freeze mode because it is blocked by hardware in other modes.
NOTE: In this mode, the MCR[SRXDIS] cannot be asserted because this will impede the self reception of
a transmitted message.
0 Automatic recovering from Bus Off state enabled, according to CAN Spec 2.0 part B.
1 Automatic recovering from Bus Off state disabled.
5 Timer Sync
TSYN
This bit enables a mechanism that resets the free-running timer each time a message is received in
Message Buffer 0. This feature provides means to synchronize multiple FlexCAN stations with a special
“SYNC” message, that is, global network time. If the RFEN bit in MCR is set (Rx FIFO enabled), the first
available Mailbox, according to CTRL2[RFFN] setting, is used for timer synchronization instead of MB0.
This bit can be written only in Freeze mode because it is blocked by hardware in other modes.
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 TIMER
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
W
MG[31:0]
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
These bits mask the Mailbox filter bits. Note that the alignment with the ID word of the Mailbox is not
perfect as the two most significant MG bits affect the fields RTR and IDE, which are located in the Control
and Status word of the Mailbox. The following table shows in detail which MG bits mask each Mailbox filter
field.
1. RTR bit of the Incoming Frame. It is saved into an auxiliary MB called Rx Serial Message Buffer (Rx
SMB).
2. If the CTRL2[EACEN] bit is negated, the RTR bit of Mailbox is never compared with the RTR bit of the
incoming frame.
3. If the CTRL2[EACEN] bit is negated, the IDE bit of Mailbox is always compared with the IDE bit of the
incoming frame.
1. RTR bit of the Incoming Frame. It is saved into an auxiliary MB called Rx Serial Message Buffer (Rx SMB).
2. If the CTRL2[EACEN] bit is negated, the RTR bit of Mailbox is never compared with the RTR bit of the incoming frame.
3. If the CTRL2[EACEN] bit is negated, the IDE bit of Mailbox is always compared with the IDE bit of the incoming frame.
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
RX14M[31:0]
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
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
RX15M[31:0]
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
The following are the basic rules for FlexCAN bus state transitions:
• If the value of TXERRCNT or RXERRCNT increases to be greater than or equal to
128, the FLTCONF field in the Error and Status Register is updated to reflect ‘Error
Passive’ state.
• If the FlexCAN state is ‘Error Passive’, and either TXERRCNT or RXERRCNT
decrements to a value less than or equal to 127 while the other already satisfies this
condition, the FLTCONF field in the Error and Status Register is updated to reflect
‘Error Active’ state.
• If the value of TXERRCNT increases to be greater than 255, the FLTCONF field in
the Error and Status Register is updated to reflect ‘Bus Off’ state, and an interrupt
may be issued. The value of TXERRCNT is then reset to zero.
• If FlexCAN is in ‘Bus Off’ state, then TXERRCNT is cascaded together with another
internal counter to count the 128th occurrences of 11 consecutive recessive bits on
the bus. Hence, TXERRCNT is reset to zero and counts in a manner where the
internal counter counts 11 such bits and then wraps around while incrementing the
TXERRCNT. When TXERRCNT reaches the value of 128, the FLTCONF field in
the Error and Status Register is updated to be ‘Error Active’ and both error counters
are reset to zero. At any instance of dominant bit following a stream of less than 11
consecutive recessive bits, the internal counter resets itself to zero without affecting
the TXERRCNT value.
• If during system start-up, only one node is operating, then its TXERRCNT increases
in each message it is trying to transmit, as a result of acknowledge errors (indicated
by the ACKERR bit in the Error and Status Register). After the transition to ‘Error
Passive’ state, the TXERRCNT does not increment anymore by acknowledge errors.
Therefore the device never goes to the ‘Bus Off’ state.
• If the RXERRCNT increases to a value greater than 127, it is not incremented
further, even if more errors are detected while being a receiver. At the next
successful message reception, the counter is set to a value between 119 and 127 to
resume to ‘Error Active’ state.
Address: 4002_4000h base + 1Ch offset = 4002_401Ch
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 RXERRCNT TXERRCNT
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
RWRNINT
TWRNINT
SYNCH
R 0
W w1c w1c
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
CRCERR
FRMERR
BOFFINT
BIT1ERR
BIT0ERR
ACKERR
STFERR
WAKINT
RXWRN
ERRINT
TXWRN
IDLE
R TX FLTCONF RX
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 No such occurrence.
1 The Tx error counter transitioned from less than 96 to greater than or equal to 96.
16 Rx Warning Interrupt Flag
RWRNINT
If the WRNEN bit in MCR is asserted, the RWRNINT bit is set when the RXWRN flag transitions from 0 to
1, meaning that the Rx error counters reached 96. If the corresponding mask bit in the Control Register
(RWRNMSK) is set, an interrupt is generated to the CPU. This bit is cleared by writing it to 1. When
WRNEN is negated, this flag is masked. CPU must clear this flag before disabling the bit. Otherwise it will
be set when the WRNEN is set again. Writing 0 has no effect. This bit is not updated during Freeze mode.
0 No such occurrence.
1 The Rx error counter transitioned from less than 96 to greater than or equal to 96.
15 Bit1 Error
BIT1ERR
This bit indicates when an inconsistency occurs between the transmitted and the received bit in a
message.
Table continues on the next page...
0 No such occurrence.
1 At least one bit sent as recessive is received as dominant.
14 Bit0 Error
BIT0ERR
This bit indicates when an inconsistency occurs between the transmitted and the received bit in a
message.
0 No such occurrence.
1 At least one bit sent as dominant is received as recessive.
13 Acknowledge Error
ACKERR
This bit indicates that an Acknowledge Error has been detected by the transmitter node, that is, a
dominant bit has not been detected during the ACK SLOT.
0 No such occurrence.
1 An ACK error occurred since last read of this register.
12 Cyclic Redundancy Check Error
CRCERR
This bit indicates that a CRC Error has been detected by the receiver node, that is, the calculated CRC is
different from the received.
0 No such occurrence.
1 A CRC error occurred since last read of this register.
11 Form Error
FRMERR
This bit indicates that a Form Error has been detected by the receiver node, that is, a fixed-form bit field
contains at least one illegal bit.
0 No such occurrence.
1 A Form Error occurred since last read of this register.
10 Stuffing Error
STFERR
This bit indicates that a Stuffing Error has been detected.
0 No such occurrence.
1 A Stuffing Error occurred since last read of this register.
9 TX Error Warning
TXWRN
This bit indicates when repetitive errors are occurring during message transmission. This bit is not updated
during Freeze mode.
0 No such occurrence.
1 TXERRCNT is greater than or equal to 96.
8 Rx Error Warning
RXWRN
This bit indicates when repetitive errors are occurring during message reception. This bit is not updated
during Freeze mode.
Table continues on the next page...
0 No such occurrence.
1 CAN bus is now IDLE.
6 FlexCAN In Transmission
TX
This bit indicates if FlexCAN is transmitting a message. See the table in the overall CAN_ESR1 register
description.
00 Error Active
01 Error Passive
1x Bus Off
3 FlexCAN In Reception
RX
This bit indicates if FlexCAN is receiving a message. See the table in the overall CAN_ESR1 register
description.
0 No such occurrence.
1 FlexCAN module entered Bus Off state.
1 Error Interrupt
ERRINT
This bit indicates that at least one of the Error Bits (bits 15-10) is set. If the corresponding mask bit
CTRL1[ERRMSK] is set, an interrupt is generated to the CPU. This bit is cleared by writing it to 1. Writing
0 has no effect.
0 No such occurrence.
1 Indicates setting of any Error Bit in the Error and Status Register.
0 Wake-Up Interrupt
WAKINT
Table continues on the next page...
When a recessive-to-dominant transition is detected on the CAN bus and if the MCR[WAKMSK] bit is set,
an interrupt is generated to the CPU. This bit is cleared by writing it to 1.
When MCR[SLFWAK] is negated, this flag is masked. The CPU must clear this flag before disabling the
bit. Otherwise it will be set when the SLFWAK is set again. Writing 0 has no effect.
0 No such occurrence.
1 Indicates a recessive to dominant transition was received on the CAN bus.
This register allows any number of a range of the 32 Message Buffer Interrupts to be
enabled or disabled for MB31 to MB0. It contains one interrupt mask bit per buffer,
enabling the CPU to determine which buffer generates an interrupt after a successful
transmission or reception, that is, when the corresponding IFLAG1 bit is set.
Address: 4002_4000h base + 28h offset = 4002_4028h
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
BUFLM
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: Setting or clearing a bit in the IMASK1 Register can assert or negate an interrupt request, if the
corresponding IFLAG1 bit is set.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R BUF31TO8I
W w1c
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
BUF7I
BUF6I
BUF5I
R BUF31TO8I BUF4TO0I
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
NOTE: This flag is cleared by the FlexCAN whenever the bit MCR[RFEN] is changed by CPU writes.
The BUF7I flag represents "Rx FIFO Overflow" when MCR[RFEN] is set. In this case, the flag indicates
that a message was lost because the Rx FIFO is full. Note that the flag will not be asserted when the Rx
FIFO is full and the message was captured by a Mailbox.
NOTE: This flag is cleared by the FlexCAN whenever the bit MCR[RFEN] is changed by CPU writes.
The BUF6I flag represents "Rx FIFO Warning" when MCR[RFEN] is set. In this case, the flag indicates
when the number of unread messages within the Rx FIFO is increased to 5 from 4 due to the reception of
a new one, meaning that the Rx FIFO is almost full. Note that if the flag is cleared while the number of
unread messages is greater than 4, it does not assert again until the number of unread messages within
the Rx FIFO is decreased to be equal to or less than 4.
NOTE: This flag is cleared by the FlexCAN whenever the bit MCR[RFEN] is changed by CPU writes.
The BUF5I flag represents "Frames available in Rx FIFO" when MCR[RFEN] is set. In this case, the flag
indicates that at least one frame is available to be read from the Rx FIFO.
NOTE: These flags are cleared by the FlexCAN whenever the bit MCR[RFEN] is changed by CPU writes.
The BUF4TO0I flags are reserved when MCR[RFEN] is set.
Table continues on the next page...
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0
WRMFRZ
EACEN
RFFN TASD MRP RRS
W
Reset 0 0 0 0 0 0 0 0 1 0 1 1 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
NOTE: Each group of eight filters occupies a memory space equivalent to two Message Buffers which
means that the more filters are implemented the less Mailboxes will be available.
Table continues on the next page...
1. The number of the last remaining available mailboxes is defined by the least value between the
parameter NUMBER_OF_MB minus 1 and the MCR[MAXMB] field.
2. If Rx Individual Mask Registers are not enabled then all Rx FIFO filters are affected by the Rx FIFO
Global Mask.
23–19 Tx Arbitration Start Delay
TASD This 5-bit field indicates how many CAN bits the Tx arbitration process start point can be delayed from the
first bit of CRC field on CAN bus. This field can be written only in Freeze mode because it is blocked by
hardware in other modes.
This field is useful to optimize the transmit performance based on factors such as: peripheral/serial clock
ratio, CAN bit timing and number of MBs. The duration of an arbitration process, in terms of CAN bits, is
directly proportional to the number of available MBs and CAN baud rate and inversely proportional to the
peripheral clock frequency.
Table continues on the next page...
where:
• fCANCLK is the Protocol Engine (PE) Clock (see section "Protocol Timing"), in Hz
• fSYS is the peripheral clock, in Hz
• MAXMB is the value in CTRL1[MAXMB] field
• RFEN is the value in CTRL1[RFEN] bit
• RFFN is the value in CTRL2[RFFN] field
• PSEG1 is the value in CTRL1[PSEG1] field
• PSEG2 is the value in CTRL1[PSEG2] field
• PROPSEG is the value in CTRL1[PROPSEG] field
• PRESDIV is the value in CTRL1[PRESDIV] field
See Section "Arbitration process" and Section "Protocol Timing" for more details.
0 Rx Mailbox filter’s IDE bit is always compared and RTR is never compared despite mask bits.
1 Enables the comparison of both Rx Mailbox filter’s IDE and RTR bit with their corresponding bits within
the incoming frame. Mask bits do apply.
15–0 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
1. The number of the last remaining available mailboxes is defined by the least value between the parameter
NUMBER_OF_MB minus 1 and the MCR[MAXMB] field.
2. If Rx Individual Mask Registers are not enabled then all Rx FIFO filters are affected by the Rx FIFO Global Mask.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 LPTM
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 VPS IMB 0
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
NOTE: ESR2[VPS] is not affected by any CPU write into Control Status (C/S) of a MB thatis blocked by
abort mechanism. When MCR[AEN] is asserted, the abort code write in C/S of a MB that is being
transmitted (pending abort), or any write attempt into a Tx MB with IFLAG set is blocked.
This bit is cleared in all start of arbitration (see Section "Arbitration process").
NOTE: LPTM mechanism have the following behavior: if an MB is successfully transmitted and
ESR2[IMB]=0 (no inactive Mailbox), then ESR2[VPS] and ESR2[IMB] are asserted and the index
related to the MB just transmitted is loaded into ESR2[LPTM].
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 MBCRC
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 TXCRC
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 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R
W
FGM[31:0]
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
1. If MCR[IDAM] field is equivalent to the format B only the fourteen most significant bits of the Identifier of
the incoming frame are compared with the Rx FIFO filter.
2. If MCR[IDAM] field is equivalent to the format C only the eight most significant bits of the Identifier of
the incoming frame are compared with the Rx FIFO filter.
1. If MCR[IDAM] field is equivalent to the format B only the fourteen most significant bits of the Identifier of the incoming frame
are compared with the Rx FIFO filter.
2. If MCR[IDAM] field is equivalent to the format C only the eight most significant bits of the Identifier of the incoming frame
are compared with the Rx FIFO filter.
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 IDHIT
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 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R
W
MI[31:0]
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.
= Unimplemented or Reserved
1. SRV: Serviced MB. MB was read and unlocked by reading TIMER or other MB.
2. A frame is considered successful reception after the frame to be moved to MB (move-in process). See Move-in) for details.
3. Remote Request Stored bit from CTRL2 register. See Section "Control 2 Register (CTRL2)" for details.
4. Code 0b1010 is not considered Tx and a MB with this code should not be aborted.
5. Note that for Tx MBs, the BUSY bit should be ignored upon read, except when AEN bit is set in the MCR register. If this bit
is asserted, the corresponding MB does not participate in the matching process.
If FlexCAN transmits this bit as '1' (recessive) and receives it as '0' (dominant), it is
interpreted as arbitration loss. If this bit is transmitted as '0' (dominant), then if it is
received as '1' (recessive), the FlexCAN module treats it as bit error. If the value received
matches the value transmitted, it is considered as a successful bit transmission.
1 = Indicates the current MB may have a Remote Request Frame to be transmitted if MB
is Tx. If the MB is Rx then incoming Remote Request Frames may be stored.
0 = Indicates the current MB has a Data Frame to be transmitted.. In Rx MB it may be
considered in matching processes.
DLC — Length of Data in Bytes
This 4-bit field is the length (in bytes) of the Rx or Tx data, which is located in offset 0x8
through 0xF of the MB space (see Table 45-69). In reception, this field is written by the
FlexCAN module, copied from the DLC (Data Length Code) field of the received frame.
In transmission, this field is written by the CPU and corresponds to the DLC field value
of the frame to be transmitted. When RTR=1, the Frame to be transmitted is a Remote
Frame and does not include the data field, regardless of the DLC field.
TIME STAMP — Free-Running Counter Time Stamp
This 16-bit field is a copy of the Free-Running Timer, captured for Tx and Rx frames at
the time when the beginning of the Identifier field appears on the CAN bus.
PRIO — Local priority
This 3-bit field is only used when LPRIO_EN bit is set in MCR and it only makes sense
for Tx mailboxes. These bits are not transmitted. They are appended to the regular ID to
define the transmission priority. See Arbitration process.
ID — Frame Identifier
In Standard Frame format, only the 11 most significant bits (28 to 18) are used for frame
identification in both receive and transmit cases. The 18 least significant bits are ignored.
In Extended Frame format, all bits are used for frame identification in both receive and
transmit cases.
DATA BYTE 0-7 — Data Field
Up to eight bytes can be used for a data frame.
For Rx frames, the data is stored as it is received from the CAN bus. DATA BYTE (n) is
valid only if n is less than DLC as shown in the table below.
For Tx frames, the CPU prepares the data field to be transmitted within the frame.
= Unimplemented or Reserved
Each ID Filter Table Element occupies an entire 32-bit word and can be compound by
one, two, or four Identifier Acceptance Filters (IDAF) depending on the MCR[IDAM]
field setting. The following figures show the IDAF indexation.
The following figures show the three different formats of the ID table elements. Note that
all elements of the table must have the same format. See Rx FIFO for more information.
Table 45-74. ID table structure
Format 31 30 29 24 23 16 15 14 13 8 7 1 0
RXIDA
A RTR IDE
(Standard = 29-19, Extended = 29-1)
RXIDB_0 RXIDB_1
B RTR IDE RTR IDE
(Standard = 29-19, Extended = 29-16) (Standard = 13-3, Extended = 13-0)
= Unimplemented or Reserved
When the MB is activated, it will participate into the arbitration process and eventually
be transmitted according to its priority. At the end of the successful transmission, the
value of the Free Running Timer is written into the Time Stamp field, the CODE field in
the Control and Status word is updated, the CRC Register is updated, a status flag is set
in the Interrupt Flag Register and an interrupt is generated if allowed by the
corresponding Interrupt Mask Register bit. The new CODE field after transmission
depends on the code that was used to activate the MB (see Table 45-70 and Table 45-71
in Message buffer structure).
When the Abort feature is enabled (MCR[AEN] is asserted), after the Interrupt Flag is
asserted for a Mailbox configured as transmit buffer, the Mailbox is blocked, therefore
the CPU is not able to update it until the Interrupt Flag is negated by CPU. This means
that the CPU must clear the corresponding IFLAG before starting to prepare this MB for
a new transmission or reception.
If the arbitration process does not manage to evaluate all Mailboxes before the CAN bus
has reached the first bit of the Intermission field the temporary arbitration winner is
invalidated and the FlexCAN will not compete for the CAN bus in the next opportunity.
The arbitration process selects the winner among the active Tx Mailboxes at the end of
the scan according to both CTRL1[LBUF] and MCR[LPRIO_EN] bits settings.
As the PRIO field is the most significant part of the arbitration value Mailboxes with low
PRIO values have higher priority than Mailboxes with high PRIO values regardless the
rest of their arbitration values.
Note that the PRIO field is not part of the frame on the CAN bus. Its purpose is only to
affect the internal arbitration process.
After the MB is activated, it will be able to receive frames that match the programmed
filter. At the end of a successful reception, the Mailbox is updated by the move-in process
(see Section "Move-in") as follows:
The recommended way for CPU servicing (read) the frame received in an Mailbox is
using the following procedure:
1. Read the Control and Status word of that Mailbox.
2. Check if the BUSY bit is deasserted, indicating that the Mailbox is locked. Repeat
step 1) while it is asserted. See Section "Message Buffer Lock Mechanism".
3. Read the contents of the Mailbox. Once Mailbox is locked now, its contents won’t be
modified by FlexCAN Move-in processes. See Section "Move-in".
4. Acknowledge the proper flag at IFLAG registers.
5. Read the Free Running Timer. It is optional but recommended to unlock Mailbox as
soon as possible and make it available for reception.
The CPU should synchronize to frame reception by the status flag bit for the specific
Mailbox in one of the IFLAG Registers and not by the CODE field of that Mailbox.
Polling the CODE field does not work because once a frame was received and the CPU
services the Mailbox (by reading the C/S word followed by unlocking the Mailbox), the
CODE field will not return to EMPTY. It will remain FULL, as explained in Table
45-70 . If the CPU tries to workaround this behavior by writing to the C/S word to force
an EMPTY code after reading the Mailbox without a prior safe inactivation, a newly
received frame matching the filter of that Mailbox may be lost.
CAUTION
In summary: never do polling by reading directly the C/S word
of the Mailboxes. Instead, read the IFLAG registers.
Note that the received frame’s Identifier field is always stored in the matching Mailbox,
thus the contents of the ID field in an Mailbox may change if the match was due to
masking. Note also that FlexCAN does receive frames transmitted by itself if there exists
a matching Rx Mailbox, provided the MCR[SRXDIS] bit is not asserted. If the
MCR[SRXDIS] bit is asserted, FlexCAN will not store frames transmitted by itself in any
MB, even if it contains a matching MB, and no interrupt flag or interrupt signal will be
generated due to the frame reception.
To be able to receive CAN frames through the Rx FIFO, the CPU must enable and
configure the Rx FIFO during Freeze mode (see Rx FIFO). Upon receiving the Frames
Available in Rx FIFO interrupt (see the description of the IFLAG[BUF5I] "Frames
available in Rx FIFO" bit in the IMASK1 register), the CPU should service the received
frame using the following procedure:
1. Read the Control and Status word (optional – needed only if a mask was used for
IDE and RTR bits)
2. Read the ID field (optional – needed only if a mask was used)
3. Read the Data field
4. Read the RXFIR register (optional)
5. Clear the Frames Available in Rx FIFO interrupt by writing 1 to IFLAG[BUF5I] bit
(mandatory – releases the MB and allows the CPU to read the next Rx FIFO entry)
• If the received frame is a data frame with DLC field equal to zero, the start point is
the CRC field of the frame
• If the received frame is a data frame with DLC field different than zero, the start
point is the DATA field of the frame
If a matching ID is found in the FIFO table or in one of the Mailboxes, the contents of the
SMB will be transferred to the FIFO or to the matched Mailbox by the move-in process.
If any CAN protocol error is detected then no match results will be transferred to the
FIFO or to the matched Mailbox at the end of reception.
The matching process scans all matching elements of both Rx FIFO (if enabled) and
active Rx Mailboxes (CODE is EMPTY, FULL, OVERRUN or RANSWER) in search of
a successful comparison with the matching elements of the Rx SMB that is receiving the
frame on the CAN bus. The SMB has the same structure of a Mailbox. The reception
structures (Rx FIFO or Mailboxes) associated with the matching elements that had a
successful comparison are the matched structures. The matching winner is selected at the
end of the scan among those matched structures and depends on conditions described
ahead. See the following table.
Table 45-77. Matching architecture
Structure SMB[RTR] CTRL2[RRS] CTRL2[EAC MB[IDE] MB[RTR] MB[ID1] MB[CODE]
EN]
Mailbox 0 - 0 cmp2 no_cmp3 cmp_msk4 EMPTY or
FULL or
OVERRUN
Mailbox 0 - 1 cmp_msk cmp_msk cmp_msk EMPTY or
FULL or
OVERRUN
Mailbox 1 0 - cmp no_cmp cmp RANSWER
Mailbox 1 1 0 cmp no_cmp cmp_msk EMPTY or
FULL or
OVERRUN
Mailbox 1 1 1 cmp_msk cmp_msk cmp_msk EMPTY or
FULL or
OVERRUN
FIFO5 - - - cmp_msk cmp_msk cmp_msk -
1. For Mailbox structure, If SMB[IDE] is asserted, the ID is 29 bits (ID Standard + ID Extended). If SMB[IDE] is negated, the
ID is only 11 bits (ID Standard). For FIFO structure, the ID depends on IDAM.
2. cmp: Compares the SMB contents with the MB contents regardless the masks.
3. no_cmp: The SMB contents are not compared with the MB contents
4. cmp_msk: Compares the SMB contents with MB contents taking into account the masks.
5. SMB[IDE] and SMB[RTR] are not taken into account when IDAM is type C.
• The CODE field of the Mailbox is either FULL or OVERRUN and it has already
been serviced (the C/S word was read by the CPU and unlocked as described in
Mailbox lock mechanism)
• The CODE field of the Mailbox is either FULL or OVERRUN and an inactivation
(see Mailbox inactivation) is performed
• The Rx FIFO is not full
The scan order for Mailboxes and Rx FIFO is from the matching element with lowest
number to the higher ones.
The matching winner search for Mailboxes is affected by the MCR[IRMQ] bit. If it is
negated the matching winner is the first matched Mailbox regardless if it is free-to-
receive or not. If it is asserted, the matching winner is selected according to the priority
below:
1. the first free-to-receive matched Mailbox;
2. the last non free-to-receive matched Mailbox.
It is possible to select the priority of scan between Mailboxes and Rx FIFO by the
CTRL2[MRP] bit.
If the selected priority is Rx FIFO first:
• If the Rx FIFO is a matched structure and is free-to-receive then the Rx FIFO is the
matching winner regardless of the scan for Mailboxes
• Otherwise (the Rx FIFO is not a matched structure or is not free-to-receive), then the
matching winner is searched among Mailboxes as described above
If the selected priority is Mailboxes first:
• If a free-to-receive matched Mailbox is found, it is the matching winner regardless
the scan for Rx FIFO
• If no matched Mailbox is found, then the matching winner is searched in the scan for
the Rx FIFO
If both conditions above are not satisfied and a non free-to-receive matched Mailbox is
found then the matching winner determination is conditioned by the MCR[IRMQ] bit:
• If MCR[IRMQ] bit is negated the matching winner is the first matched Mailbox
• If MCR[IRMQ] bit is asserted the matching winner is the Rx FIFO if it is a free-to-
receive matched structure, otherwise the matching winner is the last non free-to-
receive matched Mailbox
See the following table for a summary of matching possibilities.
45.4.5.1 Move-in
The move-in process is the copy of a message received by an Rx SMB to a Rx Mailbox
or FIFO that has matched it. If the move destination is the Rx FIFO, attributes of the
message are also copied to the RXFIR FIFO. Each Rx SMB has its own move-in process,
but only one is performed at a given time as described ahead. The move-in starts only
when the message held by the Rx SMB has a corresponding matching winner (see
Matching process) and all of the following conditions are true:
• The CAN bus has reached or let past either:
• The second bit of Intermission field next to the frame that carried the message
that is in the Rx SMB
• The first bit of an overload frame next to the frame that carried the message that
is in the Rx SMB
• There is no ongoing matching process
• The destination Mailbox is not locked by the CPU
• There is no ongoing move-in process from another Rx SMB. If more than one move-
in processes are to be started at the same time both are performed and the newest
substitutes the oldest.
The term pending move-in is used throughout the documentation and stands for a move-
to-be that still does not satisfy all of the aforementioned conditions.
The move-in is cancelled and the Rx SMB is able to receive another message if any of
the following conditions is satisfied:
• The destination Mailbox is inactivated after the CAN bus has reached the first bit of
Intermission field next to the frame that carried the message and its matching process
has finished
• There is a previous pending move-in to the same destination Mailbox
• The Rx SMB is receiving a frame transmitted by the FlexCAN itself and the self-
reception is disabled (MCR[SRXDIS] bit is asserted)
• Any CAN protocol error is detected
Note that the pending move-in is not cancelled if the module enters Freeze or Low-Power
mode. It only stays on hold waiting for exiting Freeze and Low-Power mode and to be
unlocked. If an MB is unlocked during Freeze mode, the move-in happens immediately.
The move-in process is the execution by the FlexCAN of the following steps:
1. if the message is destined to the Rx FIFO, push IDHIT into the RXFIR FIFO;
2. reads the words DATA0-3 and DATA4-7 from the Rx SMB;
3. writes it in the words DATA0-3 and DATA4-7 of the Rx Mailbox;
4. reads the words Control/Status and ID from the Rx SMB;
5. writes it in the words Control/Status and ID of the Rx Mailbox, updating the CODE
field.
The move-in process is not atomic, in such a way that it is immediately cancelled by the
inactivation of the destination Mailbox (see Mailbox inactivation) and in this case the
Mailbox may be left partially updated, thus incoherent. The exception is if the move-in
destination is an Rx FIFO Message Buffer, then the process cannot be cancelled.
The BUSY Bit (least significant bit of the CODE field) of the destination Message Buffer
is asserted while the move-in is being performed to alert the CPU that the Message
Buffer content is temporarily incoherent.
45.4.5.2 Move-out
The move-out process is the copy of the content from a Tx Mailbox to the Tx SMB when
a message for transmission is available (see Section "Arbitration process"). The move-out
occurs in the following conditions:
• The first bit of Intermission field
• During Bus Off state when TX Error Counter is in the 124 to 128 range
• During Bus Idle state
• During Wait For Bus Idle state
The move-out process is not atomic. Only the CPU has priority to access the memory
concurrently out of Bus Idle state. In Bus Idle, the move-out has the lowest priority to the
concurrent memory accesses.
If none of the conditions above are reached, the MB is transmitted correctly, the interrupt
flag is set in the IFLAG register, and an interrupt to the CPU is generated (if enabled).
The abort request is automatically cleared when the interrupt flag is set. On the other
hand, if one of the above conditions is reached, the frame is not transmitted; therefore, the
abort code is written into the CODE field, the interrupt flag is set in the IFLAG, and an
interrupt is (optionally) generated to the CPU.
If the CPU writes the abort code before the transmission begins internally, then the write
operation is not blocked; therefore, the MB is updated and the interrupt flag is set. In this
way the CPU just needs to read the abort code to make sure the active MB was safely
inactivated. Although the AEN bit is asserted and the CPU wrote the abort code, in this
case the MB is inactivated and not aborted, because the transmission did not start yet.
One Mailbox is only aborted when the abort request is captured and kept pending until
one of the previous conditions are satisfied.
The abort procedure can be summarized as follows:
• CPU checks the corresponding IFLAG and clears it, if asserted.
• CPU writes 0b1001 into the CODE field of the C/S word.
• CPU waits for the corresponding IFLAG indicating that the frame was either
transmitted or aborted.
• CPU reads the CODE field to check if the frame was either transmitted
(CODE=0b1000) or aborted (CODE=0b1001).
• It is necessary to clear the corresponding IFLAG in order to allow the MB to be
reconfigured.
1. In previous FlexCAN versions, reading the C/S word locked the MB even if it was
EMPTY. This behavior is maintained when the IRMQ bit is negated.
Note
If the BUSY bit is asserted or if the MB is empty, then reading
the Control and Status word does not lock the MB.
Inactivation takes precedence over locking. If the CPU inactivates a locked Rx MB, then
its lock status is negated and the MB is marked as invalid for the current matching round.
Any pending message on the SMB will not be transferred anymore to the MB. An MB is
unlocked when the CPU reads the Free Running Timer Register (see Section "Free
Running Timer Register (TIMER)"), or the C/S word of another MB.
Lock and unlock mechanisms have the same functionality in both Normal and Freeze
modes.
An unlock during Normal or Freeze mode results in the move-in of the pending message.
However, the move-in is postponed if an unlock occurs during a low power mode (see
Modes of operation) and it will take place only when the module resumes to Normal or
Freeze modes.
45.4.7 Rx FIFO
The receive-only FIFO is enabled by asserting the RFEN bit in the MCR. The reset value
of this bit is zero to maintain software backward compatibility with previous versions of
the module that did not have the FIFO feature. The FIFO is 6-message deep. The memory
region occupied by the FIFO structure (both Message Buffers and FIFO engine) is
described in Rx FIFO structure. The CPU can read the received messages sequentially, in
the order they were received, by repeatedly reading a Message Buffer structure at the
output of the FIFO.
The IFLAG[BUF5I] (Frames available in Rx FIFO) is asserted when there is at least one
frame available to be read from the FIFO. An interrupt is generated if it is enabled by the
corresponding mask bit. Upon receiving the interrupt, the CPU can read the message
(accessing the output of the FIFO as a Message Buffer) and the RXFIR register and then
clear the interrupt. If there are more messages in the FIFO the act of clearing the interrupt
updates the output of the FIFO with the next message and update the RXFIR with the
attributes of that message, reissuing the interrupt to the CPU. Otherwise, the flag remains
negated. The output of the FIFO is only valid whilst the IFLAG[BUF5I] is asserted.
The IFLAG[BUF6I] (Rx FIFO Warning) is asserted when the number of unread
messages within the Rx FIFO is increased to 5 from 4 due to the reception of a new one,
meaning that the Rx FIFO is almost full. The flag remains asserted until the CPU clears
it.
The IFLAG[BUF7I] (Rx FIFO Overflow) is asserted when an incoming message was lost
because the Rx FIFO is full. Note that the flag will not be asserted when the Rx FIFO is
full and the message was captured by a Mailbox. The flag remains asserted until the CPU
clears it.
Clearing one of those three flags does not affect the state of the other two.
An interrupt is generated if an IFLAG bit is asserted and the corresponding mask bit is
asserted too.
A powerful filtering scheme is provided to accept only frames intended for the target
application, reducing the interrupt servicing work load. The filtering criteria is specified
by programming a table of up to 128 32-bit registers, according to CTRL2[RFFN]
setting, that can be configured to one of the following formats (see also Rx FIFO
structure):
• Format A: 128 IDAFs (extended or standard IDs including IDE and RTR)
• Format B: 256 IDAFs (standard IDs or extended 14-bit ID slices including IDE and
RTR)
• Format C: 512 IDAFs (standard or extended 8-bit ID slices)
Note
A chosen format is applied to all entries of the filter table. It is
not possible to mix formats within the table.
Every frame available in the FIFO has a corresponding IDHIT (Identifier Acceptance
Filter Hit Indicator) that can be read by accessing the RXFIR register. The
RXFIR[IDHIT] field refers to the message at the output of the FIFO and is valid while
the IFLAG[BUF5I] flag is asserted. The RXFIR register must be read only before
clearing the flag, which guarantees that the information refers to the correct frame within
the FIFO.
Up to 32 elements of the filter table are individually affected by the Individual Mask
Registers (RXIMRx), according to the setting of CTRL2[RFFN], allowing very powerful
filtering criteria to be defined. If the IRMQ bit is negated, then the FIFO filter table is
affected by RXFGMASK.
PE Clock Sclock
Prescaler
(1 .. 256)
The crystal oscillator clock should be selected whenever a tight tolerance (up to 0.1%) is
required in the CAN bus timing. The crystal oscillator clock has better jitter performance
than PLL generated clocks.
The FlexCAN module supports a variety of means to setup bit timing parameters that are
required by the CAN protocol. The Control Register has various fields used to control bit
timing parameters: PRESDIV, PROPSEG, PSEG1, PSEG2 and RJW. See the description
of the Control 1 Register (CTRL1).
K20 Sub-Family Reference Manual, Rev. 1.1, Dec 2012
1168 Freescale Semiconductor, Inc.
Chapter 45 CAN (FlexCAN)
The PRESDIV field controls a prescaler that generates the Serial Clock (Sclock), whose
period defines the 'time quantum' used to compose the CAN waveform. A time quantum
is the atomic unit of time handled by the CAN engine.
f CANCLK
f Tq = (Prescaler Value)
A bit time is subdivided into three segments2 (see Figure 45-67 and Table 45-79):
• SYNC_SEG: This segment has a fixed length of one time quantum. Signal edges are
expected to happen within this section
• Time Segment 1: This segment includes the Propagation Segment and the Phase
Segment 1 of the CAN standard. It can be programmed by setting the PROPSEG and
the PSEG1 fields of the CTRL1 Register so that their sum (plus 2) is in the range of 4
to 16 time quanta
• Time Segment 2: This segment represents the Phase Segment 2 of the CAN standard.
It can be programmed by setting the PSEG2 field of the CTRL1 Register (plus 1) to
be 2 to 8 time quanta long
f Tq
Bit Rate = (number of Time Quanta)
NRZ Signal
1 4 ... 16 2 ... 8
2. For further explanation of the underlying concepts, see ISO/DIS 11519–1, Section 10.3. See also the CAN 2.0A/B
protocol specification for bit timing.
where:
• NCCP is the number of peripheral clocks in one CAN bit;
• fCANCLK is the Protocol Engine (PE) Clock (see Figure "CAN Engine Clocking
Scheme"), in Hz;
• fSYS is the frequency of operation of the system (CHI) clock, in Hz;
• PSEG1 is the value in CTRL1[PSEG1] field;
• PSEG2 is the value in CTRL1[PSEG2] field;
• PROPSEG is the value in CTRL1[PROPSEG] field;
• PRESDIV is the value in CTRL1[PRESDIV] field.
For example, 180 CAN bits = 180 x NCCP peripheral clock periods.
Table 45-79. Time segment syntax
Syntax Description
SYNC_SEG System expects transitions to occur on the bus during this period.
Transmit Point A node in transmit mode transfers a new value to the CAN bus at this point.
Sample Point A node samples the bus at this point. If the three samples per bit option is selected, then this point
marks the position of the third sample.
The following table gives an overview of the CAN compliant segment settings and the
related parameter values.
Table 45-80. CAN standard compliant bit time segment settings
Time segment 1 Time segment 2 Re-synchronization jump width
5 .. 10 2 1 .. 2
4 .. 11 3 1 .. 3
5 .. 12 4 1 .. 4
6 .. 13 5 1 .. 4
7 .. 14 6 1 .. 4
8 .. 15 7 1 .. 4
9 .. 16 8 1 .. 4
Note
The user must ensure the bit time settings are in compliance
with the CAN standard. For bit time calculations, use an IPT
(Information Processing Time) of 2, which is the value
implemented in the FlexCAN module.
DLC (4) DATA and/or CRC (15 to 79) EOF (7) Interm
Move-in
Matching Window (26 to 90 bits) Window
BusOff
0 1 2 3 ... 123 124 125 126 ... 128
Figure 45-70. Arbitration at the end of bus off and move-out time windows
NOTE
The matching and arbitration timing shown in the preceding
figures do not take into account the delay caused by the
Table 45-81. Minimum ratio between peripheral clock frequency and CAN
bit rate
Minimum number of peripheral
Number of Message Buffers RFEN
clocks per CAN bit
16 and 32 0 16
64 0 25
16 1 16
32 1 17
64 1 30
A direct consequence of the first requirement is that the minimum number of time quanta
per CAN bit must be 8, therefore the oscillator clock frequency should be at least 8 times
the CAN bit rate. The minimum frequency ratio specified in the preceding table can be
achieved by choosing a high enough peripheral clock frequency when compared to the
oscillator clock frequency, or by adjusting one or more of the bit timing parameters
(PRESDIV, PROPSEG, PSEG1, PSEG2) contained in the Control 1 Register (CTRL1).
In case of synchronous operation (when the peripheral clock frequency is equal to the
oscillator clock frequency), the number of peripheral clocks per CAN bit can be adjusted
by selecting an adequate value for PRESDIV in order to meet the requirement in the
preceding table. In case of asynchronous operation (the peripheral clock frequency
greater than the oscillator clock frequency), the number of peripheral clocks per CAN bit
can be adjusted by both PRESDIV and/or the frequency ratio.
As an example, taking the case of 64 MBs, if the oscillator and peripheral clock
frequencies are equal and the CAN bit timing is programmed to have 8 time quanta per
bit, then the prescaler factor (PRESDIV + 1) should be at least 2. For prescaler factor
equal to one and CAN bit timing with 8 time quanta per bit, the ratio between peripheral
and oscillator clock frequencies should be at least 2.
After requesting Freeze mode, the user must wait for the FRZ_ACK bit to be asserted in
MCR before executing any other action, otherwise FlexCAN may operate in an
unpredictable way. In Freeze mode, all memory mapped registers are accessible, except
for CTRL1[CLK_SRC] bit that can be read but cannot be written.
Exiting Freeze mode is done in one of the following ways:
• CPU negates the FRZ bit in the MCR Register
• The MCU is removed from Debug Mode and/or the HALT bit is negated
The FRZ_ACK bit is negated after the protocol engine recognizes the negation of the
freeze request. When out of Freeze mode, FlexCAN tries to re-synchronize to the CAN
bus by waiting for 11 consecutive recessive bits.
The Bus Interface Unit continues to operate, enabling the CPU to access memory mapped
registers, except the Rx Mailboxes Global Mask Registers, the Rx Buffer 14 Mask
Register, the Rx Buffer 15 Mask Register, the Rx FIFO Global Mask Register. The Rx
FIFO Information Register, the Message Buffers, the Rx Individual Mask Registers, and
the reserved words within RAM may not be accessed when the module is in Disable
Mode. Exiting from this mode is done by negating the MDIS bit by the CPU, which
causes the FlexCAN to request to resume the clocks and negate the LPM_ACK bit after
the CAN protocol engine recognizes the negation of disable mode requested by the CPU.
If FlexCAN receives the global Stop mode request during Freeze mode, it sets the
LPMACK bit, negates the FRZACK bit and then sends the Stop Acknowledge signal to
the CPU, in order to shut down the clocks globally.
If Stop mode is requested during transmission or reception, FlexCAN does the following:
• Waits to be in either Idle or Bus Off state, or else waits for the third bit of
Intermission and checks it to be recessive
• Waits for all internal activities like arbitration, matching, move-in and move-out to
finish. A pending move-in is not taken into account.
• Ignores its Rx input pin and drives its Tx pin as recessive
• Sets the NOTRDY and LPMACK bits in MCR
• Sends a Stop Acknowledge signal to the CPU, so that it can shut down the clocks
globally
Stop mode is exited when the CPU resumes the clocks and removes the Stop Mode
request. This can be as a result of the Self Wake mechanism.
In the Self Wake mechanism, if the SLFWAK bit in MCR Register was set at the time
FlexCAN entered Stop mode, then upon detection of a recessive to dominant transition
on the CAN bus, FlexCAN sets the WAKINT bit in the ESR Register and, if enabled by
the WAKMSK bit in MCR, generates a Wake Up interrupt to the CPU. Upon receiving
the interrupt, the CPU should resume the clocks and remove the Stop mode request.
FlexCAN will then wait for 11 consecutive recessive bits to synchronize to the CAN bus.
As a consequence, it will not receive the frame that woke it up. The following table
details the effect of SLFWAK and WAKMSK upon wake-up from Stop mode. Note that
wake-up from Stop mode only works when both bits are asserted.
After the CAN protocol engine recognizes the negation of the Stop mode request, the
FlexCAN negates the LPMACK bit.
Table 45-82. Wake-up from Stop Mode
MCU Wake-up interrupt
SLFWAK WAKINT WAKMSK
clocks enabled generated
0 - - No No
0 - - No No
1 0 0 No No
1 0 1 No No
1 1 0 No No
1 1 1 Yes Yes
45.4.11 Interrupts
The module has many interrupt sources: interrupts due to message buffers and interrupts
due to the ORed interrupts from MBs, Bus Off, Error, Wake Up, Tx Warning, and Rx
Warning.
Each one of the message buffers can be an interrupt source, if its corresponding IMASK
bit is set. There is no distinction between Tx and Rx interrupts for a particular buffer,
under the assumption that the buffer is initialized for either transmission or reception.
Each of the buffers has assigned a flag bit in the IFLAG Registers. The bit is set when the
corresponding buffer completes a successful transfer and is cleared when the CPU writes
it to 1 (unless another interrupt is generated at the same time).
Note
It must be guaranteed that the CPU clears only the bit causing
the current interrupt. For this reason, bit manipulation
instructions (BSET) must not be used to clear interrupt flags.
These instructions may cause accidental clearing of interrupt
flags which are set after entering the current interrupt service
routine.
If the Rx FIFO is enabled (MCR[RFEN] = 1), the interrupts corresponding to MBs 0 to 7
have different meanings. Bit 7 of the IFLAG1 becomes the "FIFO Overflow" flag; bit 6
becomes the FIFO Warning flag, bit 5 becomes the "Frames Available in FIFO flag" and
bits 4-0 are unused. See the description of the Interrupt Flags 1 Register (IFLAG1) for
more information.
For a combined interrupt where multiple MB interrupt sources are OR'd together, the
interrupt is generated when any of the associated MBs (or FIFO, if applicable) generates
an interrupt. In this case, the CPU must read the IFLAG registers to determine which MB
or FIFO source caused the interrupt.
The interrupt sources for Bus Off, Error, Wake Up, Tx Warning and Rx Warning
generate interrupts like the MB interrupt sources, and can be read from both the Error and
Status Register 1 and 2. The Bus Off, Error, Tx Warning, and Rx Warning interrupt mask
bits are located in the Control 1 Register; the Wake-Up interrupt mask bit is located in the
MCR.
• Unrestricted read and write access to supervisor registers (registers identified with S/
U in Table "Module Memory Map" in Supervisor Mode or with S only) results in
access error.
• Read and write access to implemented reserved address space results in access error.
• Write access to positions whose bits are all currently read-only results in access error.
If at least one of the bits is not read-only then no access error is issued. Write
permission to positions or some of their bits can change depending on the mode of
operation or transitory state. Refer to register and bit descriptions for details.
• Read and write access to unimplemented address space results in access error.
• Read and write access to RAM located positions during Low Power Mode results in
access error.
• If MAXMB is programmed with a value smaller than the available number of MBs,
then the unused memory space can be used as general purpose RAM space. Note that
reserved words within RAM cannot be used. As an example, suppose FlexCAN is
configured with 16 MBs, RFFN is 0x0, and MAXMB is programmed with zero. The
maximum number of MBs in this case becomes one. The RAM starts at 0x0080, and
the space from 0x0080 to 0x008F is used by the one MB. The memory space from
0x0090 to 0x017F is available. The space between 0x0180 and 0x087F is reserved.
The space from 0x0880 to 0x0883 is used by the one Individual Mask and the
available memory in the Mask Registers space would be from 0x0884 to 0x08BF.
From 0x08C0 through 0x09DF there are reserved words for internal use which
cannot be used as general purpose RAM. As a general rule, free memory space for
general purpose depends only on MAXMB.
• MCU level soft reset, which resets some of the memory mapped registers
synchronously. See Table 45-2 to see what registers are affected by soft reset.
• SOFT_RST bit in MCR, which has the same effect as the MCU level soft reset
Starting with the last event, FlexCAN attempts to synchronize to the CAN bus.
46.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The serial peripheral interface (SPI) module provides a synchronous serial bus for
communication between an MCU and an external peripheral device.
SPI
DMA and Interrupt Control
PUSHR POPR
RX FIFO
TX FIFO
32
32
SOUT
Shift Register
SIN
S PI SCK
Baud Rate, Delay &
Transfer Control PCS[x]/SS
8
46.1.2 Features
The module supports the following features:
• Full-duplex, three-wire synchronous transfers
• Master and Slave modes:
• Data streaming operation in Slave mode with continuous slave selection
• Buffered transmit operation using the transmit first in first out (TX FIFO) with depth
of four entries
• Buffered receive operation using the receive FIFO (RX FIFO) with depth of four
entries
• TX and RX FIFOs can be disabled individually for low-latency updates to SPI
queues
Addr/Ctrl
Tx Data Rx Data
DSPI
Req
TX FIFO RX FIFO
Shift Register
T
• Slave mode
• Module Disable mode
• MCU-specific modes:
• External Stop mode
• Debug mode
The module enters module-specific modes when the host writes a module register. The
MCU-specific modes are controlled by signals external to the module. The MCU-specific
modes are modes that an MCU may enter in parallel to the block-specific modes.
Contains bits to configure various attributes associated with the module operations. The
HALT and MDIS bits can be changed at any time, but the effect takes place only on the
next frame boundary. Only the HALT and MDIS bits in the MCR can be changed, while
the module is in the Running state.
Address: Base address + 0h offset
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R
CONT_SCKE
Reserved
ROOE
MSTR
MTFE
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 0
DOZE
DIS_ DIS_
HALT
MDIS SMPL_PT
TXF RXF
CLR_RXF
CLR_TXF
Reset 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1
00 SPI
01 Reserved
10 Reserved
11 Reserved
27 Freeze
FRZ
Enables the DSPI transfers to be stopped on the next frame boundary when the device enters Debug
mode.
0 TX FIFO is enabled.
1 TX FIFO is disabled.
12 Disable Receive FIFO
DIS_RXF
When the RX FIFO is disabled, the receive part of the module operates as a simplified double-buffered
SPI. This bit can only be written when the MDIS bit is cleared.
0 RX FIFO is enabled.
1 RX FIFO is disabled.
11 Clear TX FIFO
CLR_TXF
Flushes the TX FIFO. Writing a 1 to CLR_TXF clears the TX FIFO Counter. The CLR_TXF bit is always
read as zero.
0 Start transfers.
1 Stop transfers.
TCR contains a counter that indicates the number of SPI transfers made. The transfer
counter is intended to assist in queue management. Do not write the TCR when the DSPI
is in the Running state.
Address: Base address + 8h 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 0
SPI_TCNT
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
46.3.3 DSPI Clock and Transfer Attributes Register (In Master Mode)
(SPIx_CTARn)
CTARs are used to define different transfer attributes. Do not write to the CTARs while
the DSPI is in the Running state.
In Master mode, the CTARs define combinations of transfer attributes such as frame size,
clock phase and polarity, data bit ordering, baud rate, and various delays. In Slave mode,
a subset of the fields in CTAR0 are used to set the slave transfer attributes.
When the DSPI is configured as an SPI master, the CTAS field in the command portion
of the TX FIFO entry selects which of the CTAR register is used. When the DSPI is
configured as an SPI bus slave, the CTAR0 is used.
Address: Base address + Ch offset + (4d × i), where i=0d to 1d
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
LSBFE
CPHA
CPOL
DBR FMSZ PCSSCK PASC PDT PBR
W
Reset 0 1 1 1 1 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
CSSCK ASC DT BR
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 Data is captured on the leading edge of SCK and changed on the following edge.
1 Data is changed on the leading edge of SCK and captured on the following edge.
24 LSB First
LSBFE
Specifies whether the LSB or MSB of the frame is transferred first.
46.3.4 DSPI Clock and Transfer Attributes Register (In Slave Mode)
(SPIx_CTARn_SLAVE)
When the DSPI is configured as an SPI bus slave, the CTAR0 register is used.
Address: Base address + Ch offset + (4d × i), where i=0d to 0d
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 0 0
CPHA
CPOL
FMSZ
W
Reset 0 1 1 1 1 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
0 Data is captured on the leading edge of SCK and changed on the following edge.
1 Data is changed on the leading edge of SCK and captured on the following edge.
24–23 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
22 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
21–0 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
SR contains status and flag bits. The bits reflect the status of the DSPI and indicate the
occurrence of events that can generate interrupt or DMA requests. Software can clear flag
bits in the SR by writing a 1 to them. Writing a 0 to a flag bit has no effect. This register
may not be writable in Module Disable mode due to the use of power saving
mechanisms.
Address: Base address + 2Ch offset
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
TXRXS
EOQF
RFOF
RFDF
TFUF
R TCF 0 0 TFFF 0 0 0 0 0 0 0
Reset 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 No TX FIFO underflow.
1 TX FIFO underflow has occurred.
26 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
25 Transmit FIFO Fill Flag
TFFF
Provides a method for the DSPI to request more entries to be added to the TX FIFO. The TFFF bit is set
while the TX FIFO is not full. The TFFF bit can be cleared by writing 1 to it or by acknowledgement from
the DMA controller to the TX FIFO full request.
0 TX FIFO is full.
1 TX FIFO is not full.
24 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
23 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
22 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
21 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
20 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
19 Receive FIFO Overflow Flag
RFOF
Indicates an overflow condition in the RX FIFO. The field is set when the RX FIFO and shift register are
full and a transfer is initiated. The bit remains set until it is cleared by writing a 1 to it.
0 No Rx FIFO overflow.
1 Rx FIFO overflow has occurred.
18 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
17 Receive FIFO Drain Flag
RFDF
Table continues on the next page...
0 RX FIFO is empty.
1 RX FIFO is not empty.
16 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
15–12 TX FIFO Counter
TXCTR
Indicates the number of valid entries in the TX FIFO. The TXCTR is incremented every time the PUSHR is
written. The TXCTR is decremented every time an SPI command is executed and the SPI data is
transferred to the shift register.
11–8 Transmit Next Pointer
TXNXTPTR
Indicates which TX FIFO entry is transmitted during the next transfer. The TXNXTPTR field is updated
every time SPI data is transferred from the TX FIFO to the shift register.
7–4 RX FIFO Counter
RXCTR
Indicates the number of entries in the RX FIFO. The RXCTR is decremented every time the POPR is read.
The RXCTR is incremented every time data is transferred from the shift register to the RX FIFO.
3–0 Pop Next Pointer
POPNXTPTR
Contains a pointer to the RX FIFO entry to be returned when the POPR is read. The POPNXTPTR is
updated when the POPR is read.
RSER controls DMA and interrupt requests. Do not write to the RSER while the DSPI is
in the Running state.
Address: Base address + 30h offset
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
RFDF_DIRS
TFFF_DIRS
R 0 0 0 0 0 0 0 0
EOQF_RE
RFOF_RE
RFDF_RE
TFUF_RE
TFFF_RE
TCF_RE
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
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 Interrupt request.
1 DMA request.
15 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
R 0 0
CTCNT
CONT
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
TXDATA
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
000 CTAR0
001 CTAR1
010 Reserved
011 Reserved
100 Reserved
101 Reserved
110 Reserved
111 Reserved
27 End Of Queue
EOQ
Host software uses this bit to signal to the DSPI that the current SPI transfer is the last in a queue. At the
end of the transfer, the EOQF bit in the SR is set.
PUSHR provides the means to write to the TX FIFO. Data written to this register is
transferred to the TX FIFO. Eight- or sixteen-bit write accesses to the Data Field of
PUSHR transfers the 16 bit Data Field of PUSHR to the TX FIFO. The register structure
is different in master and slave modes. The register structure is different in master and
slave modes. In master mode the register provides 16-bit command and data to the TX
FIFO. In slave mode, the 16 bit Command Field of PUSHR is reserved.
Address: Base address + 34h 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 0 TXDATA
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
POPR is used to read the RX FIFO. Eight- or sixteen-bit read accesses to the POPR have
the same effect on the RX FIFO as 32-bit read accesses. A write to this register will
generate a Transfer Error.
Address: Base address + 38h 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 RXDATA
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
TXFRn registers provide visibility into the TX FIFO for debugging purposes. Each
register is an entry in the TX FIFO. The registers are read-only and cannot be modified.
Reading the TXFRx registers does not alter the state of the TX FIFO.
Address: Base address + 3Ch offset + (4d × i), where i=0d to 3d
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 TXCMD_TXDATA TXDATA
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
RXFRn provide visibility into the RX FIFO for debugging purposes. Each register is an
entry in the RX FIFO. The RXFRs are read-only. Reading the RXFRx registers does not
alter the state of the RX FIFO.
Address: Base address + 7Ch offset + (4d × i), where i=0d to 3d
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 RXDATA
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
The DCONF field in the Module Configuration Register (MCR) determines the module
Configuration. SPI configuration is selected when DCONF within SPIx_MCR is 0b00.
The CTARn registers hold clock and transfer attributes. The SPI configuration allows to
select which CTAR to use on a frame by frame basis by setting a field in the SPI
command.
See DSPI Clock and Transfer Attributes Register (In Master Mode) (SPI_CTARn) for
information on the fields of CTAR registers.
Typical master to slave connections are shown in the following figure. When a data
transfer operation is performed, data is serially shifted a predetermined number of bit
positions. Because the modules are linked, data is exchanged between the master and the
slave. The data that was in the master shift register is now in the shift register of the
slave, and vice versa. At the end of a transfer, the TCF bit in the SR is set to indicate a
completed transfer.
DSPI Master DSPI Slave
SIN SOUT
PCSx SS
Generally, more than one slave device can be connected to the module master. Six
Peripheral Chip Select (PCS) signals of the module masters can be used to select which
of the slaves to communicate with. Refer to the chip configuration chapter for the number
of PCS signals used in this MCU.
The SPI configuration share transfer protocol and timing properties which are described
independently of the configuration in Transfer formats . The transfer rate and delay
settings are described in Module baud rate and clock delay generation.
The module stops or transitions from Running to Stopped after the current frame when
any one of the following conditions exist:
• SR[EOQF] bit is set
• MCU in the Debug mode and the MCR[FRZ] bit is set
• MCR[HALT] bit is set
State transitions from Running to Stopped occur on the next frame boundary if a transfer
is in progress, or immediately if no transfers are in progress.
The module ignores attempts to push data to a full TX FIFO, and the state of the TX
FIFO does not change and no error condition is indicated.
NOTE
The clock frequencies mentioned in the preceding table are
given as an example. Refer to the clocking chapter for the
frequency used to drive this module in the device.
NOTE
The clock frequency mentioned in the preceding table is given
as an example. Refer to the clocking chapter for the frequency
used to drive this module in the device.
NOTE
The clock frequency mentioned in the preceding table is given
as an example. Refer to the clocking chapter for the frequency
used to drive this module in the device.
NOTE
The clock frequency mentioned in the preceding table is given
as an example. Refer to the clocking chapter for the frequency
used to drive this module in the device.
When in Non-Continuous Clock mode the tDT delay is configured according to the
equation specified in the CTAR[DT] bitfield description. When in Continuous Clock
mode, the delay is fixed at 1 SCK period.
Even though the bus slave does not control the SCK signal, in Slave mode these values
must be identical to the master device settings to ensure proper transmission. In SPI Slave
mode, only CTAR0 is used.
The module supports four different transfer formats:
• Classic SPI with CPHA=0
• Classic SPI with CPHA=1
• Modified Transfer Format with CPHA = 0
• Modified Transfer Format with CPHA = 1
SCK (CPOL = 0)
SCK (CPOL = 1)
Master SOUT/
Slave SIN
Master SIN/
Slave SOUT
PCSx/SS
MSB first (LSBFE = 0): MSB Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 LSB
MSB first (LSBFE = 1): LSB Bit 1 Bit 2 Bit 3 Bit 4 Bit 5 Bit 6 MSB
tCSC = PCS to SCK delay
tASC = After SCK delay
tDT = Delay after Transfer (Minimum CS idle time)
The master initiates the transfer by placing its first data bit on the SOUT pin and asserting
the appropriate peripheral chip select signals to the slave device. The slave responds by
placing its first data bit on its SOUT pin. After the tASC delay elapses, the master outputs
the first edge of SCK. The master and slave devices use this edge to sample the first input
data bit on their serial data input signals. At the second edge of the SCK, the master and
slave devices place their second data bit on their serial data output signals. For the rest of
the frame the master and the slave sample their SIN pins on the odd-numbered clock
edges and changes the data on their SOUT pins on the even-numbered clock edges. After
the last clock edge occurs, a delay of tASC is inserted before the master negates the PCS
signals. A delay of tDT is inserted before a new frame transfer can be initiated by the
master.
SCK (CPOL = 0)
SCK (CPOL = 1)
Master SOUT/
Slave SIN
Master SIN/
Slave SOUT
PCSx/SS
MSB first (LSBFE = 0): MSB Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 LSB
LSB first (LSBFE = 1): LSB Bit 1 Bit 2 Bit 3 Bit 4 Bit 5 Bit 6 MSB
P
tCSC = CS to SCK delay
tASC = After SCK delay
tDT = Delay after Transfer (minimum CS negation time)
The master initiates the transfer by asserting the PCS signal to the slave. After the tCSC
delay has elapsed, the master generates the first SCK edge and at the same time places
valid data on the master SOUT pin . The slave responds to the first SCK edge by placing
its first data bit on its slave SOUT pin.
At the second edge of the SCK the master and slave sample their SIN pins. For the rest of
the frame the master and the slave change the data on their SOUT pins on the odd-
numbered clock edges and sample their SIN pins on the even-numbered clock edges.
After the last clock edge occurs, a delay of tASC is inserted before the master negates the
PCS signal. A delay of tDT is inserted before a new frame transfer can be initiated by the
master.
When the CONT bit = 0, the module drives the asserted Chip Select signals to their idle
states in between frames. The idle states of the Chip Select signals are selected by the
PCSISn bits in the MCR. The following timing diagram is for two four-bit transfers with
CPHA = 1 and CONT = 0.
SCK (CPOL = 0)
SCK (CPOL = 1)
Master SOUT
Master SIN
PCSx
tCSC t ASC t DT t
CSC
tCSC = PCS to SCK dela
t ASC = After SCK delay
t DT = Delay after Transfer (minimum CS negation time)
When the CONT bit = 1, the PCS signal remains asserted for the duration of the two
transfers. The Delay between Transfers (tDT) is not inserted between the transfers. The
following figure shows the timing diagram for two four-bit transfers with CPHA = 1 and
CONT = 1.
SCK (CPOL = 0)
SCK (CPOL = 1)
Master SOUT
Master SIN
PCS
tCSC
t t
ASC CSC
tCSC = PC S to SCK del ay
t ASC
= After SCK delay
When using the module with continuous selection follow these rules:
• All transmit commands must have the same PCSn bits programming.
• The CTARs, selected by transmit commands, must be programmed with the same
transfer attributes. Only FMSZ field can be programmed differently in these CTARs.
• When transmitting multiple frames in this mode, the user software must ensure that
the last frame has the PUSHR[CONT] bit deasserted in Master mode and the user
software must provide sufficient frames in the TX_FIFO to be sent out in Slave mode
and the master deasserts the PCSn at end of transmission of the last frame.
• The PUSHR[CONT] / DSICR0[DCONT] bits must be deasserted before asserting
MCR[HALT] bit in master mode. This will make sure that the PCSn signals are
deasserted. Asserting MCR[HALT] bit during continuous transfer will cause the
PCSn signals to remain asserted and hence Slave Device cannot transition from
Running to Stopped state.
NOTE
User must fill the TX FIFO with the number of entries that will
be concatenated together under one PCS assertion for both
master and slave before the TX FIFO becomes empty.
When operating in Slave mode, ensure that when the last entry
in the TX FIFO is completely transmitted, that is, the
corresponding TCF flag is asserted and TXFIFO is empty, the
slave is deselected for any further serial communication;
otherwise, an underflow error occurs.
• When the module is in SPI configuration, CTAR0 is used initially. At the start of
each SPI frame transfer, the CTAR specified by the CTAS for the frame is used.
• In all configurations, the currently selected CTAR remains in use until the start of a
frame with a different CTAR specified, or the Continuous SCK mode is terminated.
It is recommended to keep the baud rate the same while using the Continuous SCK.
Switching clock polarity between frames while using Continuous SCK can cause errors
in the transfer. Continuous SCK operation is not guaranteed if the module is put into the
External Stop mode or Module Disable mode.
Enabling Continuous SCK disables the PCS to SCK delay and the Delay after Transfer
(tDT) is fixed to one SCK cycle. The following figure is the timing diagram for
Continuous SCK format with Continuous Selection disabled.
NOTE
In Continuous SCK mode, for the SPI transfer CTAR0 should
always be used, and the TX FIFO must be cleared using the
MCR[CLR_TXF] field before initiating transfer.
SCK (CPOL = 0)
SCK (CPOL = 1)
Master SOUT
Master SIN
PCS
tDT
If the CONT bit in the TX FIFO entry is set, PCS remains asserted between the transfers.
Under certain conditions, SCK can continue with PCS asserted, but with no data being
shifted out of SOUT, that is, SOUT pulled high. This can cause the slave to receive
incorrect data. Those conditions include:
• Continuous SCK with CONT bit set, but no data in the TX FIFO.
• Continuous SCK with CONT bit set and entering Stopped state (refer to Start and
Stop of module transfers).
• Continuous SCK with CONT bit set and entering Stop mode or Module Disable
mode.
The following figure shows timing diagram for Continuous SCK format with Continuous
Selection enabled.
SCK (CPOL = 0)
SCK (CPOL = 1)
Master SOUT
Master SIN
PCS
transfer 1 transfer 2
Each condition has a flag bit in the module Status Register (SR) and a Request Enable bit
in the DMA/Interrupt Request Select and Enable Register (RSER). Certain flags (as
shown in above table) generate interrupt requests or DMA requests depending on
configuration of RSER register.
The module also provides a global interrupt request line, which is asserted when any of
individual interrupt requests lines is asserted.
NOTE
This interrupt request is generated when the last bit of the SPI
frame with EOQ bit set is transmitted.
To clear TFFF when not using DMA, follow these steps for
every PUSH performed using CPU to fill TX FIFO:
1. Wait until TFFF = 1.
2. Write data to PUSHR using CPU.
3. Clear TFFF by writing a 1 to its location. If TX FIFO is not
full, this flag will not clear.
Depending on the state of the ROOE bit in the MCR, the data from the transfer that
generated the overflow is either ignored or shifted in to the shift register. If the ROOE bit
is set, the incoming data is shifted in to the shift register. If the ROOE bit is cleared, the
incoming data is ignored.
Register does not change the state of the TX FIFO. Clearing either of the FIFOs has no
effect in the Module Disable mode. Changes to the DIS_TXF and DIS_RXF fields of the
MCR have no effect in the Module Disable mode. In the Module Disable mode, all status
bits and register flags in the module return the correct values when read, but writing to
them has no effect. Writing to the TCR during Module Disable mode has no effect.
Interrupt and DMA request signals cannot be cleared while in the Module Disable mode.
10. Enable DMA channel by enabling the DMA enable request for the DMA channel
assigned to the module TX FIFO, and RX FIFO by setting the corresponding DMA
set enable request bit.
11. Enable serial transmission and serial reception of data by clearing the EOQF bit.
Transmit Next
TX FIFO Base - Data Pointer
-
Entry A (first in)
Entry B
Entry C
Entry D (last in)
-
-
+1 TX FIFO Counter -1
46.5.6.1 Address Calculation for the First-in Entry and Last-in Entry
in the TX FIFO
The memory address of the first-in entry in the TX FIFO is computed by the following
equation:
The memory address of the last-in entry in the TX FIFO is computed by the following
equation:
46.5.6.2 Address Calculation for the First-in Entry and Last-in Entry
in the RX FIFO
The memory address of the first-in entry in the RX FIFO is computed by the following
equation:
The memory address of the last-in entry in the RX FIFO is computed by the following
equation:
47.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
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.
47.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 47-1. I2C Functional block diagram
This section describes in detail all I2C registers accessible to the end user.
Read 0
AD[7:1]
Write
Reset 0 0 0 0 0 0 0 0
00 mul = 1
01 mul = 2
10 mul = 4
11 Reserved
5–0 ClockRate
ICR
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 kbps.
Table continues on the next page...
Read 0
IICEN IICIE MST TX TXAK WUEN DMAEN
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
Table continues on the next page...
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).
2 Repeat START
RSTA
Writing a one to this bit generates a repeated START condition provided it is the current master. This bit
will always be read as zero. Attempting a repeat at the wrong time results in loss of arbitration.
1 Wakeup Enable
WUEN
The I2C module can wake the MCU from low power mode with no peripheral bus running when slave
address matching occurs.
0 Normal operation. No interrupt generated when address matching in low power mode.
1 Enables the wakeup function in low power mode.
0 DMA Enable
DMAEN
The DMAEN bit enables or disables the DMA function.
If any address matching occurs, IAAS and TCF are set. If the direction of transfer is known from
master to slave, then it is not required to check the SRW. With this assumption, DMA can also be
used in this case. In other cases, if the master reads data from the slave, then it is required to rewrite
the C1 register operation. With this assumption, DMA cannot be used.
When FACK = 1, an address or a data byte is transmitted.
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.
0 Not addressed
1 Addressed as a slave
5 Bus Busy
BUSY
Indicates the status of the bus regardless of slave or master mode. This bit is set when a START signal is
detected and cleared when a STOP signal is detected.
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.
0 No interrupt pending
1 Interrupt pending
0 Receive Acknowledge
RXAK
0 Acknowledge signal was received after the completion of one byte of data transmission on the bus
1 No acknowledge signal detected
0 Disabled
1 Enabled
6 Address Extension
ADEXT
Controls the number of bits used for the slave address.
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.
2–0 Slave Address
AD[10:8]
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.
Read 0
Reserved FLT
Write
Reset 0 0 0 0 0 0 0 0
00h No filter/bypass
01-1Fh Filter glitches up to width of n bus clock cycles, where n=1-31d
Read 0
RAD
Write
Reset 0 0 0 0 0 0 0 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.
Read 0
SAD
Write
Reset 1 1 0 0 0 0 1 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
47.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 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.
47.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.
47.4.5 Resets
The I2C module is disabled after a reset. The I2C module cannot cause a core reset.
47.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 47-44. 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
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
occurs within the number of clock cycles programmed in this register is ignored by the
I2C module. The programmer must specify the size of the glitch (in terms of bus clock
cycles) for the filter to absorb and not pass.
SCL, SDA
Noise internal signals
suppress
circuits
SCL, SDA
external signals
DFF DFF DFF DFF
NOTE
Before the last byte of master receive mode, TXAK must be set
to send a NACK after the last byte’s transfer. Therefore, the
DMA must be disabled before the last byte’s transfer.
NOTE
In 10-bit address mode transmission, the addresses to send
occupy 2-3 bytes. During this transfer period, the DMA must be
disabled because the C1 register is written to send a repeat start
or to change the transfer direction.
The routine shown in the following figure can handle 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.
48.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The UART allows asynchronous serial communication with peripheral devices and
CPUs.
48.1.1 Features
The UART includes the following features:
• Full-duplex operation
• Standard mark/space non-return-to-zero (NRZ) format
• Selectable IrDA 1.4 return-to-zero-inverted (RZI) format with programmable pulse
width
• 13-bit baud rate selection with /32 fractional divide, based on the module clock
frequency
• Programmable 8-bit or 9-bit data format
• Separately enabled transmitter and receiver
• Programmable transmitter output polarity
• Programmable receive input polarity
• 13-bit break character option
C1[UARTSWAI] does not initiate any power down or power up procedures for the
ISO-7816 smartcard interface.
Setting C1[UARTSWAI] does not affect the state of the C2[RE] or C2[TE].
If C1[UARTSWAI] is set, any ongoing transmission or reception stops at the Wait mode
entry. The transmission or reception resumes when either an internal or external interrupt
brings the CPU out of Wait mode. Bringing the CPU out of Wait mode by reset aborts
any ongoing transmission or reception and resets the UART.
Read 0
LBKDIE RXEDGIE SBR
Write
Reset 0 0 0 0 0 0 0 0
NOTE: • The baud rate generator is disabled until C2[TE] or C2[RE] is set for the first time after
reset.The baud rate generator is disabled when SBR = 0.
• Writing to BDH has no effect without writing to BDL, because writing to BDH puts the data
in a temporary location until BDL is written.
NOTE: • The baud rate generator is disabled until C2[TE] or C2[RE] is set for the first time after
reset.The baud rate generator is disabled when SBR = 0.
• Writing to BDH has no effect without writing to BDL, because writing to BDH puts the data
in a temporary location until BDL is written.
• When the 1/32 narrow pulse width is selected for infrared (IrDA), the baud rate fields must
be even, the least significant bit is 0. See MODEM register for more details.
0 Normal operation.
1 Loop mode where transmitter output is internally connected to receiver input. The receiver input is
determined by RSRC.
6 UART Stops in Wait Mode
UARTSWAI
0 UART clock continues to run in Wait mode.
1 UART clock freezes while CPU is in Wait mode.
5 Receiver Source Select
RSRC
This field has no meaning or effect unless the LOOPS field is set. When LOOPS is set, the RSRC field
determines the source for the receiver shift register input.
0 Selects internal loop back mode. The receiver input is internally connected to transmitter output.
1 Single wire UART mode where the receiver input is connected to the transmit pin input signal.
4 9-bit or 8-bit Mode Select
M
This field must be set when C7816[ISO_7816E] is set/enabled.
0 Even parity.
1 Odd parity.
NOTE: If C2[TIE] and C5[TDMAS] are both set, then TCIE must be cleared, and D[D] must not be written
unless servicing a DMA request.
0 Transmitter off.
1 Transmitter on.
2 Receiver Enable
RE
Enables the UART receiver.
0 Receiver off.
1 Receiver on.
1 Receiver Wakeup Control
RWU
This field can be set to place the UART receiver in a standby state. RWU automatically clears when an
RWU event occurs, that is, an IDLE event when C1[WAKE] is clear or an address match when C1[WAKE]
is set. This field must be cleared when C7816[ISO_7816E] is set.
NOTE: RWU must be set only with C1[WAKE] = 0 (wakeup on idle) if the channel is currently not idle.
This can be determined by S2[RAF]. If the flag is set to wake up an IDLE event and the channel
is already idle, it is possible that the UART will discard data. This is because the data must be
received or a LIN break detected after an IDLE is detected before IDLE is allowed to reasserted.
0 Normal operation.
1 RWU enables the wakeup function and inhibits further receiver interrupt requests. Normally, hardware
wakes the receiver by automatically clearing RWU.
0 Send Break
SBK
Toggling SBK sends one break character from the following: See for the number of logic 0s for the
different configurations. Toggling implies clearing the SBK field before the break character has finished
Table continues on the next page...
Write
Reset 1 1 0 0 0 0 0 0
0 The amount of data in the transmit buffer is greater than the value indicated by TWFIFO[TXWATER].
1 The amount of data in the transmit buffer is less than or equal to the value indicated by
TWFIFO[TXWATER] at some point in time since the flag has been cleared.
6 Transmit Complete Flag
TC
TC is cleared when there is a transmission in progress or when a preamble or break character is loaded.
TC is set when the transmit buffer is empty and no data, preamble, or break character is being
transmitted. When TC is set, the transmit data output signal becomes idle (logic 1). TC is cleared by
reading S1 with TC set and then doing one of the following: When C7816[ISO_7816E] is set/enabled, this
field is set after any NACK signal has been received, but prior to any corresponding guard times
expiring.When C6[EN709] is set/enabled, this flag is not set on transmit packet completion.
• Writing to D to transmit new data.
• Queuing a preamble by clearing and then setting C2[TE].
• Queuing a break character by writing 1 to SBK in C2.
0 The number of datawords in the receive buffer is less than the number indicated by RXWATER.
1 The number of datawords in the receive buffer is equal to or greater than the number indicated by
RXWATER at some point in time since this flag was last cleared.
4 Idle Line Flag
IDLE After the IDLE flag is cleared, a frame must be received (although not necessarily stored in the data buffer,
for example if C2[RWU] is set), or a LIN break character must set the S2[LBKDIF] flag before an idle
condition can set the IDLE flag. To clear IDLE, read UART status S1 with IDLE set and then read D.
IDLE is set when either of the following appear on the receiver input:
• 10 consecutive logic 1s if C1[M] = 0
• 11 consecutive logic 1s if C1[M] = 1 and C4[M10] = 0
• 12 consecutive logic 1s if C1[M] = 1, C4[M10] = 1, and C1[PE] = 1
Idle detection is not supported when7816Eor EN709is set/enabled and hence this flag is ignored.
NOTE: When RWU is set and WAKE is cleared, an idle line condition sets the IDLE flag if RWUID is set,
else the IDLE flag does not become set.
Table continues on the next page...
0 No overrun has occurred since the last time the flag was cleared.
1 Overrun has occurred or the overrun flag has not been cleared since the last overrun occured.
2 Noise Flag
NF
NF is set when the UART detects noise on the receiver input. NF does not become set in the case of an
overrun or while the LIN break detect feature is enabled (S2[LBKDE] = 1). When NF is set, it indicates
only that a dataword has been received with noise since the last time it was cleared. There is no
guarantee that the first dataword read from the receive buffer has noise or that there is only one dataword
in the buffer that was received with noise unless the receive buffer has a depth of one. To clear NF, read
S1 and then read D. When EN709 is set/enabled, noise flag is not set.
0 No noise detected since the last time this flag was cleared. If the receive buffer has a depth greater
than 1 then there may be data in the receiver buffer that was received with noise.
1 At least one dataword was received with noise detected since the last time the flag was cleared.
1 Framing Error Flag
FE
FE is set when a logic 0 is accepted as the stop bit. FE does not set in the case of an overrun or while the
LIN break detect feature is enabled (S2[LBKDE] = 1). FE inhibits further data reception until it is cleared.
To clear FE, read S1 with FE set and then read D. The last data in the receive buffer represents the data
that was received with the frame error enabled. Framing errors are not supported when 7816E is set/
enabled. However, if this flag is set, data is still not received in 7816 mode.Framing errors are not
supported in 709 mode.
0 No parity error detected since the last time this flag was cleared. If the receive buffer has a depth
greater than 1, then there may be data in the receive buffer what was received with a parity error.
1 At least one dataword was received with a parity error since the last time this flag was cleared.
Read RAF
LBKDIF RXEDGIF MSBF RXINV RWUID BRK13 LBKDE
Write
Reset 0 0 0 0 0 0 0 0
NOTE: The active edge is detected only in two wire mode and on receiving data coming from the RxD
pin.
NOTE: Setting RXINV inverts the RxD input for data bits, start and stop bits, break, and idle. When
C7816[ISO7816E] is set/enabled, only the data bits and the parity bit are inverted.
Read R8
T8 TXDIR TXINV ORIE NEIE FEIE PEIE
Write
Reset 0 0 0 0 0 0 0 0
NOTE: If the value of T8 is the same as in the previous transmission, T8 does not have to be rewritten.
The same value is transmitted until T8 is rewritten.
5 Transmitter Pin Data Direction in Single-Wire mode
TXDIR
Determines whether the TXD pin is used as an input or output in the single-wire mode of operation. This
field is relevant only to the single wire mode. When C7816[ISO7816E] is set/enabled and C7816[TTYPE]
= 1, this field is automatically cleared after the requested block is transmitted. This condition is detected
when TL7816[TLEN] = 0 and 4 additional characters are transmitted. Additionally, if C7816[ISO7816E] is
set/enabled and C7816[TTYPE] = 0 and a NACK is being transmitted, the hardware automatically
overrides this field as needed. In this situation, TXDIR does not reflect the temporary state associated with
the NACK.
NOTE: Setting TXINV inverts all transmitted values, including idle, break, start, and stop bits. In loop
mode, if TXINV is set, the receiver gets the transmit inversion bit when RXINV is disabled. When
C7816[ISO7816E] is set/enabled then only the transmitted data bits and parity bit are inverted.
Read 0 0
TDMAS RDMAS
Write
Reset 0 0 0 0 0 0 0 0
NOTE: • If C2[TIE] is cleared, TDRE DMA and TDRE interrupt request signals are not asserted
when the TDRE flag is set, regardless of the state of TDMAS.
• If C2[TIE] and TDMAS are both set, then C2[TCIE] must be cleared, and D must not be
written unless a DMA request is being serviced.
0 If C2[TIE] is set and the S1[TDRE] flag is set, the TDRE interrupt request signal is asserted to request
interrupt service.
1 If C2[TIE] is set and the S1[TDRE] flag is set, the TDRE DMA request signal is asserted to request a
DMA transfer.
6 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
5 Receiver Full DMA Select
RDMAS
Configures the receiver data register full flag, S1[RDRF], to generate interrupt or DMA requests if C2[RIE]
is set.
NOTE: If C2[RIE] is cleared, and S1[RDRF] is set, the RDRF DMA and RDFR interrupt request signals
are not asserted, regardless of the state of RDMAS.
Table continues on the next page...
0 IR disabled.
1 IR enabled.
1–0 Transmitter narrow pulse
TNP
Enables whether the UART transmits a 1/16, 3/16, 1/32, or 1/4 narrow pulse.
00 3/16.
01 1/16.
10 1/32.
11 1/4.
* Notes:
• TXFIFOSIZE field: The reset value depends on whether the specific UART instance supports the FIFO and on the size of
that FIFO. See the Chip Configuration details for more information on the FIFO size supported for each
UART instance.
• RXFIFOSIZE field: The reset value depends on whether the specific UART instance supports the FIFO and on the size of
that FIFO. See the Chip Configuration details for more information on the FIFO size supported for each
UART instance.
Read 0 0 0
RXOFE TXOFE RXUFE
Write TXFLUSH RXFLUSH
Reset 0 0 0 0 0 0 0 0
0 No receive buffer overflow has occurred since the last time the flag was cleared.
1 At least one receive buffer overflow has occurred since the last time the flag was cleared.
1 Transmitter Buffer Overflow Flag
TXOF
Indicates that more data has been written to the transmit buffer than it can hold. This field will assert
regardless of the value of CFIFO[TXOFE]. However, an interrupt will be issued to the host only if
CFIFO[TXOFE] is set. This flag is cleared by writing a 1.
0 No transmit buffer overflow has occurred since the last time the flag was cleared.
1 At least one transmit buffer overflow has occurred since the last time the flag was cleared.
0 Receiver Buffer Underflow Flag
RXUF
Indicates that more data has been read from the receive buffer than was present. This field will assert
regardless of the value of CFIFO[RXUFE]. However, an interrupt will be issued to the host only if
CFIFO[RXUFE] is set. This flag is cleared by writing a 1.
0 No receive buffer underflow has occurred since the last time the flag was cleared.
1 At least one receive buffer underflow has occurred since the last time the flag was cleared.
Read TXCOUNT
Write
Reset 0 0 0 0 0 0 0 0
Read RXCOUNT
Write
Reset 0 0 0 0 0 0 0 0
0 The received data does not generate a NACK when the receipt of the data results in an overflow
event.
1 If the receiver buffer overflows, a NACK is automatically sent on a received character.
3 Generate NACK on Error
ANACK
When this field is set, the receiver automatically generates a NACK response if a parity error occurs or if
INIT is set and an invalid initial character is detected. A NACK is generated only if TTYPE = 0. If ANACK is
set, the UART attempts to retransmit the data indefinitely. To stop retransmission attempts, clear C2[TE]
or ISO_7816E and do not set until S1[TC] sets C2[TE] again.
0 Normal operating mode. Receiver does not seek to identify initial character.
1 Receiver searches for initial character.
1 Transfer Type
TTYPE
Indicates the transfer protocol being used.
See ISO-7816 / smartcard support for more details.
NOTE: This field must be modified only when no transmit or receive is occurring. If this field is changed
during a data transfer, the data being transmitted or received may be transferred incorrectly.
Read 0
WTE CWTE BWTE INITDE GTVE TXTE RXTE
Write
Reset 0 0 0 0 0 0 0 0
Read 0
WT CWT BWT INITD GTV TXT RXT
Write
Reset 0 0 0 0 0 0 0 0
0 The number of retries and corresponding NACKS does not exceed the value in
ET7816[TXTHRESHOLD].
1 The number of retries and corresponding NACKS exceeds the value in ET7816[TXTHRESHOLD].
0 Receive Threshold Exceeded Interrupt
RXT
Indicates that there are more than ET7816[RXTHRESHOLD] consecutive NACKS generated in response
to parity errors on received data. This flag requires ANACK to be set. Additionally, this flag asserts only
when C7816[TTYPE] = 0. Clearing this field also resets the counter keeping track of consecutive NACKS.
The UART will continue to attempt to receive data regardless of whether this flag is set. If 7816E is
cleared/disabled, RE is cleared/disabled, C7816[TTYPE] = 1, or packet is received without needing to
issue a NACK, the internal NACK detection counter is cleared and the count restarts from zero on the next
transmitted NACK. This interrupt is cleared by writing 1.
0 The number of consecutive NACKS generated as a result of parity errors and buffer overruns is less
than or equal to the value in ET7816[RXTHRESHOLD].
1 The number of consecutive NACKS generated as a result of parity errors and buffer overruns is
greater than the value in ET7816[RXTHRESHOLD].
Read 0
EN709 TX709 CE CP
Write
Reset 0 0 0 0 0 0 0 0
0 CEA709.1-B is disabled.
1 CEA709.1-B is enabled
6 CEA709.1-B Transmit Enable
TX709
Starts CEA709.1-B transmission.
NOTE: The minimum preamble length supported by twisted pair wire is four bit-sync fields.
0 Interrupt is disabled.
1 Interrupt is enabled.
5 Initial Sync Detection Interrupt Enable
ISDIE
Interrupt enable for initial synchronization detection flag.
Table continues on the next page...
0 Interrupt is disabled.
1 Interrupt is enabled.
4 Packet Received Interrupt Enable
PRXIE
Interrupt enable for packet received flag.
0 Interrupt is disabled.
1 Interrupt is enabled.
3 Packet Transmitted Interrupt Enable
PTXIE
Interrupt enable for packet transmitted flag.
0 Interrupt is disabled.
1 Interrupt is enabled.
2 Packet Cycle Timer Interrupt Enable
PCTEIE
Interrupt enable for packet cycle time expired flag.
0 Interrupt is disabled.
1 Interrupt is enabled.
1 Preamble Start Interrupt Enable
PSIE
Interrupt enable for preamble start flag.
0 Interrupt is disabled.
1 Interrupt is enabled.
0 Transmission Fail Interrupt Enable
TXFIE
Interrupt enable for transmission fail flag.
0 Interrupt is disabled.
1 Interrupt is enabled.
Read ISD
PEF WBEF PRXF PTXF PCTEF PSF TXFF
Write
Reset 0 0 0 0 0 0 0 0
0 Preamble is correct.
1 Preamble has an error.
6 Wbase Expired Flag
WBEF
Indicates that the Wbase time period has expired after beta1 time slots. This flag is cleared by writing 1.
Read 0 INITF
CDET ILCV FE
Write
Reset 0 0 0 0 0 0 0 0
00 No collision.
01 Collision occurred during preamble.
10 Collision occurred during data.
11 Collision occurred during line code violation.
1 Improper Line Code Violation
ILCV
Indicates that line code violation received is not proper. This flag is cleared by writing 1.
Read RPL
Write
Reset 0 0 0 0 0 0 0 0
Read RPREL
Write
Reset 0 0 0 0 0 0 0 0
48.4.1 CEA709.1-B
The UART provides support for CEA709.1-B, which is commonly used in building
automation, home networking, including all key building automation subsystems such as
heating, ventilating, airconditioning, lighting, security, fire detection, access control, and
energy monitoring.
1 1 0 1 1 0 1 0
Transmitter Enable
A logic zero is indicated with the presence of a transition in the middle of the bit period
and a logic one is indicated by the absence of any transition. When transitions occur at
the start of the bit time, polarity is arbitrary because the last bit of a transmission has no
trailing clock edge. A transmitter will transmit a preamble at the beginning of a packet to
allow other nodes to synchronize their receiver clocks. The preamble comprises a bit-
sync field followed by a byte-sync field. The bit-sync field is a series of differential
Manchester logic ones and the byte-sync field is a single differential Manchester logic
zero. The byte-sync field marks the end of the preamble and the start of the data field
(MPDU/LPDU).
The transmitter terminates the packet by forcing the data output to be transitionless long
enough for the receiver to recognize an invalid bit code. This signals the end of the
packet. At the end of the packet transmission, the line must remain transitionless for three
bit periods after the final clock transition.
The UART is responsible for providing the BitSync and ByteSync fields of the PPDU
illustrated below. The layer two software manages all other encapsulating fields and
provides these to the UART as part of the packet to be transmitted.
Bit Sync Byte Sync Priority Alt Path Delta BL NPDU CRC
Packet 1 2 1 2 w Packet
Priority Randomizing
slots w i ndow
Each node must maintain an estimation of the current channel backlog. Backlog
calculation is managed by the layer two software. Initially, the backlog is set to one. The
backlog is incremented on transmission by a value indicated in the frames backlog
increment field.
The backlog decrements under the following conditions:
• On waiting to transmit: If Wbase randomizing slots go by without channel activity.
• On receive: If a packet is received with a backlog increment of 0.
• On transmit: If a packet is transmitted with a backlog increment of 0.
• On idle: If a packet cycle time expires without channel activity.
The following actions need to be completed when a frame is received to prepare an
outgoing message for transmission after the channel becomes idle:
• CRC of incoming message needs to be verified by software.
• If the CRC is good, the BL is recalculated, otherwise BL remains the same.
• Transmit delay (secondary delay timer) is calculated and supplied to UART.
4. If a single noise event occurs, and it is possible to uniquely identify the noise event,
then resynchronization takes place.
Starting at sample 15 of the previous time bit period, five data samples are collected. The
number and location of the samples are key to decide if an adjustment in time base is
required. Table below lists the possible values and the actions associated with each
possibility. In the table, S means the data is the same as the logical value that was
received in the second half of the previous bit period. D means that the sample is
different from the logical value that was received in the second half of the previous bit
period.
Sample Values (15,16,1,2,3) Action / Event
SSSSS No start of bit transition is detected. Therefore, no adjustment
to time base is made.
SSSSD Two or more error events occurred or the time base was off.
In this case, the time base is slowed down by two. Sample 3
becomes sample 1. The next sample is treated as sample 2.
SSSDS Two or more error events occurred, time base was off along
with noise occurrence, or sample 2 is noise and there is no
start of bit transition. Therefore, no adjustment to time base is
made.
SSSDD It is possible that either noise was received during sample 1
or the time base needs shifting. In this case, the time base is
slowed down by one. Sample 2 becomes sample 1, and
sample 3 becomes sample 2. The next sample is treated as
sample 3.
SSDSS It is most likely that sample 1 is noise and there is no start of
bit transition. Therefore, no adjustment to time base is made.
SSDSD It is possible that sample 1 is noise, and time base needs
shifting by two, or that sample 2 is noise. It is more likely that
sample 2 is noise and therefore no adjustment to time base is
made.
SSDDS It is most likely that sample 3 is noise. Therefore, no
adjustment to time base is made.
SSDDD This is the expected case. Therefore, no adjustment to time
base is made.
SDSSS It is most likely that sample 16 is noise and there is no start of
bit transition. Therefore, no adjustment to time base is made.
SDSSD Either multiple errors occurred or sample 16 is noise and time
base is off by two. In this case, the time base is slowed down
by two. Sample 3 becomes sample 1. The next sample is
treated as sample 2.
SDSDS In this case, multiple errors have occurred. Therefore, no
adjustment to time base is made.
SDSDD In this case, there must either be multiple noise or one noise
at sample 16 or sample 1 with a time shift. Assuming that one
noise occurred, it is unclear what direction the time shift is.
Therefore, no adjustment to time base is made.
PREAMBLE PREAMBLE
QUALIFICATION VERIFICATION
RT CLOCK
RT4
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT1
RT2
RT3
RT5
RT6
RT7
RT8
RT9
RT10
RT11
RT12
RT13
RT14
RT15
RT16
RT1
RT2
RT3
RT4
RT CLOCK COUNT
RESET RT CLOCK
To verify the start bit and to detect noise, data recovery logic takes samples at RT3, RT5,
and RT7. The following table summarizes the results of the preamble verification
samples.
Table 48-298. Preamble/ Data bit verification
RT3, RT5, and RT7 samples Preamble verification
000 Yes
001 Yes
010 Yes
011 No
100 Yes
101 No
110 No
111 No
If preamble verification is not successful, the RT clock is reset and a new search for a
preamble begins.
To determine the value of a data bit, recovery logic takes samples at RT11, RT12, and
RT13. The following table summarizes the results of the data bit samples. If the majority
of RT11, RT12, and RT13 samples is the same as the majority of RT3, RT5, and RT7
samples, then the data bit detected is 1, else the data bit detected is 0.
Table 48-299. Data bit recovery
RT11, RT12, and RT13 samples Data bit determination
000 0
001 0
010 0
011 1
100 0
101 1
110 1
111 1
To signify the end of a data packet, the transmitter causes a line-code violation to occur,
that is, the transmitter remains transitionless for at least 3-bit periods after the final clock
transition, excluding the final data transition, if it exists. The receiver detects this
violation. For the purpose of detecting a line-code violation, the receiver monitors the
channel to locate a series of five or six back-to-back half bit periods.
4. If a valid edge is not identified before the delay time expires, and data is queued to be
transmitted, the UART considers itself synchronized, and starts the preamble
process.
5. If a valid edge is not identified before the delay time expires, and data is not queued
to be transmitted, the UART continues attempting to locate a valid edge using the
same process, and receives the incoming data packet like in step 3.
pct expired
RESET
lonen &!INITF
INITF = 1’b1
INIT
TX done
INIT DETECT
TX
Preamble Start
WAIT1
Beta1 Expired
RX LCV end detect
preamble completes, the preamble started interrupt is asserted when the UART starts
transmitting the preamble.
NOTE
If the data buffer does not contain at least one byte of valid data
and the transmit packet length register has been updated prior to
the preamble completing, an underflow event will occur and
TXEN is deasserted. The packet is terminated by transmitting
line code violation.
TX packet
ipp_ind_collision
collision flag
01 00 02 00 01
The collision signal is asynchronous to the ipg clk, therefore the collision pulse of width
exactly equal to CPW may not be detected correctly due to synchronization issue. The
collision pulse visible to design may be decreased by one peripheral clock cycle due to
the asynchronous nature of the collision pulse.
48.4.2 Transmitter
INTERNAL BUS
MODULE
BAUDRATE GENERATE UART DATA REGISTER (UART_D)
CLOCK
RTS_B
SBR12:0 BRFA4:0
START
R485 CONTROL
STOP
VARIABLE 12-BIT TRANSMIT CTS_B
M10 SHIFT REGISTER
M
TXINV
SHIFT DIRECTION
MSBF
DMA Done
TXDIR
SBK
TE
TxD
7816 LOGIC
DMA Requests
IRQ / DMA
LOGIC IRQ Requests
INFRARED LOGIC TxD
LOOP
CONTROL
LOOPS
RSRC
received. If a NACK is received, the transmitter resends the data, assuming that the
number of retries for that character, that is, the number of NACKs received, is less than
or equal to the value in ET7816[TXTHRESHOLD].
Hardware supports odd or even parity. When parity is enabled, the bit immediately
preceding the stop bit is the parity bit.
When the transmit shift register is not transmitting a frame, the transmit data output
signal goes to the idle condition, logic 1. If at any time software clears C2[TE], the
transmitter enable signal goes low and the transmit signal goes idle.
If the software clears C2[TE] while a transmission is in progress, the character in the
transmit shift register continues to shift out, provided S1[TC] was cleared during the data
write sequence. To clear S1[TC], the S1 register must be read followed by a write to D
register.
If S1[TC] is cleared during character transmission and C2[TE] is cleared, the
transmission enable signal is deasserted at the completion of the current frame. Following
this, the transmit data out signal enters the idle state even if there is data pending in the
UART transmit data buffer. To ensure that all the data written in the FIFO is transmitted
on the link before clearing C2[TE], wait for S1[TC] to set. Alternatively, the same can be
achieved by setting TWFIFO[TXWATER] to 0x0 and waiting for S1[TDRE] to set.
As long as C2[SBK] is set, the transmitter logic continuously loads break characters into
the transmit shift register. After the software clears C2[SBK], the shift register finishes
transmitting the last break character and then transmits at least one logic 1. The automatic
logic 1 at the end of a break character guarantees the recognition of the start bit of the
next character. Break bits are not supported when C7816[ISO_7816E] is set/enabled.
NOTE
When queuing a break character, it will be transmitted
following the completion of the data value currently being
shifted out from the shift register. This means that, if data is
queued in the data buffer to be transmitted, the break character
preempts that queued data. The queued data is then transmitted
after the break character is complete.
C1 in transmission
1
TXD C1 C2 C3 Break C4 C5
data
buffer
write C1 C2 C3 C4 Start Stop C5
Break Break
CTS_B
RTS_B
1. Cn = transmit characters
Figure 48-295. Transmitter RTS and CTS timing diagram
48.4.3 Receiver
INTERNAL BUS
MODULE BAUDRATE
START
CLOCK GENERATOR VARIABLE 12-BIT RECEIVE M
STOP
SHIFT REGISTER M10
LBKDE
RE RECEIVE MSBF
RAF CONTROL
RXINV
SHIFT DIRECTION
RxD
LOOPS
RECEIVER
RSRC SOURCE
CONTROL PE PARITY WAKEUP
PT LOGIC LOGIC
From Transmitter
To TxD
7816 LOGIC
INFRARED LOGIC
has no stop bit. S1[FE] is set at the same time that received data is placed in the receive
data buffer. Framing errors are not supported when C7816[ISO7816E] is set/enabled.
However, if S1[FE] is set, data will not be received when C7816[ISO7816E] is set.
The detection threshold for a break character can be adjusted when using an internal
oscillator in a LIN system by setting S2[LBKDE]. The UART break character detection
threshold depends on C1[M], C1[PE], C4[LBKDE], and C4[M10]. See the following
table.
Table 48-301. Receive break character detection threshold
LBKDE M M10 PE Threshold (bits)
0 0 — — 10
0 1 0 — 11
0 1 1 0 11
0 1 1 1 12
1 0 — — 11
1 1 — — 12
While C4[LBKDE] is set, it will have these effects on the UART registers:
• Prevents S1[RDRF], S1[FE], S1[NF], and S1[PF] from being set. However, if they
are already set, they will remain set.
• Sets the LIN break detect interrupt flag, S2[LBKDIF], if a LIN break character is
received.
1
RXD C1 C2 C3 C4
S1[RDRF]
Status
Register 1
C1 C3
read
data
buffer
C1 C2 C3
read
RTS_B
RT8, RT9, and RT10 samples are not all the same logical values. A framing error will
occur if the receiver clock is misaligned in such a way that the majority of the RT8, RT9,
and RT10 stop bit samples are a logic 0.
As the receiver samples an incoming frame, it resynchronizes the RT clock on any valid
falling edge within the frame. Resynchronization within frames corrects a misalignment
between transmitter bit times and receiver bit times.
MSB STOP
RECEIVER
RT CLOCK
RT11
RT13
RT14
RT15
RT16
RT10
RT12
RT1
RT2
RT3
RT4
RT5
RT6
RT7
RT8
RT9
DATA
SAMPLES
For an 8-bit data character, data sampling of the stop bit takes the receiver 154 RT cycles
(9 bit times × 16 RT cycles + 10 RT cycles).
With the misaligned character shown in the Figure 48-298, the receiver counts 154 RT
cycles at the point when the count of the transmitting device is 147 RT cycles (9 bit times
× 16 RT cycles + 3 RT cycles).
The maximum percent difference between the receiver count and the transmitter count of
a slow 8-bit data character with no errors is:
((154 − 147) ÷ 154) × 100 = 4.54%
For a 9-bit data character, data sampling of the stop bit takes the receiver 170 RT cycles
(10 bit times × 16 RT cycles + 10 RT cycles).
With the misaligned character shown in the Figure 48-298, the receiver counts 170 RT
cycles at the point when the count of the transmitting device is 163 RT cycles (10 bit
times × 16 RT cycles + 3 RT cycles).
The maximum percent difference between the receiver count and the transmitter count of
a slow 9-bit character with no errors is:
((170 − 163) ÷ 170) × 100 = 4.12%
RECEIVER
RT CLOCK
RT11
RT13
RT14
RT15
RT16
RT10
RT12
RT1
RT2
RT3
RT4
RT5
RT6
RT7
RT8
RT9
DATA
SAMPLES
For an 8-bit data character, data sampling of the stop bit takes the receiver 154 RT cycles
(9 bit times × 16 RT cycles + 10 RT cycles).
With the misaligned character shown in the Figure 48-299, the receiver counts 154 RT
cycles at the point when the count of the transmitting device is 160 RT cycles (10 bit
times × 16 RT cycles).
The maximum percent difference between the receiver count and the transmitter count of
a fast 8-bit character with no errors is:
((154 − 160) ÷ 154) × 100 = 3.90%
For a 9-bit data character, data sampling of the stop bit takes the receiver 170 RT cycles
(10 bit times × 16 RT cycles + 10 RT cycles).
With the misaligned character shown in the Figure 48-299, the receiver counts 170 RT
cycles at the point when the count of the transmitting device is 176 RT cycles (11 bit
times × 16 RT cycles).
The maximum percent difference between the receiver count and the transmitter count of
a fast 9-bit character with no errors is:
((170 − 176) ÷ 170) × 100 = 3.53%
The Table 48-302 lists the available baud divisor fine adjust values.
K20 Sub-Family Reference Manual, Rev. 1.1, Dec 2012
Freescale Semiconductor, Inc. 1345
Functional description
1. The address bit identifies the frame as an address character. See Receiver wakeup.
Note
Unless in 9-bit mode with M10 set, do not use address mark
wakeup with parity enabled.
Figure 48-302. Seven bits of data with LSB first and parity
START START
BIT BIT 6 BIT 5 BIT 4 BIT 3 BIT 2 BIT 1 BIT 0 PARITY STOP BIT
BIT
Figure 48-303. Seven bits of data with MSB first and parity
Figure 48-306. Eight bits of data with LSB first and parity
START START
BIT BIT 7 BIT 6 BIT 5 BIT 4 BIT 3 BIT 2 BIT 1 BIT 0 PARITY STOP BIT
BIT
Figure 48-307. Eight bits of data with MSB first and parity
Figure 48-308. Nine bits of data with LSB first and parity
ADDRESS
MARK
START START
BIT BIT 8 BIT 7 BIT 6 BIT 5 BIT 4 BIT 3 BIT 2 BIT 1 BIT 0 PARITY STOP BIT
BIT
Figure 48-309. Nine bits of data with MSB first and parity
Tx pin output
TRANSMITTER
Tx pin input
RECEIVER
RXD
RXINV
Enable single wire operation by setting C1[LOOPS] and the receiver source field,
C1[RSRC]. Setting C1[LOOPS] disables the path from the unsynchronized receiver input
signal to the receiver. Setting C1[RSRC] connects the receiver input to the output of the
TXD pin driver. Both the transmitter and receiver must be enabled (C2[TE] = 1 and
C2[RE] = 1). When C7816[ISO_7816EN] is set, it is not required that both C2[TE] and
C2[RE] are set.
RECEIVER
RXD
RXINV
takes to transmit or receive a single bit. For example, a standard 7816 packet, excluding
any guard time or NACK elements is 10 ETUs (start bit, 8 data bits, and a parity bit).
Guard times and wait times are also measured in ETUs.,
NOTE
The ISO-7816 specification may have certain configuration
options that are reserved. To maintain maximum flexibility to
support future 7816 enhancements or devices that may not
strictly conform to the specification, the UART does not
prevent those options being used. Further, the UART may
provide configuration options that exceed the flexibility of
options explicitly allowed by the 7816 specification. Failure to
correctly configure the UART may result in unexpected
behavior or incompatibility with the ISO-7816 specification.
S2[MSBF], C3[TXINV], and S2[RXINV] must be reset to their default values before
C7816[INIT] is set. Once C7816[INIT] is set, the receiver searches all received data for
the first valid initial character. Detecting a Direct Convention Initial Character will cause
no change to S2[MSBF], C3[TXINV], and S2[RXINV], while detecting an Inverse
Convention Initial Character will cause these fields to set automatically. All data
received, which is not a valid initial character, is ignored and all flags resulting from the
invalid data are blocked from asserting. If C7816[ANACK] is set, a NACK is returned
for invalid received initial characters and an RXT interrupt is generated as programmed.
48.4.8.2 Protocol T = 0
When T = 0 protocol is selected, a relatively complex error detection scheme is used.
Data characters are formatted as illustrated in the following figure. This scheme is also
used for answer to reset and Peripheral Pin Select (PPS) formats.
ISO 7816 FORMAT WITHOUT PARITY ERROR (T=0)
PARITY NEXT
START START
BIT BIT 0 BIT 1 BIT 2 BIT 3 BIT 4 BIT 5 BIT 6 BIT 7 BIT STOP STOP BIT
BIT BIT
As with other protocols supported by the UART, the data character includes a start bit.
However, in this case, there are two stop bits rather than the typical single stop bit. In
addition to a standard even parity check, the receiver has the ability to generate and return
a NACK during the second half of the first stop bit period. The NACK must be at least
one time period (ETU) in length and no more than two time periods (ETU) in length. The
transmitter must wait for at least two time units (ETU) after detection of the error signal
before attempting to retransmit the character.
It is assumed that the UART and the device (smartcard) know in advance which device is
receiving and which is transmitting. No special mechanism is supplied by the UART to
control receive and transmit in the mode other than C2[TE] and C2[RE]. Initial Character
Detect feature is also supported in this mode.
48.4.8.3 Protocol T = 1
When T = 1 protocol is selected, the NACK error detection scheme is not used. Rather,
the parity bit is used on a character basis and a CRC or LRC is used on the block basis,
that is, for each group of characters. In this mode, the data format allows for a single stop
bit although additional inactive bit periods may be present between the stop bit and the
next start bit. Data characters are formatted as illustrated in the following figure.
ISO 7816 FORMAT (T=1)
PARITY NEXT
START START
BIT BIT 0 BIT 1 BIT 2 BIT 3 BIT 4 BIT 5 BIT 6 BIT 7 BIT STOP BIT
BIT
The smallest data unit that is transferred is a block. A block is made up of several data
characters and may vary in size depending on the block type. The UART does not
provide a mechanism to decode the block type. As part of the block, an LRC or CRC is
included. The UART does not calculate the CRC or LRC for transmitted blocks, nor does
it verify the validity of the CRC or LRC for received blocks. The 7816 protocol requires
that the initiator and the smartcard (device) takes alternate turns in transmitting and
receiving blocks. When the UART detects that the last character in a block has been
transmitted it will automatically clear C2[TE] and enter receive mode. Therefore, the
software must program the transmit buffer with the next data to be transmitted, and then
enable C2[TE], once the software has determined that the last character of the received
block has been received. The UART detects that the last character of the transmit block
has been sent when TL7816[TLEN] = 0 and four additional characters have been sent.
The four additional characters are made up of three prior to TL7816[TLEN]
decrementing (prologue) and one after TL7816[TLEN] = 0, the final character of the
epilogue.
48.5 Reset
All registers reset to a particular value are indicated in Memory map and registers.
When a flag is configured for a DMA request, its associated DMA request is asserted
when the flag is set. When S1[RDRF] is configured as a DMA request, the clearing
mechanism of reading S1, followed by reading D, does not clear the associated flag. The
DMA request remains asserted until an indication is received that the DMA transactions
are done. When this indication is received, the flag bit and the associated DMA request is
cleared. If the DMA operation failed to remove the situation that caused the DMA
request, another request is issued.
depth of one. This is the default/reset behavior of the module and can be adjusted using
the PFIFO[RXFE] and PFIFO[TXFE] bits. Individual watermark levels are also provided
for transmit and receive.
There are multiple ways to ensure that a data block, which is a set of characters, has
completed transmission. These methods include:
1. Set TXFIFO[TXWATER] to 0. TDRE asserts when there is no further data in the
transmit buffer. Alternatively the S1[TC] flag can be used to indicate when the
transmit shift register is also empty.
2. Poll TCFIFO[TXCOUNT]. Assuming that only data for a data block has been put
into the data buffer, when TCFIFO[TXCOUNT] = 0, all data has been transmitted or
is in the process of transmission.
3. S1[TC] can be monitored. When S1[TC] asserts, it indicates that all data has been
transmitted and there is no data currently being transmitted in the shift register.
6. Write to set up interrupt enable fields desired (C3[ORIE], C3[NEIE], C3[PEIE], and
C3[FEIE])
7. Write to set C4[MAEN1] = 0 and C4[MAEN2] = 0.
8. Write to C5 register and configure DMA control register fields as desired for
application.
9. Write to set C7816[INIT] = 1,C7816[ TTYPE] = 0, and C7816[ISO_7816E] = 1.
Program C7816[ONACK] and C7816[ANACK] as desired.
10. Write to IE7816 to set interrupt enable parameters as desired.
11. Write to ET7816 and set as desired.
12. Write to set C2[ILIE] = 0, C2[RE] = 1, C2[TE] = 1, C2[RWU] = 0, and C2[SBK] =
0. Set up interrupt enables C2[TIE], C2[TCIE], and C2[RIE] as desired.
At this time, the UART will start listening for an initial character. After being identified,
it will automatically adjust S2[MSBF], C3[TXINV], and S2[RXINV]. The software must
then receive and process an answer to reset. Upon processing the answer to reset, the
software must write to set C2[RE] = 0 and C2[TE] = 0. The software should then adjust
7816 specific and UART generic parameters to match and configure data that was
received during the answer on reset period. After the new settings have been
programmed, including the new baud rate and C7816[TTYPE], C2[RE] and C2[TE] can
be reenabled as required.
Note
During normal operation, S1[TDRE] is set when the shift
register is loaded with the next data to be transmitted from the
transmit buffer and the number of datawords contained in the
transmit buffer is less than or equal to the value in
TWFIFO[TXWATER]. This occurs 9/16ths of a bit time after
the start of the stop bit of the previous frame.
To separate messages with preambles with minimum idle line time, use this sequence
between messages.
1. Write the last dataword of the first message to C3[T8]/D.
2. Wait for S1[TDRE] to go high with TWFIFO[TXWATER] = 0, indicating the
transfer of the last frame to the transmit shift register.
3. Queue a preamble by clearing and then setting C2[TE].
4. Write the first and subsequent datawords of the second message to C3[T8]/D.
1. Remove data from the receive data buffer. This could be done by reading data from
the data buffer and processing it if the data in the FIFO was still valuable when the
overrun event occurred, or using CFIFO[RXFLUSH] to clear the buffer.
2. Clear S1[OR]. Note that if data was cleared using CFIFO[RXFLUSH], then clearing
S1[OR] will result in SFIFO[RXUF] asserting. This is because the only way to clear
S1[OR] requires reading additional information from the FIFO. Care should be taken
to disable the SFIFO[RXUF] interrupt prior to clearing the OR flag and then clearing
SFIFO[RXUF] after the OR flag has been cleared.
Note that, in some applications, if an overrun event is responded to fast enough, the lost
data can be recovered. For example, when C7816[ISO_7816E] is asserted,
C7816[TTYPE]=1 and C7816[ONACK] = 1, the application may reasonably be able to
determine whether the lost data will be resent by the device. In this scenario, flushing the
receiver data buffer may not be required. Rather, if S1[OR] is cleared, the lost data may
be resent and therefore may be recoverable.
When LIN break detect (LBKDE) is asserted, S1[OR] has significantly different behavior
than in other modes. S1[OR] will be set, regardless of how much space is actually
available in the data buffer, if a LIN break character has been detected and the
corresponding flag, S2[LBKDIF], is not cleared before the first data character is received
after S2[LBKDIF] asserted. This behavior is intended to allow the software sufficient
time to read the LIN break character from the data buffer to ensure that a break character
was actually detected. The checking of the break character was used on some older
implementations and is therefore supported for legacy reasons. Applications that do not
require this checking can simply clear S2[LBKDIF] without checking the stored value to
ensure it is a break character.
RXD TXD
RECEIVER RTS_B CTS_B TRANSMITTER
The transmitter's CTS signal can be used for hardware flow control whether its RTS
signal is used for hardware flow control, transceiver driver enable, or not at all.
RXD RO A
RECEIVER RECEIVER B
RE_B
In the figure, the receiver enable signal is asserted. Another option for this connection is
to connect RTS_B to both DE and RE_B. The transceiver's receiver is disabled while
driving. A pullup can pull RXD to a non-floating value during this time. This option can
be refined further by operating the UART in single wire mode, freeing the RXD pin for
other uses.
If the intent of clearing the interrupt is such that it does not reassert, the interrupt service
routine must remove or clear the condition that originally caused the interrupt to assert
prior to clearing the interrupt. There are multiple ways that this can be accomplished,
including ensuring that an event that results in the wait timer resetting occurs, such as, the
transmission of another packet.
49.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The I2S (or I2S) module provides a synchronous audio interface (SAI) that supports full-
duplex serial interfaces with frame synchronization such as I2S, AC97, TDM, and codec/
DSP interfaces.
49.1.1 Features
• Transmitter with independent bit clock and frame sync supporting 2 data channels
• Receiver with independent bit clock and frame sync supporting 2 data channels
• Maximum Frame Size of 32 words
• Word size of between 8-bits and 32-bits
• Word size configured separately for first word and remaining words in frame
• Asynchronous 8 × 32-bit FIFO for each transmit and receive channel
• Graceful restart after FIFO error
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
WSF
FWF
R 0 0 0 SEF FEF FRF
STOPE
DBGE
TE BCE SR
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
FWDE
WSIE SEIE FEIE FWIE FRIE FRDE
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 Transmitter is disabled.
1 Transmitter is enabled, or transmitter has been disabled and has not yet reached end of frame.
30 Stop Enable
STOPE
Configures transmitter operation in Stop mode. This field is ignored and the transmitter is disabled in all
stop modes.
0 No effect.
1 FIFO reset.
24 Software Reset
SR
When set, resets the internal transmitter logic including the FIFO pointers. Software-visible registers are
not affected, except for the status registers.
0 No effect.
1 Software reset.
23–21 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
20 Word Start Flag
WSF
Indicates that the start of the configured word has been detected. Write a logic 1 to this field to clear this
flag.
0 Disables interrupt.
1 Enables interrupt.
11 Sync Error Interrupt Enable
SEIE
Enables/disables sync error interrupts.
0 Disables interrupt.
1 Enables interrupt.
10 FIFO Error Interrupt Enable
FEIE
Enables/disables FIFO error interrupts.
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 TFW
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
R 0
SYNC BCS BCI MSEL BCP BCD
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 DIV
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
00 Asynchronous mode.
01 Synchronous with receiver.
10 Synchronous with another SAI transmitter.
11 Synchronous with another SAI receiver.
29 Bit Clock Swap
BCS
This field swaps the bit clock used by the transmitter. When the transmitter is configured in asynchronous
mode and this bit is set, the transmitter is clocked by the receiver bit clock (SAI_RX_BCLK). This allows
the transmitter and receiver to share the same bit clock, but the transmitter continues to use the transmit
frame sync (SAI_TX_SYNC).
When the transmitter is configured in synchronous mode, the transmitter BCS field and receiver BCS field
must be set to the same value. When both are set, the transmitter and receiver are both clocked by the
transmitter bit clock (SAI_TX_BCLK) but use the receiver frame sync (SAI_RX_SYNC).
0 No effect.
1 Internal logic is clocked as if bit clock was externally generated.
27–26 MCLK Select
MSEL
Selects the Audio Master Clock used to generate an internally generated bit clock. This field has no effect
when configured for an externally generated bit clock.
0 Bit clock is active high with drive outputs on rising edge and sample inputs on falling edge.
1 Bit clock is active low with drive outputs on falling edge and sample inputs on rising edge.
24 Bit Clock Direction
BCD
Configures the direction of the bit clock.
Table continues on the next page...
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 0
TCE WDFL
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
R 0 FRSZ
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
SYWD MF FSE FSP FSD
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 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 0 0 0
WNW W0W FBT
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
R 0
W TDR[31:0]
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 WFP 0 RFP
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
W
TWM
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
0 Word N is enabled.
1 Word N is masked. The transmit data pins are tri-stated when masked.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
WSF
FWF
R 0 0 0 SEF FEF FRF
STOPE
DBGE
RE BCE SR
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
FWDE
WSIE SEIE FEIE FWIE FRIE FRDE
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 Receiver is disabled.
1 Receiver is enabled, or receiver has been disabled and has not yet reached end of frame.
30 Stop Enable
STOPE
Configures receiver operation in Stop mode. This bit is ignored and the receiver is disabled in all stop
modes.
0 No effect.
1 FIFO reset.
24 Software Reset
SR
Resets the internal receiver logic including the FIFO pointers. Software-visible registers are not affected,
except for the status registers.
0 No effect.
1 Software reset.
23–21 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
20 Word Start Flag
WSF
Indicates that the start of the configured word has been detected. Write a logic 1 to this field to clear this
flag.
0 Disables interrupt.
1 Enables interrupt.
11 Sync Error Interrupt Enable
SEIE
Enables/disables sync error interrupts.
0 Disables interrupt.
1 Enables interrupt.
10 FIFO Error Interrupt Enable
FEIE
Enables/disables FIFO error interrupts.
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 RFW
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
R 0
SYNC BCS BCI MSEL BCP BCD
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 DIV
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
00 Asynchronous mode.
01 Synchronous with transmitter.
10 Synchronous with another SAI receiver.
11 Synchronous with another SAI transmitter.
29 Bit Clock Swap
BCS
This field swaps the bit clock used by the receiver. When the receiver is configured in asynchronous mode
and this bit is set, the receiver is clocked by the transmitter bit clock (SAI_TX_BCLK). This allows the
transmitter and receiver to share the same bit clock, but the receiver continues to use the receiver frame
sync (SAI_RX_SYNC).
When the receiver is configured in synchronous mode, the transmitter BCS field and receiver BCS field
must be set to the same value. When both are set, the transmitter and receiver are both clocked by the
receiver bit clock (SAI_RX_BCLK) but use the transmitter frame sync (SAI_TX_SYNC).
0 No effect.
1 Internal logic is clocked as if bit clock was externally generated.
27–26 MCLK Select
MSEL
Selects the audio master clock used to generate an internally generated bit clock. This field has no effect
when configured for an externally generated bit clock.
0 Bit Clock is active high with drive outputs on rising edge and sample inputs on falling edge.
1 Bit Clock is active low with drive outputs on falling edge and sample inputs on rising edge.
24 Bit Clock Direction
BCD
Configures the direction of the bit clock.
Table continues on the next page...
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 0
RCE WDFL
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
R 0 FRSZ
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
SYWD MF FSE FSP FSD
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 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 0 0 0
WNW W0W FBT
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
R RDR[31:0]
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
R 0 WFP 0 RFP
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
W
RWM
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
0 Word N is enabled.
1 Word N is masked.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R DUF 0 0
MOE MICS
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
W
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 MCLK signal pin is configured as an input that bypasses the MCLK divider.
1 MCLK signal pin is configured as an output from the MCLK divider and the MCLK divider is enabled.
29–26 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
25–24 MCLK Input Clock Select
MICS
Selects the clock input to the MCLK divider. This field cannot be changed while the MCLK divider is
enabled. See the chip configuration details for information about the connections to these inputs.
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 FRACT DIVIDE
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
SAI_CLKMODE SAI_BCD
SAI_MOE
SAI_FRACT/SAI_DIVIDE
SAI_MICS
The SAI receiver includes a software reset that resets all receiver internal logic, including
the bit clock generation, status flags and FIFO pointers. It does not reset the configuration
registers. The software reset remains asserted until cleared by software.
• In synchronous mode, the transmitter is enabled only when both the receiver and
transmitter are both enabled.
• It is recommended that the receiver is the last enabled and the first disabled.
When operating in synchronous mode, only the bit clock, frame sync, and transmitter/
receiver enable are shared. The transmitter and receiver otherwise operate independently,
although configuration registers must be configured consistently across both the
transmitter and receiver.
50.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The general-purpose input and output (GPIO) module communicates to the processor
core via a zero wait state interface 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.
50.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
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.
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
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
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
0 Pin logic level is logic 0, or is not configured for use by digital function.
1 Pin logic level is logic 1.
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.
51.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The touch sensing input (TSI) module provides capacitive touch sensing detection with
high sensitivity and enhanced robustness. Each TSI pin implements the capacitive
measurement of an electrode having individual programmable detection thresholds and
result registers. The TSI module can be functional in several low-power modes with
ultra-low current adder and waking up the CPU in a touch event. It provides a solid
capacitive measurement module to the implementation of touch keypad, rotaries, and
sliders.
51.2 Features
TSI module features included:
• Support for as many as 16 input capacitive touch-sensing pins with individual result
registers
• Automatic detection of electrode capacitance change in low-power mode with
programmable upper and lower threshold
• Automatic periodic scan unit with different duty cycles for run and low-power modes
• Fully support with Freescale touch-sensing SW library suite the implementation of
keypads, rotaries and sliders
• Operation across all low-power modes: WAIT, STOP, VLPR, VLPW, VLPS, LLS,
VLLS3, VLLS2, VLLS1
• Capability to wake up MCU from low-power modes.
• Configurable interrupts:
51.3 Overview
This section presents an overview of the TSI module. The following figure presents the
simplified TSI module block diagram.
External Touch Sensing Input (TSI) Module
Electrodes
NSCN PS EXTCHRG REFCHRG
PAD0
LPSCNITV
EXTERF
SMOD
Electrode Touch
Scan Unit Detection
Unit OUTRGF
OVRF
PEN [15:0]
EOSF
TSICHLTH TSICHHTH
EXTCHRG DELVOL PS
CLK
16-bit TSICHnCNT
EN Counter
TSI Counter
Electrode Prescaler Modulo
Oscillator Control
NSCN
PAD0 16-bit
TSICHnCNT
Counter
TSI Counter
PAD1
Cap Switch
NSCN
PAD15
STM STPE SMOD LPSCNITV
Touch and Error Interrupt
Low MCGIRCLK 2 Windowed
Scan Error EXTERF
Power OSCERCLK Comparators OUTRGF
Trigger Detection
Scan LPOCLK out of range
Control VLPOSCCLK interrupt
Channel
Polling OVRF
FSM TSICHHTH TSICHLTH
PEN[15:0]
EOSF overrun interrupt
end of scan interrupt Touch Detection Unit
1. The out-of-range functionality present in the Touch Detection Unit is available only in low-power modes.
51.5.1 TSI_IN[15:0]
When TSI functionality is enabled by the PEN[PENn], the TSI analog portion uses
corresponding TSI_IN[n] pin to connect the module with the external electrode. The
connection between the pin and the touch pad must be kept as short as possible to reduce
distribution capacity on board.
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0
LPCLKS
LPSCNITV NSCN PS
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
OUTRGF
EXTERF
SCNIP
OVRF
EOSF
R 0 0
Reserved
TSIEN
ESO
TSIIE ERIE STM STPE
R
SWTS
Reset 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 No overrun.
1 Overrun occurred.
11–10 This field is reserved.
Reserved This read-only field is reserved and always has the value 0.
9 Scan In Progress Status
SCNIP
Table continues on the next page...
Bit 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
R 0 0
REFCHRG EXTCHRG
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
SMOD AMCLKS AMPSC
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
LPSP
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
PEN15
PEN14
PEN13
PEN12
PEN11
PEN10
PEN9 PEN8 PEN7 PEN6 PEN5 PEN4 PEN3 PEN2 PEN1 PEN0
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 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R 0 WUCNT
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
R CTN CTN1
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
W
LTHH HTHH
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
Hysteresis
Voltage Delta
Time
Felec I
2 * Celec * ΔV
Figure 51-35. Equation 1: TSI electrode oscillator frequency
Where:
I: constant current
Celec: electrode capacitance
The current source is used to accommodate the TSI electrode oscillator frequency with
different electrode capacitance sizes.
Tcap_samp PS * NSCN
F elec
Using Equation 1.
Where:
PS: prescaler value
NSCN: module counter maximum value
I: constant current
Celec: electrode capacitance
ΔV: Hysteresis delta voltage
By this equation, an electrode with C = 20 pF, a current source of I = 16 µA and ΔV =
600 mV, PS = 2, and NSCN = 16 has the following sampling time:
Fref_osc Iref
2 *Cref * ΔV
Figure 51-38. Equation 4: TSI reference oscillator frequency
Where:
Cref: Internal reference capacitor
Iref: Reference oscillator current source
∆V : Hysteresis delta voltage
Considering Cref = 1.0 pF, Iref = 12 µA and ∆V = 600 mV, follows
In the example where Fref_osc = 10.0MHz and Tcap_samp = 48 µs, TSICHnCNT = 480
When the electrode scan unit starts a scan sequence, all the active electrodes will be
scanned sequentially, with each electrode having a scanned time defined by the
GENCS[NSCN]. The counter value is the sum of the total scan times of that electrode.
First Active Second Active Last Active
Electrode Electrode Electrode
End-of-Scan
Signal
For the example provided, Iref = 2 µA, PS = 2; NSCN = 16, Cref = 1.0 pF and I =2 µA, the
TSIsensitivity = 0.03125 pf/count
52.1 Introduction
NOTE
For the chip-specific implementation details of this module's
instances see the chip configuration chapter.
The JTAGC block provides the means to test chip functionality and connectivity while
remaining transparent to system logic when not in test mode. Testing is performed via a
boundary scan technique, as defined in the IEEE 1149.1-2001 standard. All data input to
and output from the JTAGC block is communicated in serial format.
Power-on reset
Test Access Port (TAP)
TMS Controller
TCK
TDI TDO
Boundary Scan Register
52.1.2 Features
The JTAGC block is compliant with the IEEE 1149.1-2001 standard, and supports the
following features:
• IEEE 1149.1-2001 Test Access Port (TAP) interface
• 4 pins (TDI, TMS, TCK, and TDO)
• Instruction register that supports several IEEE 1149.1-2001 defined instructions as
well as several public and private device-specific instructions. Refer to Table 52-3
for a list of supported instructions.
• Bypass register, boundary scan register, and device identification register.
• TAP controller state machine that controls the operation of the data registers,
instruction register and associated circuitry.
52.1.3.1 Reset
The JTAGC block is placed in reset when either power-on reset is asserted, or the TMS
input is held high for enough consecutive rising edges of TCK to sequence the TAP
controller state machine into the Test-Logic-Reset state. Holding TMS high for five
consecutive rising edges of TCK guarantees entry into the Test-Logic-Reset state
regardless of the current TAP controller state. Asserting power-on reset results in
asynchronous entry into the reset state. While in reset, the following actions occur:
• The TAP controller is forced into the Test-Logic-Reset state, thereby disabling the
test logic and allowing normal operation of the on-chip system logic to continue
unhindered
• The instruction register is loaded with the IDCODE instruction
1. TDO output buffer enable is negated when the JTAGC is not in the Shift-IR or Shift-DR states. A weak pull may be
implemented at the TDO pad for use when JTAGC is inactive.
scan register cell, as described in the IEEE 1149.1-2001 standard and discussed in
Boundary scan. The size of the boundary scan register and bit ordering is device-
dependent and can be found in the device BSDL file.
TEST LOGIC
RESET
1
0
1 1 1
RUN-TEST/IDLE SELECT-DR-SCAN SELECT-IR-SCAN
0
0 0
1 1
CAPTURE-DR CAPTURE-IR
0 0
SHIFT-DR SHIFT-IR
0 0
1 1
1 1
EXIT1-DR EXIT1-IR
0 0
PAUSE-DR PAUSE-IR
0 0
1 1
0 0
EXIT2-DR EXIT2-IR
1 1
UPDATE-DR UPDATE-IR
1 1
0 0
The value shown adjacent to each state transition in this figure represents the value of TMS at the time
of a rising edge of TCK.
of the boundary scan register cells on the falling edge of TCK in the Update-DR
state. The data is applied to the external output pins by the EXTEST or CLAMP
instruction. System operation is not affected.
single bit (the bypass register) while conducting an EXTEST type of instruction through
the boundary scan register. CLAMP also asserts the internal system reset for the MCU to
force a predictable internal state.
Asia/Pacific:
Freescale Semiconductor China Ltd.
Exchange Building 23F
No. 118 Jianguo Road
Chaoyang District
Beijing 100022
China
+86 10 5879 8000
[email protected]